IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 22, 2004, 8:12:22 PM (22 years ago)
Author:
gusciora
Message:

removed the old 1d Spline Gen function.

File:
1 edited

Legend:

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

    r1859 r1861  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-23 04:56:40 $
     9 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-23 06:12:22 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    16611661
    16621662/*****************************************************************************
    1663 XXX: Ensure that domain[i+1] != domain[i]
    16641663 *****************************************************************************/
    16651664psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
     
    16811680
    16821681    tmp->domains = (float *) psAlloc((bounds->n) * sizeof(float));
     1682
    16831683    for (i=0;i<bounds->n;i++) {
    16841684        (tmp->domains)[i] = bounds->data.F32[i];
     1685        if (i<(bounds->n-1)) {
     1686            if (FLT_EPSILON < fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
     1687                // XXX: psErrorMsg(data points must be distinct)
     1688            }
     1689        }
    16851690    }
    16861691
     
    16971702 
    16981703XXX: Macro this for a few different types.
     1704 
     1705XXX: name since we don't take psVectors as input.
    16991706 *****************************************************************************/
    17001707int p_psVectorBinDisectF32(float *bins,
     
    18671874
    18681875
    1869 // This is a
     1876/*****************************************************************************
     1877p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
     1878LaGrange interpolation.
     1879 *****************************************************************************/
    18701880float p_ps1DInterpolateF32(float *domain,
    18711881                           float *range,
     
    19101920order around the point x.
    19111921 
    1912 XXX: This stuff does not work with a mask.
     1922XXX: This stuff does not currently work with a mask.
     1923 
     1924XXX: nobody asked for us to generate this routine.
    19131925 *****************************************************************************/
    19141926psScalar *p_psVectorInterpolate(psVector *domain,
     
    19481960
    19491961
     1962/*****************************************************************************
     1963psSpline1DEval(): this routine takes an existing spline of arbitrary order
     1964and an independent x value.  Each determines which spline that x corresponds
     1965to by doing a bracket disection on the domains of the spline data structure
     1966(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
     1967by a call to the 1D polynomial functions.
     1968 
     1969XXX: SDR is silent about data types.  PS_TYPE_F32 is implemented.
     1970 *****************************************************************************/
    19501971float psSpline1DEval(const psSpline1D *spline,
    19511972                     float x)
     
    19852006    return(tmpVector);
    19862007}
    1987 
    1988 
    1989 
    1990 /*****************************************************************************
    1991 psSpline1DGen(): This routine will take an existing spline data structure,
    1992 along with a set of data values for each of the domains, and fit splines of
    1993 the specified order (currently, linear only), and set the coefficients in the
    1994 appropriate spline polynomials.  This function is not part of the API in the
    1995 latest SDR, but I'm guessing it will be, and I need it to generate test
    1996 cases, so I included it here.
    1997  *****************************************************************************/
    1998 
    1999 psSpline1D *psSpline1DGen(const psSpline1D *spline,
    2000                           psVector *data)
    2001 {
    2002     int i;
    2003     float slope;
    2004 
    2005     psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
    2006             "---- Calling psSpline1DGen()\n");
    2007 
    2008     if (data->n != (1 + spline->n)) {
    2009         psLogMsg(__func__, PS_LOG_WARN,
    2010                  "data size / spline size mismatch (%d %d)\n",
    2011                  data->n, spline->n);
    2012         return(NULL);
    2013     }
    2014     // XXX: verify your math
    2015     if (2 == (spline->spline[0])->n) {
    2016         for (i=0;i<spline->n;i++) {
    2017             slope = (data->data.F32[i+1] - data->data.F32[i]) /
    2018                     (spline->domains[i+1] - spline->domains[i]);
    2019             (spline->spline[i])->coeff[0] = data->data.F32[i] -
    2020                                             (slope * spline->domains[i]);
    2021             //printf("HMMM (%f, %f, %f)\n", data->data.F32[i], slope, spline->domains[i]);
    2022 
    2023             (spline->spline[i])->coeff[1] = slope;
    2024             psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
    2025                     "---- spline %d coeffs are (%f, %f)\n", i,
    2026                     (spline->spline[i])->coeff[0],
    2027                     (spline->spline[i])->coeff[1]);
    2028         }
    2029         psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,
    2030                 "---- Exiting psSpline1DGen()\n");
    2031         return((psSpline1D *) spline);
    2032     } else if (4 == (spline->spline[0])->n) {
    2033         psLogMsg(__func__, PS_LOG_WARN,
    2034                  "Cubic splines have not been implemented.");
    2035         return(NULL);
    2036     } else {
    2037         psLogMsg(__func__, PS_LOG_WARN,
    2038                  "Don't know how to generate %d-order splines.",
    2039                  (spline->spline[0])->n-1);
    2040         return(NULL);
    2041     }
    2042 }
Note: See TracChangeset for help on using the changeset viewer.