Changeset 1775 for trunk/psLib/src/math/psPolynomial.c
- Timestamp:
- Sep 9, 2004, 4:55:59 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomial.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r1765 r1775 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09- 09 23:39:36$9 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-10 02:52:02 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1593 1593 float width; 1594 1594 1595 if (fabs(max-min) < FLT_EPSILON) { 1596 psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n"); 1597 return(NULL); 1598 } 1599 1595 1600 tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D)); 1596 1597 1601 tmp->n = numSplines; 1598 1602 1599 1603 tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *)); 1600 1604 for (i=0;i<numSplines;i++) { 1601 (tmp->spline)[i] = psPolynomial1DAlloc(order , PS_POLYNOMIAL_ORD);1605 (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD); 1602 1606 } 1603 1607 … … 1626 1630 1627 1631 numSplines = bounds->n - 1; 1632 tmp->n = numSplines; 1628 1633 1629 1634 tmp->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *)); 1630 1635 for (i=0;i<numSplines;i++) { 1631 (tmp->spline)[i] = psPolynomial1DAlloc(order , PS_POLYNOMIAL_ORD);1636 (tmp->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD); 1632 1637 } 1633 1638 … … 1668 1673 mid = (max-min)/2; 1669 1674 1670 while (min != max) { 1675 while (min+1 < max) { 1676 psTrace(".psLib.dataManip.psFunctions.VectorBinDisect", 4, "(min, max) is (%d, %d)\n", min, max); 1671 1677 mid = (max-min)/2; 1672 1678 … … 1721 1727 1722 1728 1723 psSpline1D *psSpline1D EGen(const psSpline1D *spline,1724 psVector *data)1729 psSpline1D *psSpline1DGen(const psSpline1D *spline, 1730 psVector *data) 1725 1731 { 1726 1732 int i; … … 1734 1740 } 1735 1741 // XXX: verify your math 1736 if ( 1== (spline->spline[0])->n) {1742 if (2 == (spline->spline[0])->n) { 1737 1743 for (i=0;i<spline->n;i++) { 1738 1744 slope = (data->data.F32[i+1] - data->data.F32[i]) / … … 1742 1748 (spline->spline[0])->coeff[1] = slope; 1743 1749 } 1744 1745 psLogMsg(__func__, PS_LOG_WARN, 1746 "Linear splines have not been implemented."); 1747 return(NULL); 1748 } else if (3 == (spline->spline[0])->n) { 1750 return((psSpline1D *) spline); 1751 } else if (4 == (spline->spline[0])->n) { 1749 1752 psLogMsg(__func__, PS_LOG_WARN, 1750 1753 "Cubic splines have not been implemented."); … … 1753 1756 psLogMsg(__func__, PS_LOG_WARN, 1754 1757 "Don't know how to generate %d-order splines.", 1755 (spline->spline[0])->n );1758 (spline->spline[0])->n-1); 1756 1759 return(NULL); 1757 1760 }
Note:
See TracChangeset
for help on using the changeset viewer.
