IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 22, 2005, 10:45:43 AM (21 years ago)
Author:
gusciora
Message:

Implementing the polynomial nTerm -> nOrder switch,

File:
1 edited

Legend:

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

    r5091 r5092  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.124 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-09-22 03:00:31 $
     9*  @version $Revision: 1.125 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-09-22 20:45:43 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    298298    /* This is old code that does not use Clenshaw's formula.  Get rid of it.
    299299
    300     psS32 n;
    301300    psS32 i;
    302301    psF32 tmp;
    303302    psPolynomial1D **chebPolys = NULL;
    304303
    305     n = 1 + poly->COOL_1D_n;
    306     chebPolys = createChebyshevPolys(n);
     304    chebPolys = createChebyshevPolys(1 + poly->COOL_1D_n);
    307305
    308306    tmp = 0.0;
     
    360358    // Determine how many Chebyshev polynomials
    361359    // are needed, then create them.
    362     maxChebyPoly = 1 + poly->COOL_2D_nX;
    363     if ((1 + poly->COOL_2D_nY) > maxChebyPoly) {
    364         maxChebyPoly = (1 + poly->COOL_2D_nY);
    365     }
    366     chebPolys = createChebyshevPolys(maxChebyPoly);
     360    maxChebyPoly = poly->COOL_2D_nX;
     361    if (poly->COOL_2D_nY > maxChebyPoly) {
     362        maxChebyPoly = poly->COOL_2D_nY;
     363    }
     364    chebPolys = createChebyshevPolys(maxChebyPoly + 1);
    367365
    368366    for (loop_x = 0; loop_x < (1 + poly->COOL_2D_nX); loop_x++) {
     
    375373        }
    376374    }
    377     for (i=0;i<maxChebyPoly;i++) {
     375    for (i=0;i<maxChebyPoly+1;i++) {
    378376        psFree(chebPolys[i]);
    379377    }
     
    453451    }
    454452
    455     for (i=0;i<maxChebyPoly;i++) {
     453    for (i=0;i<maxChebyPoly+1;i++) {
    456454        psFree(chebPolys[i]);
    457455    }
     
    529527        maxChebyPoly = poly->COOL_4D_nT;
    530528    }
    531     chebPolys = createChebyshevPolys(maxChebyPoly);
     529    chebPolys = createChebyshevPolys(maxChebyPoly + 1);
    532530
    533531    for (loop_x = 0; loop_x < (1 + poly->COOL_4D_nX); loop_x++) {
     
    536534                for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nZ); loop_t++) {
    537535                    if (poly->mask[loop_x][loop_y][loop_z][loop_t] == 0) {
     536                        //printf("HMMM (%d, %d, %d, %d)\n", loop_x, loop_y, loop_z, loop_t);
     537                        //printf("HMMM (%d, %d, %d, %d)\n", chebPolys[loop_x]->COOL_1D_n, chebPolys[loop_y]->COOL_1D_n, chebPolys[loop_z]->COOL_1D_n, chebPolys[loop_t]->COOL_1D_n);
     538
    538539                        polySum += poly->coeff[loop_x][loop_y][loop_z][loop_t] *
    539540                                   psPolynomial1DEval(chebPolys[loop_x], x) *
     
    547548    }
    548549
    549     for (i=0;i<maxChebyPoly;i++) {
     550    for (i=0;i<maxChebyPoly+1;i++) {
    550551        psFree(chebPolys[i]);
    551552    }
     
    618619                                    psPolynomialType type)
    619620{
    620     PS_ASSERT_INT_POSITIVE(n, NULL);
     621    PS_ASSERT_INT_NONNEGATIVE(n, NULL);
    621622
    622623    unsigned int i = 0;
     
    628629    newPoly->type = type;
    629630    newPoly->COOL_1D_n = n;
    630     newPoly->coeff = psAlloc(n * sizeof(psF64));
    631     newPoly->coeffErr = psAlloc(n * sizeof(psF64));
     631    newPoly->coeff = psAlloc((n + 1) * sizeof(psF64));
     632    newPoly->coeffErr = psAlloc((n + 1) * sizeof(psF64));
    632633    newPoly->mask = (psMaskType *)psAlloc((n + 1) * sizeof(psMaskType));
    633634    for (i = 0; i < (n + 1); i++) {
Note: See TracChangeset for help on using the changeset viewer.