IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2004, 11:30:53 AM (22 years ago)
Author:
gusciora
Message:

Vector allocation code.

File:
1 edited

Legend:

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

    r1964 r1982  
    77 *  fit a 1-D polynomial to a set of data points.
    88 *
    9  *  @author George Gusciora, MHPCC
     9 *  @author GLF, MHPCC
    1010 *
    11  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-05 23:14:15 $
     11 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-06 21:30:53 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    227227supplied, but does not equal the domains specified in mySpline?
    228228XXX: can psSpline be NULL?
     229 
     230XXX: reimplement this assuming that mySpline is NULL?
     231 
     232XXX: What happens if X is NULL, then an index vector is generated for X, but
     233that index vector lies outside the range vectors in mySpline?
    229234 *****************************************************************************/
    230235psSpline1D *psVectorFitSpline1D(psSpline1D *mySpline,              ///< The spline which will be generated.
     
    269274        CONVERT_VECTOR_F64_TO_F32(x, x32, x32Static);
    270275    }
    271     PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(x, y);
    272     PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(yErr, y);
    273 
    274     if (y->n != (1 + mySpline->n)) {
     276    PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(x32, y32);
     277    PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(yErr32, y32);
     278
     279    if (y32->n != (1 + mySpline->n)) {
    275280        psError(__func__, "data size / spline size mismatch (%d %d)\n",
    276                 y->n, mySpline->n);
     281                y32->n, mySpline->n);
    277282        return(NULL);
    278283    }
     
    282287    if (2 == (mySpline->spline[0])->n) {
    283288        for (i=0;i<mySpline->n;i++) {
    284             slope = (y->data.F32[i+1] - y->data.F32[i]) /
     289            slope = (y32->data.F32[i+1] - y32->data.F32[i]) /
    285290                    (mySpline->domains[i+1] - mySpline->domains[i]);
    286             (mySpline->spline[i])->coeff[0] = y->data.F32[i] -
     291            (mySpline->spline[i])->coeff[0] = y32->data.F32[i] -
    287292                                              (slope * mySpline->domains[i]);
    288293
     
    307312    // If we get here, then we know these are cubic splines.  We first
    308313    // generate the second derivatives at each data point.
    309     mySpline->p_psDeriv2 = CalculateSecondDerivs(x, y);
    310     for (i=0;i<y->n;i++)
     314    mySpline->p_psDeriv2 = CalculateSecondDerivs(x32, y32);
     315    for (i=0;i<y32->n;i++)
    311316        psTrace(".psLib.dataManip.psVectorFitSpline1D", 6,
    312317                "Second deriv[%d] is %f\n", i, mySpline->p_psDeriv2[i]);
     
    316321    // and Numerical Recipes in C.
    317322    for (i=0;i<numSplines;i++) {
    318         H = x->data.F32[i+1] - x->data.F32[i];
     323        H = x32->data.F32[i+1] - x32->data.F32[i];
    319324        psTrace(".psLib.dataManip.psVectorFitSpline1D", 4,
    320325                "x data (%f - %f) (%f)\n", x->data.F32[i], x->data.F32[i+1], H);
     
    323328        //
    324329        // From (1)
    325         (mySpline->spline[i])->coeff[0] = (y->data.F32[i] * x->data.F32[i+1]/H);
     330        (mySpline->spline[i])->coeff[0] = (y32->data.F32[i] * x32->data.F32[i+1]/H);
    326331        // From (2)
    327         ((mySpline->spline[i])->coeff[0])-= ((y->data.F32[i+1] * x->data.F32[i])/H);
     332        ((mySpline->spline[i])->coeff[0])-= ((y32->data.F32[i+1] * x32->data.F32[i])/H);
    328333        // From (3)
    329         tmp = (x->data.F32[i+1] * x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H);
    330         tmp-= (x->data.F32[i+1] / H);
     334        tmp = (x32->data.F32[i+1] * x32->data.F32[i+1] * x32->data.F32[i+1]) / (H * H * H);
     335        tmp-= (x32->data.F32[i+1] / H);
    331336        tmp*= (mySpline->p_psDeriv2)[i] * H * H / 6.0;
    332337        ((mySpline->spline[i])->coeff[0])+= tmp;
    333338        // From (4)
    334         tmp = -(x->data.F32[i] * x->data.F32[i] * x->data.F32[i]) / (H * H * H);
    335         tmp+= (x->data.F32[i] / H);
     339        tmp = -(x32->data.F32[i] * x32->data.F32[i] * x32->data.F32[i]) / (H * H * H);
     340        tmp+= (x32->data.F32[i] / H);
    336341        tmp*= (mySpline->p_psDeriv2)[i+1] * H * H / 6.0;
    337342        ((mySpline->spline[i])->coeff[0])+= tmp;
     
    341346        //
    342347        // From (1)
    343         (mySpline->spline[i])->coeff[1] = -(y->data.F32[i]) / H;
     348        (mySpline->spline[i])->coeff[1] = -(y32->data.F32[i]) / H;
    344349        // From (2)
    345         ((mySpline->spline[i])->coeff[1])+= (y->data.F32[i+1] / H);
     350        ((mySpline->spline[i])->coeff[1])+= (y32->data.F32[i+1] / H);
    346351        // From (3)
    347         tmp = -3.0 * (x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H);
     352        tmp = -3.0 * (x32->data.F32[i+1] * x32->data.F32[i+1]) / (H * H * H);
    348353        tmp+= (1.0 / H);
    349354        tmp*= ((mySpline->p_psDeriv2)[i]) * H * H / 6.0;
    350355        ((mySpline->spline[i])->coeff[1])+= tmp;
    351356        // From (4)
    352         tmp = 3.0 * (x->data.F32[i] * x->data.F32[i]) / (H * H * H);
     357        tmp = 3.0 * (x32->data.F32[i] * x32->data.F32[i]) / (H * H * H);
    353358        tmp-= (1.0 / H);
    354359        tmp*= ((mySpline->p_psDeriv2)[i+1]) * H * H / 6.0;
     
    359364        //
    360365        // From (3)
    361         (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x->data.F32[i+1] / (6.0 * H);
     366        (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x32->data.F32[i+1] / (6.0 * H);
    362367        // From (4)
    363         ((mySpline->spline[i])->coeff[2])-= (((mySpline->p_psDeriv2)[i+1]) * 3.0 * x->data.F32[i] / (6.0 * H));
     368        ((mySpline->spline[i])->coeff[2])-= (((mySpline->p_psDeriv2)[i+1]) * 3.0 * x32->data.F32[i] / (6.0 * H));
    364369
    365370        //
Note: See TracChangeset for help on using the changeset viewer.