Changeset 2406 for trunk/psLib/src/math/psMinimize.c
- Timestamp:
- Nov 23, 2004, 9:35:30 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimize.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 /******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
