Changeset 7193
- Timestamp:
- May 23, 2006, 5:25:14 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psUnaryOp.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psUnaryOp.c
r6885 r7193 30 30 * @author Robert DeSonia, MHPCC 31 31 * 32 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $33 * @date $Date: 2006-0 4-18 22:04:28$32 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 33 * @date $Date: 2006-05-24 03:25:14 $ 34 34 * 35 35 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 65 65 66 66 // Unary SCALAR operations 67 #define SCALAR(OUT,IN,OP,TYPE) \ 68 { \ 69 ps##TYPE *o = NULL; \ 70 ps##TYPE *i1 = NULL; \ 71 o = &((psScalar* )OUT)->data.TYPE; \ 72 i1 = &((psScalar* )IN)->data.TYPE; \ 73 *o = OP; \ 67 #define SCALAR(OUT,IN,OP,TYPE) \ 68 { \ 69 ps##TYPE *o = &((psScalar*)OUT)->data.TYPE; \ 70 ps##TYPE *i1 = &((psScalar*)IN)->data.TYPE; \ 71 *o = OP; \ 74 72 } 75 73 76 74 // Unary IMAGE operations 77 #define VECTOR(OUT,IN,OP,TYPE) \ 78 { \ 79 psS32 i = 0; \ 80 psS32 nIn = 0; \ 81 psS32 nOut = 0; \ 82 ps##TYPE *o = NULL; \ 83 ps##TYPE *i1 = NULL; \ 84 nIn = ((psVector* )IN)->n; \ 85 nOut = ((psVector* )OUT)->n; \ 86 if(nIn != nOut) { \ 87 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 88 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 89 nIn, nOut); \ 90 if (OUT != IN) { \ 91 psFree(OUT); \ 92 } \ 93 return NULL; \ 94 } \ 95 o = ((psVector* )OUT)->data.TYPE; \ 96 i1 = ((psVector* )IN)->data.TYPE; \ 97 for(i = 0; i < nIn; i++, o++, i1++) { \ 98 *o = OP; \ 99 } \ 75 #define VECTOR(OUT,IN,OP,TYPE) \ 76 { \ 77 long nIn = ((psVector*)IN)->n; \ 78 long nOut = ((psVector*)OUT)->n; \ 79 if (nIn != nOut) { \ 80 psError(PS_ERR_BAD_PARAMETER_SIZE, true, PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, nIn, nOut); \ 81 if (OUT != IN) { \ 82 psFree(OUT); \ 83 } \ 84 return NULL; \ 85 } \ 86 ps##TYPE *o = ((psVector*)OUT)->data.TYPE; \ 87 ps##TYPE *i1 = ((psVector*)IN)->data.TYPE; \ 88 for (long i = 0; i < nIn; i++, o++, i1++) { \ 89 *o = OP; \ 90 } \ 100 91 } 101 92 102 93 // Unary IMAGE operations 103 #define IMAGE(OUT,IN,OP,TYPE) \ 104 { \ 105 psS32 i = 0; \ 106 psS32 j = 0; \ 107 psS32 numRowsIn = 0; \ 108 psS32 numColsIn = 0; \ 109 psS32 numRowsOut = 0; \ 110 psS32 numColsOut = 0; \ 111 ps##TYPE *o = NULL; \ 112 ps##TYPE *i1 = NULL; \ 113 numRowsIn = ((psImage* )IN)->numRows; \ 114 numColsIn = ((psImage* )IN)->numCols; \ 115 numRowsOut = ((psImage* )OUT)->numRows; \ 116 numColsOut = ((psImage* )OUT)->numCols; \ 117 if(numRowsIn!=numRowsOut || numColsIn!=numColsOut) { \ 118 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 119 PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS, \ 120 numColsIn, numRowsIn, numColsOut, numRowsOut); \ 121 if (OUT != IN) { \ 122 psFree(OUT); \ 123 } \ 124 return NULL; \ 125 } \ 126 for(j = 0; j < numRowsIn; j++) { \ 127 o = ((psImage* )OUT)->data.TYPE[j]; \ 128 i1 = ((psImage* )IN)->data.TYPE[j]; \ 129 for(i = 0; i < numColsIn; i++, o++, i1++) { \ 130 *o = OP; \ 131 } \ 132 } \ 94 #define IMAGE(OUT,IN,OP,TYPE) \ 95 { \ 96 long numRowsIn = ((psImage*)IN)->numRows; \ 97 long numColsIn = ((psImage*)IN)->numCols; \ 98 long numRowsOut = ((psImage*)OUT)->numRows; \ 99 long numColsOut = ((psImage*)OUT)->numCols; \ 100 if(numRowsIn!=numRowsOut || numColsIn!=numColsOut) { \ 101 psError(PS_ERR_BAD_PARAMETER_SIZE, true, PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS, \ 102 numColsIn, numRowsIn, numColsOut, numRowsOut); \ 103 if (OUT != IN) { \ 104 psFree(OUT); \ 105 } \ 106 return NULL; \ 107 } \ 108 for (long j = 0; j < numRowsIn; j++) { \ 109 ps##TYPE *o = ((psImage* )OUT)->data.TYPE[j]; \ 110 ps##TYPE *i1 = ((psImage* )IN)->data.TYPE[j]; \ 111 for (long i = 0; i < numColsIn; i++, o++, i1++) { \ 112 *o = OP; \ 113 } \ 114 }\ 133 115 } 134 116 135 117 // Preprocessor macro function to create arithmetic function based on input type 136 #define UNARY_TYPE(DIM,OUT,IN,OP) \ 137 switch (IN->type) { \ 138 case PS_TYPE_S32: \ 139 DIM(OUT,IN,OP,S32); \ 140 break; \ 141 case PS_TYPE_F32: \ 142 DIM(OUT,IN,OP,F32); \ 143 break; \ 144 case PS_TYPE_F64: \ 145 DIM(OUT,IN,OP,F64); \ 146 break; \ 147 case PS_TYPE_C32: \ 148 DIM(OUT,IN,OP,C32); \ 149 break; \ 150 case PS_TYPE_S8: \ 151 DIM(OUT,IN,OP,C32); \ 152 break; \ 153 case PS_TYPE_U8: \ 154 DIM(OUT,IN,OP,C32); \ 155 break; \ 156 case PS_TYPE_S16: \ 157 DIM(OUT,IN,OP,C32); \ 158 break; \ 159 case PS_TYPE_U16: \ 160 DIM(OUT,IN,OP,C32); \ 161 break; \ 162 case PS_TYPE_U32: \ 163 DIM(OUT,IN,OP,C32); \ 164 break; \ 165 case PS_TYPE_S64: \ 166 DIM(OUT,IN,OP,C32); \ 167 break; \ 168 case PS_TYPE_U64: \ 169 DIM(OUT,IN,OP,C32); \ 170 break; \ 171 case PS_TYPE_C64: \ 172 DIM(OUT,IN,OP,C32); \ 173 break; \ 174 default: { \ 175 char* strType; \ 176 PS_TYPE_NAME(strType, IN->type); \ 177 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 178 PS_ERRORTEXT_psMatrix_TYPE_MISMATCH, \ 179 strType); \ 180 if (OUT != IN) { \ 181 psFree(OUT); \ 182 } \ 183 return NULL; \ 118 #define UNARY_TYPE(DIM,OUT,IN,OP) \ 119 switch (IN->type) { \ 120 case PS_TYPE_S32: \ 121 DIM(OUT,IN,OP,S32); \ 122 break; \ 123 case PS_TYPE_F32: \ 124 DIM(OUT,IN,OP,F32); \ 125 break; \ 126 case PS_TYPE_F64: \ 127 DIM(OUT,IN,OP,F64); \ 128 break; \ 129 case PS_TYPE_C32: \ 130 DIM(OUT,IN,OP,C32); \ 131 break; \ 132 case PS_TYPE_S8: \ 133 DIM(OUT,IN,OP,C32); \ 134 break; \ 135 case PS_TYPE_U8: \ 136 DIM(OUT,IN,OP,C32); \ 137 break; \ 138 case PS_TYPE_S16: \ 139 DIM(OUT,IN,OP,C32); \ 140 break; \ 141 case PS_TYPE_U16: \ 142 DIM(OUT,IN,OP,C32); \ 143 break; \ 144 case PS_TYPE_U32: \ 145 DIM(OUT,IN,OP,C32); \ 146 break; \ 147 case PS_TYPE_S64: \ 148 DIM(OUT,IN,OP,C32); \ 149 break; \ 150 case PS_TYPE_U64: \ 151 DIM(OUT,IN,OP,C32); \ 152 break; \ 153 case PS_TYPE_C64: \ 154 DIM(OUT,IN,OP,C32); \ 155 break; \ 156 default: { \ 157 char* strType; \ 158 PS_TYPE_NAME(strType, IN->type); \ 159 psError(PS_ERR_BAD_PARAMETER_TYPE, true, PS_ERRORTEXT_psMatrix_TYPE_MISMATCH, strType); \ 160 if (OUT != IN) { \ 161 psFree(OUT); \ 162 } \ 163 return NULL; \ 184 164 } \ 185 165 } … … 187 167 // Preprocessor macro function to create arithmetic function operation name. Functions below that add 188 168 // FLT_EPSILON are done so to align results with a 64 bit computing architecture 189 #define UNARY_OP(DIM,OUT,IN,OP) \ 190 if(!strncmp(OP, "abs", 3)) { \ 191 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 192 UNARY_TYPE(DIM,OUT,IN,cabs(*i1)); \ 193 } else { \ 194 UNARY_TYPE(DIM,OUT,IN,fabs(*i1)); \ 195 } \ 196 } else if(!strncmp(OP, "exp", 3)) { \ 197 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 198 UNARY_TYPE(DIM,OUT,IN,cexp(*i1)); \ 199 } else { \ 200 UNARY_TYPE(DIM,OUT,IN,exp(*i1)); \ 201 } \ 202 } else if(!strncmp(OP, "ln", 2)) { \ 203 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 204 UNARY_TYPE(DIM,OUT,IN,clog(*i1)); \ 205 } else { \ 206 UNARY_TYPE(DIM,OUT,IN,log(*i1)); \ 207 } \ 208 } else if(!strncmp(OP, "ten", 3)) { \ 209 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 210 UNARY_TYPE(DIM,OUT,IN,cpow(10.0,*i1)); \ 211 } else { \ 212 UNARY_TYPE(DIM,OUT,IN,pow(10.0,*i1)); \ 213 } \ 214 } else if(!strncmp(OP, "log", 3)) { \ 215 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 216 UNARY_TYPE(DIM,OUT,IN,clog(*i1)/log(10.0)); \ 217 } else { \ 218 UNARY_TYPE(DIM,OUT,IN,log10(*i1)); \ 219 } \ 220 } else if(!strncmp(OP, "sin", 3)) { \ 221 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 222 UNARY_TYPE(DIM,OUT,IN,csin(*i1)); \ 223 } else { \ 224 UNARY_TYPE(DIM,OUT,IN,sin(*i1)); \ 225 } \ 226 } else if(!strncmp(OP, "dsin", 4)) { \ 227 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 228 UNARY_TYPE(DIM,OUT,IN,csin(*i1*D2R)); \ 229 } else { \ 230 UNARY_TYPE(DIM,OUT,IN,sin(*i1*D2R)); \ 231 } \ 232 } else if(!strncmp(OP, "cos", 3)) { \ 233 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 234 UNARY_TYPE(DIM,OUT,IN,ccos(*i1)); \ 235 } else { \ 236 UNARY_TYPE(DIM,OUT,IN,cos(*i1)); \ 237 } \ 238 } else if(!strncmp(OP, "dcos", 4)) { \ 239 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 240 UNARY_TYPE(DIM,OUT,IN,ccos(*i1*D2R)); \ 241 } else { \ 242 UNARY_TYPE(DIM,OUT,IN,cos(*i1*D2R)); \ 243 } \ 244 } else if(!strncmp(OP, "tan", 3)) { \ 245 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 246 UNARY_TYPE(DIM,OUT,IN,ctan(*i1)); \ 247 } else { \ 248 UNARY_TYPE(DIM,OUT,IN,tan(*i1)); \ 249 } \ 250 } else if(!strncmp(OP, "dtan", 4)) { \ 251 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 252 UNARY_TYPE(DIM,OUT,IN,ctan(*i1*D2R)); \ 253 } else { \ 254 UNARY_TYPE(DIM,OUT,IN,tan(*i1*D2R)); \ 255 } \ 256 } else if(!strncmp(OP, "asin", 4)) { \ 257 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 258 UNARY_TYPE(DIM,OUT,IN,casin(*i1)); \ 259 } else { \ 260 UNARY_TYPE(DIM,OUT,IN,asin(*i1)); \ 261 } \ 262 } else if(!strncmp(OP, "dasin", 5)) { \ 263 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 264 UNARY_TYPE(DIM,OUT,IN,R2D*casin(*i1)); \ 265 } else if(PS_IS_PSELEMTYPE_INT(IN->type)) { \ 266 UNARY_TYPE(DIM,OUT,IN,(R2D*asin(*i1))); \ 267 } else { \ 268 UNARY_TYPE(DIM,OUT,IN,(R2D*asin(*i1))); \ 269 } \ 270 } else if(!strncmp(OP, "acos", 4)) { \ 271 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 272 UNARY_TYPE(DIM,OUT,IN,cacos(*i1)); \ 273 } else { \ 274 UNARY_TYPE(DIM,OUT,IN,acos(*i1)); \ 275 } \ 276 } else if(!strncmp(OP, "dacos", 5)) { \ 277 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 278 UNARY_TYPE(DIM,OUT,IN,R2D*cacos(*i1)); \ 279 } else if(PS_IS_PSELEMTYPE_INT(IN->type)) { \ 280 UNARY_TYPE(DIM,OUT,IN,(R2D*acos(*i1))); \ 281 } else { \ 282 UNARY_TYPE(DIM,OUT,IN,R2D*acos(*i1)); \ 283 } \ 284 } else if(!strncmp(OP, "atan", 4)) { \ 285 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 286 UNARY_TYPE(DIM,OUT,IN,catan(*i1)); \ 287 } else { \ 288 UNARY_TYPE(DIM,OUT,IN,atan(*i1)); \ 289 } \ 290 } else if(!strncmp(OP, "datan", 5)) { \ 291 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 292 UNARY_TYPE(DIM,OUT,IN,R2D*catan(*i1)); \ 293 } else { \ 294 UNARY_TYPE(DIM,OUT,IN,R2D*atan(*i1)); \ 295 } \ 296 } else { \ 297 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 298 PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED, \ 299 OP); \ 300 if (OUT != IN) { \ 301 psFree(OUT); \ 302 } \ 303 return NULL; \ 169 #define UNARY_OP(DIM,OUT,IN,OP) \ 170 if(!strncmp(OP, "abs", 3)) { \ 171 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 172 UNARY_TYPE(DIM,OUT,IN,cabs(*i1)); \ 173 } else { \ 174 UNARY_TYPE(DIM,OUT,IN,fabs(*i1)); \ 175 } \ 176 } else if(!strncmp(OP, "exp", 3)) { \ 177 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 178 UNARY_TYPE(DIM,OUT,IN,cexp(*i1)); \ 179 } else { \ 180 UNARY_TYPE(DIM,OUT,IN,exp(*i1)); \ 181 } \ 182 } else if(!strncmp(OP, "ln", 2)) { \ 183 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 184 UNARY_TYPE(DIM,OUT,IN,clog(*i1)); \ 185 } else { \ 186 UNARY_TYPE(DIM,OUT,IN,log(*i1)); \ 187 } \ 188 } else if(!strncmp(OP, "ten", 3)) { \ 189 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 190 UNARY_TYPE(DIM,OUT,IN,cpow(10.0,*i1)); \ 191 } else { \ 192 UNARY_TYPE(DIM,OUT,IN,pow(10.0,*i1)); \ 193 } \ 194 } else if(!strncmp(OP, "log", 3)) { \ 195 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 196 UNARY_TYPE(DIM,OUT,IN,clog(*i1)/log(10.0)); \ 197 } else { \ 198 UNARY_TYPE(DIM,OUT,IN,log10(*i1)); \ 199 } \ 200 } else if(!strncmp(OP, "sin", 3)) { \ 201 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 202 UNARY_TYPE(DIM,OUT,IN,csin(*i1)); \ 203 } else { \ 204 UNARY_TYPE(DIM,OUT,IN,sin(*i1)); \ 205 } \ 206 } else if(!strncmp(OP, "dsin", 4)) { \ 207 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 208 UNARY_TYPE(DIM,OUT,IN,csin(*i1*D2R)); \ 209 } else { \ 210 UNARY_TYPE(DIM,OUT,IN,sin(*i1*D2R)); \ 211 } \ 212 } else if(!strncmp(OP, "cos", 3)) { \ 213 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 214 UNARY_TYPE(DIM,OUT,IN,ccos(*i1)); \ 215 } else { \ 216 UNARY_TYPE(DIM,OUT,IN,cos(*i1)); \ 217 } \ 218 } else if(!strncmp(OP, "dcos", 4)) { \ 219 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 220 UNARY_TYPE(DIM,OUT,IN,ccos(*i1*D2R)); \ 221 } else { \ 222 UNARY_TYPE(DIM,OUT,IN,cos(*i1*D2R)); \ 223 } \ 224 } else if(!strncmp(OP, "tan", 3)) { \ 225 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 226 UNARY_TYPE(DIM,OUT,IN,ctan(*i1)); \ 227 } else { \ 228 UNARY_TYPE(DIM,OUT,IN,tan(*i1)); \ 229 } \ 230 } else if(!strncmp(OP, "dtan", 4)) { \ 231 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 232 UNARY_TYPE(DIM,OUT,IN,ctan(*i1*D2R)); \ 233 } else { \ 234 UNARY_TYPE(DIM,OUT,IN,tan(*i1*D2R)); \ 235 } \ 236 } else if(!strncmp(OP, "asin", 4)) { \ 237 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 238 UNARY_TYPE(DIM,OUT,IN,casin(*i1)); \ 239 } else { \ 240 UNARY_TYPE(DIM,OUT,IN,asin(*i1)); \ 241 } \ 242 } else if(!strncmp(OP, "dasin", 5)) { \ 243 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 244 UNARY_TYPE(DIM,OUT,IN,R2D*casin(*i1)); \ 245 } else if(PS_IS_PSELEMTYPE_INT(IN->type)) { \ 246 UNARY_TYPE(DIM,OUT,IN,(R2D*asin(*i1))); \ 247 } else { \ 248 UNARY_TYPE(DIM,OUT,IN,(R2D*asin(*i1))); \ 249 } \ 250 } else if(!strncmp(OP, "acos", 4)) { \ 251 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 252 UNARY_TYPE(DIM,OUT,IN,cacos(*i1)); \ 253 } else { \ 254 UNARY_TYPE(DIM,OUT,IN,acos(*i1)); \ 255 } \ 256 } else if(!strncmp(OP, "dacos", 5)) { \ 257 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 258 UNARY_TYPE(DIM,OUT,IN,R2D*cacos(*i1)); \ 259 } else if(PS_IS_PSELEMTYPE_INT(IN->type)) { \ 260 UNARY_TYPE(DIM,OUT,IN,(R2D*acos(*i1))); \ 261 } else { \ 262 UNARY_TYPE(DIM,OUT,IN,R2D*acos(*i1)); \ 263 } \ 264 } else if(!strncmp(OP, "atan", 4)) { \ 265 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 266 UNARY_TYPE(DIM,OUT,IN,catan(*i1)); \ 267 } else { \ 268 UNARY_TYPE(DIM,OUT,IN,atan(*i1)); \ 269 } \ 270 } else if(!strncmp(OP, "datan", 5)) { \ 271 if(PS_IS_PSELEMTYPE_COMPLEX(IN->type)) { \ 272 UNARY_TYPE(DIM,OUT,IN,R2D*catan(*i1)); \ 273 } else { \ 274 UNARY_TYPE(DIM,OUT,IN,R2D*atan(*i1)); \ 275 } \ 276 } else { \ 277 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED, OP); \ 278 if (OUT != IN) { \ 279 psFree(OUT); \ 280 } \ 281 return NULL; \ 304 282 } 305 283 … … 318 296 PS_ASSERT_GENERAL_PTR_NON_NULL(op, psUnaryOp_EXIT); 319 297 320 psDimen dimIn = psTypeIn->dimen; 321 psElemType elTypeIn = psTypeIn->type; 322 323 switch (dimIn) { 298 switch (psTypeIn->dimen) { 324 299 case PS_DIMEN_SCALAR: 325 300 if (out == NULL || 326 301 ((psType*)out)->dimen != PS_DIMEN_SCALAR || 327 ((psScalar*)out)->type.type != elTypeIn) {302 ((psScalar*)out)->type.type != psTypeIn->type) { 328 303 psFree(out); 329 out = psScalarAlloc(0.0, elTypeIn);304 out = psScalarAlloc(0.0, psTypeIn->type); 330 305 } 331 306 UNARY_OP(SCALAR, out, psTypeIn, op); // scalar … … 334 309 case PS_DIMEN_TRANSV: 335 310 if (((psVector*)in)->n == 0) { 336 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 337 PS_ERRORTEXT_psMatrix_VECTOR_EMPTY); 311 psError(PS_ERR_BAD_PARAMETER_SIZE, true, PS_ERRORTEXT_psMatrix_VECTOR_EMPTY); 338 312 psUnaryOp_EXIT; 339 313 } 340 314 341 out = psVectorRecycle(out, 342 ((psVector*)in)->n, 343 elTypeIn); 315 out = psVectorRecycle(out, ((psVector*)in)->n, psTypeIn->type); 344 316 if (out == NULL) { 345 psError(PS_ERR_UNKNOWN, false, 346 PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 317 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 347 318 psUnaryOp_EXIT; 348 319 } … … 353 324 case PS_DIMEN_IMAGE: 354 325 if (((psImage* ) in)->numCols == 0 || ((psImage* ) in)->numRows == 0) { 355 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 356 PS_ERRORTEXT_psMatrix_IMAGE_EMPTY); 326 psError(PS_ERR_BAD_PARAMETER_SIZE, true, PS_ERRORTEXT_psMatrix_IMAGE_EMPTY); 357 327 psUnaryOp_EXIT; 358 328 } 359 329 360 out = psImageRecycle(out, 361 ((psImage*)in)->numCols, 362 ((psImage*)in)->numRows, 363 elTypeIn); 330 out = psImageRecycle(out, ((psImage*)in)->numCols, ((psImage*)in)->numRows, psTypeIn->type); 364 331 if (out == NULL) { 365 psError(PS_ERR_UNKNOWN, false, 366 PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 332 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 367 333 psUnaryOp_EXIT; 368 334 } … … 374 340 psFree(out); 375 341 } 376 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 377 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 378 "in", dimIn); 342 psError(PS_ERR_BAD_PARAMETER_SIZE, true, PS_ERRORTEXT_psMatrix_DIMEN_INVALID, "in", psTypeIn->dimen); 379 343 psUnaryOp_EXIT; 380 344 } … … 382 346 // Automtically free psScalar types, since they are usually allocated in the argument list when this 383 347 // function is called, provided that the input is not the output. 384 if (psTypeIn->dimen==PS_DIMEN_SCALAR && in!=out) {348 if (psTypeIn->dimen == PS_DIMEN_SCALAR && in!=out) { 385 349 psFree(in); 386 350 }
Note:
See TracChangeset
for help on using the changeset viewer.
