IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1800


Ignore:
Timestamp:
Sep 13, 2004, 12:19:51 PM (22 years ago)
Author:
gusciora
Message:

Ensure that coords are passed correctly to the user function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMinimize05.c

    r1799 r1800  
    66#include "psTest.h"
    77#include <math.h>
    8 #define N 2
     8#define N 5
    99#define MIN_VALUE 20.0
    1010#define NUM_PARAMS 10
    1111float expectedParm[NUM_PARAMS];
     12int testStatus = true;
    1213
    1314/*****************************************************************************
     
    1617adds MIN_VALUE to it.  The minimum for this function will be MIN_VALUE, and
    1718will occur when each parameter equals the associated value in expectedParm[].
     19 
     20This procedure ignores the coordinates, other than to ensure that they were
     21passed correctly from psMinimizePowell().
    1822 *****************************************************************************/
    1923float myFunc(psVector *myParams,
     
    2125{
    2226    float sum = 0.0;
     27    float coordData = 0.0;
     28    float expData = 0.0;
    2329    int i;
     30
     31    for (i=0;i<N;i++) {
     32        coordData = ((psVector *) (myCoords->data[i]))->data.F32[0];
     33        expData = (float) (i+10);
     34        if (fabs(coordData - expData) > FLT_EPSILON) {
     35            printf("ERROR(1): coordinate data was incorrectly passed to myFunc()\n");
     36            printf("ERROR(1): was (%f) should be (%f)\n", coordData, expData);
     37            testStatus = false;
     38        }
     39        coordData = ((psVector *) (myCoords->data[i]))->data.F32[1];
     40        expData = (float) (i+3);
     41        if (fabs(coordData - expData) > FLT_EPSILON) {
     42            printf("ERROR(2): coordinate data was incorrectly passed to myFunc()\n");
     43            printf("ERROR(2): was (%f) should be (%f)\n", coordData, expData);
     44            testStatus = false;
     45        }
     46    }
     47
    2448
    2549    sum = 0.0;
     
    3660{
    3761    int currentId = psMemGetId();
    38     int testStatus = true;
    3962    int memLeaks = 0;
    4063    int i = 0;
     
    5477    for (i=0;i<N;i++) {
    5578        myCoords->data[i] = (psPTR *) psVectorAlloc(2, PS_TYPE_F32);
    56         ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) i;
    57         ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) i;
     79        ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10);
     80        ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) (i+3);
    5881    }
    5982    for (i=0;i<NUM_PARAMS;i++) {
Note: See TracChangeset for help on using the changeset viewer.