IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 19, 2005, 3:21:13 PM (21 years ago)
Author:
drobbin
Message:

changed psPolynomial fxns to use F64 and removed psDPoly fxns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/tst_psFunc00.c

    r4547 r4581  
    44*    allocated and deallocated by the psPolynomialXXXlloc() procedures.
    55*    It also calls the various psPolynomialXXXEval() procedures.
    6 * 
     6*
    77*    The F32 and F64 polynomials are tested for all orders (1 - 4) and for
    88*    both ordinary and chebyshev polynomials.
    9 * 
     9*
    1010*    NOTE: This test code requries the stdout file to verify that the results
    1111*    are good.
    12 * 
     12*
    1313*    XXX: Modify these tests so that polynomials with a variety of different
    1414*    orders are created.
    15 * 
    16 *    @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    17 *    @date $Date: 2005-07-13 02:47:00 $
     15*
     16*    @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     17*    @date $Date: 2005-07-20 01:21:13 $
    1818*
    1919*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
    20 *   
     20*
    2121*****************************************************************************/
    2222#include <stdio.h>
     
    3131static psS32 testPolynomial3DAlloc(void);
    3232static psS32 testPolynomial4DAlloc(void);
    33 static psS32 testDPolynomial1DAlloc(void);
    34 static psS32 testDPolynomial2DAlloc(void);
    35 static psS32 testDPolynomial3DAlloc(void);
    36 static psS32 testDPolynomial4DAlloc(void);
    3733
    3834testDescription tests[] = {
     
    4137                              {testPolynomial3DAlloc,578,"psPolynomial3DAlloc",0,false},
    4238                              {testPolynomial4DAlloc,578,"psPolynomial4DAlloc",0,false},
    43                               {testDPolynomial1DAlloc,579,"psDPolynomial1DAlloc",0,false},
    44                               {testDPolynomial2DAlloc,579,"psDPolynomial2DAlloc",0,false},
    45                               {testDPolynomial3DAlloc,579,"psDPolynomial3DAlloc",0,false},
    46                               {testDPolynomial4DAlloc,579,"psDPolynomial4DAlloc",0,false},
    4739                              {NULL}
    4840                          };
     
    109101}
    110102
    111 // This test will allocate a 1D polynomial and verify the structure allocated
    112 psS32 testDPolynomial1DAlloc(void)
    113 {
    114     psDPolynomial1D*  my1DDPoly  = NULL;
    115 
    116     // Allocate polynomial
    117     my1DDPoly = psDPolynomial1DAlloc(ORDER,PS_POLYNOMIAL_CHEB);
    118     // Verify structure allocated
    119     if(my1DDPoly == NULL) {
    120         psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
    121         return 1;
    122     }
    123     // Verify polynomial structure members set properly
    124     if(my1DDPoly->n != ORDER) {
    125         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    126                 my1DDPoly->n, ORDER);
    127         return 2;
    128     }
    129     if(my1DDPoly->type != PS_POLYNOMIAL_CHEB) {
    130         psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
    131                 my1DDPoly->type, PS_POLYNOMIAL_CHEB);
    132         return 3;
    133     }
    134     for(psS32 i = 0; i < ORDER; i++) {
    135         if(my1DDPoly->coeff[i] != 0.0) {
    136             psError(PS_ERR_UNKNOWN,true,"Coeff[%d] %lg not as expected %lg",
    137                     i, my1DDPoly->coeff[i], 0.0);
    138             return 4;
    139         }
    140         if(my1DDPoly->coeffErr[i] != 0.0) {
    141             psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d] %lg not as expected %lg",
    142                     i, my1DDPoly->coeffErr[i], 0.0);
    143             return 5;
    144         }
    145         if(my1DDPoly->mask[i] != 0) {
    146             psError(PS_ERR_UNKNOWN,true,"Mask[%d] %d not as expected %d",
    147                     i, my1DDPoly->mask[i], 0);
    148             return 6;
    149         }
    150     }
    151     psFree(my1DDPoly);
    152 
    153     /*    // Attempt to allocate with negative order
    154         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    155         if(psDPolynomial1DAlloc(-1,PS_POLYNOMIAL_ORD) != NULL) {
    156             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    157             return 7;
    158         }
    159     */
    160     return 0;
    161 }
    162 
    163103// This test will allocate a 2D polynomial and verify the structure allocated
    164104psS32 testPolynomial2DAlloc(void)
     
    220160        psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    221161        if(psPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) {
    222             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    223             return 9;
    224         }
    225     */
    226     return 0;
    227 }
    228 
    229 // This test will allocate a 2D polynomial and verify the structure allocated
    230 psS32 testDPolynomial2DAlloc(void)
    231 {
    232     psDPolynomial2D* my2DDPoly = NULL;
    233 
    234     // Allocate polynomial
    235     my2DDPoly = psDPolynomial2DAlloc(ORDER,ORDER+1,PS_POLYNOMIAL_CHEB);
    236     // Verify structure allocated
    237     if(my2DDPoly == NULL) {
    238         psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
    239         return 1;
    240     }
    241     // Verify polynomial structure members set properly
    242     if(my2DDPoly->nX != ORDER) {
    243         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    244                 my2DDPoly->nX, ORDER);
    245         return 2;
    246     }
    247     // Verify polynomial structure members set properly
    248     if(my2DDPoly->nY != ORDER+1) {
    249         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    250                 my2DDPoly->nY, ORDER+1);
    251         return 3;
    252     }
    253     if(my2DDPoly->type != PS_POLYNOMIAL_CHEB) {
    254         psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
    255                 my2DDPoly->type, PS_POLYNOMIAL_ORD);
    256         return 4;
    257     }
    258     for(psS32 i = 0; i < ORDER; i++) {
    259         for(psS32 j = 0; j < ORDER+1; j++) {
    260             if(my2DDPoly->coeff[i][j] != 0.0) {
    261                 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d] %lg not as expected %lg",
    262                         i, j, my2DDPoly->coeff[i][j], 0.0);
    263                 return 5;
    264             }
    265             if(my2DDPoly->coeffErr[i][j] != 0.0) {
    266                 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d] %lg not as expected %lg",
    267                         i, j, my2DDPoly->coeffErr[i][j], 0.0);
    268                 return 6;
    269             }
    270             if(my2DDPoly->mask[i][j] != 0) {
    271                 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
    272                         i, j, my2DDPoly->mask[i][j], 0);
    273                 return 7;
    274             }
    275         }
    276     }
    277     psFree(my2DDPoly);
    278     /*
    279         // Attempt to allocate with negative order
    280         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    281         if(psDPolynomial2DAlloc(-1,1,PS_POLYNOMIAL_ORD) != NULL) {
    282             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    283             return 8;
    284         }
    285         // Attempt to allocate with negative order
    286         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    287         if(psDPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) {
    288162            psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    289163            return 9;
     
    366240        psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    367241        if(psPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
    368             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    369             return 11;
    370         }
    371     */
    372     return 0;
    373 }
    374 
    375 // This test will allocate a 3D polynomial and verify the structure allocated
    376 psS32 testDPolynomial3DAlloc(void)
    377 {
    378     psDPolynomial3D* my3DDPoly = NULL;
    379 
    380     // Allocate polynomial
    381     my3DDPoly = psDPolynomial3DAlloc(ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_CHEB);
    382     // Verify structure allocated
    383     if(my3DDPoly == NULL) {
    384         psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
    385         return 1;
    386     }
    387     // Verify polynomial structure members set properly
    388     if(my3DDPoly->nX != ORDER) {
    389         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    390                 my3DDPoly->nX, ORDER);
    391         return 2;
    392     }
    393     // Verify polynomial structure members set properly
    394     if(my3DDPoly->nY != ORDER+1) {
    395         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    396                 my3DDPoly->nY, ORDER+1);
    397         return 3;
    398     }
    399     // Verify polynomial structure members set properly
    400     if(my3DDPoly->nZ != ORDER+2) {
    401         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    402                 my3DDPoly->nZ, ORDER+2);
    403         return 4;
    404     }
    405     if(my3DDPoly->type != PS_POLYNOMIAL_CHEB) {
    406         psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
    407                 my3DDPoly->type, PS_POLYNOMIAL_ORD);
    408         return 5;
    409     }
    410     for(psS32 i = 0; i < ORDER; i++) {
    411         for(psS32 j = 0; j < ORDER+1; j++) {
    412             for(psS32 k = 0; k < ORDER+2; k++) {
    413                 if(my3DDPoly->coeff[i][j][k] != 0.0) {
    414                     psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d] %lg not as expected %lg",
    415                             i, j, k, my3DDPoly->coeff[i][j][k], 0.0);
    416                     return 6;
    417                 }
    418                 if(my3DDPoly->coeffErr[i][j][k] != 0.0) {
    419                     psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d] %lg not as expected %lg",
    420                             i, j, k, my3DDPoly->coeffErr[i][j][k], 0.0);
    421                     return 7;
    422                 }
    423                 if(my3DDPoly->mask[i][j][k] != 0) {
    424                     psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d",
    425                             i, j, k, my3DDPoly->mask[i][j][k], 0);
    426                     return 8;
    427                 }
    428             }
    429         }
    430     }
    431     psFree(my3DDPoly);
    432 
    433     /*    // Attempt to allocate with negative order
    434         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    435         if(psDPolynomial3DAlloc(-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
    436             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    437             return 9;
    438         }
    439         // Attempt to allocate with negative order
    440         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    441         if(psDPolynomial3DAlloc(1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
    442             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    443             return 10;
    444         }
    445         // Attempt to allocate with negative order
    446         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    447         if(psDPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
    448242            psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    449243            return 11;
     
    547341}
    548342
    549 // This test will allocate a 4D polynomial and verify the structure allocated
    550 psS32 testDPolynomial4DAlloc(void)
    551 {
    552     psDPolynomial4D* my4DDPoly = NULL;
    553 
    554     // Allocate polynomial
    555     my4DDPoly = psDPolynomial4DAlloc(ORDER+3,ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD);
    556     // Verify structure allocated
    557     if(my4DDPoly == NULL) {
    558         psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected");
    559         return 1;
    560     }
    561     // Verify polynomial structure members set properly
    562     if(my4DDPoly->nY != ORDER) {
    563         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    564                 my4DDPoly->nY, ORDER);
    565         return 2;
    566     }
    567     // Verify polynomial structure members set properly
    568     if(my4DDPoly->nZ != ORDER+1) {
    569         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    570                 my4DDPoly->nZ, ORDER+1);
    571         return 3;
    572     }
    573     // Verify polynomial structure members set properly
    574     if(my4DDPoly->nT != ORDER+2) {
    575         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    576                 my4DDPoly->nT, ORDER+2);
    577         return 4;
    578     }
    579     // Verify polynomial structure members set properly
    580     if(my4DDPoly->nX != ORDER+3) {
    581         psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d",
    582                 my4DDPoly->nX, ORDER+3);
    583         return 5;
    584     }
    585     if(my4DDPoly->type != PS_POLYNOMIAL_ORD) {
    586         psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
    587                 my4DDPoly->type, PS_POLYNOMIAL_ORD);
    588         return 6;
    589     }
    590     for(psS32 i = 0; i < ORDER+3; i++) {
    591         for(psS32 j = 0; j < ORDER; j++) {
    592             for(psS32 k = 0; k < ORDER+1; k++) {
    593                 for(psS32 l = 0; l < ORDER+2; l++) {
    594                     if(my4DDPoly->coeff[i][j][k][l] != 0.0) {
    595                         psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d][%d] %lg not as expected %lg",
    596                                 i, j, k, l, my4DDPoly->coeff[i][j][k][l], 0.0);
    597                         return 7;
    598                     }
    599                     if(my4DDPoly->coeffErr[i][j][k][l] != 0.0) {
    600                         psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d][l] %lg not as expected %lg",
    601                                 i, j, k, l, my4DDPoly->coeffErr[i][j][k][l], 0.0);
    602                         return 8;
    603                     }
    604                     if(my4DDPoly->mask[i][j][k][l] != 0) {
    605                         psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d][%d][%d] %d not as expected %d",
    606                                 i, j, k, l, my4DDPoly->mask[i][j][k][l], 0);
    607                         return 9;
    608                     }
    609                 }
    610             }
    611         }
    612     }
    613     psFree(my4DDPoly);
    614 
    615     /*    // Attempt to allocate with negative order
    616         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    617         if(psDPolynomial4DAlloc(-1,1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
    618             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    619             return 10;
    620         }
    621         // Attempt to allocate with negative order
    622         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    623         if(psDPolynomial4DAlloc(1,-1,1,1,PS_POLYNOMIAL_ORD) != NULL) {
    624             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    625             return 11;
    626         }
    627         // Attempt to allocate with negative order
    628         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    629         if(psDPolynomial4DAlloc(1,1,-1,1,PS_POLYNOMIAL_ORD) != NULL) {
    630             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    631             return 12;
    632         }
    633         // Attempt to allocate with negative order
    634         psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms");
    635         if(psDPolynomial4DAlloc(1,1,1,-1,PS_POLYNOMIAL_ORD) != NULL) {
    636             psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL");
    637             return 13;
    638         }
    639     */
    640     return 0;
    641 }
    642 
Note: See TracChangeset for help on using the changeset viewer.