IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 23, 2004, 9:35:30 AM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psMinimize.c

    r2347 r2406  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.88 $ $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 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    416416                                  const psArray *coords)
    417417{
     418    PS_PTR_CHECK_NULL(coords, NULL);
     419    PS_PTR_CHECK_NULL(params, NULL);
     420
    418421    psTrace(".psLib.dataManip.psMinimize", 4,
    419422            "---- psMinimizeLMChi2Gauss1D() begin ----\n");
    420 
    421     PS_PTR_CHECK_NULL(coords, NULL);
    422     PS_PTR_CHECK_NULL(params, NULL);
    423423    float x;
    424424    int i;
     
    432432    if (deriv == NULL) {
    433433        deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32);
     434    } else {
     435        // XXX: Check size of derivative
    434436    }
    435437
     
    453455}
    454456
     457
     458psVector *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}
    455507
    456508/******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.