Changeset 7579
- Timestamp:
- Jun 14, 2006, 4:29:12 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 5 edited
-
src/mathtypes/psImage.c (modified) (5 diffs)
-
src/mathtypes/psImage.h (modified) (2 diffs)
-
src/mathtypes/psVector.c (modified) (3 diffs)
-
src/mathtypes/psVector.h (modified) (2 diffs)
-
test/mathtypes/tst_psImage.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r7533 r7579 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.10 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-06-1 3 19:53:54$11 * @version $Revision: 1.107 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-06-15 02:29:12 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 363 363 #define IMAGE_SET_CASE(TYPE) \ 364 364 case PS_TYPE_##TYPE: \ 365 image->data.TYPE[y][x] = value; \365 image->data.TYPE[y][x] = (ps##TYPE)value; \ 366 366 break; 367 367 … … 400 400 "Invalid x-position %d. Position out of range (%d-%d)\n", 401 401 x, image->col0, image->numCols+image->col0-1 ); 402 return false;402 return NAN; 403 403 } else if ( y >= (image->row0 + image->numRows) ) { 404 404 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 405 405 "Invalid y-position %d. Position out of range (%d-%d)\n", 406 406 y, image->row0, image->numRows+image->row0-1 ); 407 return false;407 return NAN; 408 408 } else if (x < image->col0 && x >= 0) { 409 409 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 410 410 "Invalid x-position %d. Position out of range (%d-%d)\n", 411 411 x, image->col0, image->numCols+image->col0-1 ); 412 return false;412 return NAN; 413 413 } else if (y < image->row0 && y >= 0) { 414 414 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 415 415 "Invalid y-position %d. Position out of range (%d-%d)\n", 416 416 y, image->row0, image->numRows+image->row0-1 ); 417 return false;417 return NAN; 418 418 } else if (x < 0 || y < 0) { 419 419 if (x < 0) { … … 424 424 "Invalid x-position %d. Position out of range (%d-%d)\n", 425 425 (x+image->col0), image->col0, image->numCols+image->col0-1 ); 426 return false;426 return NAN; 427 427 } 428 428 if (y < 0) { … … 433 433 "Invalid y-position %d. Position out of range (%d-%d)\n", 434 434 (y+image->row0), image->row0, image->numRows+image->row0-1 ); 435 return false;435 return NAN; 436 436 } 437 437 } else { -
trunk/psLib/src/mathtypes/psImage.h
r7553 r7579 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.7 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-06-1 4 01:29:16$13 * @version $Revision: 1.79 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-06-15 02:29:12 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 93 93 */ 94 94 psImage* psImageAlloc( 95 int numCols, ///< Number of rows in image.96 int numRows, ///< Number of columns in image.95 int numCols, ///< Number of columns in image. 96 int numRows, ///< Number of rows in image. 97 97 psElemType type ///< Type of data for image. 98 98 ) -
trunk/psLib/src/mathtypes/psVector.c
r7255 r7579 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.7 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-06- 01 01:00:03$11 * @version $Revision: 1.76 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-06-15 02:29:12 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 873 873 } 874 874 875 bool psVectorSet( constpsVector *input,875 bool psVectorSet(psVector *input, 876 876 long position, 877 877 double complex value) … … 904 904 switch (input->type.type) { 905 905 case PS_TYPE_U8: 906 *(psU8*)&input->data.U8[position] =value;906 input->data.U8[position] = (psU8)value; 907 907 break; 908 908 case PS_TYPE_U16: 909 *(psU16*)&input->data.U16[position] =value;909 input->data.U16[position] = (psU16)value; 910 910 break; 911 911 case PS_TYPE_U32: 912 *(psU32*)&input->data.U32[position] =value;912 input->data.U32[position] = (psU32)value; 913 913 break; 914 914 case PS_TYPE_U64: 915 *(psU64*)&input->data.U64[position] =value;915 input->data.U64[position] = (psU64)value; 916 916 break; 917 917 case PS_TYPE_S8: 918 *(psS8*)&input->data.S8[position] =value;918 input->data.S8[position] = (psS8)value; 919 919 break; 920 920 case PS_TYPE_S16: 921 *(psS16*)&input->data.S16[position] =value;921 input->data.S16[position] = (psS16)value; 922 922 break; 923 923 case PS_TYPE_S32: 924 *(psS32*)&input->data.S32[position] =value;924 input->data.S32[position] = (psS32)value; 925 925 break; 926 926 case PS_TYPE_S64: 927 *(psS64*)&input->data.S64[position] =value;927 input->data.S64[position] = (psS64)value; 928 928 break; 929 929 case PS_TYPE_F32: 930 *(psF32*)&input->data.F32[position] =value;930 input->data.F32[position] = (psF32)value; 931 931 break; 932 932 case PS_TYPE_F64: 933 *(psF64*)&input->data.F64[position] =value;933 input->data.F64[position] = (psF64)value; 934 934 break; 935 935 case PS_TYPE_C32: 936 *(psC32*)&input->data.C32[position] =value;936 input->data.C32[position] = (psC32)value; 937 937 break; 938 938 case PS_TYPE_C64: 939 *(psC64*)&input->data.C64[position] =value;939 input->data.C64[position] = (psC64)value; 940 940 break; 941 941 default: -
trunk/psLib/src/mathtypes/psVector.h
r6500 r7579 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.5 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-0 2-28 02:53:03$13 * @version $Revision: 1.53 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-06-15 02:29:12 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 233 233 */ 234 234 bool psVectorSet( 235 const psVector *input,///< Input vector to set235 psVector *input, ///< Input vector to set 236 236 long position, ///< vector position 237 237 double complex value ///< value to set -
trunk/psLib/test/mathtypes/tst_psImage.c
r6578 r7579 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 3-14 03:25:48$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-15 02:29:12 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 361 361 { 362 362 psImage *image = NULL; 363 image = psImageAlloc(5, 5, PS_TYPE_S32);363 image = psImageAlloc(5, 4, PS_TYPE_S32); 364 364 365 365 //Set the position of the subimage relative to the parent. 366 366 image->col0 = 10; 367 367 image->row0 = 10; 368 for (int i = 0; i < 5; i++) {368 for (int i = 0; i < 4; i++) { 369 369 for (int j = 0; j < 5; j++) { 370 370 image->data.S32[i][j] = i+j; … … 419 419 420 420 //Try to set a position inside of the subimage. 421 if ( !psImageSet(image, 1 3, 14, 666) ) {421 if ( !psImageSet(image, 14, 12, 666) ) { 422 422 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 423 423 "psImageSet failed to return true when passed valid parameters.\n"); 424 424 return 6; 425 } else if (image->data.S32[3][4] != 666) { 426 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 427 "psImageSet failed to set the data values correctly.\n"); 425 } 426 if (image->data.S32[2][4] != 666) { 427 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 428 "psImageSet failed to set the data values correctly. value=%d\n", image->data.S32[2][4]); 428 429 return 7; 429 430 } … … 433 434 "psImageSet failed to return true when passed valid parameters.\n"); 434 435 return 8; 435 } else if (image->data.S32[ 4][4] != 666) {436 } else if (image->data.S32[3][4] != 666) { 436 437 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 437 438 "psImageSet failed to set (from the tail) the data values correctly.\n"); 438 printf("\n value at 14,14 is %d\n", image->data.S32[ 4][4]);439 printf("\n value at 14,14 is %d\n", image->data.S32[3][4]); 439 440 return 9; 440 441 } … … 477 478 { 478 479 psImage *image = NULL; 479 image = psImageAlloc(5, 5, PS_TYPE_S32);480 image = psImageAlloc(5, 3, PS_TYPE_S32); 480 481 481 482 //Set the position of the subimage relative to the parent. 482 483 image->col0 = 10; 483 484 image->row0 = 10; 484 for (int i = 0; i < 5; i++) {485 for (int i = 0; i < 3; i++) { 485 486 for (int j = 0; j < 5; j++) { 486 487 image->data.S32[i][j] = i+j; … … 535 536 536 537 //Try to get a position inside of the subimage. 537 if ( psImageGet(image, 1 3, 14) != 7) {538 if ( psImageGet(image, 14, 12) != 6 ) { 538 539 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 539 540 "psImageGet failed to return the correct value.\n"); … … 541 542 } 542 543 //Try to get a position inside of the subimage from the tail. 543 if ( psImageGet(image, -1, -1) != 8) {544 if ( psImageGet(image, -1, -1) != 6 ) { 544 545 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 545 546 "psImageGet failed to return the correct value.\n"); … … 549 550 //Try to get a position outside of the subimage but inside of the parent image. 550 551 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 551 if ( isnan( psImageGet(image, 1, 1) ) ) {552 if ( !isnan( psImageGet(image, 1, 1) ) ) { 552 553 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 553 554 "psImageGet failed to return NAN when passed an invalid location.\n"); … … 555 556 } 556 557 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 557 if ( isnan( psImageGet(image, 9, 10) ) ) {558 if ( !isnan( psImageGet(image, 9, 10) ) ) { 558 559 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 559 560 "psImageGet failed to return NAN when passed an invalid location.\n"); … … 563 564 //Try to set a position outside of the subimage. 564 565 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 565 if ( isnan( psImageGet(image, 15, 14) ) ) {566 if ( !isnan( psImageGet(image, 15, 14) ) ) { 566 567 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 567 568 "psImageGet failed to return NAN when passed an invalid location.\n"); … … 570 571 //Try to set a position outside of the subimage, indexing from the tail. 571 572 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 572 if ( isnan( psImageGet(image, -6, -1) ) ) {573 if ( !isnan( psImageGet(image, -6, -1) ) ) { 573 574 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 574 575 "psImageGet failed to return NAN when passed an invalid location.\n");
Note:
See TracChangeset
for help on using the changeset viewer.
