Changeset 6484 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Feb 24, 2006, 1:43:16 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r6449 r6484 16 16 * use ->min and ->max (PS_STAT_USE_RANGE) 17 17 * 18 * @version $Revision: 1.1 69$ $Name: not supported by cvs2svn $19 * @date $Date: 2006-02- 18 00:56:44$18 * @version $Revision: 1.170 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2006-02-24 23:43:15 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 569 569 // Allocate temporary vectors for the data. 570 570 unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 571 unsortedVector->n = nValues; 571 572 572 573 // Determine if we must only use data points within a min/max range. … … 657 658 psS32 numBins = histogram->nums->n; 658 659 psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); 660 smooth->n = smooth->nalloc; 659 661 psS32 jMin = 0; 660 662 psS32 jMax = 0; … … 783 785 // Allocate temporary vectors for the data. 784 786 unsortedVector = psVectorAlloc(nValues, PS_TYPE_F32); 787 unsortedVector->n = unsortedVector->nalloc; 785 788 786 789 if (stats->options & PS_STAT_USE_RANGE) { … … 1037 1040 // However, we do no want to modify the original mask vector. 1038 1041 tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8); 1042 tmpMask->n = tmpMask->nalloc; 1039 1043 1040 1044 // If we were called with a mask vector, then initialize the temporary … … 1198 1202 psVector *x = psVectorAlloc(3, PS_TYPE_F64); 1199 1203 psVector *y = psVectorAlloc(3, PS_TYPE_F64); 1204 x->n = 3; 1205 y->n = 3; 1200 1206 psF32 tmpFloat = 0.0f; 1201 1207 … … 1313 1319 if (deriv == NULL) { 1314 1320 deriv = psVectorAlloc(2, PS_TYPE_F32); 1321 deriv->n = 2; 1315 1322 } else { 1316 1323 PS_ASSERT_VECTOR_SIZE(deriv, 2, NAN); … … 1365 1372 psS32 rcBool = false; 1366 1373 psVector *tmpMaskVec = psVectorAlloc(myVector->n, PS_TYPE_U8); 1374 tmpMaskVec->n = tmpMaskVec->nalloc; 1367 1375 if (maskVector != NULL) { 1368 1376 for (psS32 i = 0 ; i < myVector->n ; i++) { … … 1850 1858 psArray *x = psArrayAlloc((1 + (binMax - binMin))); 1851 1859 psS32 j = 0; 1860 y->n = y->nalloc; 1852 1861 1853 1862 for (psS32 i = binMin ; i <= binMax ; i++) { … … 1856 1865 x->n++; 1857 1866 ((psVector *) x->data[j])->data.F32[0] = PS_BIN_MIDPOINT(newHistogram, i); 1867 ((psVector *) x->data[j])->n++; 1858 1868 j++; 1859 1869 } … … 1886 1896 psMinimization *min = psMinimizationAlloc(100, 0.01); 1887 1897 psVector *params = psVectorAlloc(2, PS_TYPE_F32); 1898 params->n = params->nalloc; 1888 1899 // Initial guess for the mean ([0]) and standard dev. 1889 1900 params->data.F32[0] = stats->robustMedian; … … 2049 2060 // Allocate the bins, and initialize them to zero. 2050 2061 newHist->nums = psVectorAlloc(n, PS_TYPE_F32); 2051 for (i = 0; i < newHist->nums->n ; i++) {2062 for (i = 0; i < newHist->nums->nalloc; i++) { 2052 2063 newHist->nums->data.F32[i] = 0.0; 2064 newHist->nums->n++; 2053 2065 } 2054 2066 … … 2094 2106 // then there are N-1 bins. 2095 2107 newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32); 2096 for (i = 0; i < newHist->nums->n ; i++) {2108 for (i = 0; i < newHist->nums->nalloc; i++) { 2097 2109 newHist->nums->data.F32[i] = 0.0; 2110 newHist->nums->n++; 2098 2111 } 2099 2112 … … 2366 2379 for (i = 0; i < in->n; i++) { 2367 2380 tmp->data.F32[i] = (psF32)in->data.S8[i]; 2381 tmp->n++; 2368 2382 } 2369 2383 } else if (in->type.type == PS_TYPE_S16) { … … 2371 2385 for (i = 0; i < in->n; i++) { 2372 2386 tmp->data.F32[i] = (psF32) in->data.S16[i]; 2387 tmp->n++; 2373 2388 } 2374 2389 } else if (in->type.type == PS_TYPE_S32) { … … 2376 2391 for (i = 0; i < in->n; i++) { 2377 2392 tmp->data.F32[i] = (psF32)in->data.S32[i]; 2393 tmp->n++; 2378 2394 } 2379 2395 } else if (in->type.type == PS_TYPE_S64) { … … 2381 2397 for (i = 0; i < in->n; i++) { 2382 2398 tmp->data.F32[i] = (psF32)in->data.S64[i]; 2399 tmp->n++; 2383 2400 } 2384 2401 } else if (in->type.type == PS_TYPE_U8) { … … 2386 2403 for (i = 0; i < in->n; i++) { 2387 2404 tmp->data.F32[i] = (psF32)in->data.U8[i]; 2405 tmp->n++; 2388 2406 } 2389 2407 } else if (in->type.type == PS_TYPE_U16) { … … 2391 2409 for (i = 0; i < in->n; i++) { 2392 2410 tmp->data.F32[i] = (psF32)in->data.U16[i]; 2411 tmp->n++; 2393 2412 } 2394 2413 } else if (in->type.type == PS_TYPE_U32) { … … 2396 2415 for (i = 0; i < in->n; i++) { 2397 2416 tmp->data.F32[i] = (psF32)in->data.U32[i]; 2417 tmp->n++; 2398 2418 } 2399 2419 } else if (in->type.type == PS_TYPE_U64) { … … 2401 2421 for (i = 0; i < in->n; i++) { 2402 2422 tmp->data.F32[i] = (psF32)in->data.U64[i]; 2423 tmp->n++; 2403 2424 } 2404 2425 } else if (in->type.type == PS_TYPE_F64) { … … 2406 2427 for (i = 0; i < in->n; i++) { 2407 2428 tmp->data.F32[i] = (psF32)in->data.F64[i]; 2429 tmp->n++; 2408 2430 } 2409 2431 } else if (in->type.type == PS_TYPE_F32) { … … 2463 2485 inF32 = p_psConvertToF32((psVector *) in); 2464 2486 if (inF32 == NULL) { 2465 inF32 = (psVector *) in; 2466 mustFreeVectorIn = 0; 2467 } 2487 // printf("\n\ninF32 is NULL\n\n"); 2488 // inF32 = (psVector *) in; 2489 // mustFreeVectorIn = 0; 2490 inF32 = psVectorCopy(inF32, in, PS_TYPE_F32); 2491 inF32->n = inF32->nalloc; 2492 mustFreeVectorIn = 1; 2493 } 2494 // else printf("\ninF32 has n=%ld, nalloc=%ld\n", inF32->n, inF32->nalloc); 2468 2495 errorsF32 = p_psConvertToF32((psVector *) errors); 2469 2496 if (errorsF32 == NULL) { … … 2471 2498 mustFreeVectorErrors = 0; 2472 2499 } 2473 2500 // inF32->n = inF32->nalloc; 2501 // errorsF32->n = errorsF32->nalloc; 2474 2502 if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) { 2475 2503 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, stats->min, stats);
Note:
See TracChangeset
for help on using the changeset viewer.
