IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4760


Ignore:
Timestamp:
Aug 11, 2005, 1:04:32 PM (21 years ago)
Author:
gusciora
Message:

Deleted code for the Gauss1D min routines.

Location:
trunk/psLib/src/math
Files:
2 edited

Legend:

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

    r4753 r4760  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.129 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-08-10 22:41:17 $
     11 *  @version $Revision: 1.130 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-08-11 23:04:32 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    698698
    699699
    700 
    701 /******************************************************************************
    702 XXX: We assume unnormalized gaussians.
    703  *****************************************************************************/
    704 psVector *psMinimizeLMChi2Gauss1D(psImage *deriv,
    705                                   const psVector *params,
    706                                   const psArray *coords)
    707 {
    708     PS_ASSERT_PTR_NON_NULL(coords, NULL);
    709     PS_ASSERT_PTR_NON_NULL(params, NULL);
    710 
    711     psTrace(".psLib.dataManip.psMinimize", 4,
    712             "---- psMinimizeLMChi2Gauss1D() begin ----\n");
    713     psF32 x;
    714     psS32 i;
    715     psF32 mean = params->data.F32[0];
    716     psF32 stdev = params->data.F32[1];
    717     psVector *out = psVectorAlloc(coords->n, PS_TYPE_F32);
    718 
    719     psTrace(".psLib.dataManip.psMinimize", 6,
    720             "(mean, stdev) is (%f, %f)\n", mean, stdev);
    721 
    722     if (deriv == NULL) {
    723         deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32);
    724     } else {
    725         PS_ASSERT_IMAGE_SIZE(deriv, params->n, coords->n, NULL);
    726         PS_ASSERT_IMAGE_TYPE(deriv, PS_TYPE_F32, NULL);
    727     }
    728 
    729     for (i=0;i<coords->n;i++) {
    730         x = ((psVector *) (coords->data[i]))->data.F32[0];
    731         out->data.F32[i] = psGaussian(x, mean, stdev, false);
    732     }
    733 
    734     for (i=0;i<coords->n;i++) {
    735         x = ((psVector *) (coords->data[i]))->data.F32[0];
    736         psF32 tmp = (x - mean) * psGaussian(x, mean, stdev, false);
    737         deriv->data.F32[i][0] = tmp / (stdev * stdev);
    738         tmp = (x - mean) * (x - mean) *
    739               psGaussian(x, mean, stdev, 0);
    740         deriv->data.F32[i][1] = tmp / (stdev * stdev * stdev);
    741     }
    742 
    743     psTrace(".psLib.dataManip.psMinimize", 4,
    744             "---- psMinimizeLMChi2Gauss1D() end ----\n");
    745     return(out);
    746 }
    747 
    748 /*
    749 XXX: from bug 230:
    750  
    751 We first perform a rotation:
    752 u = - (x-x0)*cos(theta) + (y-y0)*sin(theta)
    753 v = (x-x0)*cos(theta) + (y-y0)*sin(theta)
    754  
    755 Here u is the major axis, and v is the minor axis, x0,y0 is the centre, and
    756 theta is the position angle.
    757  
    758 Then the flux is
    759  
    760 flux = norm * exp(-( u*u/2.0/sigmau/sigmau + v*v/2.0/sigmav/sigmav)
    761 )/2.0/pi/sigmau/sigmav
    762  
    763 Here sigmau and sigmav are the widths of the major and minor axes.
    764  
    765 The "norm" parameter in the equation above corresponds to the normalisation.
    766  
    767 Suggest order:
    768  
    769 norm
    770 x0
    771 y0
    772 sigma_u
    773 sigma_v
    774 theta
    775 */
    776 
    777 psVector *psMinimizeLMChi2Gauss2D(psImage *deriv,
    778                                   const psVector *params,
    779                                   const psArray *coords)
    780 {
    781     PS_ASSERT_PTR_NON_NULL(coords, NULL);
    782     PS_ASSERT_PTR_NON_NULL(params, NULL);
    783 
    784     psF64 normalization = params->data.F32[0];
    785     psF64 x0 = params->data.F32[1];
    786     psF64 y0 = params->data.F32[2];
    787     psF64 sigmaX = params->data.F32[3];
    788     psF64 sigmaY = params->data.F32[4];
    789     psF64 theta = params->data.F32[5];
    790     psVector *out = psVectorAlloc(coords->n, PS_TYPE_F32);
    791 
    792     if (deriv == NULL) {
    793         deriv = psImageAlloc(params->n, coords->n, PS_TYPE_F32);
    794     } else {
    795         PS_ASSERT_IMAGE_SIZE(deriv, 6, coords->n, NULL);
    796         PS_ASSERT_IMAGE_TYPE(deriv, PS_TYPE_F32, NULL);
    797     }
    798 
    799     psTrace(".psLib.dataManip.psMinimize", 4,
    800             "---- psMinimizeLMChi2Gauss2D() begin ----\n");
    801 
    802     for (psS32 i=0;i<coords->n;i++) {
    803         psF64 x = ((psVector *) coords->data[i])->data.F32[0];
    804         psF64 y = ((psVector *) coords->data[i])->data.F32[0];
    805 
    806         psF64 u = - (x-x0)*cos(theta) + (y-y0)*sin(theta);
    807         psF64 v = (x-x0)*cos(theta) + (y-y0)*sin(theta);
    808 
    809         psF64 flux = normalization * exp(-( u*u/(2.0 * sigmaX * sigmaX) +
    810                                             v*v/(2.0 * sigmaY * sigmaY)))/
    811                      (2.0 * M_PI * sigmaX * sigmaY);
    812         out->data.F32[i] = flux;
    813 
    814         // XXX: Calculate these correctly.
    815         deriv->data.F32[i][0] = 0.0;
    816         deriv->data.F32[i][1] = 0.0;
    817         deriv->data.F32[i][2] = 0.0;
    818         deriv->data.F32[i][3] = 0.0;
    819         deriv->data.F32[i][4] = 0.0;
    820         deriv->data.F32[i][5] = 0.0;
    821     }
    822 
    823     psTrace(".psLib.dataManip.psMinimize", 4,
    824             "---- psMinimizeLMChi2Gauss2D() end ----\n");
    825     return(out);
    826 }
    827700
    828701//XXX: What's this for?
     
    21882061
    21892062/******************************************************************************
    2190 XXX: We assume unnormalized gaussians.
    2191 XXX: Currently, yErr is ignored.
    2192  *****************************************************************************/
    2193 psVector *psMinimizePowellChi2Gauss1D(const psVector *params,
    2194                                       const psArray *coords)
    2195 {
    2196     PS_ASSERT_PTR_NON_NULL(coords, NULL);
    2197     PS_ASSERT_PTR_NON_NULL(params, NULL);
    2198 
    2199     psF32 x;
    2200     psS32 i;
    2201     psF32 mean = params->data.F32[0];
    2202     psF32 stdev = params->data.F32[1];
    2203     psVector *out = psVectorAlloc(coords->n, PS_TYPE_F32);
    2204 
    2205     for (i=0;i<coords->n;i++) {
    2206         x = ((psVector *) (coords->data[i]))->data.F32[0];
    2207         out->data.F32[i] = psGaussian(x, mean, stdev, false);
    2208     }
    2209 
    2210     return(out);
    2211 }
    2212 
    2213 /******************************************************************************
    22142063This routine is to be used with the psMinimizeChi2Powell() function below.
    22152064and the psMinimizePowell() function above.
  • trunk/psLib/src/math/psMinimize.h

    r4730 r4760  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-08-08 21:42:07 $
     10 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-08-11 23:04:32 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    183183);
    184184
    185 /** Calculates the one-dimensional Gaussian in a format acceptable to the Levenberg-
    186  *  Marquardt minimizer routine.
    187  *
    188  *  @return psVector*:    Calculated values
    189  */
    190 psVector *psMinimizeLMChi2Gauss1D(
    191     psImage *deriv,                    ///< Derivative Matrix
    192     const psVector *params,            ///< Parameters used in evaluation
    193     const psArray *coords              ///< Measurement coordinates
    194 );
    195 
    196 /** Calculates the one-dimensional Gaussian in a format acceptable to the Powell
    197  *  chi-squared minimizer routine.
    198  *
    199  *  @return psVector*:   Calculated values
    200  */
    201 psVector *psMinimizePowellChi2Gauss1D(
    202     const psVector *params,            ///< Parameters used in evaluation
    203     const psArray *coords              ///< Measurement coordinates
    204 );
    205 
    206185/** Specifies the format of a user-defined function that the general Powell chi-
    207186 *  squared minimizer routine will accept.
Note: See TracChangeset for help on using the changeset viewer.