Changeset 2406
- Timestamp:
- Nov 23, 2004, 9:35:30 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 7 edited
-
dataManip/psFunctions.c (modified) (3 diffs)
-
dataManip/psMinimize.c (modified) (4 diffs)
-
dataManip/psStats.c (modified) (9 diffs)
-
math/psMinimize.c (modified) (4 diffs)
-
math/psPolynomial.c (modified) (3 diffs)
-
math/psSpline.c (modified) (3 diffs)
-
math/psStats.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r2370 r2406 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-11- 15 21:13:17$9 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-23 19:35:30 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 14 * XXX: What happens if the polyEVal functions are called with data of the wrong 15 15 * type? 16 * XXX: Should the "coeffErr[]" be used as well? Bug ???. Ignore coeffErr 17 * 16 18 */ 17 19 /*****************************************************************************/ … … 274 276 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 275 277 276 XXX: Should the "coeffErr[]" be used as well?277 278 *****************************************************************************/ 278 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) -
trunk/psLib/src/dataManip/psMinimize.c
r2347 r2406 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11- 12 20:45:27$11 * @version $Revision: 1.89 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-23 19:35:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 416 416 const psArray *coords) 417 417 { 418 PS_PTR_CHECK_NULL(coords, NULL); 419 PS_PTR_CHECK_NULL(params, NULL); 420 418 421 psTrace(".psLib.dataManip.psMinimize", 4, 419 422 "---- psMinimizeLMChi2Gauss1D() begin ----\n"); 420 421 PS_PTR_CHECK_NULL(coords, NULL);422 PS_PTR_CHECK_NULL(params, NULL);423 423 float x; 424 424 int i; … … 432 432 if (deriv == NULL) { 433 433 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 434 } else { 435 // XXX: Check size of derivative 434 436 } 435 437 … … 453 455 } 454 456 457 458 psVector *psMinimizeLMChi2Gauss2D(psImage *deriv, 459 const psVector *params, 460 const psArray *coords) 461 { 462 PS_PTR_CHECK_NULL(coords, NULL); 463 PS_PTR_CHECK_NULL(params, NULL); 464 465 double normalization = params->data.F32[0]; 466 double x0 = params->data.F32[1]; 467 double y0 = params->data.F32[2]; 468 double sigmaX = params->data.F32[3]; 469 double sigmaY = params->data.F32[4]; 470 double theta = params->data.F32[5]; 471 psVector *out = psVectorAlloc(coords->n, PS_TYPE_F32); 472 473 if (deriv == NULL) { 474 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 475 } else { 476 // XXX: Check size of derivative 477 } 478 479 psTrace(".psLib.dataManip.psMinimize", 4, 480 "---- psMinimizeLMChi2Gauss2D() begin ----\n"); 481 482 for (int i=0;i<coords->n;i++) { 483 double x = ((psVector *) coords->data[i])->data.F32[0]; 484 double y = ((psVector *) coords->data[i])->data.F32[0]; 485 486 double u = - (x-x0)*cos(theta) + (y-y0)*sin(theta); 487 double v = (x-x0)*cos(theta) + (y-y0)*sin(theta); 488 489 double flux = normalization * exp(-( u*u/(2.0 * sigmaX * sigmaX) + 490 v*v/(2.0 * sigmaY * sigmaY)))/ 491 (2.0 * M_PI * sigmaX * sigmaY); 492 out->data.F32[i] = flux; 493 494 // XXX: Calculate these correctly. 495 deriv->data.F32[i][0] = 0.0; 496 deriv->data.F32[i][1] = 0.0; 497 deriv->data.F32[i][2] = 0.0; 498 deriv->data.F32[i][3] = 0.0; 499 deriv->data.F32[i][4] = 0.0; 500 deriv->data.F32[i][5] = 0.0; 501 } 502 503 psTrace(".psLib.dataManip.psMinimize", 4, 504 "---- psMinimizeLMChi2Gauss2D() end ----\n"); 505 return(out); 506 } 455 507 456 508 /****************************************************************************** -
trunk/psLib/src/dataManip/psStats.c
r2370 r2406 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11- 15 21:13:17$11 * @version $Revision: 1.98 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-23 19:35:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 146 146 this routine sets stats->sampleMean to NAN. 147 147 *****************************************************************************/ 148 voidp_psVectorSampleMean(const psVector* restrict myVector,149 const psVector* restrict maskVector,150 psU32 maskVal,151 psStats* stats)148 int p_psVectorSampleMean(const psVector* restrict myVector, 149 const psVector* restrict maskVector, 150 psU32 maskVal, 151 psStats* stats) 152 152 { 153 153 psS32 i = 0; // Loop index variable … … 210 210 211 211 stats->sampleMean = mean; 212 if (isnan(mean)) { 213 return(0); 214 } else { 215 return(-1); 216 } 217 212 218 } 213 219 … … 217 223 this routine sets stats->max to NAN. 218 224 *****************************************************************************/ 219 voidp_psVectorMax(const psVector* restrict myVector,220 const psVector* restrict maskVector,221 psU32 maskVal,222 psStats* stats)225 int p_psVectorMax(const psVector* restrict myVector, 226 const psVector* restrict maskVector, 227 psU32 maskVal, 228 psStats* stats) 223 229 { 224 230 psS32 i = 0; // Loop index variable … … 272 278 } else { 273 279 stats->max = NAN; 274 } 280 return(1); 281 } 282 return(0); 275 283 } 276 284 … … 280 288 this routine sets stats->min to NAN. 281 289 *****************************************************************************/ 282 voidp_psVectorMin(const psVector* restrict myVector,283 const psVector* restrict maskVector,284 psU32 maskVal,285 psStats* stats)290 int p_psVectorMin(const psVector* restrict myVector, 291 const psVector* restrict maskVector, 292 psU32 maskVal, 293 psStats* stats) 286 294 { 287 295 psS32 i = 0; // Loop index variable … … 335 343 } else { 336 344 stats->min = NAN; 337 } 345 return(1); 346 } 347 return(0); 338 348 } 339 349 … … 1205 1215 // Determine minimum and maximum values in the data vector. 1206 1216 if (isnan(stats->min)) { 1207 p_psVectorMin(myVector, maskVector, maskVal, stats); 1208 } 1217 if (0 != p_psVectorMin(myVector, maskVector, maskVal, stats)) { 1218 psLogMsg(__func__, PS_LOG_WARN, 1219 "WARNING: p_psVectorMin(): p_psVectorMin() reported a NAN mean.\n"); 1220 return(1); 1221 } 1222 } 1223 1224 1209 1225 if (isnan(stats->max)) { 1210 p_psVectorMax(myVector, maskVector, maskVal, stats);1226 if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {} 1211 1227 } 1212 1228 … … 1771 1787 // ************************************************************************ 1772 1788 if (stats->options & PS_STAT_MAX) { 1773 p_psVectorMax(inF32, mask, maskVal, stats); 1789 if (0 != p_psVectorMax(inF32, mask, maskVal, stats)) { 1790 psError(PS_ERR_UNKNOWN, false, 1791 "Failed to calculate vector maximum"); 1792 psFree(stats); 1793 return(NULL); 1794 } 1774 1795 } 1775 1796 // ************************************************************************ 1776 1797 if (stats->options & PS_STAT_MIN) { 1777 p_psVectorMin(inF32, mask, maskVal, stats); 1798 if (0 != p_psVectorMin(inF32, mask, maskVal, stats)) { 1799 psError(PS_ERR_UNKNOWN, false, 1800 "Failed to calculate vector minimum"); 1801 psFree(stats); 1802 return(NULL); 1803 } 1778 1804 } 1779 1805 -
trunk/psLib/src/math/psMinimize.c
r2347 r2406 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11- 12 20:45:27$11 * @version $Revision: 1.89 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-23 19:35:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 416 416 const psArray *coords) 417 417 { 418 PS_PTR_CHECK_NULL(coords, NULL); 419 PS_PTR_CHECK_NULL(params, NULL); 420 418 421 psTrace(".psLib.dataManip.psMinimize", 4, 419 422 "---- psMinimizeLMChi2Gauss1D() begin ----\n"); 420 421 PS_PTR_CHECK_NULL(coords, NULL);422 PS_PTR_CHECK_NULL(params, NULL);423 423 float x; 424 424 int i; … … 432 432 if (deriv == NULL) { 433 433 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 434 } else { 435 // XXX: Check size of derivative 434 436 } 435 437 … … 453 455 } 454 456 457 458 psVector *psMinimizeLMChi2Gauss2D(psImage *deriv, 459 const psVector *params, 460 const psArray *coords) 461 { 462 PS_PTR_CHECK_NULL(coords, NULL); 463 PS_PTR_CHECK_NULL(params, NULL); 464 465 double normalization = params->data.F32[0]; 466 double x0 = params->data.F32[1]; 467 double y0 = params->data.F32[2]; 468 double sigmaX = params->data.F32[3]; 469 double sigmaY = params->data.F32[4]; 470 double theta = params->data.F32[5]; 471 psVector *out = psVectorAlloc(coords->n, PS_TYPE_F32); 472 473 if (deriv == NULL) { 474 deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32); 475 } else { 476 // XXX: Check size of derivative 477 } 478 479 psTrace(".psLib.dataManip.psMinimize", 4, 480 "---- psMinimizeLMChi2Gauss2D() begin ----\n"); 481 482 for (int i=0;i<coords->n;i++) { 483 double x = ((psVector *) coords->data[i])->data.F32[0]; 484 double y = ((psVector *) coords->data[i])->data.F32[0]; 485 486 double u = - (x-x0)*cos(theta) + (y-y0)*sin(theta); 487 double v = (x-x0)*cos(theta) + (y-y0)*sin(theta); 488 489 double flux = normalization * exp(-( u*u/(2.0 * sigmaX * sigmaX) + 490 v*v/(2.0 * sigmaY * sigmaY)))/ 491 (2.0 * M_PI * sigmaX * sigmaY); 492 out->data.F32[i] = flux; 493 494 // XXX: Calculate these correctly. 495 deriv->data.F32[i][0] = 0.0; 496 deriv->data.F32[i][1] = 0.0; 497 deriv->data.F32[i][2] = 0.0; 498 deriv->data.F32[i][3] = 0.0; 499 deriv->data.F32[i][4] = 0.0; 500 deriv->data.F32[i][5] = 0.0; 501 } 502 503 psTrace(".psLib.dataManip.psMinimize", 4, 504 "---- psMinimizeLMChi2Gauss2D() end ----\n"); 505 return(out); 506 } 455 507 456 508 /****************************************************************************** -
trunk/psLib/src/math/psPolynomial.c
r2370 r2406 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-11- 15 21:13:17$9 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-23 19:35:30 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 14 * XXX: What happens if the polyEVal functions are called with data of the wrong 15 15 * type? 16 * XXX: Should the "coeffErr[]" be used as well? Bug ???. Ignore coeffErr 17 * 16 18 */ 17 19 /*****************************************************************************/ … … 274 276 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 275 277 276 XXX: Should the "coeffErr[]" be used as well?277 278 *****************************************************************************/ 278 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) -
trunk/psLib/src/math/psSpline.c
r2370 r2406 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-11- 15 21:13:17$9 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-23 19:35:30 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 14 * XXX: What happens if the polyEVal functions are called with data of the wrong 15 15 * type? 16 * XXX: Should the "coeffErr[]" be used as well? Bug ???. Ignore coeffErr 17 * 16 18 */ 17 19 /*****************************************************************************/ … … 274 276 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 275 277 276 XXX: Should the "coeffErr[]" be used as well?277 278 *****************************************************************************/ 278 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) -
trunk/psLib/src/math/psStats.c
r2370 r2406 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11- 15 21:13:17$11 * @version $Revision: 1.98 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-23 19:35:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 146 146 this routine sets stats->sampleMean to NAN. 147 147 *****************************************************************************/ 148 voidp_psVectorSampleMean(const psVector* restrict myVector,149 const psVector* restrict maskVector,150 psU32 maskVal,151 psStats* stats)148 int p_psVectorSampleMean(const psVector* restrict myVector, 149 const psVector* restrict maskVector, 150 psU32 maskVal, 151 psStats* stats) 152 152 { 153 153 psS32 i = 0; // Loop index variable … … 210 210 211 211 stats->sampleMean = mean; 212 if (isnan(mean)) { 213 return(0); 214 } else { 215 return(-1); 216 } 217 212 218 } 213 219 … … 217 223 this routine sets stats->max to NAN. 218 224 *****************************************************************************/ 219 voidp_psVectorMax(const psVector* restrict myVector,220 const psVector* restrict maskVector,221 psU32 maskVal,222 psStats* stats)225 int p_psVectorMax(const psVector* restrict myVector, 226 const psVector* restrict maskVector, 227 psU32 maskVal, 228 psStats* stats) 223 229 { 224 230 psS32 i = 0; // Loop index variable … … 272 278 } else { 273 279 stats->max = NAN; 274 } 280 return(1); 281 } 282 return(0); 275 283 } 276 284 … … 280 288 this routine sets stats->min to NAN. 281 289 *****************************************************************************/ 282 voidp_psVectorMin(const psVector* restrict myVector,283 const psVector* restrict maskVector,284 psU32 maskVal,285 psStats* stats)290 int p_psVectorMin(const psVector* restrict myVector, 291 const psVector* restrict maskVector, 292 psU32 maskVal, 293 psStats* stats) 286 294 { 287 295 psS32 i = 0; // Loop index variable … … 335 343 } else { 336 344 stats->min = NAN; 337 } 345 return(1); 346 } 347 return(0); 338 348 } 339 349 … … 1205 1215 // Determine minimum and maximum values in the data vector. 1206 1216 if (isnan(stats->min)) { 1207 p_psVectorMin(myVector, maskVector, maskVal, stats); 1208 } 1217 if (0 != p_psVectorMin(myVector, maskVector, maskVal, stats)) { 1218 psLogMsg(__func__, PS_LOG_WARN, 1219 "WARNING: p_psVectorMin(): p_psVectorMin() reported a NAN mean.\n"); 1220 return(1); 1221 } 1222 } 1223 1224 1209 1225 if (isnan(stats->max)) { 1210 p_psVectorMax(myVector, maskVector, maskVal, stats);1226 if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {} 1211 1227 } 1212 1228 … … 1771 1787 // ************************************************************************ 1772 1788 if (stats->options & PS_STAT_MAX) { 1773 p_psVectorMax(inF32, mask, maskVal, stats); 1789 if (0 != p_psVectorMax(inF32, mask, maskVal, stats)) { 1790 psError(PS_ERR_UNKNOWN, false, 1791 "Failed to calculate vector maximum"); 1792 psFree(stats); 1793 return(NULL); 1794 } 1774 1795 } 1775 1796 // ************************************************************************ 1776 1797 if (stats->options & PS_STAT_MIN) { 1777 p_psVectorMin(inF32, mask, maskVal, stats); 1798 if (0 != p_psVectorMin(inF32, mask, maskVal, stats)) { 1799 psError(PS_ERR_UNKNOWN, false, 1800 "Failed to calculate vector minimum"); 1801 psFree(stats); 1802 return(NULL); 1803 } 1778 1804 } 1779 1805
Note:
See TracChangeset
for help on using the changeset viewer.
