IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5517


Ignore:
Timestamp:
Nov 15, 2005, 10:10:32 AM (21 years ago)
Author:
gusciora
Message:

Bug fix for psSpline, some new psConstant macros, ....

Location:
trunk/psLib/src
Files:
6 edited

Legend:

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

    r5294 r5517  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-12 21:02:20 $
     8 *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-11-15 20:10:32 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    222222the wrong type.
    223223*****************************************************************************/
     224#define PS_WARN_PTR_NON_NULL(NAME) \
     225if ((NAME) == NULL) { \
     226    psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \
     227} \
     228
    224229#define PS_ASSERT_PTR_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, return RVAL)
    225230#define PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, CLEANUP) \
     
    501506    PS_POLY macros:
    502507*****************************************************************************/
     508#define PS_ASSERT_POLY1D(NAME, RVAL) \
     509if (false == psMemCheckPolynomial1D(NAME)) { \
     510    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     511            "Unallowable operation: argument %s is not a psPolynomial1D struct.\n",\
     512            #NAME); \
     513    return(RVAL); \
     514} \
     515
    503516#define PS_ASSERT_POLY_NON_NULL(NAME, RVAL) \
    504517if ((NAME) == NULL || (NAME)->coeff == NULL) { \
     
    582595    printf("%s->coeff[%d] is %f\n", #NAME, i, NAME->coeff[i]); \
    583596}\
     597
     598/*****************************************************************************
     599    PS_SPLINE macros:
     600*****************************************************************************/
     601#define PS_ASSERT_SPLINE(NAME, RVAL) \
     602if (false == psMemCheckSpline1D(NAME)) { \
     603    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     604            "Unallowable operation: argument %s is not a psSpline1D struct.\n",\
     605            #NAME); \
     606    return(RVAL); \
     607} \
     608
     609#define PS_ASSERT_SPLINE_NON_NULL(NAME, RVAL) \
     610if ((NAME) == NULL) { \
     611    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     612            "Unallowable operation: psSpline1D %s is NULL.", \
     613            #NAME); \
     614    return(RVAL); \
     615} \
    584616
    585617/*****************************************************************************
     
    755787((A) * (A))
    756788
     789#define PRINT_MEMLEAKS(NUM) \
     790printf("A: ---------------------------------------- (ID: %d)\n", NUM); \
     791memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); \
     792printf("B: ---------------------------------------- (%d)\n", memLeaks); \
     793
    757794# define PS_SWAP(X,Y) {double tmp=(X); (X) = (Y); (Y) = tmp;}
  • trunk/psLib/src/math/psSpline.c

    r5180 r5517  
    77*  splines.
    88*
    9 *  @version $Revision: 1.131 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-09-29 20:06:58 $
     9*  @version $Revision: 1.132 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-11-15 20:10:32 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    496496    PS_ASSERT_VECTOR_NON_NULL(y, NULL);
    497497    PS_ASSERT_VECTOR_TYPE_F32_OR_F64(y, NULL);
     498    PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(y->n, 2, NULL);
    498499    psS32 numSplines = (y->n)-1;
    499500    psTrace(__func__, 5, "numSplines is %d\n", numSplines);
     501
     502    //
     503    // Create the psSpline1D struct.
     504    //
     505    psSpline1D *spline = psSpline1DAlloc();
     506    spline->n = numSplines;
     507    spline->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
     508    for (psS32 i=0;i<numSplines;i++) {
     509        spline->spline[i] = psPolynomial1DAlloc(3, PS_POLYNOMIAL_ORD);
     510    }
     511
    500512    //
    501513    // The following code ensures that xPtr and yPtr points to a psF32 psVector.
    502514    //
    503     psVector *xPtr = NULL;
     515    // XXX: When you debug, use the vector copy and create routines here:
     516    //
     517
     518    spline->knots = psVectorAlloc(y->n, PS_TYPE_F32);
    504519    if (x != NULL) {
    505520        PS_ASSERT_VECTOR_NON_NULL(x, NULL);
     521        PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL);
    506522        PS_ASSERT_VECTOR_TYPE_F32_OR_F64(x, NULL);
    507         PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL);
    508         // Convert x to F32 if necessary.
    509         if (PS_TYPE_F64 == x->type.type) {
    510             xPtr = psVectorCopy(NULL, x, PS_TYPE_F32);
    511         } else if (PS_TYPE_F32 == x->type.type) {
    512             xPtr = (psVector *) x;
     523        if (x->type.type == PS_TYPE_F32) {
     524            for (psS32 i = 0 ; i < x->n ; i++) {
     525                spline->knots->data.F32[i] = x->data.F32[i];
     526            }
     527        } else if (x->type.type == PS_TYPE_F64) {
     528            for (psS32 i = 0 ; i < x->n ; i++) {
     529                spline->knots->data.F32[i] = (psF32) x->data.F64[i];
     530            }
    513531        }
    514532    } else {
    515         // Allocate an index vector for x
    516         xPtr = psVectorCreate(NULL, 0.0, (psF64) y->n, 1.0, PS_TYPE_F32);
    517     }
     533        for (psS32 i = 0 ; i < y->n ; i++) {
     534            spline->knots->data.F32[i] = (psF32) i;
     535        }
     536    }
     537    psVector *xPtr = spline->knots;
    518538
    519539    psVector *yPtr = NULL;
     
    526546
    527547    //
    528     // Create the psSpline1D struct.
    529     //
    530     psSpline1D *spline = psSpline1DAlloc();
    531     spline->n = numSplines;
    532     spline->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
    533     for (psS32 i=0;i<numSplines;i++) {
    534         spline->spline[i] = psPolynomial1DAlloc(3, PS_POLYNOMIAL_ORD);
    535     }
    536     spline->knots = psVectorCopy(NULL, xPtr, PS_TYPE_F32);
    537     //
    538548    // Generate the second derivatives at each data point.
    539549    //
     
    548558        psF32 H = xPtr->data.F32[i+1] - xPtr->data.F32[i];
    549559        if (fabs(H) <= FLT_EPSILON) {
    550             psError(PS_ERR_UNKNOWN, false, "x data points are not distinct (%d %d).\n", i, i+1);
     560            psError(PS_ERR_UNKNOWN, false, "x data points are not distinct (%d %d) (%f %f).\n",
     561                    i, i+1, xPtr->data.F32[i], xPtr->data.F32[i+1]);
    551562        }
    552563        psTrace(__func__, 6, "x data (%f - %f) (%f)\n", xPtr->data.F32[i], xPtr->data.F32[i+1], H);
     
    609620    }
    610621
    611     if ((x == NULL) || (PS_TYPE_F64 == x->type.type)) {
    612         psFree(xPtr);
    613     }
    614622    if (PS_TYPE_F64 == y->type.type) {
    615623        psFree(yPtr);
     
    618626    return(spline);
    619627}
     628
     629void PS_POLY1D_PRINT(
     630    psPolynomial1D *poly)
     631{
     632    printf("-------------- PS_POLY1D_PRINT() --------------\n");
     633    printf("poly->nX is %d\n", poly->nX);
     634    for (psS32 i = 0 ; i < (1 + poly->nX) ; i++) {
     635        printf("poly->coeff[%d] is %f\n", i, poly->coeff[i]);
     636    }
     637}
     638
     639void PS_PRINT_SPLINE2(psSpline1D *mySpline)
     640{
     641    printf("-------------- PS_PRINT_SPLINE2() --------------\n");
     642    printf("mySpline->n is %d\n", mySpline->n);
     643    for (psS32 i = 0 ; i < mySpline->n ; i++) {
     644        PS_POLY1D_PRINT(mySpline->spline[i]);
     645    }
     646    PS_VECTOR_PRINT_F32(mySpline->knots);
     647}
     648
     649
     650
     651
     652
     653
     654
     655
     656
     657
     658
     659
     660
     661
     662
     663
     664
     665
     666
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
     682
    620683
    621684
     
    650713        //
    651714        psLogMsg(__func__, PS_LOG_WARN,
    652                  "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f).",
    653                  x, spline->knots->data.F32[0],
    654                  spline->knots->data.F32[n-1]);
     715                 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f) (%d).",
     716                 x, spline->knots->data.F32[0], spline->knots->data.F32[n-1], n);
    655717
    656718        if (x < spline->knots->data.F32[0]) {
  • trunk/psLib/src/math/psSpline.h

    r5155 r5517  
    66 *  and evaluate splines.
    77 *
     8 *  XXX: What is the purpose of the SplineAlloc() function?
     9 *
    810 *  @ingroup GROUP00
    911 *
    1012 *  @author GLG, MHPCC
    1113 *
    12  *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-09-27 23:16:59 $
     14 *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-11-15 20:10:32 $
    1416 *
    1517 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/math/psStats.c

    r5116 r5517  
    11/** @file  psStats.c
    22 *  \brief basic statistical operations
    3  *  @ingroup Stats
     3 *  @ingroup Stat
    44 *
    55 *  This file will hold the definition of the histogram and stats data
     
    1717*
    1818*
    19 *  @version $Revision: 1.149 $ $Name: not supported by cvs2svn $
    20 *  @date $Date: 2005-09-24 00:46:45 $
     19*  @version $Revision: 1.150 $ $Name: not supported by cvs2svn $
     20*  @date $Date: 2005-11-15 20:10:32 $
    2121*
    2222*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    16761676    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); \
    16771677    printf("B: ---------------------------------------- (%d)\n", memLeaks); \
    1678 */
    16791678#define PRINT_MEMLEAKS(NUM) \
    16801679memLeaks = currentId;
     1680*/
    16811681
    16821682
  • trunk/psLib/src/sys/psAbort.c

    r4307 r5517  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-17 23:39:51 $
     12 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-11-15 20:10:32 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424{
    2525    va_list argPtr;             // variable list arguement pointer
    26 
    2726    // Get the variable list parameters to pass to logging function
    2827    va_start(argPtr, format);
  • trunk/psLib/src/types/psMetadata.c

    r5454 r5517  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.88 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-10-29 00:05:53 $
     14 *  @version $Revision: 1.89 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-11-15 20:10:32 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    966966        logLevel = 5;
    967967    }
    968     psLogSetLevel (logLevel);  // XXX: This function should return an error if the log level is invalid
     968    psLogSetLevel(logLevel);  // XXX: This function should return an error if the log level is invalid
    969969
    970970    if ( (argnum = psArgumentGet(*argc, argv, "-logfmt")) ) {
Note: See TracChangeset for help on using the changeset viewer.