IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5180


Ignore:
Timestamp:
Sep 29, 2005, 10:06:58 AM (21 years ago)
Author:
gusciora
Message:

Misc mods to psSPline.c

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

Legend:

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

    r5113 r5180  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.128 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-09-23 23:01:30 $
     9*  @version $Revision: 1.129 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-09-29 20:06:58 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    784784}
    785785
     786
     787
     788
     789
     790
     791
     792
     793
     794
     795
     796
     797
     798
     799
     800
     801
     802
     803
     804
     805
     806
     807
    786808psF64 psPolynomial1DEval(const psPolynomial1D* poly,
    787809                         psF64 x)
  • trunk/psLib/src/math/psSpline.c

    r5179 r5180  
    77*  splines.
    88*
    9 *  @version $Revision: 1.130 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-09-29 19:40:59 $
     9*  @version $Revision: 1.131 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-09-29 20:06:58 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7979derivatives of the interpolating cubic splines at those n points.
    8080 
    81 The first and second derivatives at the endpoints, undefined in the SDR, are
    82 here defined to be 0.0.  They can be modified via ypo and yp1.
     81The first and second derivatives at the endpoints were previously undefined in
     82the SDR.  From bugzilla #???, they are required to be 0.0, impementing natural
     83splines.
     84 
     85Endpoints are defined by
     86    PS_LEFT_SPLINE_DERIV
     87    PS_RIGHT_SPLINE_DERIV
    8388 
    8489This routine assumes that vectors x and y are of the appropriate types/sizes
     
    8994XXX: do an F64 version?
    9095 *****************************************************************************/
    91 static psF32 *calculateSecondDerivs(const psVector* x,        ///< Ordinates
    92                                     const psVector* y)        ///< Coordinates
     96#define PS_LEFT_SPLINE_DERIV 0.0
     97#define PS_RIGHT_SPLINE_DERIV 0.0
     98static psF32 *calculateSecondDerivs(
     99    const psVector* x,                  ///< Ordinates
     100    const psVector* y)                  ///< Coordinates
    93101{
    94102    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
    95103    if (psTraceGetLevel(__func__) >= 6) {
    96         PS_VECTOR_PRINT_F32(x);
    97         PS_VECTOR_PRINT_F32(y);
     104        p_psVectorPrint(1, (psVector *) x, "x");
     105        p_psVectorPrint(1, (psVector *) y, "y");
    98106    }
    99107    psS32 n = y->n;
     
    339347
    340348    psS32 binNum;
    341     unsigned int numIntPoints = order+1;
     349    psS32 numIntPoints = order+1;
    342350    psS32 origin;
    343351
     
    460468    return(tmpSpline);
    461469}
    462 
    463470
    464471/*****************************************************************************
     
    481488 
    482489XXX: What types must be supported?
    483  
    484 XXX: Should we allow x==NULL?
    485490 *****************************************************************************/
    486491psSpline1D *psVectorFitSpline1D(
    487     const psVector* x,        ///< Ordinates.
    488     const psVector* y)         ///< Coordinates.
     492    const psVector* x,                  ///< Ordinates.
     493    const psVector* y)                  ///< Coordinates.
    489494{
    490495    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     
    498503    psVector *xPtr = NULL;
    499504    if (x != NULL) {
    500         // Convert x to F32 if necessary.
    501505        PS_ASSERT_VECTOR_NON_NULL(x, NULL);
    502506        PS_ASSERT_VECTOR_TYPE_F32_OR_F64(x, NULL);
    503507        PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL);
     508        // Convert x to F32 if necessary.
    504509        if (PS_TYPE_F64 == x->type.type) {
    505             xPtr = psVectorAlloc(y->n, PS_TYPE_F32);
    506             for (psS32 i = 0 ; i < x->n ; i++) {
    507                 xPtr->data.F32[i] = (psF32) x->data.F64[i];
    508             }
     510            xPtr = psVectorCopy(NULL, x, PS_TYPE_F32);
    509511        } else if (PS_TYPE_F32 == x->type.type) {
    510512            xPtr = (psVector *) x;
     
    513515        // Allocate an index vector for x
    514516        xPtr = psVectorCreate(NULL, 0.0, (psF64) y->n, 1.0, PS_TYPE_F32);
    515         printf("x, y is (%d, %d)\n", (psS32) xPtr->n, (psS32) y->n);
    516         xPtr = xPtr;
    517517    }
    518518
     
    520520    // Convert y to F32 if necessary.
    521521    if (PS_TYPE_F64 == y->type.type) {
    522         yPtr = psVectorAlloc(y->n, PS_TYPE_F32);
    523         for (psS32 i = 0 ; i < y->n ; i++) {
    524             yPtr->data.F32[i] = (psF32) y->data.F64[i];
    525         }
     522        yPtr = psVectorCopy(NULL, y, PS_TYPE_F32);
    526523    } else {
    527524        yPtr = (psVector *) y;
     
    570567        tmp+= xPtr->data.F32[i] / H;
    571568        tmp*= spline->p_psDeriv2[i+1] * H * H / 6.0;
    572         (spline->spline[i]->coeff[0])+= tmp;
     569        spline->spline[i]->coeff[0]+= tmp;
    573570
    574571        //
     
    594591        //
    595592        // From (3)
    596         spline->spline[i]->coeff[2] = ((spline->p_psDeriv2)[i]) * 3.0 * xPtr->data.F32[i+1] / (6.0 * H);
     593        spline->spline[i]->coeff[2] = spline->p_psDeriv2[i] * 3.0 * xPtr->data.F32[i+1] / (6.0 * H);
    597594        // From (4)
    598         (spline->spline[i]->coeff[2])-= (((spline->p_psDeriv2)[i+1]) * 3.0 * xPtr->data.F32[i] / (6.0 * H));
     595        spline->spline[i]->coeff[2]-= spline->p_psDeriv2[i+1] * 3.0 * xPtr->data.F32[i] / (6.0 * H);
    599596
    600597        //
     
    602599        //
    603600        // From (3)
    604         spline->spline[i]->coeff[3] = -((spline->p_psDeriv2)[i]) / (6.0 * H);
     601        spline->spline[i]->coeff[3] = -spline->p_psDeriv2[i] / (6.0 * H);
    605602        // From (4)
    606         (spline->spline[i]->coeff[3])+=  ((spline->p_psDeriv2)[i+1]) / (6.0 * H);
     603        spline->spline[i]->coeff[3]+=  spline->p_psDeriv2[i+1] / (6.0 * H);
    607604
    608605        psTrace(__func__, 6, "(spline->spline[%u])->coeff[0] is %f\n", i, spline->spline[i]->coeff[0]);
Note: See TracChangeset for help on using the changeset viewer.