Changeset 4108 for trunk/psLib/src/math/psConstants.h
- Timestamp:
- Jun 3, 2005, 2:49:48 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psConstants.h (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psConstants.h
r4051 r4108 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.7 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 5-31 21:48:13$8 * @version $Revision: 1.72 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-06-04 00:49:48 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 60 60 61 61 #define PS_ASSERT_INT_UNEQUAL(NAME1, NAME2, RVAL) \ 62 if ( NAME1 == NAME2) { \62 if ((NAME1) == (NAME2)) { \ 63 63 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 64 64 "Error: %s and %s are equal.", \ … … 68 68 69 69 #define PS_ASSERT_INT_EQUAL(NAME1, NAME2, RVAL) \ 70 if ( NAME1 != NAME2) { \70 if ((NAME1) != (NAME2)) { \ 71 71 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 72 72 "Error: %s and %s are not equal.", \ … … 76 76 77 77 #define PS_ASSERT_INT_NONNEGATIVE(NAME, RVAL) \ 78 if ( NAME< 0) { \78 if ((NAME) < 0) { \ 79 79 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 80 80 "Error: %s is less than 0.", #NAME); \ … … 83 83 84 84 #define PS_ASSERT_INT_POSITIVE(NAME, RVAL) \ 85 if ( NAME< 1) { \85 if ((NAME) < 1) { \ 86 86 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 87 87 "Error: %s is 0 or less.", #NAME); \ … … 90 90 91 91 #define PS_ASSERT_INT_ZERO(NAME, RVAL) \ 92 if ( NAME!= 0) { \92 if ((NAME) != 0) { \ 93 93 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 94 94 "Error: %s is 0.", #NAME); \ … … 97 97 98 98 #define PS_ASSERT_INT_NONZERO(NAME, RVAL) \ 99 if ( NAME== 0) { \99 if ((NAME) == 0) { \ 100 100 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 101 101 "Error: %s is 0.", #NAME); \ … … 103 103 } 104 104 105 // XXX: Where did these int casts come from? 105 106 #define PS_ASSERT_INT_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \ 106 if ((int) NAME < LOWER || (int)NAME> UPPER) { \107 if ((int)(NAME) < LOWER || (int)(NAME) > UPPER) { \ 107 108 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 108 109 "Error: %s, %d, is out of range. Must be between %d and %d.", \ … … 111 112 } 112 113 114 #define PS_ASSERT_INT_LARGER_THAN(NAME1, NAME2, RVAL) \ 115 if (!((NAME1) > (NAME2))) { \ 116 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 117 "Error: !(%s > %s) (%d %d).", \ 118 #NAME1, #NAME2, NAME1, NAME2); \ 119 return(RVAL); \ 120 } 121 122 #define PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \ 123 if (!((NAME1) >= (NAME2))) { \ 124 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 125 "Error: !(%s >= %s) (%d %d).", \ 126 #NAME1, #NAME2, NAME1, NAME2); \ 127 return(RVAL); \ 128 } 129 #define PS_ASSERT_FLOAT_LARGER_THAN(NAME1, NAME2, RVAL) \ 130 if (!((NAME1) > (NAME2))) { \ 131 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 132 "Error: !(%s > %s) (%f %f).", \ 133 #NAME1, #NAME2, NAME1, NAME2); \ 134 return(RVAL); \ 135 } 136 137 #define PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \ 138 if (!((NAME1) >= (NAME2))) { \ 139 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 140 "Error: !(%s >= %s) (%f %f).", \ 141 #NAME1, #NAME2, NAME1, NAME2); \ 142 return(RVAL); \ 143 } 144 113 145 // Produce an error if (NAME1 > NAME2) 114 // XXX: rename: ASSERT146 // XXX: Get rid of this, use above macros. 115 147 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \ 116 if ( NAME1 > NAME2) { \148 if ((NAME1) > (NAME2)) { \ 117 149 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 118 150 "Error: (%s > %s) (%d %d).", \ … … 122 154 123 155 // Produce an error if ((NAME1 > NAME2) 124 // XXX: rename: ASSERT156 // XXX: Get rid of this, use above macros. 125 157 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 126 if ( NAME1 > NAME2) { \158 if ((NAME1) > (NAME2)) { \ 127 159 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 128 160 "Error: (%s > %s) (%f %f)", \ … … 131 163 } 132 164 133 // Generate an error if the two floats are equal.134 // XXX: Inconsistent naming.135 165 #define PS_ASSERT_FLOAT_NON_EQUAL(NAME1, NAME2, RVAL) \ 136 if (fabs( NAME2 - NAME1) < FLT_EPSILON) { \166 if (fabs((NAME2) - (NAME1)) < FLT_EPSILON) { \ 137 167 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 138 168 "Error: %s and %s are equal.", \ 169 #NAME1, #NAME2); \ 170 return(RVAL); \ 171 } 172 173 #define PS_ASSERT_FLOAT_EQUAL(NAME1, NAME2, RVAL) \ 174 if (fabs((NAME2) - (NAME1)) > FLT_EPSILON) { \ 175 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 176 "Error: %s and %s are not equal.", \ 139 177 #NAME1, #NAME2); \ 140 178 return(RVAL); \ … … 165 203 #define PS_ASSERT_PTR_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, return RVAL) 166 204 #define PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, CLEANUP) \ 167 if ( NAME== NULL) { \205 if ((NAME) == NULL) { \ 168 206 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 169 207 "Unallowable operation: %s is NULL.", \ … … 173 211 174 212 #define PS_ASSERT_PTR_TYPE(NAME, TYPE, RVAL) \ 175 if ( NAME->type.type != TYPE) { \213 if ((NAME)->type.type != TYPE) { \ 176 214 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 177 215 "Unallowable operation: %s has incorrect type.", \ … … 182 220 #define PS_ASSERT_PTR_DIMEN(NAME, DIMEN, RVAL) PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, return RVAL) 183 221 #define PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, CLEANUP) \ 184 if ( NAME->type.dimen != DIMEN) { \222 if ((NAME)->type.dimen != DIMEN) { \ 185 223 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 186 224 "Unallowable operation: %s has incorrect dimensionality.", \ … … 190 228 191 229 #define PS_ASSERT_PTR_DIMEN_GENERAL_NOT(NAME, DIMEN, CLEANUP) \ 192 if ( NAME->type.dimen == DIMEN) { \230 if ((NAME)->type.dimen == DIMEN) { \ 193 231 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 194 232 "Unallowable operation: %s has incorrect dimensionality.", \ … … 221 259 #define PS_ASSERT_VECTOR_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_VECTOR_NON_NULL(NAME, return RVAL) 222 260 #define PS_ASSERT_GENERAL_VECTOR_NON_NULL(NAME, CLEANUP) \ 223 if ( NAME == NULL || NAME->data.U8 == NULL) { \261 if ((NAME) == NULL || (NAME)->data.U8 == NULL) { \ 224 262 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 225 263 "Unallowable operation: psVector %s or its data is NULL.", \ … … 230 268 #define PS_ASSERT_VECTOR_NON_EMPTY(NAME, RVAL) PS_ASSERT_GENERAL_VECTOR_NON_EMPTY(NAME, return RVAL) 231 269 #define PS_ASSERT_GENERAL_VECTOR_NON_EMPTY(NAME, CLEANUP) \ 232 if ( NAME->n < 1) { \270 if ((NAME)->n < 1) { \ 233 271 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 234 272 "Unallowable operation: psVector %s has no elements.", \ … … 238 276 239 277 #define PS_ASSERT_VECTOR_TYPE_F32_OR_F64(NAME, RVAL) \ 240 if (( NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \278 if (((NAME)->type.type != PS_TYPE_F32) && ((NAME)->type.type != PS_TYPE_F64)) { \ 241 279 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 242 280 "psVector %s: bad type(%d)", \ … … 246 284 247 285 #define PS_ASSERT_VECTOR_TYPE_S16_S32_F32(NAME, RVAL) \ 248 if (( NAME->type.type != PS_TYPE_S16) && (NAME->type.type != PS_TYPE_S32) && (NAME->type.type != PS_TYPE_F32)) { \286 if (((NAME)->type.type != PS_TYPE_S16) && ((NAME)->type.type != PS_TYPE_S32) && ((NAME)->type.type != PS_TYPE_F32)) { \ 249 287 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 250 288 "psVector %s: bad type(%d)", \ … … 254 292 255 293 #define PS_ASSERT_VECTOR_TYPE(NAME, TYPE, RVAL) \ 256 if ( NAME->type.type != TYPE) { \294 if ((NAME)->type.type != TYPE) { \ 257 295 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 258 296 "Unallowable operation: psVector %s has incorrect type.", \ … … 298 336 299 337 #define PS_VECTOR_PRINT_F32(NAME) \ 300 for (int my_i=0;my_i< NAME->n;my_i++) { \301 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, NAME->data.F32[my_i]); \338 for (int my_i=0;my_i<(NAME)->n;my_i++) { \ 339 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, (NAME)->data.F32[my_i]); \ 302 340 } \ 303 341 printf("\n"); \ … … 364 402 #define PS_VECTOR_GEN_STATIC_RECYCLED(NAME, SIZE, TYPE) \ 365 403 static psVector *NAME = NULL; \ 366 NAME = psVectorRecycle(NAME, SIZE, TYPE); \367 p_psMemSetPersistent( NAME, true); \368 p_psMemSetPersistent( NAME->data.U8, true); \404 (NAME) = psVectorRecycle((NAME), SIZE, TYPE); \ 405 p_psMemSetPersistent((NAME), true); \ 406 p_psMemSetPersistent((NAME)->data.U8, true); \ 369 407 370 408 #define PS_VECTOR_DECLARE_ALLOC_STATIC(NAME, SIZE, TYPE) \ 371 static psVector * NAME= NULL; \372 if ( NAME== NULL) { \373 NAME= psVectorAlloc(SIZE, TYPE); \374 p_psMemSetPersistent( NAME, true); \409 static psVector *(NAME) = NULL; \ 410 if ((NAME) == NULL) { \ 411 (NAME) = psVectorAlloc(SIZE, TYPE); \ 412 p_psMemSetPersistent((NAME), true); \ 375 413 } \ 376 414 … … 430 468 *****************************************************************************/ 431 469 #define PS_ASSERT_POLY_NON_NULL(NAME, RVAL) \ 432 if ( NAME == NULL || NAME->coeff == NULL) { \470 if ((NAME) == NULL || (NAME)->coeff == NULL) { \ 433 471 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 434 472 "Unallowable operation: polynomial %s or its coeffs is NULL.", \ … … 438 476 439 477 #define PS_ASSERT_POLY_TYPE(NAME, TYPE, RVAL) \ 440 if ( NAME->type != TYPE) { \478 if ((NAME)->type != TYPE) { \ 441 479 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 442 480 "Unallowable operation: polynomial %s has wrong type.", #NAME); \ … … 448 486 449 487 #define PS_POLY_1D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 450 static psPolynomial1D * NAME= NULL; \451 if ( NAME== NULL) { \452 NAME= psPolynomial1DAlloc(ORDER, TYPE); \453 p_psMemSetPersistent( NAME, true); \454 p_psMemSetPersistent( NAME->coeff, true); \455 p_psMemSetPersistent( NAME->coeffErr, true); \456 p_psMemSetPersistent( NAME->mask, true); \488 static psPolynomial1D *(NAME) = NULL; \ 489 if ((NAME) == NULL) { \ 490 (NAME) = psPolynomial1DAlloc(ORDER, TYPE); \ 491 p_psMemSetPersistent((NAME), true); \ 492 p_psMemSetPersistent((NAME)->coeff, true); \ 493 p_psMemSetPersistent((NAME)->coeffErr, true); \ 494 p_psMemSetPersistent((NAME)->mask, true); \ 457 495 } \ 458 496 459 497 #define PS_POLY_2D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 460 static psPolynomial2D * NAME= NULL; \461 if ( NAME== NULL) { \462 NAME= psPolynomial2DAlloc(ORDER, TYPE); \463 p_psMemSetPersistent( NAME, true); \498 static psPolynomial2D *(NAME) = NULL; \ 499 if ((NAME) == NULL) { \ 500 (NAME) = psPolynomial2DAlloc(ORDER, TYPE); \ 501 p_psMemSetPersistent((NAME), true); \ 464 502 } \ 465 503 466 504 #define PS_POLY_3D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 467 static psPolynomial3D * NAME= NULL; \468 if ( NAME== NULL) { \469 NAME= psPolynomial3DAlloc(ORDER, TYPE); \470 p_psMemSetPersistent( NAME, true); \505 static psPolynomial3D *(NAME) = NULL; \ 506 if ((NAME) == NULL) { \ 507 (NAME) = psPolynomial3DAlloc(ORDER, TYPE); \ 508 p_psMemSetPersistent((NAME), true); \ 471 509 } \ 472 510 473 511 #define PS_POLY_4D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 474 static psPolynomial4D * NAME= NULL; \475 if ( NAME== NULL) { \476 NAME= psPolynomial4DAlloc(ORDER, TYPE); \477 p_psMemSetPersistent( NAME, true); \512 static psPolynomial4D *(NAME) = NULL; \ 513 if ((NAME) == NULL) { \ 514 (NAME) = psPolynomial4DAlloc(ORDER, TYPE); \ 515 p_psMemSetPersistent((NAME), true); \ 478 516 } \ 479 517 480 518 #define PS_POLY_1D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 481 static psPolynomial1D * NAME= NULL; \482 if ( NAME== NULL) { \483 NAME= psPolynomial1DAlloc(ORDER, TYPE); \484 p_psMemSetPersistent( NAME, true); \519 static psPolynomial1D *(NAME) = NULL; \ 520 if ((NAME) == NULL) { \ 521 (NAME) = psPolynomial1DAlloc(ORDER, TYPE); \ 522 p_psMemSetPersistent((NAME), true); \ 485 523 } \ 486 524 487 525 #define PS_POLY_2D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 488 static psPolynomial2D * NAME= NULL; \489 if ( NAME== NULL) { \490 NAME= psPolynomial2DAlloc(ORDER, TYPE); \491 p_psMemSetPersistent( NAME, true); \526 static psPolynomial2D *(NAME) = NULL; \ 527 if ((NAME) == NULL) { \ 528 (NAME) = psPolynomial2DAlloc(ORDER, TYPE); \ 529 p_psMemSetPersistent((NAME), true); \ 492 530 } \ 493 531 494 532 #define PS_POLY_3D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 495 static psPolynomial3D * NAME= NULL; \496 if ( NAME== NULL) { \497 NAME= psPolynomial3DAlloc(ORDER, TYPE); \498 p_psMemSetPersistent( NAME, true); \533 static psPolynomial3D *(NAME) = NULL; \ 534 if ((NAME) == NULL) { \ 535 (NAME) = psPolynomial3DAlloc(ORDER, TYPE); \ 536 p_psMemSetPersistent((NAME), true); \ 499 537 } \ 500 538 501 539 #define PS_POLY_4D_D_DECLARE_ALLOC_STATIC(NAME, ORDER, TYPE) \ 502 static psPolynomial4D * NAME= NULL; \503 if ( NAME== NULL) { \504 NAME= psPolynomial4DAlloc(ORDER, TYPE); \505 p_psMemSetPersistent( NAME, true); \540 static psPolynomial4D *(NAME) = NULL; \ 541 if ((NAME) == NULL) { \ 542 (NAME) = psPolynomial4DAlloc(ORDER, TYPE); \ 543 p_psMemSetPersistent((NAME), true); \ 506 544 } \ 507 545 … … 511 549 #define PS_ASSERT_IMAGE_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_IMAGE_NON_NULL(NAME, return RVAL) 512 550 #define PS_ASSERT_GENERAL_IMAGE_NON_NULL(NAME, CLEANUP) \ 513 if ( NAME == NULL || NAME->data.V == NULL) { \551 if ((NAME) == NULL || (NAME)->data.V == NULL) { \ 514 552 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 515 553 "Unallowable operation: psImage %s or its data is NULL.", \ … … 520 558 #define PS_ASSERT_IMAGE_NON_EMPTY(NAME, RVAL) PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(NAME, return RVAL) 521 559 #define PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(NAME, CLEANUP) \ 522 if ( NAME->numCols < 1 || NAME->numRows < 1) { \560 if ((NAME)->numCols < 1 || (NAME)->numRows < 1) { \ 523 561 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 524 562 "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \ 525 #NAME, NAME->numCols, NAME->numRows); \563 #NAME, (NAME)->numCols, (NAME)->numRows); \ 526 564 CLEANUP; \ 527 565 } 528 566 529 567 #define PS_ASSERT_IMAGE_TYPE(NAME, TYPE, RVAL) \ 530 if ( NAME->type.type != TYPE) { \568 if ((NAME)->type.type != TYPE) { \ 531 569 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 532 570 "Unallowable operation: psImage %s has incorrect type.", \ … … 536 574 537 575 #define PS_ASSERT_IMAGES_SIZE_EQUAL(NAME1, NAME2, RVAL) \ 538 if (( NAME1->numCols != NAME2->numCols) || \539 ( NAME1->numRows != NAME2->numRows)) { \576 if (((NAME1)->numCols != (NAME2)->numCols) || \ 577 ((NAME1)->numRows != (NAME2)->numRows)) { \ 540 578 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 541 579 "Unallowable operation: psImages %s and %s are not the same size.", \ … … 545 583 546 584 #define PS_ASSERT_IMAGE_SIZE(NAME1, NUM_COLS, NUM_ROWS, RVAL) \ 547 if (( NAME1->numCols != NUM_COLS) || \548 ( NAME1->numRows != NUM_ROWS)) { \585 if (((NAME1)->numCols != NUM_COLS) || \ 586 ((NAME1)->numRows != NUM_ROWS)) { \ 549 587 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 550 588 "Unallowable operation: psImages %s is not the correct size.", \ … … 555 593 #define PS_IMAGE_PRINT_F32(NAME) \ 556 594 printf("======== printing %s ========\n", #NAME); \ 557 for (int i = 0 ; i < NAME->numRows ; i++) { \558 for (int j = 0 ; j < NAME->numCols ; j++) { \559 printf("%.2f ", NAME->data.F32[i][j]); \595 for (int i = 0 ; i < (NAME)->numRows ; i++) { \ 596 for (int j = 0 ; j < (NAME)->numCols ; j++) { \ 597 printf("%.2f ", (NAME)->data.F32[i][j]); \ 560 598 } \ 561 599 printf("\n"); \ … … 636 674 *****************************************************************************/ 637 675 #define PS_ASSERT_READOUT_NON_NULL(NAME, RVAL) \ 638 if ( NAME == NULL || NAME->image == NULL) { \676 if ((NAME) == NULL || (NAME)->image == NULL) { \ 639 677 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 640 678 "Unallowable operation: psReadout %s or its data is NULL.", \ … … 644 682 645 683 #define PS_ASSERT_READOUT_NON_EMPTY(NAME, RVAL) \ 646 if ( NAME->image->numCols < 1 || NAME->image->numRows < 1) { \684 if ((NAME)->image->numCols < 1 || (NAME)->image->numRows < 1) { \ 647 685 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 648 686 "Unallowable operation: psReadout %s or its data is NULL.", #NAME); \ … … 651 689 652 690 #define PS_ASSERT_READOUT_TYPE(NAME, TYPE, RVAL) \ 653 if ( NAME->image->type.type != TYPE) { \691 if ((NAME)->image->type.type != TYPE) { \ 654 692 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 655 693 "Unallowable operation: psImage %s has incorrect type.", #NAME); \
Note:
See TracChangeset
for help on using the changeset viewer.
