Changeset 9730 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Oct 24, 2006, 12:55:05 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r9540 r9730 16 16 * use ->min and ->max (PS_STAT_USE_RANGE) 17 17 * 18 * @version $Revision: 1.18 7$ $Name: not supported by cvs2svn $19 * @date $Date: 2006-10- 13 22:04:58$18 * @version $Revision: 1.188 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2006-10-24 22:52:56 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 388 388 389 389 // Allocate temporary vectors for the data. 390 psVector* vector = psVectorAlloc (myVector->n, PS_TYPE_F32); // Vector containing the unmasked values390 psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values 391 391 long count = 0; // Number of valid entries 392 392 … … 486 486 long numBins = histogram->nums->n; // Number of histogram bins 487 487 psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins 488 smooth->n = smooth->nalloc;489 488 const psVector *bounds = histogram->bounds; // The bounds for the histogram bins 490 489 … … 723 722 // We copy the mask vector, to preserve the original 724 723 psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8); 725 tmpMask->n = tmpMask->nalloc;726 724 psVectorInit(tmpMask, 0); 727 725 if (maskVector) { … … 901 899 psVector *x = psVectorAlloc(3, PS_TYPE_F64); 902 900 psVector *y = psVectorAlloc(3, PS_TYPE_F64); 903 x->n = 3;904 y->n = 3;905 901 psF32 tmpFloat = 0.0f; 906 902 … … 1066 1062 1067 1063 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use 1068 mask->n = myVector->n;1069 1064 psVectorInit(mask, 0); 1070 1065 if (maskVector) { … … 1487 1482 psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates 1488 1483 psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates 1489 y->n = y->nalloc;1490 x->n = x->nalloc;1491 1484 for (long i = binMin, j = 0; i <= binMax ; i++, j++) { 1492 1485 y->data.F32[j] = smoothed->data.F32[i]; 1493 1486 psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value 1494 ordinate->n = 1;1495 1487 ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i); 1496 1488 x->data[j] = ordinate; … … 1521 1513 psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information 1522 1514 psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian 1523 params->n = params->nalloc;1524 1515 // Initial guess for the mean (index 0) and standard dev (index 1). 1525 1516 params->data.F32[0] = stats->robustMedian; … … 1654 1645 psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32); 1655 1646 newHist->bounds = newBounds; 1656 newBounds->n = newHist->bounds->nalloc;1657 1647 1658 1648 // Calculate the bounds for each bin. … … 1666 1656 // Allocate the bins, and initialize them to zero. 1667 1657 newHist->nums = psVectorAlloc(n, PS_TYPE_F32); 1668 for (long i = 0; i < newHist->nums->nalloc; i++) { 1669 newHist->nums->data.F32[i] = 0.0; 1670 newHist->nums->n++; 1671 } 1658 psVectorInit(newHist->nums, 0.0); 1672 1659 1673 1660 // Initialize the other members. … … 1699 1686 psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure 1700 1687 psMemSetDeallocator(newHist, (psFreeFunc) histogramFree); 1701 psVector* newBounds = psVector Alloc(bounds->n, PS_TYPE_F32);1688 psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32); 1702 1689 newHist->bounds = newBounds; 1703 newBounds->n = newHist->bounds->nalloc;1704 for (long i = 0; i < bounds->n; i++) {1705 newBounds->data.F32[i] = bounds->data.F32[i];1706 }1707 1690 1708 1691 // Allocate the bins, and initialize them to zero. If there are N bounds, 1709 1692 // then there are N-1 bins. 1710 1693 newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32); 1711 for (long i = 0; i < newHist->nums->nalloc; i++) { 1712 newHist->nums->data.F32[i] = 0.0; 1713 newHist->nums->n++; 1714 } 1694 psVectorInit(newHist->nums, 0.0); 1715 1695 1716 1696 // Initialize the other members.
Note:
See TracChangeset
for help on using the changeset viewer.
