IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3096 for trunk/psLib/src


Ignore:
Timestamp:
Jan 26, 2005, 10:41:04 AM (22 years ago)
Author:
gusciora
Message:

Substituted knots for domains in the spline structs.

Location:
trunk/psLib/src
Files:
8 edited

Legend:

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

    r3027 r3096  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-17 23:25:09 $
     9 *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-26 20:41:04 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9292        psFree(tmpSpline->p_psDeriv2);
    9393    }
    94     psFree(tmpSpline->domains);
     94    psFree(tmpSpline->knots);
    9595
    9696    return;
     
    18331833//    psPolynomial1D **spline;
    18341834//    psF32 *p_psDeriv2;
    1835 //    psF32 *domains;
     1835//    psVector *knots;
    18361836//} psSpline1D;
    18371837
    18381838/*****************************************************************************
    18391839    NOTE: "n" specifies the number of spline polynomials.  Therefore, there
    1840     must exist n+1 points in "domains".
     1840    must exist n+1 points in "knots".
    18411841 
    18421842XXX: Ensure that domain[i+1] != domain[i]
     
    18671867    tmp->p_psDeriv2 = NULL;
    18681868
    1869     tmp->domains = (psF32 *) psAlloc((numSplines+1) * sizeof(psF32));
     1869    tmp->knots = psVectorAlloc(numSplines+1, PS_TYPE_F32);
    18701870    width = (max - min) / ((psF32) numSplines);
    18711871
    1872     (tmp->domains)[0] = min;
     1872    tmp->knots->data.F32[0] = min;
    18731873    tmpDomain = min+width;
    18741874    for (i=1;i<numSplines+1;i++) {
    1875         (tmp->domains)[i] = tmpDomain;
     1875        tmp->knots->data.F32[i] = tmpDomain;
    18761876        tmpDomain+= width;
    18771877    }
    1878     (tmp->domains)[numSplines] = max;
     1878    tmp->knots->data.F32[numSplines] = max;
    18791879
    18801880    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     
    19091909    tmp->p_psDeriv2 = NULL;
    19101910
    1911     tmp->domains = (psF32 *) psAlloc((bounds->n) * sizeof(psF32));
     1911    tmp->knots = psVectorAlloc(bounds->n, PS_TYPE_F32);
    19121912
    19131913    for (i=0;i<bounds->n;i++) {
    1914         (tmp->domains)[i] = bounds->data.F32[i];
     1914        tmp->knots->data.F32[i] = bounds->data.F32[i];
    19151915        if (i<(bounds->n-1)) {
    19161916            if (FLT_EPSILON >= fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
     
    21362136psSpline1DEval(): this routine takes an existing spline of arbitrary order
    21372137and an independent x value.  Each determines which spline that x corresponds
    2138 to by doing a bracket disection on the domains of the spline data structure
     2138to by doing a bracket disection on the knots of the spline data structure
    21392139(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    21402140by a call to the 1D polynomial functions.
     
    21552155
    21562156    n = spline->n;
    2157     binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2157    //XXX    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2158    binNum = vectorBinDisectF32(spline->knots->data.F32, (spline->n)+1, x);
    21582159    if (binNum < 0) {
    21592160        psLogMsg(__func__, PS_LOG_WARN,
    21602161                 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f).",
    2161                  x, (spline->domains)[0],
    2162                  (spline->domains)[n-1]);
    2163 
    2164         if (x < (spline->domains)[0]) {
     2162                 x, spline->knots->data.F32[0],
     2163                 spline->knots->data.F32[n-1]);
     2164
     2165        if (x < spline->knots->data.F32[0]) {
    21652166            return(psPolynomial1DEval(spline->spline[0],
    21662167                                      x));
    2167         } else if (x > (spline->domains)[n-1]) {
     2168        } else if (x > spline->knots->data.F32[n-1]) {
    21682169            return(psPolynomial1DEval(spline->spline[n-1],
    21692170                                      x));
  • trunk/psLib/src/dataManip/psFunctions.h

    r2847 r3096  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-12-29 22:15:51 $
     14*  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-01-26 20:41:04 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    394394typedef struct
    395395{
    396     psS32 n;                        ///< The number of spline polynomials
    397     psPolynomial1D **spline;      ///< An array of n pointers to the spline polynomials
    398     psF32 *p_psDeriv2;            ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
    399     psF32 *domains;               ///< The boundaries between each spline piece.  Size is n+1.
     396    psS32 n;                       ///< The number of spline polynomials
     397    psPolynomial1D **spline;       ///< An array of n pointers to the spline polynomials
     398    psF32 *p_psDeriv2;             ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
     399    psF32 *domains;                ///< The boundaries between each spline piece.  Size is n+1.
     400    psVector *knots;               ///< The boundaries between each spline piece.  Size is n+1.
    400401}
    401402psSpline1D;
  • trunk/psLib/src/dataManip/psMinimize.c

    r3027 r3096  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-01-17 23:25:09 $
     11 *  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-01-26 20:41:04 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    171171    PS_PTR_CHECK_NULL(spline, NAN);
    172172    PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN);
    173     PS_PTR_CHECK_NULL(spline->domains, NAN);
     173    PS_VECTOR_CHECK_NULL(spline->domains, NAN);
    174174    PS_PTR_CHECK_NULL(spline->p_psDeriv2, NAN);
    175175    PS_VECTOR_CHECK_NULL(x, NAN);
     
    189189 
    190190    n = spline->n;
    191     klo = p_psVectorBinDisect32(spline->domains, (spline->n)+1, X);
     191    klo = p_psVectorBinDisect32(spline->knots->data.F32, (spline->n)+1, X);
    192192    if (klo < 0) {
    193193        psLogMsg(__func__, PS_LOG_WARN,
     
    196196    }
    197197    khi = klo + 1;
    198     H = (spline->domains)[khi] - (spline->domains)[klo];
    199     A = ((spline->domains)[khi] - X) / H;
    200     B = (X - (spline->domains)[klo]) / H;
     198    H = spline->knots->data.F32[khi] - spline->knots->data.F32[klo];
     199    A = (spline->knots->data.F32[khi] - X) / H;
     200    B = (X - spline->knots->data.F32[klo]) / H;
    201201    C = ((A*A*A)-A) * (H*H/6.0);
    202202    D = ((B*B*B)-B) * (H*H/6.0);
     
    236236 
    237237XXX: Is the x argument redundant?  What do we do if the x argument is
    238 supplied, but does not equal the domains specified in mySpline?
     238supplied, but does not equal the knots specified in mySpline?
    239239 
    240240XXX: can psSpline be NULL?
     
    314314        for (i=0;i<mySpline->n;i++) {
    315315            slope = (y32->data.F32[i+1] - y32->data.F32[i]) /
    316                     (mySpline->domains[i+1] - mySpline->domains[i]);
     316                    (mySpline->knots->data.F32[i+1] - mySpline->knots->data.F32[i]);
    317317            (mySpline->spline[i])->coeff[0] = y32->data.F32[i] -
    318                                               (slope * mySpline->domains[i]);
     318                                              (slope * mySpline->knots->data.F32[i]);
    319319
    320320            (mySpline->spline[i])->coeff[1] = slope;
  • trunk/psLib/src/math/psMinimize.c

    r3027 r3096  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-01-17 23:25:09 $
     11 *  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-01-26 20:41:04 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    171171    PS_PTR_CHECK_NULL(spline, NAN);
    172172    PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN);
    173     PS_PTR_CHECK_NULL(spline->domains, NAN);
     173    PS_VECTOR_CHECK_NULL(spline->domains, NAN);
    174174    PS_PTR_CHECK_NULL(spline->p_psDeriv2, NAN);
    175175    PS_VECTOR_CHECK_NULL(x, NAN);
     
    189189 
    190190    n = spline->n;
    191     klo = p_psVectorBinDisect32(spline->domains, (spline->n)+1, X);
     191    klo = p_psVectorBinDisect32(spline->knots->data.F32, (spline->n)+1, X);
    192192    if (klo < 0) {
    193193        psLogMsg(__func__, PS_LOG_WARN,
     
    196196    }
    197197    khi = klo + 1;
    198     H = (spline->domains)[khi] - (spline->domains)[klo];
    199     A = ((spline->domains)[khi] - X) / H;
    200     B = (X - (spline->domains)[klo]) / H;
     198    H = spline->knots->data.F32[khi] - spline->knots->data.F32[klo];
     199    A = (spline->knots->data.F32[khi] - X) / H;
     200    B = (X - spline->knots->data.F32[klo]) / H;
    201201    C = ((A*A*A)-A) * (H*H/6.0);
    202202    D = ((B*B*B)-B) * (H*H/6.0);
     
    236236 
    237237XXX: Is the x argument redundant?  What do we do if the x argument is
    238 supplied, but does not equal the domains specified in mySpline?
     238supplied, but does not equal the knots specified in mySpline?
    239239 
    240240XXX: can psSpline be NULL?
     
    314314        for (i=0;i<mySpline->n;i++) {
    315315            slope = (y32->data.F32[i+1] - y32->data.F32[i]) /
    316                     (mySpline->domains[i+1] - mySpline->domains[i]);
     316                    (mySpline->knots->data.F32[i+1] - mySpline->knots->data.F32[i]);
    317317            (mySpline->spline[i])->coeff[0] = y32->data.F32[i] -
    318                                               (slope * mySpline->domains[i]);
     318                                              (slope * mySpline->knots->data.F32[i]);
    319319
    320320            (mySpline->spline[i])->coeff[1] = slope;
  • trunk/psLib/src/math/psPolynomial.c

    r3027 r3096  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-17 23:25:09 $
     9 *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-26 20:41:04 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9292        psFree(tmpSpline->p_psDeriv2);
    9393    }
    94     psFree(tmpSpline->domains);
     94    psFree(tmpSpline->knots);
    9595
    9696    return;
     
    18331833//    psPolynomial1D **spline;
    18341834//    psF32 *p_psDeriv2;
    1835 //    psF32 *domains;
     1835//    psVector *knots;
    18361836//} psSpline1D;
    18371837
    18381838/*****************************************************************************
    18391839    NOTE: "n" specifies the number of spline polynomials.  Therefore, there
    1840     must exist n+1 points in "domains".
     1840    must exist n+1 points in "knots".
    18411841 
    18421842XXX: Ensure that domain[i+1] != domain[i]
     
    18671867    tmp->p_psDeriv2 = NULL;
    18681868
    1869     tmp->domains = (psF32 *) psAlloc((numSplines+1) * sizeof(psF32));
     1869    tmp->knots = psVectorAlloc(numSplines+1, PS_TYPE_F32);
    18701870    width = (max - min) / ((psF32) numSplines);
    18711871
    1872     (tmp->domains)[0] = min;
     1872    tmp->knots->data.F32[0] = min;
    18731873    tmpDomain = min+width;
    18741874    for (i=1;i<numSplines+1;i++) {
    1875         (tmp->domains)[i] = tmpDomain;
     1875        tmp->knots->data.F32[i] = tmpDomain;
    18761876        tmpDomain+= width;
    18771877    }
    1878     (tmp->domains)[numSplines] = max;
     1878    tmp->knots->data.F32[numSplines] = max;
    18791879
    18801880    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     
    19091909    tmp->p_psDeriv2 = NULL;
    19101910
    1911     tmp->domains = (psF32 *) psAlloc((bounds->n) * sizeof(psF32));
     1911    tmp->knots = psVectorAlloc(bounds->n, PS_TYPE_F32);
    19121912
    19131913    for (i=0;i<bounds->n;i++) {
    1914         (tmp->domains)[i] = bounds->data.F32[i];
     1914        tmp->knots->data.F32[i] = bounds->data.F32[i];
    19151915        if (i<(bounds->n-1)) {
    19161916            if (FLT_EPSILON >= fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
     
    21362136psSpline1DEval(): this routine takes an existing spline of arbitrary order
    21372137and an independent x value.  Each determines which spline that x corresponds
    2138 to by doing a bracket disection on the domains of the spline data structure
     2138to by doing a bracket disection on the knots of the spline data structure
    21392139(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    21402140by a call to the 1D polynomial functions.
     
    21552155
    21562156    n = spline->n;
    2157     binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2157    //XXX    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2158    binNum = vectorBinDisectF32(spline->knots->data.F32, (spline->n)+1, x);
    21582159    if (binNum < 0) {
    21592160        psLogMsg(__func__, PS_LOG_WARN,
    21602161                 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f).",
    2161                  x, (spline->domains)[0],
    2162                  (spline->domains)[n-1]);
    2163 
    2164         if (x < (spline->domains)[0]) {
     2162                 x, spline->knots->data.F32[0],
     2163                 spline->knots->data.F32[n-1]);
     2164
     2165        if (x < spline->knots->data.F32[0]) {
    21652166            return(psPolynomial1DEval(spline->spline[0],
    21662167                                      x));
    2167         } else if (x > (spline->domains)[n-1]) {
     2168        } else if (x > spline->knots->data.F32[n-1]) {
    21682169            return(psPolynomial1DEval(spline->spline[n-1],
    21692170                                      x));
  • trunk/psLib/src/math/psPolynomial.h

    r2847 r3096  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-12-29 22:15:51 $
     14*  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-01-26 20:41:04 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    394394typedef struct
    395395{
    396     psS32 n;                        ///< The number of spline polynomials
    397     psPolynomial1D **spline;      ///< An array of n pointers to the spline polynomials
    398     psF32 *p_psDeriv2;            ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
    399     psF32 *domains;               ///< The boundaries between each spline piece.  Size is n+1.
     396    psS32 n;                       ///< The number of spline polynomials
     397    psPolynomial1D **spline;       ///< An array of n pointers to the spline polynomials
     398    psF32 *p_psDeriv2;             ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
     399    psF32 *domains;                ///< The boundaries between each spline piece.  Size is n+1.
     400    psVector *knots;               ///< The boundaries between each spline piece.  Size is n+1.
    400401}
    401402psSpline1D;
  • trunk/psLib/src/math/psSpline.c

    r3027 r3096  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-01-17 23:25:09 $
     9 *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-26 20:41:04 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9292        psFree(tmpSpline->p_psDeriv2);
    9393    }
    94     psFree(tmpSpline->domains);
     94    psFree(tmpSpline->knots);
    9595
    9696    return;
     
    18331833//    psPolynomial1D **spline;
    18341834//    psF32 *p_psDeriv2;
    1835 //    psF32 *domains;
     1835//    psVector *knots;
    18361836//} psSpline1D;
    18371837
    18381838/*****************************************************************************
    18391839    NOTE: "n" specifies the number of spline polynomials.  Therefore, there
    1840     must exist n+1 points in "domains".
     1840    must exist n+1 points in "knots".
    18411841 
    18421842XXX: Ensure that domain[i+1] != domain[i]
     
    18671867    tmp->p_psDeriv2 = NULL;
    18681868
    1869     tmp->domains = (psF32 *) psAlloc((numSplines+1) * sizeof(psF32));
     1869    tmp->knots = psVectorAlloc(numSplines+1, PS_TYPE_F32);
    18701870    width = (max - min) / ((psF32) numSplines);
    18711871
    1872     (tmp->domains)[0] = min;
     1872    tmp->knots->data.F32[0] = min;
    18731873    tmpDomain = min+width;
    18741874    for (i=1;i<numSplines+1;i++) {
    1875         (tmp->domains)[i] = tmpDomain;
     1875        tmp->knots->data.F32[i] = tmpDomain;
    18761876        tmpDomain+= width;
    18771877    }
    1878     (tmp->domains)[numSplines] = max;
     1878    tmp->knots->data.F32[numSplines] = max;
    18791879
    18801880    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     
    19091909    tmp->p_psDeriv2 = NULL;
    19101910
    1911     tmp->domains = (psF32 *) psAlloc((bounds->n) * sizeof(psF32));
     1911    tmp->knots = psVectorAlloc(bounds->n, PS_TYPE_F32);
    19121912
    19131913    for (i=0;i<bounds->n;i++) {
    1914         (tmp->domains)[i] = bounds->data.F32[i];
     1914        tmp->knots->data.F32[i] = bounds->data.F32[i];
    19151915        if (i<(bounds->n-1)) {
    19161916            if (FLT_EPSILON >= fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
     
    21362136psSpline1DEval(): this routine takes an existing spline of arbitrary order
    21372137and an independent x value.  Each determines which spline that x corresponds
    2138 to by doing a bracket disection on the domains of the spline data structure
     2138to by doing a bracket disection on the knots of the spline data structure
    21392139(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    21402140by a call to the 1D polynomial functions.
     
    21552155
    21562156    n = spline->n;
    2157     binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2157    //XXX    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2158    binNum = vectorBinDisectF32(spline->knots->data.F32, (spline->n)+1, x);
    21582159    if (binNum < 0) {
    21592160        psLogMsg(__func__, PS_LOG_WARN,
    21602161                 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f).",
    2161                  x, (spline->domains)[0],
    2162                  (spline->domains)[n-1]);
    2163 
    2164         if (x < (spline->domains)[0]) {
     2162                 x, spline->knots->data.F32[0],
     2163                 spline->knots->data.F32[n-1]);
     2164
     2165        if (x < spline->knots->data.F32[0]) {
    21652166            return(psPolynomial1DEval(spline->spline[0],
    21662167                                      x));
    2167         } else if (x > (spline->domains)[n-1]) {
     2168        } else if (x > spline->knots->data.F32[n-1]) {
    21682169            return(psPolynomial1DEval(spline->spline[n-1],
    21692170                                      x));
  • trunk/psLib/src/math/psSpline.h

    r2847 r3096  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-12-29 22:15:51 $
     14*  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-01-26 20:41:04 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    394394typedef struct
    395395{
    396     psS32 n;                        ///< The number of spline polynomials
    397     psPolynomial1D **spline;      ///< An array of n pointers to the spline polynomials
    398     psF32 *p_psDeriv2;            ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
    399     psF32 *domains;               ///< The boundaries between each spline piece.  Size is n+1.
     396    psS32 n;                       ///< The number of spline polynomials
     397    psPolynomial1D **spline;       ///< An array of n pointers to the spline polynomials
     398    psF32 *p_psDeriv2;             ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
     399    psF32 *domains;                ///< The boundaries between each spline piece.  Size is n+1.
     400    psVector *knots;               ///< The boundaries between each spline piece.  Size is n+1.
    400401}
    401402psSpline1D;
Note: See TracChangeset for help on using the changeset viewer.