Changeset 37404 for trunk/psLib/src/math/psMinimizePolyFit.c
- Timestamp:
- Sep 19, 2014, 4:33:54 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimizePolyFit.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimizePolyFit.c
r36296 r37404 700 700 701 701 // Define values that may be used by PS_POLYNOMIAL_ORD form. 702 // these scaling values put the dynamic range of the data into some vaguely sensible location 702 703 bool scale = false; 703 704 double median = 0.0; 704 705 double sigma = 1.0; 705 psVector *sorted = NULL; 706 psVector *z64 = NULL; 707 706 708 707 switch (poly->type) { 709 708 case PS_POLYNOMIAL_ORD: 710 709 if ((f64->n < 10000)&&(poly->nX > 1)) { 711 710 scale = true; 712 sorted = psVectorSort(NULL,x64); 711 712 // generate a subset of the unmasked values: 713 psVector *tmp = psVectorAllocEmpty (x64->n, PS_TYPE_F64); 714 for (int itmp = 0; itmp < x64->n; itmp++) { 715 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[itmp] && maskValue)) continue; 716 psVectorAppend (tmp, x64->data.F64[itmp]); 717 } 718 psVector *sorted = psVectorSort(NULL,tmp); 713 719 median = sorted->data.F64[sorted->n / 2]; 714 720 // CZW: I'm not bothering to scale this because it doesn't really matter. 715 721 sigma = (sorted->data.F64[3 * sorted->n / 4] - sorted->data.F64[sorted->n / 4]); 716 722 psFree(sorted); 723 psFree(tmp); 717 724 718 725 if ((!isfinite(median))|| … … 725 732 } 726 733 // I can't see a way to not clobber x if it's already F64, so make a copy.x 727 z64 = psVectorCopy(NULL,x64,PS_TYPE_F64);734 psVector *z64 = psVectorCopy(NULL,x64,PS_TYPE_F64); 728 735 psBinaryOp(z64,z64,"-",psScalarAlloc(median,PS_TYPE_F64)); 729 736 psBinaryOp(z64,z64,"/",psScalarAlloc(sigma,PS_TYPE_F64));
Note:
See TracChangeset
for help on using the changeset viewer.
