IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 17, 2006, 5:09:15 PM (20 years ago)
Author:
Paul Price
Message:

Increasing number of data values. Increasing background value (makes
it a bit easier to pass, since the DC value drowns out small
differences between the actual and expected). Masking out unnecessary
polynomial terms, since it's really hard to get a good fit leaving
everything open.

File:
1 edited

Legend:

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

    r7118 r7137  
    1111#include "pslib.h"
    1212#include "psTest.h"
    13 #define NUM_DATA 30
    14 #define POLY_ORDER_X 2
    15 #define POLY_ORDER_Y 2
    16 #define POLY_ORDER_Z 2
    17 #define POLY_ORDER_T 2
    18 #define A 1.0
     13#define NUM_DATA 200
     14#define POLY_ORDER_X 1
     15#define POLY_ORDER_Y 1
     16#define POLY_ORDER_Z 1
     17#define POLY_ORDER_T 1
     18#define A 100.0
    1919#define B 2.0
    2020#define C 3.0
    2121#define D 4.0
    2222#define E 5.0
    23 #define F 4.0
     23#define F 6.0
    2424#define H 3.0
    2525#define J 3.0
     
    3131#define P 1.0
    3232#define Q 5.0
    33 #define ERROR_TOLERANCE 0.10
    34 #define YERR 10.0
    35 #define VERBOSE 1
     33#define ERROR_TOLERANCE 0.05
     34#define YERR 0.1
     35#define VERBOSE 0
    3636#define NUM_ITERATIONS 5
    37 #define CLIP_SIGMA 4.0
     37#define CLIP_SIGMA 3.0
    3838#define OUTLIERS true
    3939#define MASK_VALUE 1
     
    7676        return(A + (B * x) + (C * y) + (D * z) + (E * t));
    7777    } else {
     78        #if 0
    7879        return(A + (B * x) + (C * y) + (D * z) + (E * t) +
    7980               (F * x * x) + (H * y * y) + (J * z * z) + (K * t * t) +
    8081               (L * x * y) + (M * x * z) + (N * x * t) + (O * y * z) + (P * y * t) + (Q * z * t));
     82        #else
     83
     84        return A + (B * x) + (C * y) + (D * z) + (E * t) + (F * x * y);
     85        #endif
     86
    8187    }
    8288}
     
    143149        myPoly = psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, polyOrderX, polyOrderY,
    144150                                     polyOrderZ, polyOrderT);
     151
     152        #if 1
     153
     154        for (int ix = 0; ix < polyOrderX + 1; ix++) {
     155            for (int iy = 0; iy < polyOrderY + 1; iy++) {
     156                for (int iz = 0; iz < polyOrderZ + 1; iz++) {
     157                    for (int it = 0; it < polyOrderT + 1; it++) {
     158                        myPoly->mask[ix][iy][iz][it] = 0xff; // Mask it out
     159                    }
     160                }
     161            }
     162        }
     163
     164        // Put these back in
     165        myPoly->mask[0][0][0][0] = 0;   // A
     166        myPoly->mask[1][0][0][0] = 0;   // B * x
     167        myPoly->mask[0][1][0][0] = 0;   // C * y
     168        myPoly->mask[0][0][1][0] = 0;   // D * z
     169        myPoly->mask[0][0][0][1] = 0;   // E * t
     170        myPoly->mask[1][1][0][0] = 0;   // F * xy
     171        #endif
     172
    145173    }
    146174
     
    232260        // Set a few outliers in the data.
    233261        if (OUTLIERS && (flags & TS00_CLIP_FIT)) {
    234             f->data.F32[numData/4]*= 2.0;
    235             f->data.F32[numData/2]*= 2.0;
    236             f->data.F32[3*numData/4]*= 2.0;
     262            f->data.F32[numData/4] *= 2.0;
     263            f->data.F32[numData/2] *= 2.0;
     264            f->data.F32[3*numData/4] *= 2.0;
    237265        }
    238266    }
     
    243271        // Set a few outliers in the data.
    244272        if (OUTLIERS && (flags & TS00_CLIP_FIT)) {
    245             f->data.S32[numData/4]*= 2.0;
    246             f->data.S32[numData/2]*= 2.0;
    247             f->data.S32[3*numData/4]*= 2.0;
     273            f->data.S32[numData/4] *= 2.0;
     274            f->data.S32[numData/2] *= 2.0;
     275            f->data.S32[3*numData/4] *= 2.0;
    248276        }
    249277    }
     
    254282        // Set a few outliers in the data.
    255283        if (OUTLIERS && (flags & TS00_CLIP_FIT)) {
    256             f->data.F64[numData/4]*= 2.0;
    257             f->data.F64[numData/2]*= 2.0;
    258             f->data.F64[3*numData/4]*= 2.0;
     284            f->data.F64[numData/4] *= 2.0;
     285            f->data.F64[numData/2] *= 2.0;
     286            f->data.F64[3*numData/4] *= 2.0;
    259287        }
    260288    }
     
    354382
    355383            if (fabs(actualData-expectData) > fabs(ERROR_TOLERANCE * expectData)) {
    356                 printf("TEST ERROR: Fitted data %d: (%.1f), expected was (%.1f)\n",
     384                printf("TEST ERROR: Fitted data %d: (%f), expected was (%f)\n",
    357385                       i, actualData, expectData);
    358386                testStatus = false;
Note: See TracChangeset for help on using the changeset viewer.