Changeset 2215
- Timestamp:
- Oct 27, 2004, 10:29:12 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
dataManip/psConstants.h (modified) (12 diffs)
-
dataManip/psMinimize.c (modified) (5 diffs)
-
math/psConstants.h (modified) (12 diffs)
-
math/psMinimize.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r2214 r2215 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-27 20:2 0:11$8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 20:29:12 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 *****************************************************************************/ 25 25 26 27 28 /***************************************************************************** 29 30 *****************************************************************************/ 31 #define CONVERT_VECTOR_F64_TO_F32(OLD, NEW_PTR32, NEW_STATIC32) \ 26 #define PS_ONE 1.0 27 /***************************************************************************** 28 Macros which take a generic psLib type and determine if it is NULL, or has 29 the wrong type. 30 *****************************************************************************/ 31 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 32 if (NAME == NULL) { \ 33 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 34 return(RVAL); \ 35 } 36 37 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 38 if (NAME->type.type != TYPE) { \ 39 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 40 return(RVAL); \ 41 } 42 43 /***************************************************************************** 44 PS_VECTOR macros: 45 *****************************************************************************/ 46 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \ 47 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \ 48 psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \ 49 return(RVAL); \ 50 } \ 51 52 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 53 if (NAME->type.type != TYPE) { \ 54 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 55 return(RVAL); \ 56 } 57 58 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 59 if (NAME == NULL || NAME->data.V == NULL) { \ 60 psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \ 61 return(RVAL); \ 62 } \ 63 64 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 65 if (NAME->n < 1) { \ 66 psError(__func__,"Unallowable operation: %s has zero n value.", #NAME); \ 67 return(RVAL); \ 68 } \ 69 70 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 71 if (VEC1->n != VEC2->n) { \ 72 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 73 return(RVAL); \ 74 } 75 76 #define PS_VECTOR_F64_TO_F32(X64, X32) \ 77 psVector *X32 = psVectorAlloc(X64->n, PS_TYPE_F32); \ 78 for (int i=0;i<X64->n;i++) { \ 79 X32->data.F32[i] = (float) X64->data.F64[i]; \ 80 } \ 81 82 #define PS_VECTOR_F32_TO_F64(X32, X64) \ 83 psVector *X64 = psVectorAlloc(X32->n, PS_TYPE_F64); \ 84 for (int i=0;i<X32->n;i++) { \ 85 X64->data.F64[i] = (float) X32->data.F32[i]; \ 86 } \ 87 88 #define PS_VECTOR_PRINT(NAME) \ 89 for (int my_i=0;my_i<NAME->n;my_i++) { \ 90 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, NAME->data.F32[my_i]); \ 91 } \ 92 printf("\n"); \ 93 94 95 #define PS_VECTOR_CONVERT_F64_TO_F32_STATIC(OLD, NEW_PTR32, NEW_STATIC32) \ 32 96 if (OLD->type.type == PS_TYPE_F32) { \ 33 97 NEW_PTR32 = (psVector *) OLD; \ … … 42 106 } \ 43 107 44 #define CONVERT_VECTOR_F32_TO_F64(OLD, NEW_PTR64, NEW_STATIC64) \108 #define PS_VECTOR_CONVERT_F32_TO_F64_STATIC(OLD, NEW_PTR64, NEW_STATIC64) \ 45 109 if (OLD->type.type == PS_TYPE_F64) { \ 46 110 NEW_PTR64 = (psVector *) OLD; \ … … 55 119 } \ 56 120 57 #define GEN_PERSIST_YERR_VEC_F32(VEC, N) \121 #define PS_VECTOR_GEN_YERR_STATIC_F32(VEC, N) \ 58 122 VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \ 59 123 p_psMemSetPersistent(VEC, true); \ … … 63 127 } \ 64 128 65 #define GEN_PERSIST_YERR_VEC_F64(VEC, N) \129 #define PS_VECTOR_GEN_YERR_STATIC_F64(VEC, N) \ 66 130 VEC = psVectorRecycle(VEC, N, PS_TYPE_F64); \ 67 131 p_psMemSetPersistent(VEC, true); \ … … 71 135 } \ 72 136 73 #define GEN_PERSIST_X_INDEX_VEC_F32(VEC, N) \137 #define PS_VECTOR_GEN_X_INDEX_STATIC_F32(VEC, N) \ 74 138 VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \ 75 139 p_psMemSetPersistent(VEC, true); \ … … 79 143 } \ 80 144 81 #define GEN_PERSIST_X_INDEX_VEC_F64(VEC, N) \145 #define PS_VECTOR_GEN_X_INDEX_STATIC_F64(VEC, N) \ 82 146 VEC = psVectorRecycle(VEC, N, PS_TYPE_F64); \ 83 147 p_psMemSetPersistent(VEC, true); \ … … 87 151 } \ 88 152 89 #define GEN_STATIC_RECYCLED_VECTOR(NAME, SIZE, TYPE) \153 #define PS_VECTOR_GEN_STATIC_RECYCLED(NAME, SIZE, TYPE) \ 90 154 static psVector *NAME = NULL; \ 91 155 NAME = psVectorRecycle(NAME, SIZE, TYPE); \ … … 95 159 96 160 /***************************************************************************** 97 Macros which take a generic psLib type and determine if it is NULL, or has 98 the wrong type. 99 *****************************************************************************/ 100 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 101 if (NAME == NULL) { \ 102 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 103 return(RVAL); \ 104 } 105 106 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 107 if (NAME->type.type != TYPE) { \ 108 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 109 return(RVAL); \ 110 } 111 112 113 /***************************************************************************** 114 Macros which take a psVector type and determine if it is NULL, or has the 115 wrong type. 116 *****************************************************************************/ 117 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \ 118 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \ 119 psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \ 120 return(RVAL); \ 121 } \ 122 123 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 124 if (NAME->type.type != TYPE) { \ 125 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 126 return(RVAL); \ 127 } 128 129 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 130 if (NAME == NULL || NAME->data.V == NULL) { \ 131 psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \ 132 return(RVAL); \ 133 } \ 134 135 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 136 if (NAME->n < 1) { \ 137 psError(__func__,"Unallowable operation: %s has zero n value.", #NAME); \ 138 return(RVAL); \ 139 } \ 140 141 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 142 if (VEC1->n != VEC2->n) { \ 143 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 144 return(RVAL); \ 145 } 146 147 #define PS_VECTOR_F64_TO_F32(X64, X32) \ 148 psVector *X32 = psVectorAlloc(X64->n, PS_TYPE_F32); \ 149 for (int i=0;i<X64->n;i++) { \ 150 X32->data.F32[i] = (float) X64->data.F64[i]; \ 151 } \ 152 153 #define PS_VECTOR_F32_TO_F64(X32, X64) \ 154 psVector *X64 = psVectorAlloc(X32->n, PS_TYPE_F64); \ 155 for (int i=0;i<X32->n;i++) { \ 156 X64->data.F64[i] = (float) X32->data.F32[i]; \ 157 } \ 158 159 #define PS_VECTOR_PRINT(NAME) \ 160 for (int my_i=0;my_i<NAME->n;my_i++) { \ 161 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, NAME->data.F32[my_i]); \ 162 } \ 163 printf("\n"); \ 164 165 166 /***************************************************************************** 167 161 PS_POLY macros: 168 162 *****************************************************************************/ 169 163 #define PS_POLY_CHECK_NULL(NAME, NULL) \ … … 174 168 175 169 /***************************************************************************** 176 170 PS_IMAGE macros: 177 171 *****************************************************************************/ 178 172 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \ … … 195 189 } 196 190 /***************************************************************************** 197 191 PS_READOUT macros: 198 192 *****************************************************************************/ 199 193 /** Preprocessor macro to generate error on a NULL image */ … … 204 198 } 205 199 206 207 208 209 210 /***************************************************************************** 211 200 /***************************************************************************** 201 Misc. macros: 212 202 *****************************************************************************/ 213 203 #define PS_MAX(A, B) \ -
trunk/psLib/src/dataManip/psMinimize.c
r2214 r2215 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.6 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-27 20:2 0:11$11 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 20:29:12 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 255 255 PS_PTR_CHECK_NULL(y, NULL); 256 256 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); 257 CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);257 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(y, y32, y32Static); 258 258 259 259 // If yErr==NULL, set all errors equal. 260 260 if (yErr == NULL) { 261 GEN_PERSIST_YERR_VEC_F32(yErr32Static, y->n);261 PS_VECTOR_GEN_YERR_STATIC_F32(yErr32Static, y->n); 262 262 yErr32 = yErr32Static; 263 263 } else { 264 264 PS_VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL); 265 CONVERT_VECTOR_F64_TO_F32(yErr, yErr32, yErr32Static);265 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(yErr, yErr32, yErr32Static); 266 266 } 267 267 268 268 // If x==NULL, create an x32 vector with x values set to (0:n). 269 269 if (x == NULL) { 270 GEN_PERSIST_X_INDEX_VEC_F32(x32Static, y->n);270 PS_VECTOR_GEN_X_INDEX_STATIC_F32(x32Static, y->n); 271 271 x32 = x32Static; 272 272 } else { 273 273 PS_VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL); 274 CONVERT_VECTOR_F64_TO_F32(x, x32, x32Static);274 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(x, x32, x32Static); 275 275 } 276 276 PS_VECTOR_CHECK_SIZE_EQUAL(x32, y32, NULL); … … 668 668 double fac; 669 669 double sum; 670 GEN_STATIC_RECYCLED_VECTOR(f, n, PS_TYPE_F64);670 PS_VECTOR_GEN_STATIC_RECYCLED(f, n, PS_TYPE_F64); 671 671 psScalar *fScalar; 672 672 psScalar tmpScalar; … … 866 866 867 867 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); 868 CONVERT_VECTOR_F32_TO_F64(y, y64, y64Static);868 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(y, y64, y64Static); 869 869 870 870 // If yErr==NULL, set all errors equal. 871 871 if (yErr == NULL) { 872 GEN_PERSIST_YERR_VEC_F64(yErr64Static, y->n);872 PS_VECTOR_GEN_YERR_STATIC_F64(yErr64Static, y->n); 873 873 yErr64 = yErr64Static; 874 874 } else { 875 875 PS_VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL); 876 CONVERT_VECTOR_F32_TO_F64(yErr, yErr64, yErr64Static);876 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(yErr, yErr64, yErr64Static); 877 877 } 878 878 879 879 // If x==NULL, create an x64 vector with x values set to (0:n). 880 880 if (x == NULL) { 881 GEN_PERSIST_X_INDEX_VEC_F64(x64Static, y->n);881 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 882 882 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 883 883 p_psNormalizeVector(x64Static); … … 886 886 } else { 887 887 PS_VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL); 888 CONVERT_VECTOR_F32_TO_F64(x, x64, x64Static);888 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(x, x64, x64Static); 889 889 } 890 890 PS_VECTOR_CHECK_SIZE_EQUAL(x64, y64, NULL); -
trunk/psLib/src/math/psConstants.h
r2214 r2215 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-27 20:2 0:11$8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 20:29:12 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 *****************************************************************************/ 25 25 26 27 28 /***************************************************************************** 29 30 *****************************************************************************/ 31 #define CONVERT_VECTOR_F64_TO_F32(OLD, NEW_PTR32, NEW_STATIC32) \ 26 #define PS_ONE 1.0 27 /***************************************************************************** 28 Macros which take a generic psLib type and determine if it is NULL, or has 29 the wrong type. 30 *****************************************************************************/ 31 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 32 if (NAME == NULL) { \ 33 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 34 return(RVAL); \ 35 } 36 37 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 38 if (NAME->type.type != TYPE) { \ 39 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 40 return(RVAL); \ 41 } 42 43 /***************************************************************************** 44 PS_VECTOR macros: 45 *****************************************************************************/ 46 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \ 47 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \ 48 psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \ 49 return(RVAL); \ 50 } \ 51 52 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 53 if (NAME->type.type != TYPE) { \ 54 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 55 return(RVAL); \ 56 } 57 58 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 59 if (NAME == NULL || NAME->data.V == NULL) { \ 60 psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \ 61 return(RVAL); \ 62 } \ 63 64 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 65 if (NAME->n < 1) { \ 66 psError(__func__,"Unallowable operation: %s has zero n value.", #NAME); \ 67 return(RVAL); \ 68 } \ 69 70 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 71 if (VEC1->n != VEC2->n) { \ 72 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 73 return(RVAL); \ 74 } 75 76 #define PS_VECTOR_F64_TO_F32(X64, X32) \ 77 psVector *X32 = psVectorAlloc(X64->n, PS_TYPE_F32); \ 78 for (int i=0;i<X64->n;i++) { \ 79 X32->data.F32[i] = (float) X64->data.F64[i]; \ 80 } \ 81 82 #define PS_VECTOR_F32_TO_F64(X32, X64) \ 83 psVector *X64 = psVectorAlloc(X32->n, PS_TYPE_F64); \ 84 for (int i=0;i<X32->n;i++) { \ 85 X64->data.F64[i] = (float) X32->data.F32[i]; \ 86 } \ 87 88 #define PS_VECTOR_PRINT(NAME) \ 89 for (int my_i=0;my_i<NAME->n;my_i++) { \ 90 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, NAME->data.F32[my_i]); \ 91 } \ 92 printf("\n"); \ 93 94 95 #define PS_VECTOR_CONVERT_F64_TO_F32_STATIC(OLD, NEW_PTR32, NEW_STATIC32) \ 32 96 if (OLD->type.type == PS_TYPE_F32) { \ 33 97 NEW_PTR32 = (psVector *) OLD; \ … … 42 106 } \ 43 107 44 #define CONVERT_VECTOR_F32_TO_F64(OLD, NEW_PTR64, NEW_STATIC64) \108 #define PS_VECTOR_CONVERT_F32_TO_F64_STATIC(OLD, NEW_PTR64, NEW_STATIC64) \ 45 109 if (OLD->type.type == PS_TYPE_F64) { \ 46 110 NEW_PTR64 = (psVector *) OLD; \ … … 55 119 } \ 56 120 57 #define GEN_PERSIST_YERR_VEC_F32(VEC, N) \121 #define PS_VECTOR_GEN_YERR_STATIC_F32(VEC, N) \ 58 122 VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \ 59 123 p_psMemSetPersistent(VEC, true); \ … … 63 127 } \ 64 128 65 #define GEN_PERSIST_YERR_VEC_F64(VEC, N) \129 #define PS_VECTOR_GEN_YERR_STATIC_F64(VEC, N) \ 66 130 VEC = psVectorRecycle(VEC, N, PS_TYPE_F64); \ 67 131 p_psMemSetPersistent(VEC, true); \ … … 71 135 } \ 72 136 73 #define GEN_PERSIST_X_INDEX_VEC_F32(VEC, N) \137 #define PS_VECTOR_GEN_X_INDEX_STATIC_F32(VEC, N) \ 74 138 VEC = psVectorRecycle(VEC, N, PS_TYPE_F32); \ 75 139 p_psMemSetPersistent(VEC, true); \ … … 79 143 } \ 80 144 81 #define GEN_PERSIST_X_INDEX_VEC_F64(VEC, N) \145 #define PS_VECTOR_GEN_X_INDEX_STATIC_F64(VEC, N) \ 82 146 VEC = psVectorRecycle(VEC, N, PS_TYPE_F64); \ 83 147 p_psMemSetPersistent(VEC, true); \ … … 87 151 } \ 88 152 89 #define GEN_STATIC_RECYCLED_VECTOR(NAME, SIZE, TYPE) \153 #define PS_VECTOR_GEN_STATIC_RECYCLED(NAME, SIZE, TYPE) \ 90 154 static psVector *NAME = NULL; \ 91 155 NAME = psVectorRecycle(NAME, SIZE, TYPE); \ … … 95 159 96 160 /***************************************************************************** 97 Macros which take a generic psLib type and determine if it is NULL, or has 98 the wrong type. 99 *****************************************************************************/ 100 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 101 if (NAME == NULL) { \ 102 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 103 return(RVAL); \ 104 } 105 106 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 107 if (NAME->type.type != TYPE) { \ 108 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 109 return(RVAL); \ 110 } 111 112 113 /***************************************************************************** 114 Macros which take a psVector type and determine if it is NULL, or has the 115 wrong type. 116 *****************************************************************************/ 117 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \ 118 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \ 119 psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \ 120 return(RVAL); \ 121 } \ 122 123 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 124 if (NAME->type.type != TYPE) { \ 125 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 126 return(RVAL); \ 127 } 128 129 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 130 if (NAME == NULL || NAME->data.V == NULL) { \ 131 psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \ 132 return(RVAL); \ 133 } \ 134 135 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 136 if (NAME->n < 1) { \ 137 psError(__func__,"Unallowable operation: %s has zero n value.", #NAME); \ 138 return(RVAL); \ 139 } \ 140 141 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 142 if (VEC1->n != VEC2->n) { \ 143 psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 144 return(RVAL); \ 145 } 146 147 #define PS_VECTOR_F64_TO_F32(X64, X32) \ 148 psVector *X32 = psVectorAlloc(X64->n, PS_TYPE_F32); \ 149 for (int i=0;i<X64->n;i++) { \ 150 X32->data.F32[i] = (float) X64->data.F64[i]; \ 151 } \ 152 153 #define PS_VECTOR_F32_TO_F64(X32, X64) \ 154 psVector *X64 = psVectorAlloc(X32->n, PS_TYPE_F64); \ 155 for (int i=0;i<X32->n;i++) { \ 156 X64->data.F64[i] = (float) X32->data.F32[i]; \ 157 } \ 158 159 #define PS_VECTOR_PRINT(NAME) \ 160 for (int my_i=0;my_i<NAME->n;my_i++) { \ 161 printf("%s->data.F32[%d] is %f\n", #NAME, my_i, NAME->data.F32[my_i]); \ 162 } \ 163 printf("\n"); \ 164 165 166 /***************************************************************************** 167 161 PS_POLY macros: 168 162 *****************************************************************************/ 169 163 #define PS_POLY_CHECK_NULL(NAME, NULL) \ … … 174 168 175 169 /***************************************************************************** 176 170 PS_IMAGE macros: 177 171 *****************************************************************************/ 178 172 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \ … … 195 189 } 196 190 /***************************************************************************** 197 191 PS_READOUT macros: 198 192 *****************************************************************************/ 199 193 /** Preprocessor macro to generate error on a NULL image */ … … 204 198 } 205 199 206 207 208 209 210 /***************************************************************************** 211 200 /***************************************************************************** 201 Misc. macros: 212 202 *****************************************************************************/ 213 203 #define PS_MAX(A, B) \ -
trunk/psLib/src/math/psMinimize.c
r2214 r2215 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.6 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-27 20:2 0:11$11 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 20:29:12 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 255 255 PS_PTR_CHECK_NULL(y, NULL); 256 256 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); 257 CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);257 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(y, y32, y32Static); 258 258 259 259 // If yErr==NULL, set all errors equal. 260 260 if (yErr == NULL) { 261 GEN_PERSIST_YERR_VEC_F32(yErr32Static, y->n);261 PS_VECTOR_GEN_YERR_STATIC_F32(yErr32Static, y->n); 262 262 yErr32 = yErr32Static; 263 263 } else { 264 264 PS_VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL); 265 CONVERT_VECTOR_F64_TO_F32(yErr, yErr32, yErr32Static);265 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(yErr, yErr32, yErr32Static); 266 266 } 267 267 268 268 // If x==NULL, create an x32 vector with x values set to (0:n). 269 269 if (x == NULL) { 270 GEN_PERSIST_X_INDEX_VEC_F32(x32Static, y->n);270 PS_VECTOR_GEN_X_INDEX_STATIC_F32(x32Static, y->n); 271 271 x32 = x32Static; 272 272 } else { 273 273 PS_VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL); 274 CONVERT_VECTOR_F64_TO_F32(x, x32, x32Static);274 PS_VECTOR_CONVERT_F64_TO_F32_STATIC(x, x32, x32Static); 275 275 } 276 276 PS_VECTOR_CHECK_SIZE_EQUAL(x32, y32, NULL); … … 668 668 double fac; 669 669 double sum; 670 GEN_STATIC_RECYCLED_VECTOR(f, n, PS_TYPE_F64);670 PS_VECTOR_GEN_STATIC_RECYCLED(f, n, PS_TYPE_F64); 671 671 psScalar *fScalar; 672 672 psScalar tmpScalar; … … 866 866 867 867 PS_VECTOR_CHECK_TYPE_F32_OR_F64(y, NULL); 868 CONVERT_VECTOR_F32_TO_F64(y, y64, y64Static);868 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(y, y64, y64Static); 869 869 870 870 // If yErr==NULL, set all errors equal. 871 871 if (yErr == NULL) { 872 GEN_PERSIST_YERR_VEC_F64(yErr64Static, y->n);872 PS_VECTOR_GEN_YERR_STATIC_F64(yErr64Static, y->n); 873 873 yErr64 = yErr64Static; 874 874 } else { 875 875 PS_VECTOR_CHECK_TYPE_F32_OR_F64(yErr, NULL); 876 CONVERT_VECTOR_F32_TO_F64(yErr, yErr64, yErr64Static);876 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(yErr, yErr64, yErr64Static); 877 877 } 878 878 879 879 // If x==NULL, create an x64 vector with x values set to (0:n). 880 880 if (x == NULL) { 881 GEN_PERSIST_X_INDEX_VEC_F64(x64Static, y->n);881 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 882 882 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 883 883 p_psNormalizeVector(x64Static); … … 886 886 } else { 887 887 PS_VECTOR_CHECK_TYPE_F32_OR_F64(x, NULL); 888 CONVERT_VECTOR_F32_TO_F64(x, x64, x64Static);888 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(x, x64, x64Static); 889 889 } 890 890 PS_VECTOR_CHECK_SIZE_EQUAL(x64, y64, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
