IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1907


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

...

Location:
trunk/psLib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psConstants.h

    r1903 r1907  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-25 23:05:07 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-27 23:41:42 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848}
    4949
     50/** Preprocessor macro to generate error on a NULL image */
     51#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
     52if (NAME == NULL || NAME->data.V == NULL) {                                                         \
     53    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
     54}
     55
     56/** Preprocessor macro to generate error for zero length rows or columns */
     57#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
     58if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
     59    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
     60            NAME->numCols, NAME->numRows);                                                          \
     61}
     62
     63/** Preprocessor macro to generate error on a NULL 1DPolynomial */
     64#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
     65if (NAME == NULL || NAME->coeff == NULL) {                                                         \
     66    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
     67}
     68
    5069#define PS_PRINT_VECTOR(NAME) \
    5170for (int my_i=0;my_i<NAME->n;my_i++) { \
  • trunk/psLib/src/dataManip/psFunctions.c

    r1903 r1907  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-25 23:05:07 $
     9 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-27 23:41:42 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    111111/*****************************************************************************/
    112112
    113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
     113/*****************************************************************************
     114CreateChebyshevPolys(n): this routine takes as input the required order n,
     115and returns as output as a pointer to an array of n psPolynomial1D
     116structures, corresponding to the first n Chebyshev polynomials.
     117 
     118XXX: The output should be static since the Chebyshev polynomials might be
     119used frequently and the data structure created here does not contain the
     120outer coefficients of the Chebyshev polynomials.
     121 *****************************************************************************/
     122static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
    114123{
    115124    psPolynomial1D **chebPolys = NULL;
     
    430439    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    431440 
    432     XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
    433     in polynomial evaluation.  If so, then all of the following polynomial
    434     evaluation functions must be modified to do so.
    435  
    436441    XXX: Should the "coeffErr[]" should be used as well?
    437442 *****************************************************************************/
     
    502507    psFree(d);
    503508    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);
     524    */
    504525}
    505526
  • trunk/psLib/src/dataManip/psMinimize.c

    r1879 r1907  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-24 20:08:22 $
     11 *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-27 23:41:42 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5353/* DEFINE STATEMENTS                                                         */
    5454/*****************************************************************************/
    55 
    56 /** Preprocessor macro to generate error on a NULL 1DPolynomial */
    57 #define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
    58 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
    59     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    60 }
    61 
    62 /** Preprocessor macro to generate error on a NULL vector */
    63 #define PS_CHECK_NULL_VECTOR(NAME)                                                          \
    64 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    65     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    66 }
    67 
    68 /** Preprocessor macro to generate error for zero length vector */
    69 #define PS_CHECK_EMPTY_VECTOR(NAME)                                                          \
    70 if (NAME->n < 1) {                                                                                  \
    71     psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
    72 }
    73 
    74 /** Preprocessor macro to generate error on differing size vectors */
    75 #define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2)                                                          \
    76 if (VEC1->n != VEC2->n) {               \
    77     psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
    78 }
    79 
    80 /** Preprocessor macro to generate error on a NULL image */
    81 #define PS_CHECK_NULL_IMAGE(NAME)                                                           \
    82 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    83     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    84 }
    85 
    86 /** Preprocessor macro to generate error for zero length rows or columns */
    87 #define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
    88 if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
    89     psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
    90             NAME->numCols, NAME->numRows);                                                          \
    91 }
    9255
    9356/*****************************************************************************/
     
    692655}
    693656
     657
     658/*****************************************************************************
     659CreateChebyshevPolys(n): this routine takes as input the required order n,
     660and returns as output as a pointer to an array of n psPolynomial1D
     661structures, corresponding to the first n Chebyshev polynomials.
     662 
     663XXX: The output should be static since the Chebyshev polynomials might be
     664used frequently and the data structure created here does not contain the
     665outer coefficients of the Chebyshev polynomials.
     666 *****************************************************************************/
     667static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
     668{
     669    psPolynomial1D **chebPolys = NULL;
     670    int i = 0;
     671    int j = 0;
     672
     673    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
     674    for (i = 0; i < maxChebyPoly; i++) {
     675        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
     676    }
     677
     678    // Create the Chebyshev polynomials.
     679    // Polynomial i has i-th order.
     680    chebPolys[0]->coeff[0] = 1;
     681    chebPolys[1]->coeff[1] = 1;
     682    for (i = 2; i < maxChebyPoly; i++) {
     683        for (j = 0; j < chebPolys[i - 1]->n; j++) {
     684            chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
     685        }
     686        for (j = 0; j < chebPolys[i - 2]->n; j++) {
     687            chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
     688        }
     689    }
     690
     691    return (chebPolys);
     692}
     693
     694
     695
     696psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly,
     697        const psVector* restrict x,
     698        const psVector* restrict y,
     699        const psVector* restrict yErr)
     700{
     701    int j;
     702    int k;
     703    int n = x->n;
     704    psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n);
     705    ;
     706    float fac;
     707    float sum;
     708    /*
     709        fac = 2.0/((float) n);
     710        for (j=0;j<n;j++) {
     711            sum = 0.0;
     712            for (k=0;k<n;k++) {
     713                sum+= y->data.F64[k] *
     714                      cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n));
     715    //            sum+= y->data.F64[k] *
     716    //                  cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) *
     717    //                  cos(M_PI * (-0.5 + ((float) k)) / ((float) n));
     718     
     719            }
     720            myPoly->coeff[j] = fac * sum;
     721     
     722        }
     723        return(myPoly);
     724    */
     725
     726    fac = 2.0/((float) n);
     727    for (j=0;j<myPoly->n;j++) {
     728        sum = 0.0;
     729        for (k=1;k<n;k++) {
     730            sum+= (y->data.F64[k] *
     731                   psPolynomial1DEval((float) x->data.F64[k], chebPolys[j]));
     732        }
     733        myPoly->coeff[j] = fac * sum;
     734    }
     735    return(myPoly);
     736}
     737
    694738/******************************************************************************
    695739psVectorFitPolynomial1D():  This routine must fit a polynomial of degree
     
    704748 
    705749XXX: Must do: if yErr==NULL, set all errors equal.
     750 
     751XXX: type is currently ignored.  Must implement this for Chebyshev
     752polynomials.
    706753 *****************************************************************************/
    707754psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,
     
    710757                                        const psVector* restrict yErr)
    711758{
     759    // XXX: Create a p_psVectorFitPolynomial1DOrd() function.  Here, we
     760    // should only be calling that or the Cheby function.
     761
     762    if (myPoly->type == PS_POLYNOMIAL_CHEB) {
     763        return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr));
     764    }
     765
    712766    int polyOrder = myPoly->n;
    713767    psImage* A = NULL;
  • trunk/psLib/src/dataManip/psStats.c

    r1904 r1907  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-27 20:37:48 $
     11 *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-27 23:41:42 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    858858    for (i = 0; i < myData->n; i++) {
    859859        myData->data.F32[i] = (myData->data.F32[i] - min) / range;
     860    }
     861}
     862
     863/*****************************************************************************
     864p_psNormalizeVectorF64(myData): this is a private function which normalizes the
     865elements of a vector to a range between -1.0 and 1.0.
     866 
     867XXX: incorporate this into above
     868 
     869XXX: 0-1 or -1:1?
     870 *****************************************************************************/
     871void p_psNormalizeVectorF64(psVector* myData)
     872{
     873    float min = (float)HUGE;
     874    float max = (float)-HUGE;
     875    float range = 0.0;
     876    int i = 0;
     877
     878    for (i = 0; i < myData->n; i++) {
     879        if (myData->data.F64[i] < min) {
     880            min = myData->data.F64[i];
     881        }
     882        if (myData->data.F64[i] > max) {
     883            max = myData->data.F64[i];
     884        }
     885    }
     886
     887    range = max - min;
     888    for (i = 0; i < myData->n; i++) {
     889        myData->data.F64[i] = -1.0 + 2.0 *
     890                              ((myData->data.F64[i] - min) / range);
    860891    }
    861892}
  • trunk/psLib/src/dataManip/psStats.h

    r1898 r1907  
    1010 *  @author George Gusciora, MHPCC
    1111 *
    12  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-25 19:11:01 $
     12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-27 23:41:42 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    174174);
    175175
     176
     177void p_psNormalizeVector(psVector* myData);
     178void p_psNormalizeVectorF64(psVector* myData);
     179
     180
    176181/// @}
    177182
  • trunk/psLib/src/math/psConstants.h

    r1903 r1907  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-25 23:05:07 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-27 23:41:42 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848}
    4949
     50/** Preprocessor macro to generate error on a NULL image */
     51#define PS_CHECK_NULL_IMAGE(NAME)                                                           \
     52if (NAME == NULL || NAME->data.V == NULL) {                                                         \
     53    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
     54}
     55
     56/** Preprocessor macro to generate error for zero length rows or columns */
     57#define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
     58if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
     59    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
     60            NAME->numCols, NAME->numRows);                                                          \
     61}
     62
     63/** Preprocessor macro to generate error on a NULL 1DPolynomial */
     64#define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
     65if (NAME == NULL || NAME->coeff == NULL) {                                                         \
     66    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
     67}
     68
    5069#define PS_PRINT_VECTOR(NAME) \
    5170for (int my_i=0;my_i<NAME->n;my_i++) { \
  • trunk/psLib/src/math/psMinimize.c

    r1879 r1907  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-24 20:08:22 $
     11 *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-27 23:41:42 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5353/* DEFINE STATEMENTS                                                         */
    5454/*****************************************************************************/
    55 
    56 /** Preprocessor macro to generate error on a NULL 1DPolynomial */
    57 #define PS_CHECK_NULL_1DPOLY(NAME)                                                          \
    58 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
    59     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    60 }
    61 
    62 /** Preprocessor macro to generate error on a NULL vector */
    63 #define PS_CHECK_NULL_VECTOR(NAME)                                                          \
    64 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    65     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    66 }
    67 
    68 /** Preprocessor macro to generate error for zero length vector */
    69 #define PS_CHECK_EMPTY_VECTOR(NAME)                                                          \
    70 if (NAME->n < 1) {                                                                                  \
    71     psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
    72 }
    73 
    74 /** Preprocessor macro to generate error on differing size vectors */
    75 #define PS_CHECK_VECTOR_SIZE_EQUAL(VEC1, VEC2)                                                          \
    76 if (VEC1->n != VEC2->n) {               \
    77     psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
    78 }
    79 
    80 /** Preprocessor macro to generate error on a NULL image */
    81 #define PS_CHECK_NULL_IMAGE(NAME)                                                           \
    82 if (NAME == NULL || NAME->data.V == NULL) {                                                         \
    83     psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
    84 }
    85 
    86 /** Preprocessor macro to generate error for zero length rows or columns */
    87 #define PS_CHECK_EMPTY_IMAGE(NAME)                                                           \
    88 if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
    89     psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
    90             NAME->numCols, NAME->numRows);                                                          \
    91 }
    9255
    9356/*****************************************************************************/
     
    692655}
    693656
     657
     658/*****************************************************************************
     659CreateChebyshevPolys(n): this routine takes as input the required order n,
     660and returns as output as a pointer to an array of n psPolynomial1D
     661structures, corresponding to the first n Chebyshev polynomials.
     662 
     663XXX: The output should be static since the Chebyshev polynomials might be
     664used frequently and the data structure created here does not contain the
     665outer coefficients of the Chebyshev polynomials.
     666 *****************************************************************************/
     667static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
     668{
     669    psPolynomial1D **chebPolys = NULL;
     670    int i = 0;
     671    int j = 0;
     672
     673    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
     674    for (i = 0; i < maxChebyPoly; i++) {
     675        chebPolys[i] = psPolynomial1DAlloc(i + 1, PS_POLYNOMIAL_ORD);
     676    }
     677
     678    // Create the Chebyshev polynomials.
     679    // Polynomial i has i-th order.
     680    chebPolys[0]->coeff[0] = 1;
     681    chebPolys[1]->coeff[1] = 1;
     682    for (i = 2; i < maxChebyPoly; i++) {
     683        for (j = 0; j < chebPolys[i - 1]->n; j++) {
     684            chebPolys[i]->coeff[j + 1] = 2 * chebPolys[i - 1]->coeff[j];
     685        }
     686        for (j = 0; j < chebPolys[i - 2]->n; j++) {
     687            chebPolys[i]->coeff[j] -= chebPolys[i - 2]->coeff[j];
     688        }
     689    }
     690
     691    return (chebPolys);
     692}
     693
     694
     695
     696psPolynomial1D* p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly,
     697        const psVector* restrict x,
     698        const psVector* restrict y,
     699        const psVector* restrict yErr)
     700{
     701    int j;
     702    int k;
     703    int n = x->n;
     704    psPolynomial1D **chebPolys = CreateChebyshevPolys(myPoly->n);
     705    ;
     706    float fac;
     707    float sum;
     708    /*
     709        fac = 2.0/((float) n);
     710        for (j=0;j<n;j++) {
     711            sum = 0.0;
     712            for (k=0;k<n;k++) {
     713                sum+= y->data.F64[k] *
     714                      cos(M_PI * ((float) j) * (0.5 + ((float) k)) / ((float) n));
     715    //            sum+= y->data.F64[k] *
     716    //                  cos(M_PI * ((float) j) * (-0.5 + ((float) k)) / ((float) n)) *
     717    //                  cos(M_PI * (-0.5 + ((float) k)) / ((float) n));
     718     
     719            }
     720            myPoly->coeff[j] = fac * sum;
     721     
     722        }
     723        return(myPoly);
     724    */
     725
     726    fac = 2.0/((float) n);
     727    for (j=0;j<myPoly->n;j++) {
     728        sum = 0.0;
     729        for (k=1;k<n;k++) {
     730            sum+= (y->data.F64[k] *
     731                   psPolynomial1DEval((float) x->data.F64[k], chebPolys[j]));
     732        }
     733        myPoly->coeff[j] = fac * sum;
     734    }
     735    return(myPoly);
     736}
     737
    694738/******************************************************************************
    695739psVectorFitPolynomial1D():  This routine must fit a polynomial of degree
     
    704748 
    705749XXX: Must do: if yErr==NULL, set all errors equal.
     750 
     751XXX: type is currently ignored.  Must implement this for Chebyshev
     752polynomials.
    706753 *****************************************************************************/
    707754psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,
     
    710757                                        const psVector* restrict yErr)
    711758{
     759    // XXX: Create a p_psVectorFitPolynomial1DOrd() function.  Here, we
     760    // should only be calling that or the Cheby function.
     761
     762    if (myPoly->type == PS_POLYNOMIAL_CHEB) {
     763        return(p_psVectorFitPolynomial1DCheby(myPoly, x, y, yErr));
     764    }
     765
    712766    int polyOrder = myPoly->n;
    713767    psImage* A = NULL;
  • trunk/psLib/src/math/psPolynomial.c

    r1903 r1907  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-25 23:05:07 $
     9 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-27 23:41:42 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    111111/*****************************************************************************/
    112112
    113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
     113/*****************************************************************************
     114CreateChebyshevPolys(n): this routine takes as input the required order n,
     115and returns as output as a pointer to an array of n psPolynomial1D
     116structures, corresponding to the first n Chebyshev polynomials.
     117 
     118XXX: The output should be static since the Chebyshev polynomials might be
     119used frequently and the data structure created here does not contain the
     120outer coefficients of the Chebyshev polynomials.
     121 *****************************************************************************/
     122static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
    114123{
    115124    psPolynomial1D **chebPolys = NULL;
     
    430439    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    431440 
    432     XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
    433     in polynomial evaluation.  If so, then all of the following polynomial
    434     evaluation functions must be modified to do so.
    435  
    436441    XXX: Should the "coeffErr[]" should be used as well?
    437442 *****************************************************************************/
     
    502507    psFree(d);
    503508    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);
     524    */
    504525}
    505526
  • trunk/psLib/src/math/psSpline.c

    r1903 r1907  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-09-25 23:05:07 $
     9 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-27 23:41:42 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    111111/*****************************************************************************/
    112112
    113 static psPolynomial1D* *CreateChebyshevPolys(int maxChebyPoly)
     113/*****************************************************************************
     114CreateChebyshevPolys(n): this routine takes as input the required order n,
     115and returns as output as a pointer to an array of n psPolynomial1D
     116structures, corresponding to the first n Chebyshev polynomials.
     117 
     118XXX: The output should be static since the Chebyshev polynomials might be
     119used frequently and the data structure created here does not contain the
     120outer coefficients of the Chebyshev polynomials.
     121 *****************************************************************************/
     122static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
    114123{
    115124    psPolynomial1D **chebPolys = NULL;
     
    430439    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
    431440 
    432     XXX: Determine, from IfA, whether or not the "mask[]" terms should be used
    433     in polynomial evaluation.  If so, then all of the following polynomial
    434     evaluation functions must be modified to do so.
    435  
    436441    XXX: Should the "coeffErr[]" should be used as well?
    437442 *****************************************************************************/
     
    502507    psFree(d);
    503508    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);
     524    */
    504525}
    505526
  • trunk/psLib/src/math/psStats.c

    r1904 r1907  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-27 20:37:48 $
     11 *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-27 23:41:42 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    858858    for (i = 0; i < myData->n; i++) {
    859859        myData->data.F32[i] = (myData->data.F32[i] - min) / range;
     860    }
     861}
     862
     863/*****************************************************************************
     864p_psNormalizeVectorF64(myData): this is a private function which normalizes the
     865elements of a vector to a range between -1.0 and 1.0.
     866 
     867XXX: incorporate this into above
     868 
     869XXX: 0-1 or -1:1?
     870 *****************************************************************************/
     871void p_psNormalizeVectorF64(psVector* myData)
     872{
     873    float min = (float)HUGE;
     874    float max = (float)-HUGE;
     875    float range = 0.0;
     876    int i = 0;
     877
     878    for (i = 0; i < myData->n; i++) {
     879        if (myData->data.F64[i] < min) {
     880            min = myData->data.F64[i];
     881        }
     882        if (myData->data.F64[i] > max) {
     883            max = myData->data.F64[i];
     884        }
     885    }
     886
     887    range = max - min;
     888    for (i = 0; i < myData->n; i++) {
     889        myData->data.F64[i] = -1.0 + 2.0 *
     890                              ((myData->data.F64[i] - min) / range);
    860891    }
    861892}
  • trunk/psLib/src/math/psStats.h

    r1898 r1907  
    1010 *  @author George Gusciora, MHPCC
    1111 *
    12  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-25 19:11:01 $
     12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-27 23:41:42 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    174174);
    175175
     176
     177void p_psNormalizeVector(psVector* myData);
     178void p_psNormalizeVectorF64(psVector* myData);
     179
     180
    176181/// @}
    177182
  • trunk/psLib/test/dataManip/Makefile

    r1900 r1907  
    33##  Makefile:   test/sysUtils
    44##
    5 ##  $Revision: 1.45 $  $Name: not supported by cvs2svn $
    6 ##  $Date: 2004-09-25 20:17:43 $
     5##  $Revision: 1.46 $  $Name: not supported by cvs2svn $
     6##  $Date: 2004-09-27 23:41:42 $
    77##
    88##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242tst_psMatrixVectorArithmetic03 \
    4343tst_psMinimize04 \
     44tst_psMinimize04b \
    4445tst_psMinimize05 \
    4546tst_psMinimize06 \
  • trunk/psLib/test/dataManip/tst_psMinimize04.c

    r1811 r1907  
    1212#include <math.h>
    1313#define NUM_DATA 10
    14 #define POLY_ORDER 2
     14#define POLY_ORDER 5
    1515
    1616double setData(double A,
     
    4040    for (i=0;i<NUM_DATA;i++) {
    4141        x->data.F64[i] = (double) i;
    42         y->data.F64[i] = setData(2.0, 3.0, 2.0, x->data.F64[i]);
     42        y->data.F64[i] = setData(3.0, 2.0, 3.0, x->data.F64[i]);
    4343        yErr->data.F64[i] = 0.1;
    4444        printf("Original data %d: (%.1f %.1f)\n", i, x->data.F64[i], y->data.F64[i]);
Note: See TracChangeset for help on using the changeset viewer.