IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2406


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

...

Location:
trunk/psLib/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psFunctions.c

    r2370 r2406  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.65 $ $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 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1414 *  XXX: What happens if the polyEVal functions are called with data of the wrong
    1515 *       type?
     16 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
     17 *
    1618 */
    1719/*****************************************************************************/
     
    274276    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    275277 
    276     XXX: Should the "coeffErr[]" be used as well?
    277278 *****************************************************************************/
    278279static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
  • trunk/psLib/src/dataManip/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/******************************************************************************
  • trunk/psLib/src/dataManip/psStats.c

    r2370 r2406  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.97 $ $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 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    146146this routine sets stats->sampleMean to NAN.
    147147 *****************************************************************************/
    148 void p_psVectorSampleMean(const psVector* restrict myVector,
    149                           const psVector* restrict maskVector,
    150                           psU32 maskVal,
    151                           psStats* stats)
     148int p_psVectorSampleMean(const psVector* restrict myVector,
     149                         const psVector* restrict maskVector,
     150                         psU32 maskVal,
     151                         psStats* stats)
    152152{
    153153    psS32 i = 0;                // Loop index variable
     
    210210
    211211    stats->sampleMean = mean;
     212    if (isnan(mean)) {
     213        return(0);
     214    } else {
     215        return(-1);
     216    }
     217
    212218}
    213219
     
    217223this routine sets stats->max to NAN.
    218224 *****************************************************************************/
    219 void p_psVectorMax(const psVector* restrict myVector,
    220                    const psVector* restrict maskVector,
    221                    psU32 maskVal,
    222                    psStats* stats)
     225int p_psVectorMax(const psVector* restrict myVector,
     226                  const psVector* restrict maskVector,
     227                  psU32 maskVal,
     228                  psStats* stats)
    223229{
    224230    psS32 i = 0;                // Loop index variable
     
    272278    } else {
    273279        stats->max = NAN;
    274     }
     280        return(1);
     281    }
     282    return(0);
    275283}
    276284
     
    280288this routine sets stats->min to NAN.
    281289 *****************************************************************************/
    282 void p_psVectorMin(const psVector* restrict myVector,
    283                    const psVector* restrict maskVector,
    284                    psU32 maskVal,
    285                    psStats* stats)
     290int p_psVectorMin(const psVector* restrict myVector,
     291                  const psVector* restrict maskVector,
     292                  psU32 maskVal,
     293                  psStats* stats)
    286294{
    287295    psS32 i = 0;                // Loop index variable
     
    335343    } else {
    336344        stats->min = NAN;
    337     }
     345        return(1);
     346    }
     347    return(0);
    338348}
    339349
     
    12051215    // Determine minimum and maximum values in the data vector.
    12061216    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
    12091225    if (isnan(stats->max)) {
    1210         p_psVectorMax(myVector, maskVector, maskVal, stats);
     1226        if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {}
    12111227    }
    12121228
     
    17711787    // ************************************************************************
    17721788    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        }
    17741795    }
    17751796    // ************************************************************************
    17761797    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        }
    17781804    }
    17791805
  • 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/******************************************************************************
  • trunk/psLib/src/math/psPolynomial.c

    r2370 r2406  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.65 $ $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 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1414 *  XXX: What happens if the polyEVal functions are called with data of the wrong
    1515 *       type?
     16 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
     17 *
    1618 */
    1719/*****************************************************************************/
     
    274276    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    275277 
    276     XXX: Should the "coeffErr[]" be used as well?
    277278 *****************************************************************************/
    278279static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
  • trunk/psLib/src/math/psSpline.c

    r2370 r2406  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.65 $ $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 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1414 *  XXX: What happens if the polyEVal functions are called with data of the wrong
    1515 *       type?
     16 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
     17 *
    1618 */
    1719/*****************************************************************************/
     
    274276    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    275277 
    276     XXX: Should the "coeffErr[]" be used as well?
    277278 *****************************************************************************/
    278279static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
  • trunk/psLib/src/math/psStats.c

    r2370 r2406  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.97 $ $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 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    146146this routine sets stats->sampleMean to NAN.
    147147 *****************************************************************************/
    148 void p_psVectorSampleMean(const psVector* restrict myVector,
    149                           const psVector* restrict maskVector,
    150                           psU32 maskVal,
    151                           psStats* stats)
     148int p_psVectorSampleMean(const psVector* restrict myVector,
     149                         const psVector* restrict maskVector,
     150                         psU32 maskVal,
     151                         psStats* stats)
    152152{
    153153    psS32 i = 0;                // Loop index variable
     
    210210
    211211    stats->sampleMean = mean;
     212    if (isnan(mean)) {
     213        return(0);
     214    } else {
     215        return(-1);
     216    }
     217
    212218}
    213219
     
    217223this routine sets stats->max to NAN.
    218224 *****************************************************************************/
    219 void p_psVectorMax(const psVector* restrict myVector,
    220                    const psVector* restrict maskVector,
    221                    psU32 maskVal,
    222                    psStats* stats)
     225int p_psVectorMax(const psVector* restrict myVector,
     226                  const psVector* restrict maskVector,
     227                  psU32 maskVal,
     228                  psStats* stats)
    223229{
    224230    psS32 i = 0;                // Loop index variable
     
    272278    } else {
    273279        stats->max = NAN;
    274     }
     280        return(1);
     281    }
     282    return(0);
    275283}
    276284
     
    280288this routine sets stats->min to NAN.
    281289 *****************************************************************************/
    282 void p_psVectorMin(const psVector* restrict myVector,
    283                    const psVector* restrict maskVector,
    284                    psU32 maskVal,
    285                    psStats* stats)
     290int p_psVectorMin(const psVector* restrict myVector,
     291                  const psVector* restrict maskVector,
     292                  psU32 maskVal,
     293                  psStats* stats)
    286294{
    287295    psS32 i = 0;                // Loop index variable
     
    335343    } else {
    336344        stats->min = NAN;
    337     }
     345        return(1);
     346    }
     347    return(0);
    338348}
    339349
     
    12051215    // Determine minimum and maximum values in the data vector.
    12061216    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
    12091225    if (isnan(stats->max)) {
    1210         p_psVectorMax(myVector, maskVector, maskVal, stats);
     1226        if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {}
    12111227    }
    12121228
     
    17711787    // ************************************************************************
    17721788    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        }
    17741795    }
    17751796    // ************************************************************************
    17761797    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        }
    17781804    }
    17791805
Note: See TracChangeset for help on using the changeset viewer.