IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 28, 2004, 1:27:37 PM (22 years ago)
Author:
gusciora
Message:

Chebyshev polynomila fitting routines.

File:
1 edited

Legend:

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

    r1907 r1921  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-27 23:41:42 $
     9 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-28 23:27:37 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    486486float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
    487487{
     488    /*
    488489    psVector *d;
    489490    int n;
     
    507508    psFree(d);
    508509    return(tmp);
    509     /*
    510         int n;
    511         int i;
    512         float tmp;
    513         psPolynomial1D **chebPolys = NULL;
    514      
    515         n = myPoly->n;
    516         chebPolys = CreateChebyshevPolys(n);
    517      
    518         tmp = 0.0;
    519         for (i=0;i<myPoly->n;i++) {
    520             tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
    521         }
    522         tmp-= (myPoly->coeff[0]/2.0);
    523         return(tmp);
    524510    */
     511
     512    int n;
     513    int i;
     514    float tmp;
     515    psPolynomial1D **chebPolys = NULL;
     516
     517    n = myPoly->n;
     518    chebPolys = CreateChebyshevPolys(n);
     519
     520    tmp = 0.0;
     521    for (i=0;i<myPoly->n;i++) {
     522        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
     523        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
     524    }
     525    tmp-= (myPoly->coeff[0]/2.0);
     526
     527
     528    return(tmp);
    525529}
    526530
     
    19421946
    19431947/*****************************************************************************
    1944 p_psInterpolate1D(): This routine will take as input psVectors domain and
     1948p_psVectorInterpolate(): This routine will take as input psVectors domain and
    19451949range, and the x value, assumed to lie with the domain vector.  It produces
    19461950as output the LaGrange interpolated value of a polynomial of the specified
     
    19591963            "---- p_psVectorInterpolate() begin ----\n");
    19601964
    1961     if (domain->type.type != range->type.type != x->type.type) {
     1965    if ((domain->type.type != range->type.type) ||
     1966            (domain->type.type != x->type.type)) {
    19621967        // XXX psError
     1968        printf("domain->type.type != range->type.type != x->type.type\n");
     1969        printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);
    19631970    }
    19641971    if (domain->n != range->n) {
    19651972        // XXX psError
     1973        printf("domain->n != range->n\n");
    19661974    }
    19671975    if (order > (domain->n - 1)) {
    19681976        // XXX psError: not enough data points for order-order interpolation.
     1977        printf("not enough data points for order-order interpolation.\n");
    19691978    }
    19701979
     
    19791988    } else {
    19801989        // XXX psError: type not supported
    1981     }
    1982 
     1990        printf("XXX psError: type not supported\n");
     1991    }
     1992
     1993    printf("return(NULL)\n");
    19831994    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
    19841995            "---- p_psVectorInterpolate() end ----\n");
Note: See TracChangeset for help on using the changeset viewer.