Changeset 2218
- Timestamp:
- Oct 27, 2004, 11:25:52 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 5 edited
-
dataManip/psConstants.h (modified) (3 diffs)
-
dataManip/psFunctions.c (modified) (10 diffs)
-
math/psConstants.h (modified) (3 diffs)
-
math/psPolynomial.c (modified) (10 diffs)
-
math/psSpline.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r2217 r2218 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-27 21: 06:30$8 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 21:25:52 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 } 37 37 38 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 39 if ((NAME1 - NAME2) < -FLT_EPSILON) { \ 40 psError(__func__,"%s is less than %s.", #NAME1, #NAME2); \ 41 return(RVAL); \ 42 } 43 38 44 39 45 … … 54 60 } 55 61 62 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \ 63 if (PTR1->n != PTR2->n) { \ 64 psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \ 65 return(RVAL); \ 66 } 67 68 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \ 69 if (PTR1->type.type != PTR2->type.type) { \ 70 psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 71 return(RVAL); \ 72 } 56 73 57 74 -
trunk/psLib/src/dataManip/psFunctions.c
r2217 r2218 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-27 21: 06:30$9 * @version $Revision: 1.56 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-27 21:25:52 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1688 1688 float max) 1689 1689 { 1690 PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL); 1691 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1692 PS_FLOAT_COMPARE(max, min, NULL); 1693 1690 1694 psSpline1D *tmp = NULL; 1691 1695 psS32 i; 1692 1696 float tmpDomain; 1693 1697 float width; 1694 1695 if (fabs(max-min) < FLT_EPSILON) {1696 psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");1697 return(NULL);1698 }1699 1698 1700 1699 tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D)); … … 1753 1752 psS32 order) 1754 1753 { 1754 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1755 PS_VECTOR_CHECK_NULL(bounds, NULL); 1756 PS_VECTOR_CHECK_EMPTY(bounds, NULL); 1757 1755 1758 psSpline1D *tmp = NULL; 1756 1759 psS32 i; … … 1898 1901 psScalar *x) 1899 1902 { 1900 if (x->type.type != bins->type.type) { 1901 psError(__func__, "x->type.type != bins->type.type"); 1902 return(-2); 1903 } 1903 PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2); 1904 1904 1905 1905 if (x->type.type == PS_TYPE_S32) { … … 1927 1927 float x) 1928 1928 { 1929 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 1930 PS_PTR_CHECK_NULL(domain, NAN); 1931 PS_PTR_CHECK_NULL(range, NAN); 1932 1929 1933 psS32 i; 1930 1934 psS32 m; … … 2037 2041 psScalar *x) 2038 2042 { 2043 PS_VECTOR_CHECK_NULL(domain, NULL); 2044 PS_VECTOR_CHECK_NULL(range, NULL); 2045 PS_PTR_CHECK_NULL(x, NULL); 2046 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 2047 PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL); 2048 PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL); 2049 PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL); 2050 2039 2051 psVector *range32 = NULL; 2040 2052 psVector *domain32 = NULL; … … 2042 2054 "---- p_psVectorInterpolate() begin ----\n"); 2043 2055 2044 if ((domain->type.type != range->type.type) ||2045 (domain->type.type != x->type.type)) {2046 // XXX psError2047 printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");2048 printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);2049 exit(1);2050 }2051 if (domain->n != range->n) {2052 // XXX psError2053 printf("domain->n != range->n\n");2054 exit(1);2055 }2056 2056 if (order > (domain->n - 1)) { 2057 // XXX psError: not enough data points for order-order interpolation. 2058 printf("not enough data points for order-order interpolation.\n"); 2059 exit(1); 2057 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2058 return(NULL); 2060 2059 } 2061 2060 … … 2089 2088 } else { 2090 2089 // XXX psError: type not supported 2091 printf("XXX psError: type not supported\n"); 2092 } 2093 2094 printf("return(NULL)\n"); 2090 psError(__func__, "type %d not supported\n", x->type.type); 2091 } 2092 2093 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2094 "return(NULL)\n"); 2095 2095 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2096 2096 "---- p_psVectorInterpolate() end ----\n"); 2097 2097 2098 return(NULL); 2098 2099 } … … 2112 2113 float x) 2113 2114 { 2115 PS_PTR_CHECK_NULL(spline, NAN); 2116 PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN); 2117 2114 2118 psS32 binNum; 2115 2119 psS32 n; … … 2138 2142 const psSpline1D *spline) 2139 2143 { 2144 PS_PTR_CHECK_NULL(spline, NULL); 2145 PS_VECTOR_CHECK_NULL(x, NULL); 2146 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL); 2147 2140 2148 psS32 i; 2141 2149 psVector *tmpVector; -
trunk/psLib/src/math/psConstants.h
r2217 r2218 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-27 21: 06:30$8 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 21:25:52 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 } 37 37 38 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 39 if ((NAME1 - NAME2) < -FLT_EPSILON) { \ 40 psError(__func__,"%s is less than %s.", #NAME1, #NAME2); \ 41 return(RVAL); \ 42 } 43 38 44 39 45 … … 54 60 } 55 61 62 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \ 63 if (PTR1->n != PTR2->n) { \ 64 psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \ 65 return(RVAL); \ 66 } 67 68 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \ 69 if (PTR1->type.type != PTR2->type.type) { \ 70 psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 71 return(RVAL); \ 72 } 56 73 57 74 -
trunk/psLib/src/math/psPolynomial.c
r2217 r2218 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-27 21: 06:30$9 * @version $Revision: 1.56 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-27 21:25:52 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1688 1688 float max) 1689 1689 { 1690 PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL); 1691 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1692 PS_FLOAT_COMPARE(max, min, NULL); 1693 1690 1694 psSpline1D *tmp = NULL; 1691 1695 psS32 i; 1692 1696 float tmpDomain; 1693 1697 float width; 1694 1695 if (fabs(max-min) < FLT_EPSILON) {1696 psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");1697 return(NULL);1698 }1699 1698 1700 1699 tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D)); … … 1753 1752 psS32 order) 1754 1753 { 1754 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1755 PS_VECTOR_CHECK_NULL(bounds, NULL); 1756 PS_VECTOR_CHECK_EMPTY(bounds, NULL); 1757 1755 1758 psSpline1D *tmp = NULL; 1756 1759 psS32 i; … … 1898 1901 psScalar *x) 1899 1902 { 1900 if (x->type.type != bins->type.type) { 1901 psError(__func__, "x->type.type != bins->type.type"); 1902 return(-2); 1903 } 1903 PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2); 1904 1904 1905 1905 if (x->type.type == PS_TYPE_S32) { … … 1927 1927 float x) 1928 1928 { 1929 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 1930 PS_PTR_CHECK_NULL(domain, NAN); 1931 PS_PTR_CHECK_NULL(range, NAN); 1932 1929 1933 psS32 i; 1930 1934 psS32 m; … … 2037 2041 psScalar *x) 2038 2042 { 2043 PS_VECTOR_CHECK_NULL(domain, NULL); 2044 PS_VECTOR_CHECK_NULL(range, NULL); 2045 PS_PTR_CHECK_NULL(x, NULL); 2046 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 2047 PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL); 2048 PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL); 2049 PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL); 2050 2039 2051 psVector *range32 = NULL; 2040 2052 psVector *domain32 = NULL; … … 2042 2054 "---- p_psVectorInterpolate() begin ----\n"); 2043 2055 2044 if ((domain->type.type != range->type.type) ||2045 (domain->type.type != x->type.type)) {2046 // XXX psError2047 printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");2048 printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);2049 exit(1);2050 }2051 if (domain->n != range->n) {2052 // XXX psError2053 printf("domain->n != range->n\n");2054 exit(1);2055 }2056 2056 if (order > (domain->n - 1)) { 2057 // XXX psError: not enough data points for order-order interpolation. 2058 printf("not enough data points for order-order interpolation.\n"); 2059 exit(1); 2057 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2058 return(NULL); 2060 2059 } 2061 2060 … … 2089 2088 } else { 2090 2089 // XXX psError: type not supported 2091 printf("XXX psError: type not supported\n"); 2092 } 2093 2094 printf("return(NULL)\n"); 2090 psError(__func__, "type %d not supported\n", x->type.type); 2091 } 2092 2093 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2094 "return(NULL)\n"); 2095 2095 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2096 2096 "---- p_psVectorInterpolate() end ----\n"); 2097 2097 2098 return(NULL); 2098 2099 } … … 2112 2113 float x) 2113 2114 { 2115 PS_PTR_CHECK_NULL(spline, NAN); 2116 PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN); 2117 2114 2118 psS32 binNum; 2115 2119 psS32 n; … … 2138 2142 const psSpline1D *spline) 2139 2143 { 2144 PS_PTR_CHECK_NULL(spline, NULL); 2145 PS_VECTOR_CHECK_NULL(x, NULL); 2146 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL); 2147 2140 2148 psS32 i; 2141 2149 psVector *tmpVector; -
trunk/psLib/src/math/psSpline.c
r2217 r2218 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-27 21: 06:30$9 * @version $Revision: 1.56 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-27 21:25:52 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1688 1688 float max) 1689 1689 { 1690 PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL); 1691 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1692 PS_FLOAT_COMPARE(max, min, NULL); 1693 1690 1694 psSpline1D *tmp = NULL; 1691 1695 psS32 i; 1692 1696 float tmpDomain; 1693 1697 float width; 1694 1695 if (fabs(max-min) < FLT_EPSILON) {1696 psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");1697 return(NULL);1698 }1699 1698 1700 1699 tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D)); … … 1753 1752 psS32 order) 1754 1753 { 1754 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 1755 PS_VECTOR_CHECK_NULL(bounds, NULL); 1756 PS_VECTOR_CHECK_EMPTY(bounds, NULL); 1757 1755 1758 psSpline1D *tmp = NULL; 1756 1759 psS32 i; … … 1898 1901 psScalar *x) 1899 1902 { 1900 if (x->type.type != bins->type.type) { 1901 psError(__func__, "x->type.type != bins->type.type"); 1902 return(-2); 1903 } 1903 PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2); 1904 1904 1905 1905 if (x->type.type == PS_TYPE_S32) { … … 1927 1927 float x) 1928 1928 { 1929 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 1930 PS_PTR_CHECK_NULL(domain, NAN); 1931 PS_PTR_CHECK_NULL(range, NAN); 1932 1929 1933 psS32 i; 1930 1934 psS32 m; … … 2037 2041 psScalar *x) 2038 2042 { 2043 PS_VECTOR_CHECK_NULL(domain, NULL); 2044 PS_VECTOR_CHECK_NULL(range, NULL); 2045 PS_PTR_CHECK_NULL(x, NULL); 2046 PS_INT_CHECK_NON_NEGATIVE(order, NULL); 2047 PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL); 2048 PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL); 2049 PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL); 2050 2039 2051 psVector *range32 = NULL; 2040 2052 psVector *domain32 = NULL; … … 2042 2054 "---- p_psVectorInterpolate() begin ----\n"); 2043 2055 2044 if ((domain->type.type != range->type.type) ||2045 (domain->type.type != x->type.type)) {2046 // XXX psError2047 printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");2048 printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);2049 exit(1);2050 }2051 if (domain->n != range->n) {2052 // XXX psError2053 printf("domain->n != range->n\n");2054 exit(1);2055 }2056 2056 if (order > (domain->n - 1)) { 2057 // XXX psError: not enough data points for order-order interpolation. 2058 printf("not enough data points for order-order interpolation.\n"); 2059 exit(1); 2057 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2058 return(NULL); 2060 2059 } 2061 2060 … … 2089 2088 } else { 2090 2089 // XXX psError: type not supported 2091 printf("XXX psError: type not supported\n"); 2092 } 2093 2094 printf("return(NULL)\n"); 2090 psError(__func__, "type %d not supported\n", x->type.type); 2091 } 2092 2093 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2094 "return(NULL)\n"); 2095 2095 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2096 2096 "---- p_psVectorInterpolate() end ----\n"); 2097 2097 2098 return(NULL); 2098 2099 } … … 2112 2113 float x) 2113 2114 { 2115 PS_PTR_CHECK_NULL(spline, NAN); 2116 PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN); 2117 2114 2118 psS32 binNum; 2115 2119 psS32 n; … … 2138 2142 const psSpline1D *spline) 2139 2143 { 2144 PS_PTR_CHECK_NULL(spline, NULL); 2145 PS_VECTOR_CHECK_NULL(x, NULL); 2146 PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL); 2147 2140 2148 psS32 i; 2141 2149 psVector *tmpVector;
Note:
See TracChangeset
for help on using the changeset viewer.
