IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 17, 2004, 3:50:45 PM (22 years ago)
Author:
gusciora
Message:

Functions for psMinimizeLMChi2().

File:
1 edited

Legend:

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

    r1823 r1831  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-17 02:14:52 $
     9 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-18 01:50:45 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    18091809p_psInterpolate1D(): This routine will take as input n-element floating
    18101810point arrays domain and range, and the x value, assumed to lie with the
    1811 domain vector.  It produces as output the n-order LaGrange interpolated
     1811domain vector.  It produces as output the (n-1)-order LaGrange interpolated
    18121812value of x.
    18131813 
    18141814XXX: do we error check for non-distinct domain values?
    18151815 *****************************************************************************/
    1816 float p_psFullInterpolate1DF32(float *domain,
     1816float p_ps1DFullInterpolateF32(float *domain,
    18171817                               float *range,
    18181818                               int n,
     
    18221822    int m;
    18231823    static psVector *p = NULL;
    1824     psVectorRecycle(p, n, PS_TYPE_F32);
     1824    p = psVectorRecycle(p, n, PS_TYPE_F32);
    18251825    p_psMemSetPersistent(p, true);
     1826    p_psMemSetPersistent(p->data.F32, true);
     1827
     1828    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
     1829            "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
     1830
     1831    for (i=0;i<n;i++) {
     1832        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
     1833                "domain/range is (%f %f)\n", domain[i], range[i]);
     1834    }
     1835
     1836    for (i=0;i<n;i++) {
     1837        p->data.F32[i] = range[i];
     1838        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
     1839                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
     1840
     1841    }
    18261842
    18271843    // From NR, during each iteration of the m loop, we are computing the
    18281844    // p_{i ... i+m} terms.
    1829     for (m=0;m<n;m++) {
     1845    for (m=1;m<n;m++) {
    18301846        for (i=0;i<n-m;i++) {
    1831             if (m == 0) {
    1832                 p->data.F32[i] = range[i];
    1833             } else {
    1834                 // From NR: we are computing P_{i ... i+m}
    1835                 p->data.F32[i] = (((x-range[i+m]) * p->data.F32[i]) +
    1836                                   ((range[i]-x) * p->data.F32[i+1])) /
    1837                                  (domain[i] - domain[i+m]);
    1838             }
    1839         }
    1840     }
     1847            // From NR: we are computing P_{i ... i+m}
     1848            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
     1849                              ((domain[i]-x) * p->data.F32[i+1])) /
     1850                             (domain[i] - domain[i+m]);
     1851            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
     1852            psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
     1853                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
     1854        }
     1855    }
     1856    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
     1857            "---- p_ps1DFullInterpolateF32() end ----\n");
     1858
    18411859    return(p->data.F32[0]);
    18421860}
     
    18441862
    18451863// This is a
    1846 float p_psInterpolate1DF32(float *domain,
     1864float p_ps1DInterpolateF32(float *domain,
    18471865                           float *range,
    18481866                           int n,
     
    18541872    int origin;
    18551873
     1874    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
     1875            "---- p_ps1DInterpolateF32() begin ----\n");
     1876
    18561877    binNum = VectorBinDisectF32(domain, n, x);
     1878
    18571879    if (0 == numIntPoints%2) {
    18581880        origin = binNum - ((numIntPoints/2) - 1);
     
    18711893    }
    18721894
    1873     return(p_psFullInterpolate1DF32(&domain[origin], &range[origin], n, x));
     1895    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
     1896            "---- p_ps1DInterpolateF32() end ----\n");
     1897    return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));
    18741898}
    18751899
     
    18821906XXX: This stuff does not work with a mask.
    18831907 *****************************************************************************/
    1884 float p_psInterpolate1D(psVector *domain,
    1885                         psVector *range,
    1886                         int order,
    1887                         psScalar *x)
    1888 {
     1908psScalar *p_psVectorInterpolate(psVector *domain,
     1909                                psVector *range,
     1910                                int order,
     1911                                psScalar *x)
     1912{
     1913    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
     1914            "---- p_psVectorInterpolate() begin ----\n");
     1915
    18891916    if (domain->type.type != range->type.type != x->type.type) {
    18901917        // XXX psError
     
    18981925
    18991926    if (x->type.type == PS_TYPE_F32) {
    1900         return(p_psInterpolate1DF32(domain->data.F32, range->data.F32,
    1901                                     domain->n, order, x->data.F32));
     1927        psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
     1928                "---- p_psVectorInterpolate() end ----\n");
     1929        return(psScalarAlloc(p_ps1DInterpolateF32(domain->data.F32,
     1930                             range->data.F32,
     1931                             domain->n,
     1932                             order,
     1933                             x->data.F32), PS_TYPE_F32));
    19021934    } else {
    19031935        // XXX psError: type not supported
    19041936    }
    19051937
    1906     return(-1.0);
     1938    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
     1939            "---- p_psVectorInterpolate() end ----\n");
     1940    return(NULL);
    19071941}
    19081942
Note: See TracChangeset for help on using the changeset viewer.