Changeset 2812 for trunk/psModules/test/tst_pmReadoutCombine.c
- Timestamp:
- Dec 23, 2004, 1:16:36 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/tst_pmReadoutCombine.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/tst_pmReadoutCombine.c
r2590 r2812 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12- 01 22:08:32$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-23 23:16:36 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 15 15 #include "pmReadoutCombine.h" 16 16 static int test00(void); 17 static int test01(void); 17 18 testDescription tests[] = { 18 19 {test00, 000, "pmSubtractBias", 0, false}, 20 {test01, 000, "pmSubtractBias(): input parameter error conditions", 0, false}, 19 21 {NULL} 20 22 }; … … 34 36 int doit() 35 37 { 38 return(0); 36 39 int i; 37 40 int j; … … 238 241 return(testStatus); 239 242 } 243 244 psS32 VerifyTheOutput(psImage *output) 245 { 246 bool testStatus = true; 247 248 for (psS32 i = 0 ; i < output->numRows ; i++) { 249 for (psS32 j = 0 ; j < output->numCols ; j++) { 250 if (output->data.F32[i][j] != 45.0) { 251 printf("ERROR: output[%d][%d] is %.2f, should be 45.0\n", i, j, output->data.F32[i][j]); 252 testStatus = false; 253 } 254 } 255 } 256 return(testStatus); 257 } 258 259 260 int test01() 261 { 262 int i; 263 int j; 264 int r; 265 psList *list = NULL; 266 int baseRowsReadout[NUM_READOUTS]; 267 int baseColsReadout[NUM_READOUTS]; 268 int baseRows[NUM_READOUTS]; 269 int baseCols[NUM_READOUTS]; 270 int numRows[NUM_READOUTS]; 271 int numCols[NUM_READOUTS]; 272 int minOutRow = 10000; 273 int minOutCol = 10000; 274 int maxOutRow = -1; 275 int maxOutCol = -1; 276 psImage *output = NULL; 277 psImage *rc = NULL; 278 psCombineParams *params = (psCombineParams *) psAlloc(sizeof(psCombineParams)); 279 psVector *zero = psVectorAlloc(NUM_READOUTS, PS_TYPE_F32); 280 psVector *zeroHalf = psVectorAlloc(NUM_READOUTS/2, PS_TYPE_F32); 281 psVector *zeroBig = psVectorAlloc(NUM_READOUTS+1, PS_TYPE_F32); 282 psVector *zeroF64 = psVectorAlloc(NUM_READOUTS, PS_TYPE_F64); 283 psVector *scale = psVectorAlloc(NUM_READOUTS, PS_TYPE_F32); 284 psVector *scaleHalf = psVectorAlloc(NUM_READOUTS/2, PS_TYPE_F32); 285 psVector *scaleBig = psVectorAlloc(NUM_READOUTS*2, PS_TYPE_F32); 286 psVector *scaleF64 = psVectorAlloc(NUM_READOUTS, PS_TYPE_F64); 287 int testStatus = true; 288 for (i=0;i<NUM_READOUTS;i++) { 289 zero->data.F32[i] = 3.0; 290 zeroBig->data.F32[i] = 3.0; 291 } 292 for (i=0;i<NUM_READOUTS;i++) { 293 scale->data.F32[i] = 6.0; 294 scaleBig->data.F32[i] = 6.0; 295 } 296 297 params->stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 298 params->maskVal = 1; 299 params->fracLow = 0.0; 300 params->fracHigh = 10000.0; 301 params->nKeep = 0; 302 303 for (r=0;r<NUM_READOUTS;r++) { 304 baseRowsReadout[r] = r + 40; 305 baseColsReadout[r] = r + 42; 306 baseRows[r] = r; 307 baseCols[r] = r+2; 308 numRows[r] = 4 + (2 * r); 309 numCols[r] = 8 + (2 * r); 310 311 baseRowsReadout[r] = 0; 312 baseColsReadout[r] = 0; 313 baseRows[r] = 0; 314 baseCols[r] = 0; 315 numRows[r] = 10; 316 numCols[r] = 10; 317 318 psImage *tmpImage = psImageAlloc(numCols[r], numRows[r], PS_TYPE_F32); 319 for (i=0;i<numRows[r];i++) { 320 for (j=0;j<numCols[r];j++) { 321 tmpImage->data.F32[i][j] = (float) (i + j); 322 tmpImage->data.F32[i][j] = 1.0; 323 tmpImage->data.F32[i][j] = (float) r; 324 } 325 } 326 327 *(int *) (& (tmpImage->row0)) = baseRows[r]; 328 *(int *) (& (tmpImage->col0)) = baseCols[r]; 329 psReadout *tmpReadout = psReadoutAlloc(baseColsReadout[r], 330 baseRowsReadout[r], 331 tmpImage); 332 minOutRow = PS_MIN(minOutRow, (baseRowsReadout[r] + baseRows[r])); 333 minOutCol = PS_MIN(minOutCol, (baseColsReadout[r] + baseCols[r])); 334 maxOutRow = PS_MAX(maxOutRow, (baseRowsReadout[r] + baseRows[r] + numRows[r])); 335 maxOutCol = PS_MAX(maxOutCol, (baseColsReadout[r] + baseCols[r] + numCols[r])); 336 337 if (r == 0) { 338 list = psListAlloc(tmpReadout); 339 } else { 340 psListAdd(list, PS_LIST_HEAD, tmpReadout); 341 } 342 } 343 344 printf("----------------------------------------------------------------------------\n"); 345 printf("Calling pmReadoutCombine() with NULL zero vector.\n"); 346 rc = pmReadoutCombine(NULL, list, params, NULL, scale, true, 1.0, 0.0); 347 if (rc == NULL) { 348 //XXX: We should verify the output image here. 349 printf("ERROR: pmReadoutCombine() returned NULL\n"); 350 testStatus = false; 351 } 352 if (rc->type.type != scale->type.type) { 353 printf("ERROR: output readout->image has incorrect type.\n"); 354 testStatus = false; 355 } 356 psFree(rc); 357 358 printf("----------------------------------------------------------------------------\n"); 359 printf("Calling pmReadoutCombine() with incorrect length zero vector (too small). Should generate error.\n"); 360 rc = pmReadoutCombine(NULL, list, params, zeroHalf, scale, true, 1.0, 0.0); 361 if (rc != NULL) { 362 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 363 testStatus = false; 364 } 365 366 printf("----------------------------------------------------------------------------\n"); 367 printf("Calling pmReadoutCombine() with incorrect type zero vector. Should generate error.\n"); 368 rc = pmReadoutCombine(NULL, list, params, zeroF64, scale, true, 1.0, 0.0); 369 if (rc != NULL) { 370 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 371 testStatus = false; 372 } 373 374 printf("----------------------------------------------------------------------------\n"); 375 printf("Calling pmReadoutCombine() with incorrect length zero vector (too big). Should generate warning.\n"); 376 rc = pmReadoutCombine(output, list, params, zeroBig, scale, true, 1.0, 0.0); 377 if (rc != NULL) { 378 if (false == VerifyTheOutput(rc)) { 379 testStatus = false; 380 } 381 psFree(rc); 382 rc = NULL; 383 } else { 384 printf("ERROR: pmReadoutCombine() returned NULL\n"); 385 testStatus = false; 386 } 387 388 printf("----------------------------------------------------------------------------\n"); 389 printf("Calling pmReadoutCombine() with NULL scale vector.\n"); 390 rc = pmReadoutCombine(output, list, params, zero, NULL, true, 1.0, 0.0); 391 if (rc == NULL) { 392 //XXX: We should verify the output image here. 393 printf("ERROR: pmReadoutCombine() returned NULL\n"); 394 testStatus = false; 395 } 396 psFree(rc); 397 398 printf("----------------------------------------------------------------------------\n"); 399 printf("Calling pmReadoutCombine() with incorrect length scale vector (too small). Should generate error.\n"); 400 rc = pmReadoutCombine(output, list, params, zero, scaleHalf, true, 1.0, 0.0); 401 if (rc != NULL) { 402 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 403 testStatus = false; 404 } 405 406 printf("----------------------------------------------------------------------------\n"); 407 printf("Calling pmReadoutCombine() with incorrect type scale vector. Should generate error.\n"); 408 rc = pmReadoutCombine(output, list, params, zero, scaleF64, true, 1.0, 0.0); 409 if (rc != NULL) { 410 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 411 testStatus = false; 412 } 413 414 printf("----------------------------------------------------------------------------\n"); 415 printf("Calling pmReadoutCombine() with incorrect length scale vector (too big). Should generate warning.\n"); 416 rc = pmReadoutCombine(output, list, params, zero, scaleBig, true, 1.0, 0.0); 417 if (rc != NULL) { 418 if (false == VerifyTheOutput(rc)) { 419 testStatus = false; 420 } 421 psFree(rc); 422 rc = NULL; 423 } else { 424 printf("ERROR: pmReadoutCombine() returned NULL\n"); 425 testStatus = false; 426 } 427 428 printf("----------------------------------------------------------------------------\n"); 429 printf("Calling pmReadoutCombine() insufficient size output image. Should generate error, return NULL.\n"); 430 output = psImageAlloc(1, 1, PS_TYPE_F32); 431 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 432 if (rc != NULL) { 433 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 434 testStatus = false; 435 } 436 psFree(output); 437 output = NULL; 438 439 printf("----------------------------------------------------------------------------\n"); 440 printf("Calling pmReadoutCombine() with NULL input list. Should generate error, return NULL.\n"); 441 rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 1.0, 0.0); 442 if (rc != NULL) { 443 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 444 testStatus = false; 445 } 446 447 printf("----------------------------------------------------------------------------\n"); 448 printf("Calling pmReadoutCombine() with NULL params. Should generate error, return NULL.\n"); 449 rc = pmReadoutCombine(output, list, NULL, zero, scale, true, 1.0, 0.0); 450 if (rc != NULL) { 451 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 452 testStatus = false; 453 } 454 455 printf("----------------------------------------------------------------------------\n"); 456 psStatsOptions oldStatsOpts = params->stats->options |= PS_STAT_MIN; 457 printf("Calling pmReadoutCombine() with multiple stats->options. Should generate error, return NULL.\n"); 458 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 459 if (rc != NULL) { 460 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 461 testStatus = false; 462 } 463 params->stats->options = oldStatsOpts; 464 465 printf("----------------------------------------------------------------------------\n"); 466 psStats *oldStats = params->stats; 467 printf("Calling pmReadoutCombine() with NULL param->stats. Should generate error, return NULL.\n"); 468 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 469 if (rc != NULL) { 470 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 471 testStatus = false; 472 } 473 params->stats = oldStats; 474 475 printf("----------------------------------------------------------------------------\n"); 476 printf("============================================================================\n"); 477 478 psFree(params->stats); 479 psFree(params); 480 // psFree(output); 481 // psFree(rc); 482 psFree(zero); 483 psFree(zeroHalf); 484 psFree(zeroBig); 485 psFree(zeroF64); 486 psFree(scale); 487 psFree(scaleHalf); 488 psFree(scaleBig); 489 psFree(scaleF64); 490 psListElem *tmpInput = (psListElem *) list->head; 491 while (NULL != tmpInput) { 492 psReadout *tmpReadout = (psReadout *) tmpInput->data; 493 psFree(tmpReadout); 494 tmpInput = tmpInput->next; 495 } 496 psFree(list); 497 498 return(!testStatus); 499 } 500 // This code will
Note:
See TracChangeset
for help on using the changeset viewer.
