Changeset 5089
- Timestamp:
- Sep 21, 2005, 4:32:00 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 edited
-
src/imageops/psImageStats.c (modified) (7 diffs)
-
src/imageops/psImageStats.h (modified) (2 diffs)
-
src/mathtypes/psVector.c (modified) (4 diffs)
-
src/mathtypes/psVector.h (modified) (3 diffs)
-
src/types/psMetadata.c (modified) (2 diffs)
-
test/mathtypes/tst_psVector.c (modified) (5 diffs)
-
test/mathtypes/verified/tst_psVector.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStats.c
r4970 r5089 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.7 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09- 08 00:07:59$11 * @version $Revision: 1.78 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-22 02:32:00 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 250 250 Output: 251 251 Internal Data Structures: 252 chebPolys[i][j] 253 sums[i][j]: This will contain the sum of 252 chebPolys[i][j] 253 sums[i][j]: This will contain the sum of 254 254 input->data.F32[x][y] * 255 255 psPolynomial1DEval( … … 258 258 psPolynomial1DEval( 259 259 chebPolys[j], 260 (float) y, 260 (float) y, 261 261 ); 262 262 over all pixels (x,y) in the image. … … 373 373 Output: 374 374 Internal Data Structures: 375 chebPolys[i][j] 376 sums[i][j]: This will contain the sum of 375 chebPolys[i][j] 376 sums[i][j]: This will contain the sum of 377 377 input->data.F32[x][y] * 378 378 psPolynomial1DEval( … … 381 381 psPolynomial1DEval( 382 382 chebPolys[j], 383 (float) y, 383 (float) y, 384 384 ); 385 385 over all pixels (x,y) in the image. … … 514 514 515 515 /***************************************************************************** 516 XXX: Use static variables for Chebyshev polynomials and scaling factors. 516 XXX: Use static variables for Chebyshev polynomials and scaling factors. 517 517 *****************************************************************************/ 518 518 psImage* p_psImageEvalPolynomialCheb(psImage* input, … … 634 634 } 635 635 636 // count number of pixels with given mask value 637 long psImageCountPixelMask (psImage *mask, 638 psMaskType value) 639 { 640 long Npixels = 0; 641 642 for (long i = 0; i < mask->numRows; i++) { 643 for (long j = 0; j < mask->numCols; j++) { 644 if (mask->data.U8[i][j] & value) { 645 Npixels ++; 646 } 647 } 648 } 649 return (Npixels); 650 } 651 -
trunk/psLib/src/imageops/psImageStats.h
r4970 r5089 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09- 08 00:07:59$11 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-22 02:32:00 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 85 85 ); 86 86 87 long psImageCountPixelMask( 88 psImage *mask, 89 psMaskType value 90 ); 91 87 92 /// @} 88 93 -
trunk/psLib/src/mathtypes/psVector.c
r5087 r5089 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.5 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09-2 1 21:37:21$11 * @version $Revision: 1.54 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-22 02:32:00 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 746 746 747 747 #define FUNC_MACRO_VECTOR_CREATE(TYPE) \ 748 static psVector *vectorCreate##TYPE( double lower, double upper, double delta) \748 static psVector *vectorCreate##TYPE(psVector *input, double lower, double upper, double delta) \ 749 749 { \ 750 750 \ 751 751 int nBin = (upper - lower) / delta; \ 752 psVector *vec = psVector Alloc(nBin, PS_TYPE_##TYPE); \752 psVector *vec = psVectorRecycle(input, nBin, PS_TYPE_##TYPE); \ 753 753 for (int i = 0; i < nBin; i++) \ 754 754 { \ … … 769 769 FUNC_MACRO_VECTOR_CREATE(F64) 770 770 771 psVector *psVectorCreate (double lower, 771 psVector *psVectorCreate (psVector *input, 772 double lower, 772 773 double upper, 773 774 double delta, … … 777 778 switch (type) { 778 779 case PS_TYPE_S8: 779 out = vectorCreateS8( lower, upper, delta);780 out = vectorCreateS8(input, lower, upper, delta); 780 781 break; 781 782 case PS_TYPE_S16: 782 out = vectorCreateS16( lower, upper, delta);783 out = vectorCreateS16(input, lower, upper, delta); 783 784 break; 784 785 case PS_TYPE_S32: 785 out = vectorCreateS32( lower, upper, delta);786 out = vectorCreateS32(input, lower, upper, delta); 786 787 break; 787 788 case PS_TYPE_S64: 788 out = vectorCreateS64( lower, upper, delta);789 out = vectorCreateS64(input, lower, upper, delta); 789 790 break; 790 791 case PS_TYPE_U8: 791 out = vectorCreateU8( lower, upper, delta);792 out = vectorCreateU8(input, lower, upper, delta); 792 793 break; 793 794 case PS_TYPE_U16: 794 out = vectorCreateU16( lower, upper, delta);795 out = vectorCreateU16(input, lower, upper, delta); 795 796 break; 796 797 case PS_TYPE_U32: 797 out = vectorCreateU32( lower, upper, delta);798 out = vectorCreateU32(input, lower, upper, delta); 798 799 break; 799 800 case PS_TYPE_U64: 800 out = vectorCreateU64( lower, upper, delta);801 out = vectorCreateU64(input, lower, upper, delta); 801 802 break; 802 803 case PS_TYPE_F32: 803 out = vectorCreateF32( lower, upper, delta);804 out = vectorCreateF32(input, lower, upper, delta); 804 805 break; 805 806 case PS_TYPE_F64: 806 out = vectorCreateF64( lower, upper, delta);807 out = vectorCreateF64(input, lower, upper, delta); 807 808 break; 808 809 default: 809 810 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psType for Vector Create\n"); 810 811 } 811 /*812 for (int i = 0; i < nBin; i++) {813 out->data.F64[i] = lower + i * delta;814 }815 */816 812 return (out); 817 813 } 818 814 815 bool psVectorSet(const psVector *input, 816 long position, 817 complex value) 818 { 819 if (input == NULL) 820 return false; 821 if (position >= input->n) 822 return false; 823 if(position < 0) 824 position += input->n; 825 826 switch (input->type.type) { 827 case PS_TYPE_U8: 828 *(psU8*)&input->data.U8[position] = value; 829 break; 830 case PS_TYPE_U16: 831 *(psU16*)&input->data.U16[position] = value; 832 break; 833 case PS_TYPE_U32: 834 *(psU32*)&input->data.U32[position] = value; 835 break; 836 case PS_TYPE_U64: 837 *(psU64*)&input->data.U64[position] = value; 838 break; 839 case PS_TYPE_S8: 840 *(psS8*)&input->data.S8[position] = value; 841 break; 842 case PS_TYPE_S16: 843 *(psS16*)&input->data.S16[position] = value; 844 break; 845 case PS_TYPE_S32: 846 *(psS32*)&input->data.S32[position] = value; 847 break; 848 case PS_TYPE_S64: 849 *(psS64*)&input->data.S64[position] = value; 850 break; 851 case PS_TYPE_F32: 852 *(psF32*)&input->data.F32[position] = value; 853 break; 854 case PS_TYPE_F64: 855 *(psF64*)&input->data.F64[position] = value; 856 break; 857 case PS_TYPE_C32: 858 *(psC32*)&input->data.C32[position] = value; 859 break; 860 case PS_TYPE_C64: 861 *(psC64*)&input->data.C64[position] = value; 862 break; 863 default: 864 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n"); 865 } 866 867 return true; 868 } 869 870 complex psVectorGet(const psVector *input, 871 long position) 872 { 873 if (input == NULL) 874 return NAN; 875 if (position >= input->n) { 876 return NAN; 877 } 878 if(position < 0) 879 position += input->n; 880 881 switch (input->type.type) { 882 case PS_TYPE_U8: 883 return input->data.U8[position]; 884 break; 885 case PS_TYPE_U16: 886 return input->data.U16[position]; 887 break; 888 case PS_TYPE_U32: 889 return input->data.U32[position]; 890 break; 891 case PS_TYPE_U64: 892 return input->data.U64[position]; 893 break; 894 case PS_TYPE_S8: 895 return input->data.S8[position]; 896 break; 897 case PS_TYPE_S16: 898 return input->data.S16[position]; 899 break; 900 case PS_TYPE_S32: 901 return input->data.S32[position]; 902 break; 903 case PS_TYPE_S64: 904 return input->data.S64[position]; 905 break; 906 case PS_TYPE_F32: 907 return input->data.F32[position]; 908 break; 909 case PS_TYPE_F64: 910 return input->data.F64[position]; 911 break; 912 case PS_TYPE_C32: 913 return input->data.C32[position]; 914 break; 915 case PS_TYPE_C64: 916 return input->data.C64[position]; 917 break; 918 default: 919 return NAN; 920 } 921 922 } 923 -
trunk/psLib/src/mathtypes/psVector.h
r5087 r5089 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09-2 1 21:37:21$13 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-22 02:32:00 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 217 217 */ 218 218 psVector *psVectorCreate ( 219 psVector *input, ///< Input vector 219 220 double lower, ///< lower bound 220 221 double upper, ///< upper bound … … 223 224 ); 224 225 226 /** Sets the value of the input vector at the specified position to value. 227 * 228 * A negative position means index from the end. 229 * 230 * @return bool: True if successful, otherwise false. 231 */ 232 bool psVectorSet( 233 const psVector *input, ///< Input vector to set 234 long position, ///< vector position 235 complex value ///< value to set 236 ); 237 238 /** Returns the value of the input vector at the specified position. 239 * 240 * A negative position means index from the end. 241 * 242 * @return complex: Value of the input vector at the specified position. 243 */ 244 complex psVectorGet( 245 const psVector *input, ///< Input vector from which to get value 246 long position ///< vector position 247 ); 248 225 249 /// @} 226 250 -
trunk/psLib/src/types/psMetadata.c
r5057 r5089 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.8 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-09- 15 21:22:22$14 * @version $Revision: 1.84 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-09-22 02:32:00 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1269 1269 } 1270 1270 1271 // we have log levels 1 (Error), 2 (Warning), 3 (Info), 4 (Details), 5 (Minutiae) 1272 // 2 = default, -v = 3, -vv = 4, -vvv = 5 1273 psS32 psLogArguments (int *argc, char **argv) 1274 { 1275 1276 int N, level; 1277 1278 // default log level is 2 1279 level = 2; 1280 1281 // set in order, so that -vvv overrides -vv overrides -v 1282 if ((N = psArgumentGet (*argc, argv, "-v"))) { 1283 psArgumentRemove (N, argc, argv); 1284 level = 3; 1285 } 1286 if ((N = psArgumentGet (*argc, argv, "-vv"))) { 1287 psArgumentRemove (N, argc, argv); 1288 level = 4; 1289 } 1290 if ((N = psArgumentGet (*argc, argv, "-vvv"))) { 1291 psArgumentRemove (N, argc, argv); 1292 level = 5; 1293 } 1294 1295 if ((N = psArgumentGet (*argc, argv, "-logfmt"))) { 1296 if (*argc < N + 2) { 1297 psAbort ("psLogArguments", "USAGE: -logfmt (format)"); 1298 } 1299 psArgumentRemove (N, argc, argv); 1300 psLogSetFormat (argv[N]); // XXX EAM : this function should return an error if the log format is invalid 1301 psArgumentRemove (N, argc, argv); 1302 } 1303 1304 // set the level, return the level 1305 psLogSetLevel (level); 1306 return (level); 1307 } 1308 1309 // set trace levels by facility 1310 psS32 psTraceArguments (int *argc, char **argv) 1311 { 1312 1313 int N; 1314 1315 // argument format is: -trace (facil) (level) 1316 while ((N = psArgumentGet (*argc, argv, "-trace"))) { 1317 if (*argc < N + 3) { 1318 psAbort ("psTraceArguments", "USAGE: -trace (facility) (level)"); 1319 } 1320 psArgumentRemove (N, argc, argv); 1321 psTraceSetLevel (argv[N], atoi(argv[N+1])); 1322 psArgumentRemove (N, argc, argv); 1323 psArgumentRemove (N, argc, argv); 1324 } 1325 if ((N = psArgumentGet (*argc, argv, "-trace-levels"))) { 1326 psTracePrintLevels (); 1327 exit (2); 1328 } 1329 return (TRUE); 1330 } 1331 -
trunk/psLib/test/mathtypes/tst_psVector.c
r5087 r5089 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $17 * @date $Date: 2005-09-2 1 21:37:21$16 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2005-09-22 02:32:00 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 29 static psS32 testVectorInit(void); 30 30 static psS32 testVectorCreate(void); 31 static psS32 testVectorGetSet(void); 31 32 32 33 testDescription tests[] = { … … 36 37 {testVectorInit,-4,"psVectorInit",0,false}, 37 38 {testVectorCreate,-5,"psVectorCreate",0,false}, 39 {testVectorGetSet,-6,"psVectorGet/Set",0,false}, 38 40 {NULL} 39 41 }; … … 364 366 psVector *test = NULL; 365 367 psVector *test2 = NULL; 366 367 test = psVectorCreate(0.0, 10.0, 1.0, PS_TYPE_S32); 368 test2 = psVectorCreate(0.0, 5.0, 0.5, PS_TYPE_F32); 368 psVector *input = NULL; 369 psVector *input2 = psVectorAlloc(5, PS_TYPE_F64); 370 371 test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S32); 372 test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F32); 369 373 370 374 for (int i = 0; i < 10; i++) { … … 383 387 } 384 388 389 psS32 testVectorGetSet(void) 390 { 391 psVector *vec = NULL; 392 vec = psVectorAlloc(5, PS_TYPE_S32); 393 394 if ( !psVectorSet(vec, 0, 10) ) 395 fprintf(stderr, "VectorSet failed to set S32 at position 0\n"); 396 if ( psVectorSet(vec, 10, 10) ) 397 fprintf(stderr, "VectorSet Improperly set S32 at out of range position\n"); 398 if ( !psVectorSet(vec, -1, 4) ) 399 fprintf(stderr, "VectorSet Failed to set S32 at position 4\n"); 400 if ( (psS32)psVectorGet(vec, 0) != 10 ) 401 fprintf(stderr, "VectorGet Failed to return the correct S32 from position 0\n"); 402 if ( (psS32)psVectorGet(vec, -1) != 4 ) 403 fprintf(stderr, "VectorGet Failed to return the correct S32 from tail using -1\n"); 404 405 psFree(vec); 406 return 0; 407 } 408 409 410 -
trunk/psLib/test/mathtypes/verified/tst_psVector.stderr
r5087 r5089 58 58 ---> TESTPOINT PASSED (psVector{psVectorCreate} | tst_psVector.c) 59 59 60 /***************************** TESTPOINT ******************************************\ 61 * TestFile: tst_psVector.c * 62 * TestPoint: psVector{psVectorGet/Set} * 63 * TestType: Positive * 64 \**********************************************************************************/ 65 66 67 ---> TESTPOINT PASSED (psVector{psVectorGet/Set} | tst_psVector.c) 68
Note:
See TracChangeset
for help on using the changeset viewer.
