IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5094


Ignore:
Timestamp:
Sep 22, 2005, 12:22:15 PM (21 years ago)
Author:
gusciora
Message:

Implementing psPoly nOrder/nTerm switch.

Location:
trunk/psLib
Files:
3 edited

Legend:

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

    r5092 r5094  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.125 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-09-22 20:45:43 $
     9*  @version $Revision: 1.126 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-09-22 22:22:15 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    161161used frequently and the data structure created here does not contain the
    162162outer coefficients of the Chebyshev polynomials.
     163 
     164XXX: From the poly nOrder/nTerm changem the maxChebyPoly here is still nTerms,
     165not nOrder.
    163166 *****************************************************************************/
    164 static psPolynomial1D **createChebyshevPolys(unsigned int maxChebyPoly)
    165 {
     167static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
     168{
     169    //printf("createChebyshevPolys(%d)\n", maxChebyPoly);
    166170    PS_ASSERT_INT_NONNEGATIVE(maxChebyPoly, NULL);
    167171
     
    169173
    170174    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
    171     for (unsigned int i = 0; i < maxChebyPoly; i++) {
    172         chebPolys[i] = psPolynomial1DAlloc(i, PS_POLYNOMIAL_ORD);
     175    for (psS32 i = 0; i < maxChebyPoly; i++) {
     176        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
    173177    }
    174178
     
    184188            for (psS32 j = 0; j < chebPolys[i - 1]->COOL_1D_n; j++) {
    185189                chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
     190                //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j + 1, chebPolys[i]->coeff[j + 1]);
    186191            }
    187192            for (psS32 j = 0; j < chebPolys[i - 2]->COOL_1D_n; j++) {
    188193                chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
     194                //printf("chebPolys[%d]->coeff[%d] is %.2f\n", i, j, chebPolys[i]->coeff[j]);
    189195            }
    190196        }
     
    203209                                 const psPolynomial1D* poly)
    204210{
     211    //printf("ordPolynomial1DEval(%f): ", x);
     212    //for (psS32 i = 0 ; i < (1 + poly->COOL_1D_n) ; i++) printf("(%.2f) ", poly->coeff[i]);
     213    //printf("\n");
     214
    205215    unsigned int loop_x = 0;
    206216    psF64 polySum = 0.0;
     
    527537        maxChebyPoly = poly->COOL_4D_nT;
    528538    }
     539    // XXX: Add 1 since createChebyshevPolys() takes nTerms, not nOrder.
    529540    chebPolys = createChebyshevPolys(maxChebyPoly + 1);
    530541
     
    532543        for (loop_y = 0; loop_y < (1 + poly->COOL_4D_nY); loop_y++) {
    533544            for (loop_z = 0; loop_z < (1 + poly->COOL_4D_nZ); loop_z++) {
    534                 for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nZ); loop_t++) {
     545                for (loop_t = 0; loop_t < (1 + poly->COOL_4D_nT); loop_t++) {
    535546                    if (poly->mask[loop_x][loop_y][loop_z][loop_t] == 0) {
    536547                        //printf("HMMM (%d, %d, %d, %d)\n", loop_x, loop_y, loop_z, loop_t);
    537548                        //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 
     549                        //printf("chebPolynomial4DEval()\n");
    539550                        polySum += poly->coeff[loop_x][loop_y][loop_z][loop_t] *
    540551                                   psPolynomial1DEval(chebPolys[loop_x], x) *
  • trunk/psLib/test/math/tst_psFunc10.c

    r5092 r5094  
    44*  ORD and CHEB type polynomials.
    55*
    6 *  @version  $Revision: 1.5 $  $Name: not supported by cvs2svn $
    7 *  @date  $Date: 2005-09-22 20:45:43 $
     6*  @version  $Revision: 1.6 $  $Name: not supported by cvs2svn $
     7*  @date  $Date: 2005-09-22 22:22:15 $
    88*
    99* Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    184184    psFree(polyOrd);
    185185
    186     return 0;
     186    return(testStatus);
    187187}
    188188
     
    320320    psFree(polyCheb);
    321321
    322     return 0;
     322    return(testStatus);
    323323}
    324324
  • trunk/psLib/test/math/tst_psFunc11.c

    r5092 r5094  
    44*  ORD and CHEB type polynomials.
    55*
    6 *  @version  $Revision: 1.5 $  $Name: not supported by cvs2svn $
    7 *  @date  $Date: 2005-09-22 20:45:43 $
     6*  @version  $Revision: 1.6 $  $Name: not supported by cvs2svn $
     7*  @date  $Date: 2005-09-22 22:22:15 $
    88*
    99* Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    1919
    2020static psS32 testPoly4DEval(void);
    21 //static psS32 testPoly4DEvalVector(void);
     21static psS32 testPoly4DEvalVector(void);
    2222
    2323testDescription tests[] = {
    2424                              {testPoly4DEval,583,"psPolynomial4DEval",true,false},
    25                               //                              {testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false},
     25                              {testPoly4DEvalVector,000,"psPolynomial4DEvalVector",true,false},
    2626                              {NULL}
    2727                          };
     
    378378{
    379379    psBool testStatus = true;
    380 
    381380    // Allocate polynomial structure
    382381    psPolynomial4D*  polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD);
     
    405404            testStatus = false;
    406405        }
    407 
    408406        psF64 resultCheb = psPolynomial4DEval(polyCheb,Dpoly4DWXYZChebValue[i][0],Dpoly4DWXYZChebValue[i][1],
    409407                                              Dpoly4DWXYZChebValue[i][2],Dpoly4DWXYZChebValue[i][3]);
     
    431429    return(testStatus);
    432430}
    433 /*
     431
    434432psS32 testPoly4DEvalVector(void)
    435433{
     434    psBool testStatus = true;
    436435    // Allocate polynomial
    437436    psPolynomial4D* polyOrd = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_ORD);
    438437    psPolynomial4D* polyCheb = psPolynomial4DAlloc(TERMS-1, TERMS-1, TERMS-1, TERMS-1, PS_POLYNOMIAL_CHEB);
    439  
     438
    440439    // Set polynomial members
    441440    for(psS32 i = 0; i < TERMS; i++) {
     
    451450        }
    452451    }
    453  
     452
    454453    // Create input vectors
    455454    psVector* inputOrdW  = psVectorAlloc(TESTPOINTS, PS_TYPE_F64);
     
    471470        inputChebZ->data.F64[i] = Dpoly4DWXYZChebValue[i][3];
    472471    }
    473  
     472
    474473    // Evaluate the vectors
    475474    psVector* outputOrd = psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ);
     
    480479    if(outputOrd->type.type != PS_TYPE_F64) {
    481480        printf("TEST ERROR: Output vector of type %d expected %d",
    482                 outputOrd->type.type, PS_TYPE_F64);
     481               outputOrd->type.type, PS_TYPE_F64);
    483482        testStatus = false;
    484483    }
     
    490489    if(outputCheb->type.type != PS_TYPE_F64) {
    491490        printf("TEST ERROR: Output vector of type %d expected %d",
    492                 outputCheb->type.type, PS_TYPE_F64);
    493         testStatus = false;
    494     }
    495  
     491               outputCheb->type.type, PS_TYPE_F64);
     492        testStatus = false;
     493    }
     494
    496495    // Verify the results
    497496    for(psS32 i = 0; i < TESTPOINTS; i++) {
    498497        if(fabs(Dpoly4DResult[i]-outputOrd->data.F64[i]) > ERROR_TOL) {
    499498            printf("TEST ERROR: Result[%d] %lg not equal to expected %lg",
    500                     i, outputOrd->data.F64[i], Dpoly4DResult[i]);
     499                   i, outputOrd->data.F64[i], Dpoly4DResult[i]);
    501500            testStatus = false;
    502501        }
    503502        if(fabs(Dpoly4DChebResult[i]-outputCheb->data.F64[i]) > ERROR_TOL) {
    504503            printf("TEST ERROR: ResultCheb[%d] %lg not equal to expected %lg",
    505                     i, outputCheb->data.F64[i], Dpoly4DChebResult[i]);
     504                   i, outputCheb->data.F64[i], Dpoly4DChebResult[i]);
    506505            testStatus = false;
    507506        }
    508507    }
    509  
     508
    510509    // Attempt to invoke function with null polynomial
    511510    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL polynomial");
     
    514513        testStatus = false;
    515514    }
    516  
     515
    517516    // Attempt to invoke function with null input vector
    518517    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL input vector");
     
    539538        testStatus = false;
    540539    }
    541  
     540
    542541    // Attempt to invoke function with a non F64 type input vector
    543542    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid input type");
     
    572571    }
    573572    inputOrdW->type.type = PS_TYPE_F64;
    574  
     573
    575574    psFree(inputOrdX);
    576575    psFree(inputOrdY);
     
    585584    psFree(polyOrd);
    586585    psFree(polyCheb);
    587  
     586
    588587    return(testStatus);
    589588}
    590  
    591 */
Note: See TracChangeset for help on using the changeset viewer.