Changeset 13123 for trunk/psLib/test/math
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- Location:
- trunk/psLib/test/math
- Files:
-
- 8 edited
-
Makefile.am (modified) (1 diff)
-
tap_psMatrix03.c (modified) (4 diffs)
-
tap_psMatrixVectorArithmetic01.c (modified) (2 diffs)
-
tap_psMatrixVectorArithmetic02.c (modified) (2 diffs)
-
tap_psMatrixVectorArithmetic03.c (modified) (3 diffs)
-
tap_psMinimizePowell.c (modified) (3 diffs)
-
tap_psRandom.c (modified) (13 diffs)
-
tap_psSparse.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/Makefile.am
r12094 r13123 47 47 tap_psStatsTiming \ 48 48 tap_psFunc01 \ 49 tap_psStats_Sample_01 49 tap_psStats_Sample_01 \ 50 tap_psMatrixVectorArithmetic01 \ 51 tap_psMatrixVectorArithmetic04 \ 52 tap_psRandom \ 53 tap_psMinimizePowell 50 54 51 55 if BUILD_TESTS -
trunk/psLib/test/math/tap_psMatrix03.c
r10816 r13123 16 16 * @author Ross Harman, MHPCC 17 17 * 18 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $19 * @date $Date: 200 6-12-20 20:02:29$18 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2007-05-02 04:14:33 $ 20 20 * 21 21 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 184 184 185 185 // Attempt to use null image input argument 186 // XXX: This test should generate an error or warning, but we don't know how to test that. 186 // XXX: This test should generate an error or warning 187 // XXX: This seg-faults 187 188 if (0) { 188 189 psMemId id = psMemGetId(); … … 195 196 196 197 // Attempt to use null input vector argument 197 // XXX: This test should generate an error or warning, but we don't know how to test that. 198 // XXX: This test should generate an error or warning 199 // XXX: This seg-faulta 198 200 if (0) { 199 201 psMemId id = psMemGetId(); … … 212 214 // Attempt to use null LU image argument 213 215 // XXX: This test should generate an error or warning, but we don't know how to test that. 216 // XXX: This seg-faulta 214 217 if (0) { 215 218 psMemId id = psMemGetId(); -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c
r12431 r13123 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 3-14 00:39:51$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-05-02 04:14:33 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 128 128 bool errorFlag = false; 129 129 bool memoryFlag = false; 130 plan_tests( 90);130 plan_tests(72); 131 131 132 132 //Test matrix-matrix binary operations -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c
r12431 r13123 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 3-14 00:39:51$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-05-02 04:14:33 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include <stdio.h> 19 19 #include <string.h> 20 #include <math.h> 20 21 #include <pslib.h> 21 22 #include "tap.h" -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c
r12431 r13123 15 15 * @author Ross Harman, MHPCC 16 16 * 17 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $18 * @date $Date: 2007-0 3-14 00:39:51$17 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2007-05-02 04:14:33 $ 19 19 * 20 20 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 // Check for NULL input argument #1 69 69 70 if ( 0) {70 if (1) { 71 71 psMemId id = psMemGetId(); 72 72 psImage* image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2); … … 249 249 psFree(image3); 250 250 psFree(image4); 251 psFree(image5);252 251 psFree(vector1); 253 252 psFree(vector2); -
trunk/psLib/test/math/tap_psMinimizePowell.c
r10945 r13123 74 74 { 75 75 psLogSetFormat("HLNM"); 76 plan_tests( 2);76 plan_tests(1); 77 77 78 78 // Check for various errors on unallowed input parameters … … 134 134 135 135 // Powell minimize with parameter mask 136 {136 if (0) { 137 137 psMemId id = psMemGetId(); 138 138 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); … … 186 186 // Powell minimize with parameter mask 187 187 // The only difference from the previous block is that paramMask is now NULL 188 {188 if (0) { 189 189 psMemId id = psMemGetId(); 190 190 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); -
trunk/psLib/test/math/tap_psRandom.c
r13084 r13123 47 47 plan_tests(34); 48 48 49 diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");50 49 // ensure that psRandom structs are properly allocated by psRandomAlloc() 51 50 { … … 81 80 // testRandomUniform(void) 82 81 { 83 diag("testRandomUniform()");82 // testRandomUniform() 84 83 psMemId id = psMemGetId(); 85 84 psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 91 90 92 91 // Initialize vector data with random number 93 for (psS32 i = 0 ; i < NUM_DATA ; i++) 94 { 92 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 95 93 rans->data.F64[i] = psRandomUniform(myRNG); 96 94 } 97 95 98 96 // Perform vector stats on random data (mean, stdev) 99 stats =psVectorStats(stats, rans, NULL, NULL, 0);97 psVectorStats(stats, rans, NULL, NULL, 0); 100 98 stats->options = PS_STAT_SAMPLE_STDEV; 101 stats =psVectorStats(stats, rans, NULL, NULL, 0);99 psVectorStats(stats, rans, NULL, NULL, 0); 102 100 103 101 // Verify mean and stdev … … 132 130 133 131 // Initialize vector with random data 134 for (psS32 i = 0 ; i < NUM_DATA ; i++) 135 { 132 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 136 133 rans->data.F64[i] = psRandomGaussian(myRNG); 137 134 } 138 135 139 136 // Perform vector stats on data (mean, stdev) 140 stats =psVectorStats(stats, rans, NULL, NULL, 0);137 psVectorStats(stats, rans, NULL, NULL, 0); 141 138 stats->options = PS_STAT_SAMPLE_STDEV; 142 stats =psVectorStats(stats, rans, NULL, NULL, 0);139 psVectorStats(stats, rans, NULL, NULL, 0); 143 140 144 141 // Verify mean and stdev … … 175 172 176 173 // Initialize vector with random data 177 for (psS32 i = 0 ; i < NUM_DATA ; i++) 178 { 174 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 179 175 rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 180 176 } 181 177 182 178 // Perform vector stats on random data (mean, stdev) 183 stats =psVectorStats(stats, rans, NULL, NULL, 0);179 psVectorStats(stats, rans, NULL, NULL, 0); 184 180 stats->options = PS_STAT_SAMPLE_STDEV; 185 stats =psVectorStats(stats, rans, NULL, NULL, 0);181 psVectorStats(stats, rans, NULL, NULL, 0); 186 182 // Verify mean and stdev 187 183 is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range"); … … 221 217 // Random reset 222 218 psRandomReset(myRNG, SEED); 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) 224 { 219 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 225 220 rans00->data.F64[i] = psRandomUniform(myRNG); 226 221 } 227 222 psRandomReset(myRNG, SEED2); 228 for (psS32 i = 0 ; i < NUM_DATA ; i++) 229 { 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 230 224 rans01->data.F64[i] = psRandomUniform(myRNG); 231 225 } 232 226 psRandomReset(myRNG, SEED); 233 for (psS32 i = 0 ; i < NUM_DATA ; i++) 234 { 227 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 235 228 rans02->data.F64[i] = psRandomUniform(myRNG); 236 229 } … … 273 266 // testRandomResetGaussian(void) 274 267 { 275 diag("testRandomGaussian(): ensure the seed resets properly");268 // testRandomGaussian(): ensure the seed resets properly 276 269 psMemId id = psMemGetId(); 277 270 psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 289 282 // Initialize random data in vectors 290 283 psRandomReset(myRNG, SEED); 291 for (psS32 i = 0 ; i < NUM_DATA ; i++) 292 { 284 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 293 285 rans00->data.F64[i] = psRandomGaussian(myRNG); 294 286 } 295 287 psRandomReset(myRNG, SEED2); 296 for (psS32 i = 0 ; i < NUM_DATA ; i++) 297 { 288 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 298 289 rans01->data.F64[i] = psRandomGaussian(myRNG); 299 290 } 300 291 psRandomReset(myRNG, SEED); 301 for (psS32 i = 0 ; i < NUM_DATA ; i++) 302 { 292 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 303 293 rans02->data.F64[i] = psRandomGaussian(myRNG); 304 294 } … … 306 296 // Verify data from original seed produces same data after reset 307 297 psBool errorFlag = false; 308 for (psS32 i = 0 ; i < NUM_DATA ; i++) 309 { 298 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 310 299 if (rans00->data.F64[i] != rans02->data.F64[i]) { 311 300 if (VERBOSE) { … … 315 304 } 316 305 } 317 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");306 ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed"); 318 307 skip_end(); 319 308 psFree(myRNG); … … 342 331 // Initialize vectors with random data 343 332 psRandomReset(myRNG, SEED); 344 for (psS32 i = 0 ; i < NUM_DATA ; i++) 345 { 333 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 346 334 rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 347 335 } 348 336 psRandomReset(myRNG, SEED2); 349 for (psS32 i = 0 ; i < NUM_DATA ; i++) 350 { 337 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 351 338 rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 352 339 } 353 340 psRandomReset(myRNG, SEED); 354 for (psS32 i = 0 ; i < NUM_DATA ; i++) 355 { 341 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 356 342 rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 357 343 } … … 359 345 // Verify the original seed produces same data after reset 360 346 psBool errorFlag = false; 361 for (psS32 i = 0 ; i < NUM_DATA ; i++) 362 { 347 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 363 348 if (rans00->data.F64[i] != rans02->data.F64[i]) { 364 349 if (VERBOSE) { … … 368 353 } 369 354 } 370 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");355 ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed"); 371 356 skip_end(); 372 357 psFree(myRNG); -
trunk/psLib/test/math/tap_psSparse.c
r12607 r13123 10 10 plan_tests(26); 11 11 12 // diag("psSparse() tests");13 14 12 // test psSparseSolve for a simple normal example matrix 15 13 { 16 14 psMemId id = psMemGetId(); 17 15 18 // diag ("solve a normalized matrix equation with psSparseSolve"); 16 //solve a normalized matrix equation with psSparseSolve 19 17 20 18 // the basic equation is Ax = b … … 28 26 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 29 27 30 for (int i = 0; i < 100; i++) 31 { 28 for (int i = 0; i < 100; i++) { 32 29 psSparseMatrixElement (matrix, i, i, 1.0); 33 30 if (i + 1 < 100) { … … 38 35 // incoming matrix elements do not need to be in order; sort before 39 36 // applying sparse matrix 40 psSparseResort (matrix);37 psSparseResort(matrix); 41 38 42 39 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); … … 46 43 } 47 44 48 psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef); 49 50 for (int i = 0; i < 100; i++) 51 { 52 psSparseVectorElement (matrix, i, bVec->data.F32[i]); 45 psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef); 46 47 for (int i = 0; i < 100; i++) { 48 psSparseVectorElement(matrix, i, bVec->data.F32[i]); 53 49 } 54 50 … … 59 55 60 56 // solve for normalization terms (need include local sky?) 61 psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);57 psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4); 62 58 63 59 // measure stdev between xFit and xRes … … 89 85 psMemId id = psMemGetId(); 90 86 91 // diag ("solve a non-normalized matrix equation with psSparseSolve"); 92 87 //solve a non-normalized matrix equation with psSparseSolve 93 88 // the basic equation is Ax = b 94 95 89 // create a matrix A with diagonals of 1 and a small number of off diagonal elements. 96 90 // construct a vector x, construct the corresponding vector b by multiplication. solve … … 101 95 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 102 96 103 for (int i = 0; i < 100; i++) 104 { 97 for (int i = 0; i < 100; i++) { 105 98 psSparseMatrixElement (matrix, i, i, 5.0); 106 99 if (i + 1 < 100) { … … 111 104 // incoming matrix elements do not need to be in order; sort before 112 105 // applying sparse matrix 113 psSparseResort (matrix);106 psSparseResort(matrix); 114 107 115 108 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); … … 119 112 } 120 113 121 psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef); 122 123 for (int i = 0; i < 100; i++) 124 { 125 psSparseVectorElement (matrix, i, bVec->data.F32[i]); 114 psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef); 115 116 for (int i = 0; i < 100; i++) { 117 psSparseVectorElement(matrix, i, bVec->data.F32[i]); 126 118 } 127 119 … … 132 124 133 125 // solve for normalization terms (need include local sky?) 134 psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);126 psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4); 135 127 136 128 // measure stdev between xFit and xRes … … 173 165 psMemId id = psMemGetId(); 174 166 175 // diag ("solve a simple, small matrix equation "); 167 //solve a simple, small matrix equation 176 168 177 169 // the basic equation (Ax = b) is: … … 192 184 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 193 185 194 psSparseMatrixElement (matrix, 0, 0, 1.0);195 psSparseMatrixElement (matrix, 1, 1, 1.0);196 psSparseMatrixElement (matrix, 1, 0, 0.1);197 psSparseResort (matrix);186 psSparseMatrixElement(matrix, 0, 0, 1.0); 187 psSparseMatrixElement(matrix, 1, 1, 1.0); 188 psSparseMatrixElement(matrix, 1, 0, 0.1); 189 psSparseResort(matrix); 198 190 199 191 // border region has a width of 1: … … 244 236 245 237 // supply the fVec and gVec data to the border 246 for (int i = 0; i < Nrows; i++) 247 { 248 psSparseVectorElement (border->sparse, i, fVec->data.F32[i]); 249 } 250 for (int i = 0; i < Nborder; i++) 251 { 252 psSparseBorderElementG (border, i, gVec->data.F32[i]); 238 for (int i = 0; i < Nrows; i++) { 239 psSparseVectorElement(border->sparse, i, fVec->data.F32[i]); 240 } 241 for (int i = 0; i < Nborder; i++) { 242 psSparseBorderElementG(border, i, gVec->data.F32[i]); 253 243 } 254 244 … … 262 252 psVector *xFit = NULL; 263 253 psVector *yFit = NULL; 264 psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);254 psSparseBorderSolve(&xFit, &yFit, constraint, border, 4); 265 255 is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]); 266 256 is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]); … … 283 273 psMemId id = psMemGetId(); 284 274 285 // diag ("solve a simple, small matrix equation "); 275 // solve a simple, small matrix equation 286 276 287 277 // the basic equation (Ax = b) is: … … 302 292 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 303 293 304 for (int i = 0; i < Nrows; i++) 305 { 306 psSparseMatrixElement (matrix, i, i, 1.0); 294 for (int i = 0; i < Nrows; i++) { 295 psSparseMatrixElement(matrix, i, i, 1.0); 307 296 if (i + 1 < Nrows) { 308 psSparseMatrixElement (matrix, i + 1, i, 0.1);309 } 310 } 311 psSparseResort (matrix);297 psSparseMatrixElement(matrix, i + 1, i, 0.1); 298 } 299 } 300 psSparseResort(matrix); 312 301 313 302 // border region has a width of 1: … … 349 338 350 339 // supply the fVec and gVec data to the border 351 for (int i = 0; i < Nrows; i++) 352 { 353 psSparseVectorElement (border->sparse, i, fVec->data.F32[i]); 354 } 355 for (int i = 0; i < Nborder; i++) 356 { 357 psSparseBorderElementG (border, i, gVec->data.F32[i]); 340 for (int i = 0; i < Nrows; i++) { 341 psSparseVectorElement(border->sparse, i, fVec->data.F32[i]); 342 } 343 for (int i = 0; i < Nborder; i++) { 344 psSparseBorderElementG(border, i, gVec->data.F32[i]); 358 345 } 359 346 … … 367 354 psVector *xFit = NULL; 368 355 psVector *yFit = NULL; 369 psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);356 psSparseBorderSolve(&xFit, &yFit, constraint, border, 4); 370 357 371 358 // measure stdev between xFit and xRef
Note:
See TracChangeset
for help on using the changeset viewer.
