Changeset 2273
- Timestamp:
- Nov 3, 2004, 3:05:00 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 109 edited
-
psLib.kdevelop.filelist (modified) (1 diff)
-
psLib.kdevses (modified) (1 diff)
-
src/Makefile.Globals (modified) (2 diffs)
-
src/astro/psCoord.c (modified) (8 diffs)
-
src/astro/psTime.c (modified) (38 diffs)
-
src/astronomy/psAstrometry.c (modified) (3 diffs)
-
src/astronomy/psAstronomyErrors.dat (modified) (1 diff)
-
src/astronomy/psAstronomyErrors.h (modified) (2 diffs)
-
src/astronomy/psCoord.c (modified) (8 diffs)
-
src/astronomy/psMetadata.c (modified) (25 diffs)
-
src/astronomy/psMetadataIO.c (modified) (23 diffs)
-
src/astronomy/psTime.c (modified) (38 diffs)
-
src/collections/psBitSet.c (modified) (12 diffs)
-
src/collections/psHash.c (modified) (6 diffs)
-
src/collections/psList.c (modified) (7 diffs)
-
src/collections/psMetadata.c (modified) (25 diffs)
-
src/collections/psMetadataIO.c (modified) (23 diffs)
-
src/collections/psScalar.c (modified) (4 diffs)
-
src/collections/psVector.c (modified) (10 diffs)
-
src/dataManip/psConstants.h (modified) (14 diffs)
-
src/dataManip/psDataManipErrors.dat (modified) (2 diffs)
-
src/dataManip/psDataManipErrors.h (modified) (3 diffs)
-
src/dataManip/psFunctions.c (modified) (40 diffs)
-
src/dataManip/psFunctions.h (modified) (2 diffs)
-
src/dataManip/psMatrix.c (modified) (17 diffs)
-
src/dataManip/psMatrixVectorArithmetic.c (modified) (34 diffs)
-
src/dataManip/psMinimize.c (modified) (8 diffs)
-
src/dataManip/psStats.c (modified) (10 diffs)
-
src/dataManip/psVectorFFT.c (modified) (9 diffs)
-
src/fft/psImageFFT.c (modified) (10 diffs)
-
src/fft/psVectorFFT.c (modified) (9 diffs)
-
src/image/psImage.c (modified) (11 diffs)
-
src/image/psImageConvolve.c (modified) (10 diffs)
-
src/image/psImageExtraction.c (modified) (29 diffs)
-
src/image/psImageFFT.c (modified) (10 diffs)
-
src/image/psImageIO.c (modified) (21 diffs)
-
src/image/psImageManip.c (modified) (36 diffs)
-
src/image/psImageStats.c (modified) (12 diffs)
-
src/imageops/psImageConvolve.c (modified) (10 diffs)
-
src/imageops/psImageStats.c (modified) (12 diffs)
-
src/math/psConstants.h (modified) (14 diffs)
-
src/math/psMatrix.c (modified) (17 diffs)
-
src/math/psMinimize.c (modified) (8 diffs)
-
src/math/psPolynomial.c (modified) (40 diffs)
-
src/math/psPolynomial.h (modified) (2 diffs)
-
src/math/psSpline.c (modified) (40 diffs)
-
src/math/psSpline.h (modified) (2 diffs)
-
src/math/psStats.c (modified) (10 diffs)
-
src/mathtypes/psImage.c (modified) (11 diffs)
-
src/mathtypes/psScalar.c (modified) (4 diffs)
-
src/mathtypes/psVector.c (modified) (10 diffs)
-
src/psErrorCodes.dat (modified) (1 diff)
-
src/sys/psError.c (modified) (4 diffs)
-
src/sys/psError.h (modified) (2 diffs)
-
src/sys/psErrorCodes.c (modified) (4 diffs)
-
src/sys/psErrorCodes.h (modified) (2 diffs)
-
src/sys/psLogMsg.c (modified) (6 diffs)
-
src/sys/psMemory.c (modified) (5 diffs)
-
src/sys/psString.c (modified) (2 diffs)
-
src/sys/psTrace.c (modified) (5 diffs)
-
src/sysUtils/psError.c (modified) (4 diffs)
-
src/sysUtils/psError.h (modified) (2 diffs)
-
src/sysUtils/psErrorCodes.c (modified) (4 diffs)
-
src/sysUtils/psErrorCodes.h (modified) (2 diffs)
-
src/sysUtils/psLogMsg.c (modified) (6 diffs)
-
src/sysUtils/psMemory.c (modified) (5 diffs)
-
src/sysUtils/psString.c (modified) (2 diffs)
-
src/sysUtils/psTrace.c (modified) (5 diffs)
-
src/types/psBitSet.c (modified) (12 diffs)
-
src/types/psHash.c (modified) (6 diffs)
-
src/types/psList.c (modified) (7 diffs)
-
src/types/psMetadata.c (modified) (25 diffs)
-
src/types/psMetadataConfig.c (modified) (23 diffs)
-
src/xml/psXML.c (modified) (23 diffs)
-
test/astronomy/tst_psMetadata_01.c (modified) (4 diffs)
-
test/astronomy/tst_psMetadata_02.c (modified) (2 diffs)
-
test/astronomy/tst_psMetadata_03.c (modified) (11 diffs)
-
test/astronomy/tst_psMetadata_04.c (modified) (9 diffs)
-
test/astronomy/tst_psMetadata_05.c (modified) (6 diffs)
-
test/astronomy/tst_psMetadata_06.c (modified) (5 diffs)
-
test/collections/tst_psArray.c (modified) (8 diffs)
-
test/collections/tst_psList.c (modified) (77 diffs)
-
test/collections/tst_psMetadata_01.c (modified) (4 diffs)
-
test/collections/tst_psMetadata_02.c (modified) (2 diffs)
-
test/collections/tst_psMetadata_03.c (modified) (11 diffs)
-
test/collections/tst_psMetadata_04.c (modified) (9 diffs)
-
test/collections/tst_psMetadata_05.c (modified) (6 diffs)
-
test/collections/tst_psMetadata_06.c (modified) (5 diffs)
-
test/dataManip/tst_psFunc02.c (modified) (6 diffs)
-
test/dataManip/tst_psFunc03.c (modified) (2 diffs)
-
test/dataManip/tst_psFunc04.c (modified) (2 diffs)
-
test/dataManip/tst_psFunc05.c (modified) (1 diff)
-
test/dataManip/tst_psFunc07.c (modified) (2 diffs)
-
test/dataManip/tst_psMatrixVectorArithmetic02.c (modified) (2 diffs)
-
test/dataManip/tst_psMatrixVectorArithmetic03.c (modified) (4 diffs)
-
test/dataManip/tst_psMinimize04.c (modified) (1 diff)
-
test/dataManip/tst_psMinimize04b.c (modified) (3 diffs)
-
test/dataManip/tst_psMinimize04b_F32.c (modified) (3 diffs)
-
test/dataManip/tst_psMinimize06.c (modified) (1 diff)
-
test/dataManip/tst_psVectorFFT.c (modified) (18 diffs)
-
test/image/tst_psImage.c (modified) (19 diffs)
-
test/image/tst_psImageConvolve.c (modified) (30 diffs)
-
test/image/tst_psImageExtraction.c (modified) (54 diffs)
-
test/image/tst_psImageFFT.c (modified) (23 diffs)
-
test/image/tst_psImageIO.c (modified) (19 diffs)
-
test/image/tst_psImageManip.c (modified) (83 diffs)
-
test/psTest.c (modified) (5 diffs)
-
test/sysUtils/tst_psError.c (modified) (10 diffs)
-
test/sysUtils/tst_psMemory.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevelop.filelist
r2110 r2273 1 1 # KDevelop Custom Project File List 2 psLib.kdevelop3 psLib.kdevses4 testbin/CVS/Entries5 testbin/CVS/Repository6 testbin/CVS/Root7 test/FullUnitTest8 test/Makefile9 test/psTest.c10 test/psTest.h11 test/runTest12 test/tst_template.c13 test/sysUtils/Makefile14 test/sysUtils/tst_psAbort.c15 test/sysUtils/tst_psError.c16 test/sysUtils/tst_psLogMsg.c17 test/sysUtils/tst_psMemory.c18 test/sysUtils/tst_psStringCopy.c19 test/sysUtils/tst_psTrace.c20 test/sysUtils/verified/tst_psAbort.stderr21 test/sysUtils/verified/tst_psAbort.stdout22 test/sysUtils/verified/tst_psError.stderr23 test/sysUtils/verified/tst_psError.stdout24 test/sysUtils/verified/tst_psHash00.stderr25 test/sysUtils/verified/tst_psHash00.stdout26 test/sysUtils/verified/tst_psHash01.stderr27 test/sysUtils/verified/tst_psHash01.stdout28 test/sysUtils/verified/tst_psHash02.stderr29 test/sysUtils/verified/tst_psHash03.stderr30 test/sysUtils/verified/tst_psHash03.stdout31 test/sysUtils/verified/tst_psHash04.stderr32 test/sysUtils/verified/tst_psHash04.stdout33 test/sysUtils/verified/tst_psLogMsg.stderr34 test/sysUtils/verified/tst_psLogMsg.stdout35 test/sysUtils/verified/tst_psMemory.stderr36 test/sysUtils/verified/tst_psStringCopy.stderr37 test/sysUtils/verified/tst_psStringCopy.stdout38 test/sysUtils/verified/tst_psTrace.stderr39 test/sysUtils/verified/tst_psTrace.stdout40 test/sysUtils/verified/CVS/Entries41 test/sysUtils/verified/CVS/Repository42 test/sysUtils/verified/CVS/Root43 test/sysUtils/CVS/Entries44 test/sysUtils/CVS/Entries.Log45 test/sysUtils/CVS/Repository46 test/sysUtils/CVS/Root47 test/sysUtils/builddir/CVS/Entries48 test/sysUtils/builddir/CVS/Repository49 test/sysUtils/builddir/CVS/Root50 test/image/Makefile51 test/image/tst_psImage.c52 test/image/tst_psImageExtraction.c53 test/image/tst_psImageFFT.c54 test/image/tst_psImageIO.c55 test/image/tst_psImageManip.c56 test/image/tst_psImageStats00.c57 test/image/tst_psImageStats01.c58 test/image/tst_psImageStats02.c59 test/image/tst_psImageStats03.c60 test/image/verified/fOut.fits61 test/image/verified/sOut.fits62 test/image/verified/tst_psImage.stderr63 test/image/verified/tst_psImageExtraction.stderr64 test/image/verified/tst_psImageFFT.stderr65 test/image/verified/tst_psImageIO.stderr66 test/image/verified/tst_psImageManip.stderr67 test/image/verified/tst_psImageManip.stdout68 test/image/verified/tst_psImageStats00.stderr69 test/image/verified/tst_psImageStats00.stdout70 test/image/verified/tst_psImageStats01.stderr71 test/image/verified/tst_psImageStats01.stdout72 test/image/verified/tst_psImageStats02.stdout73 test/image/verified/CVS/Entries74 test/image/verified/CVS/Repository75 test/image/verified/CVS/Root76 test/image/CVS/Entries77 test/image/CVS/Entries.Log78 test/image/CVS/Repository79 test/image/CVS/Root80 test/dataManip/Makefile81 test/dataManip/tst_psFunc00.c82 test/dataManip/tst_psFunc01.c83 test/dataManip/tst_psFunc02.c84 test/dataManip/tst_psFunc03.c85 test/dataManip/tst_psFunc04.c86 test/dataManip/tst_psFunc05.c87 test/dataManip/tst_psFunc07.c88 test/dataManip/tst_psHist00.c89 test/dataManip/tst_psHist01.c90 test/dataManip/tst_psHist02.c91 test/dataManip/tst_psHist03.c92 test/dataManip/tst_psMatrix01.c93 test/dataManip/tst_psMatrix02.c94 test/dataManip/tst_psMatrix03.c95 test/dataManip/tst_psMatrix04.c96 test/dataManip/tst_psMatrix05.c97 test/dataManip/tst_psMatrix06.c98 test/dataManip/tst_psMatrix07.c99 test/dataManip/tst_psMatrixVectorArithmetic01.c100 test/dataManip/tst_psMatrixVectorArithmetic02.c101 test/dataManip/tst_psMatrixVectorArithmetic03.c102 test/dataManip/tst_psMinimize00.c103 test/dataManip/tst_psMinimize01.c104 test/dataManip/tst_psMinimize02.c105 test/dataManip/tst_psMinimize03.c106 test/dataManip/tst_psMinimize04.c107 test/dataManip/tst_psMinimize05.c108 test/dataManip/tst_psMinimize06.c109 test/dataManip/tst_psStats00.c110 test/dataManip/tst_psStats01.c111 test/dataManip/tst_psStats02.c112 test/dataManip/tst_psStats03.c113 test/dataManip/tst_psStats04.c114 test/dataManip/tst_psStats05.c115 test/dataManip/tst_psStats06.c116 test/dataManip/tst_psStats07.c117 test/dataManip/tst_psStats08.c118 test/dataManip/tst_psStats09.c119 test/dataManip/tst_psVectorFFT.c120 test/dataManip/verified/tst_psFunc00.stderr121 test/dataManip/verified/tst_psFunc00.stdout122 test/dataManip/verified/tst_psFunc01.stdout123 test/dataManip/verified/tst_psHist00.stdout124 test/dataManip/verified/tst_psHist01.stdout125 test/dataManip/verified/tst_psHist02.stdout126 test/dataManip/verified/tst_psMatrix01.stdout127 test/dataManip/verified/tst_psMatrix02.stderr128 test/dataManip/verified/tst_psMatrix02.stdout129 test/dataManip/verified/tst_psMatrix03.stderr130 test/dataManip/verified/tst_psMatrix03.stdout131 test/dataManip/verified/tst_psMatrix04.stderr132 test/dataManip/verified/tst_psMatrix04.stdout133 test/dataManip/verified/tst_psMatrix05.stdout134 test/dataManip/verified/tst_psMatrix06.stdout135 test/dataManip/verified/tst_psMatrix07.stderr136 test/dataManip/verified/tst_psMatrix07.stdout137 test/dataManip/verified/tst_psMatrixVectorArithmetic01.stderr138 test/dataManip/verified/tst_psMatrixVectorArithmetic01.stdout139 test/dataManip/verified/tst_psMatrixVectorArithmetic02.stdout140 test/dataManip/verified/tst_psMatrixVectorArithmetic03.stderr141 test/dataManip/verified/tst_psMatrixVectorArithmetic03.stdout142 test/dataManip/verified/tst_psStats00.stdout143 test/dataManip/verified/tst_psStats01.stdout144 test/dataManip/verified/tst_psStats02.stdout145 test/dataManip/verified/tst_psStats03.stdout146 test/dataManip/verified/tst_psStats05.stdout147 test/dataManip/verified/tst_psStats06.stdout148 test/dataManip/verified/tst_psStats07.stdout149 test/dataManip/verified/tst_psStats08.stdout150 test/dataManip/verified/tst_psStats09.stdout151 test/dataManip/verified/tst_psVectorFFT.stderr152 test/dataManip/verified/CVS/Entries153 test/dataManip/verified/CVS/Repository154 test/dataManip/verified/CVS/Root155 test/dataManip/CVS/Entries156 test/dataManip/CVS/Entries.Log157 test/dataManip/CVS/Repository158 test/dataManip/CVS/Root159 test/dataManip/builddir/CVS/Entries160 test/dataManip/builddir/CVS/Repository161 test/dataManip/builddir/CVS/Root162 test/CVS/Entries163 test/CVS/Entries.Log164 test/CVS/Repository165 test/CVS/Root166 test/collections/Makefile167 test/collections/tst_psArray.c168 test/collections/tst_psBitSet.c169 test/collections/tst_psHash00.c170 test/collections/tst_psHash01.c171 test/collections/tst_psHash02.c172 test/collections/tst_psHash03.c173 test/collections/tst_psHash04.c174 test/collections/tst_psList.c175 test/collections/tst_psVector.c176 test/collections/tst_psVectorSort_01.c177 test/collections/tst_psVectorSort_02.c178 test/collections/tst_psVectorSort_03.c179 test/collections/tst_psVectorSort_04.c180 test/collections/verified/tst_psArray.stdout181 test/collections/verified/tst_psBitSet.stderr182 test/collections/verified/tst_psHash00.stderr183 test/collections/verified/tst_psHash00.stdout184 test/collections/verified/tst_psHash01.stderr185 test/collections/verified/tst_psHash01.stdout186 test/collections/verified/tst_psHash02.stderr187 test/collections/verified/tst_psHash03.stderr188 test/collections/verified/tst_psHash03.stdout189 test/collections/verified/tst_psHash04.stderr190 test/collections/verified/tst_psHash04.stdout191 test/collections/verified/tst_psList.stderr192 test/collections/verified/tst_psSort_01.stderr193 test/collections/verified/tst_psSort_01.stdout194 test/collections/verified/tst_psSort_02.stdout195 test/collections/verified/tst_psSort_03.stderr196 test/collections/verified/tst_psSort_03.stdout197 test/collections/verified/tst_psSort_04.stderr198 test/collections/verified/tst_psSort_04.stdout199 test/collections/verified/tst_psVector.stderr200 test/collections/verified/tst_psVector.stdout201 test/collections/verified/tst_psVector_01.stderr202 test/collections/verified/tst_psVector_01.stdout203 test/collections/verified/tst_psVector_02.stdout204 test/collections/verified/tst_psVector_03.stdout205 test/collections/verified/tst_psVectorSort_01.stderr206 test/collections/verified/tst_psVectorSort_01.stdout207 test/collections/verified/tst_psVectorSort_02.stderr208 test/collections/verified/tst_psVectorSort_02.stdout209 test/collections/verified/tst_psVectorSort_03.stderr210 test/collections/verified/tst_psVectorSort_03.stdout211 test/collections/verified/tst_psVectorSort_04.stderr212 test/collections/verified/tst_psVectorSort_04.stdout213 test/collections/verified/CVS/Entries214 test/collections/verified/CVS/Repository215 test/collections/verified/CVS/Root216 test/collections/CVS/Entries217 test/collections/CVS/Entries.Log218 test/collections/CVS/Repository219 test/collections/CVS/Root220 test/collections/builddir/CVS/Entries221 test/collections/builddir/CVS/Repository222 test/collections/builddir/CVS/Root223 test/astronomy/header_1.fits224 test/astronomy/header_2.fits225 test/astronomy/Makefile226 test/astronomy/tst_psMetadata_01.c227 test/astronomy/tst_psMetadata_02.c228 test/astronomy/tst_psMetadata_03.c229 test/astronomy/tst_psMetadata_04.c230 test/astronomy/tst_psMetadata_05.c231 test/astronomy/tst_psMetadata_06.c232 test/astronomy/tst_psTime_01.c233 test/astronomy/tst_psTime_02.c234 test/astronomy/verified/tst_psMetadata_01.stderr235 test/astronomy/verified/tst_psMetadata_01.stdout236 test/astronomy/verified/tst_psMetadata_02.stderr237 test/astronomy/verified/tst_psMetadata_02.stdout238 test/astronomy/verified/tst_psMetadata_03.stderr239 test/astronomy/verified/tst_psMetadata_03.stdout240 test/astronomy/verified/tst_psMetadata_04.stderr241 test/astronomy/verified/tst_psMetadata_04.stdout242 test/astronomy/verified/tst_psMetadata_05.stderr243 test/astronomy/verified/tst_psMetadata_05.stdout244 test/astronomy/verified/tst_psMetadata_06.stdout245 test/astronomy/verified/tst_psTime_01.stdout246 test/astronomy/verified/tst_psTime_02.stderr247 test/astronomy/verified/tst_psTime_02.stdout248 test/astronomy/verified/CVS/Entries249 test/astronomy/verified/CVS/Repository250 test/astronomy/verified/CVS/Root251 test/astronomy/CVS/Entries252 test/astronomy/CVS/Entries.Log253 test/astronomy/CVS/Repository254 test/astronomy/CVS/Root255 test/astronomy/builddir/tst_psMetadata_01.d256 test/astronomy/builddir/tst_psMetadata_02.d257 test/astronomy/builddir/tst_psMetadata_03.d258 test/astronomy/builddir/tst_psMetadata_04.d259 test/astronomy/builddir/tst_psMetadata_05.d260 test/astronomy/builddir/tst_psMetadata_06.d261 test/astronomy/builddir/tst_psTime_01.d262 test/astronomy/builddir/tst_psTime_02.d263 test/astronomy/builddir/CVS/Entries264 test/astronomy/builddir/CVS/Repository265 test/astronomy/builddir/CVS/Root266 src/Doxyfile267 src/mainpage.dox268 src/Makefile269 src/Makefile.Globals270 src/parseErrorCodes.pl271 src/psErrorCodes.dat272 src/pslib.h273 src/sysUtils/Makefile274 src/sysUtils/psAbort.c275 src/sysUtils/psAbort.h276 src/sysUtils/psError.c277 src/sysUtils/psError.h278 src/sysUtils/psErrorCodes.c279 src/sysUtils/psErrorCodes.h280 src/sysUtils/psLogMsg.c281 src/sysUtils/psLogMsg.h282 src/sysUtils/psMemory.c283 src/sysUtils/psMemory.h284 src/sysUtils/psString.c285 src/sysUtils/psString.h286 src/sysUtils/psSysUtilsErrors.dat287 src/sysUtils/psSysUtilsErrors.h288 src/sysUtils/psTrace.c289 src/sysUtils/psTrace.h290 src/sysUtils/psType.h291 src/sysUtils/README292 src/sysUtils/makedir/psAbort.d293 src/sysUtils/makedir/psError.d294 src/sysUtils/makedir/psErrorCodes.d295 src/sysUtils/makedir/psHash.d296 src/sysUtils/makedir/psLogMsg.d297 src/sysUtils/makedir/psMemory.d298 src/sysUtils/makedir/psString.d299 src/sysUtils/makedir/psTrace.d300 src/sysUtils/makedir/CVS/Entries301 src/sysUtils/makedir/CVS/Repository302 src/sysUtils/makedir/CVS/Root303 src/sysUtils/CVS/Entries304 src/sysUtils/CVS/Entries.Log305 src/sysUtils/CVS/Repository306 src/sysUtils/CVS/Root307 src/image/Makefile308 src/image/psImage.c309 src/image/psImage.h310 src/image/psImageConvolve.c311 src/image/psImageConvolve.h312 src/image/psImageErrors.dat313 src/image/psImageErrors.h314 src/image/psImageExtraction.c315 src/image/psImageExtraction.h316 src/image/psImageFFT.c317 src/image/psImageFFT.h318 src/image/psImageIO.c319 src/image/psImageIO.h320 src/image/psImageManip.c321 src/image/psImageManip.h322 src/image/psImageStats.c323 src/image/psImageStats.h324 src/image/makedir/psImage.d325 src/image/makedir/psImageConvolve.d326 src/image/makedir/psImageExtraction.d327 src/image/makedir/psImageFFT.d328 src/image/makedir/psImageIO.d329 src/image/makedir/psImageManip.d330 src/image/makedir/psImageStats.d331 src/image/makedir/CVS/Entries332 src/image/makedir/CVS/Repository333 src/image/makedir/CVS/Root334 src/image/CVS/Entries335 src/image/CVS/Entries.Log336 src/image/CVS/Repository337 src/image/CVS/Root338 src/dataManip/Makefile339 src/dataManip/psDataManipErrors.dat340 src/dataManip/psDataManipErrors.h341 src/dataManip/psFunctions.c342 src/dataManip/psFunctions.h343 src/dataManip/psMatrix.c344 src/dataManip/psMatrix.h345 src/dataManip/psMatrixVectorArithmetic.c346 src/dataManip/psMatrixVectorArithmetic.h347 src/dataManip/psMinimize.c348 src/dataManip/psMinimize.h349 src/dataManip/psStats.c350 src/dataManip/psStats.h351 src/dataManip/psVectorFFT.c352 src/dataManip/psVectorFFT.h353 src/dataManip/makedir/psFunctions.d354 src/dataManip/makedir/psMatrix.d355 src/dataManip/makedir/psMatrixVectorArithmetic.d356 src/dataManip/makedir/psMinimize.d357 src/dataManip/makedir/psStats.d358 src/dataManip/makedir/psVectorFFT.d359 src/dataManip/makedir/CVS/Entries360 src/dataManip/makedir/CVS/Repository361 src/dataManip/makedir/CVS/Root362 src/dataManip/CVS/Entries363 src/dataManip/CVS/Entries.Log364 src/dataManip/CVS/Repository365 src/dataManip/CVS/Root366 src/CVS/Entries367 src/CVS/Entries.Log368 src/CVS/Repository369 src/CVS/Root370 src/collections/Makefile371 src/collections/psArray.c372 src/collections/psArray.h373 src/collections/psBitSet.c374 src/collections/psBitSet.h375 src/collections/psCollectionsErrors.dat376 src/collections/psCollectionsErrors.h377 src/collections/psCompare.c378 src/collections/psCompare.h379 src/collections/psHash.c380 src/collections/psHash.h381 src/collections/psList.c382 src/collections/psList.h383 src/collections/psScalar.c384 src/collections/psScalar.h385 src/collections/psVector.c386 src/collections/psVector.h387 src/collections/makedir/psArray.d388 src/collections/makedir/psBitSet.d389 src/collections/makedir/psCompare.d390 src/collections/makedir/psHash.d391 src/collections/makedir/psList.d392 src/collections/makedir/psScalar.d393 src/collections/makedir/psVector.d394 src/collections/makedir/CVS/Entries395 src/collections/makedir/CVS/Repository396 src/collections/makedir/CVS/Root397 src/collections/CVS/Entries398 src/collections/CVS/Entries.Log399 src/collections/CVS/Repository400 src/collections/CVS/Root401 src/astronomy/Makefile402 src/astronomy/psAstrometry.c403 src/astronomy/psAstrometry.h404 src/astronomy/psAstronomyErrors.dat405 src/astronomy/psAstronomyErrors.h406 src/astronomy/psCoord.c407 src/astronomy/psCoord.h408 src/astronomy/psMetadata.c409 src/astronomy/psMetadata.h410 src/astronomy/psPhotometry.h411 src/astronomy/psTime.c412 src/astronomy/psTime.h413 src/astronomy/slalib.h414 src/astronomy/makedir/psAstrometry.d415 src/astronomy/makedir/psCoord.d416 src/astronomy/makedir/psMetadata.d417 src/astronomy/makedir/psTime.d418 src/astronomy/makedir/CVS/Entries419 src/astronomy/makedir/CVS/Repository420 src/astronomy/makedir/CVS/Root421 src/astronomy/depend/CVS/Entries422 src/astronomy/depend/CVS/Repository423 src/astronomy/depend/CVS/Root424 src/astronomy/CVS/Entries425 src/astronomy/CVS/Entries.Log426 src/astronomy/CVS/Repository427 src/astronomy/CVS/Root428 lib/CVS/Entries429 lib/CVS/Repository430 lib/CVS/Root431 include/CVS/Entries432 include/CVS/Repository433 include/CVS/Root434 data/eopc01.1900-2004435 data/finals.all436 data/readme.eopc01437 data/readme.finals438 data/readme.ser7439 data/readme.tai-utc440 data/ser7.dat441 data/tai-utc.dat442 data/CVS/Entries443 data/CVS/Repository444 data/CVS/Root445 CVS/Entries446 CVS/Entries.Log447 CVS/Repository448 CVS/Root449 test/image/tst_psImageConvolve.c450 test/astronomy/tst_psAstrometry.c451 test/astronomy/tst_psMetadataIO.c -
trunk/psLib/psLib.kdevses
r2156 r2273 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments="3" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/Doxyfile" > 6 <View0 line="27" Type="???" > 7 <AdditionalSettings Top="2" Width="1212" Attach="1" Height="1027" Left="2" MinMaxMode="0" /> 8 </View0> 9 </Doc0> 10 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.c" > 11 <View0 line="311" Type="???" > 12 <AdditionalSettings Top="2" Width="1212" Attach="1" Height="752" Left="2" MinMaxMode="0" /> 13 </View0> 14 </Doc1> 15 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" > 16 <View0 line="21" Type="???" > 17 <AdditionalSettings Top="2" Width="1212" Attach="1" Height="1001" Left="2" MinMaxMode="0" /> 18 </View0> 19 </Doc2> 20 </DocsAndViews> 4 <DocsAndViews NumberOfDocuments="0" /> 21 5 <pluginList> 22 6 <kdevbookmarks> 23 <bookmarks> 24 <bookmark url="/home/desonia/psLib/test/dataManip/tst_psImageManip.c" > 25 <mark line="615" /> 26 <mark line="652" /> 27 <mark line="593" /> 28 </bookmark> 29 <bookmark url="/home/desonia/psLib/src/dataManip/psMatrixVectorArithmetic.c" > 30 <mark line="60" /> 31 </bookmark> 32 <bookmark url="/home/desonia/psLib/src/collections/psBitSet.c" > 33 <mark line="194" /> 34 </bookmark> 35 </bookmarks> 7 <bookmarks/> 36 8 </kdevbookmarks> 37 <kdevsubversion>38 <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />39 </kdevsubversion>40 9 <kdevvalgrind> 41 10 <executable path="" params="" /> -
trunk/psLib/src/Makefile.Globals
r2246 r2273 5 5 ## Assumptions: Variable "prefix" already defined 6 6 ## 7 ## $Revision: 1.2 1$ $Name: not supported by cvs2svn $8 ## $Date: 2004-11-0 1 18:55:38$7 ## $Revision: 1.22 $ $Name: not supported by cvs2svn $ 8 ## $Date: 2004-11-04 01:04:57 $ 9 9 ## 10 10 ## Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 54 54 # Set initial value for CFLAGS which will include all OS common flags for GCC 55 55 GCOVFLAGS := 56 CFLAGS := - O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS)56 CFLAGS := -Werror -O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS) 57 57 58 58 ifdef NO_TRACE -
trunk/psLib/src/astro/psCoord.c
r2221 r2273 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 23:31:43$12 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:04:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psConstants.h" 28 28 #include "psError.h" 29 #include "psAstronomyErrors.h" 29 30 #include <math.h> 30 31 #include <float.h> … … 278 279 279 280 } else if (projection->type == PS_PROJ_PAR) { 280 psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 281 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 282 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 283 "PS_PROJ_PAR"); 281 284 282 285 } else if (projection->type == PS_PROJ_GLS) { 283 psError(__func__, "The projection type PS_PROJ_GLS is undefined.\n"); 286 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 287 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 288 "PS_PROJ_GLS"); 284 289 } else { 285 psError(__func__, "Unknown projection type.\n"); 290 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 291 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN, 292 projection->type); 286 293 } 287 294 … … 333 340 334 341 } else if (projection->type == PS_PROJ_PAR) { 335 psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 342 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 343 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 344 "PS_PROJ_PAR"); 336 345 337 346 } else if (projection->type == PS_PROJ_GLS) { 338 psError(__func__, "The projection type PS_PROJ_GLG is undefined.\n"); 347 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 348 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 349 "PS_PROJ_GLS"); 339 350 } else { 340 psError(__func__, "Unknown projection type.\n"); 351 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 352 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN, 353 projection->type); 341 354 } 342 355 … … 407 420 } else if (unit == PS_RADIAN) {} 408 421 else { 409 psError(__func__, "Unknown offset unit: 0x%x\n", unit); 422 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 423 PS_ERRORTEXT_psCoord_UNITS_UNKNOWN, 424 unit); 410 425 } 411 426 … … 413 428 } 414 429 415 psError(__func__, "Unrecognized offset mode\n"); 430 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 431 PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN, 432 mode); 416 433 return (NULL); 417 434 } … … 469 486 tmpD = offset->d; 470 487 } else { 471 psError(__func__, "Unknown offset unit: 0x%x\n", unit); 488 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 489 PS_ERRORTEXT_psCoord_UNITS_UNKNOWN, 490 unit); 472 491 } 473 492 … … 483 502 } 484 503 485 psError(__func__, "Unrecognized offset mode\n"); 504 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 505 PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN, 506 mode); 507 486 508 return (NULL); 487 509 } -
trunk/psLib/src/astro/psTime.c
r2204 r2273 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:30$13 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psMetadata.h" 32 32 #include "psMetadataIO.h" 33 33 #include "psConstants.h" 34 34 #include "psAstronomyErrors.h" 35 35 … … 151 151 char line[LINESIZE]; 152 152 psS32 j = 0; 153 psS32 maxLines = 100 ;153 psS32 maxLines = 1000; 154 154 psF64 *ptr = NULL; 155 155 psImage *table = NULL; … … 159 159 fd=fopen(fileName, "r"); 160 160 if(fd==NULL) { 161 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName); 161 psError(PS_ERR_IO,true, 162 PS_ERRORTEXT_psTime_FILE_NOT_FOUND, 163 fileName,"Tai-Utc"); 162 164 return NULL; 163 165 } … … 168 170 while(fgets(line, LINESIZE, fd) != NULL) { 169 171 if(j>=maxLines) { 170 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines); 172 psError(PS_ERR_IO,true, 173 PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS, 174 fileName,maxLines); 171 175 return NULL; 172 176 psFree(table); … … 201 205 fd=fopen(fileName, "r"); 202 206 if(fd==NULL) { 203 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName); 207 psError(PS_ERR_IO,true, 208 PS_ERRORTEXT_psTime_FILE_NOT_FOUND, 209 fileName,"Ser7"); 204 210 return NULL ; 205 211 } … … 218 224 219 225 if(j>=maxLines) { 220 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines); 226 psError(PS_ERR_IO,true, 227 PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS, 228 fileName,maxLines); 221 229 return NULL; 222 230 psFree(table); … … 240 248 } 241 249 242 /* Not yet used...243 static psImage* readEopcFile(char *fileName)244 {245 char line[LINESIZE];246 psS32 i = 0;247 psS32 j = 0;248 psS32 maxLines = 2500;249 psImage *table = NULL;250 FILE *fd = NULL;251 252 253 fd=fopen(fileName, "r");254 if(fd==NULL) {255 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);256 return NULL ;257 }258 259 // Table shouldn't be larger than 2500 rows. All columns are read.260 table = psImageAlloc(11, maxLines, PS_TYPE_F64);261 for(i=0; i<3; i++) {262 if((fgets(line, LINESIZE, fd) != NULL)) {263 psError(__func__, " : Line %d - Error reading %s", __LINE__, fileName);264 }265 }266 267 while(fgets(line, LINESIZE, fd) != NULL) {268 if(j>=maxLines) {269 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);270 return NULL;271 psFree(table);272 }273 psF64 *ptr = table->data.F64[j++];274 sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",275 ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10);276 }277 278 *(psU32 *)&table->numRows = j;279 280 return table;281 }282 283 static psImage* readFinalsFile(char *fileName)284 {285 char line[LINESIZE];286 psS32 j = 0;287 psS32 maxLines = 15000;288 psImage *table = NULL;289 FILE *fd = NULL;290 291 292 fd=fopen(fileName, "r");293 if(fd==NULL) {294 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);295 return NULL ;296 }297 298 // Table shouldn't be larger than 15000 rows. Select columns are read.299 table = psImageAlloc(6, maxLines, PS_TYPE_F64);300 while(fgets(line, LINESIZE, fd) != NULL) {301 if(j>=maxLines) {302 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);303 return NULL;304 psFree(table);305 }306 307 psF64 *ptr = table->data.F64[j++];308 ptr = table->data.F64[j++];309 310 // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry311 if(*(line+7) == ' ') { // MJD312 *ptr = 0.0;313 } else {314 *ptr = atof(line+7);315 }316 317 if(*(line+18) == ' ') { // Polar motion X318 *(ptr+1) = 0.0;319 } else {320 *(ptr+1) = atof(line+18);321 }322 323 if(*(line+27) == ' ') { // Polar motion X error324 *(ptr+2) = 0.0;325 } else {326 *(ptr+2) = atof(line+27);327 }328 329 if(*(line+37) == ' ') { // Polar motion Y330 *(ptr+3) = 0.0;331 } else {332 *(ptr+3) = atof(line+37);333 }334 335 if(*(line+46) == ' ') { // Polar motion Y error336 *(ptr+4) = 0.0;337 } else {338 *(ptr+4) = atof(line+46);339 }340 341 if(*(line+58) == ' ') { // UT1-UTC342 *(ptr+5) = 0.0;343 } else {344 *(ptr+5) = atof(line+58);345 }346 }347 348 *(psU32 *)&table->numRows = j;349 350 return table;351 }352 */353 250 354 251 static double lookupTaiUtcTable(const psTime *time) … … 389 286 hiIdx++; 390 287 if(hiIdx >= numRows) { 391 psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx); 288 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 289 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 290 jd, "TAI-UTC"); 392 291 return 0.0; 393 292 } … … 395 294 loIdx = hiIdx--; 396 295 if(loIdx < 0) { 397 psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx); 296 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 297 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 298 jd, "TAI-UTC"); 398 299 return 0.0; 399 300 } 400 301 302 // since rows of table can not have same jd, this check is probably not needed. 401 303 denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0]; 402 304 if(fabs(denom) < FLT_EPSILON) { 403 psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__); 305 psError(PS_ERR_UNKNOWN,true, 306 PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS 307 "Ser7"); 404 308 return 0.0; 405 309 } else { 406 407 310 // Interpolate three constants required to calculate TAI-UTC 408 311 const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1]) … … 445 348 mjdUtc = psTimeToMJD(time); 446 349 if(mjdUtc < table->data.F64[0][3]) { // MJD time before start of table 447 psError(__func__, " : Line %d - MJD too small. Value: %d", __LINE__, mjdUtc); 350 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 351 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 352 mjdUtc, "Ser7"); 448 353 449 354 } else if(mjdUtc > table->data.F64[numRows-1][3]) { // MJD time after end of table 450 psError(__func__, " : Line %d - MJD too big. Value: %d", __LINE__, mjdUtc); 355 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 356 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 357 mjdUtc, "Ser7"); 451 358 } else { // All other times..interpolate 452 359 while(mjdUtc > table->data.F64[hiIdx][3]) { 453 360 hiIdx++; 454 361 if(hiIdx >= numRows) { 455 psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx); 362 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 363 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 364 mjdUtc, "Ser7"); 456 365 return 0.0; 457 366 } … … 460 369 loIdx = hiIdx--; 461 370 if(loIdx < 0) { 462 psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx); 371 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 372 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 373 mjdUtc, "Ser7"); 463 374 } 464 375 465 376 denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3]; 466 377 if(fabs(denom) < FLT_EPSILON) { 467 psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__); 378 psError(PS_ERR_UNKNOWN,true, 379 PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS, 380 "Ser7"); 468 381 } else { 469 382 out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col]) … … 525 438 // Error checks 526 439 if(type!=PS_TIME_TAI && type!=PS_TIME_UTC) { 527 psError(__func__, " : Line %d - Incorrect type. Type: %d", __LINE__, type); 440 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 441 PS_ERRORTEXT_psTime_TYPE_UNKNOWN, 442 type); 528 443 return NULL; 529 444 } 530 445 531 446 outTime = (psTime*)psAlloc(sizeof(psTime)); 532 if(outTime == NULL) {533 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);534 }535 447 536 448 outTime->sec = 0; … … 551 463 552 464 if (gettimeofday(&now, (struct timezone *)0) == -1) { 553 psError(__func__, " : Line %d - Failed to get time", __LINE__); 465 psError(PS_ERR_OS_CALL_FAILED, true, 466 PS_ERRORTEXT_psTime_GET_TOD_FAILED); 554 467 return NULL; 555 468 } … … 573 486 574 487 // Error checks 575 if(time == NULL) { 576 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 577 return NULL; 578 } else if(time->usec >= 1e6) { 579 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 580 return NULL; 581 } else if(time->type == type) { 582 psError(__func__, " : Line %d - Time already in correct psTime type. Time type: %d", __LINE__, type); 583 return NULL; 488 PS_PTR_CHECK_NULL(time,NULL); 489 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 490 491 if (time->type == type) { // time already right type. That was easy! 492 return time; 584 493 } 585 494 586 495 delta = psTimeGetTAIDelta(time); 587 496 588 if (type == PS_TIME_UTC) {497 if (type == PS_TIME_UTC) { 589 498 time->sec = time->sec - delta; // User wants UTC time. Subtract leapseconds. 590 499 } else if(type == PS_TIME_TAI) { 591 500 time->sec = time->sec + delta; // User wants TAI time. Add leapseconds. 592 501 } else { 593 psError(__func__, " : Line %d - Invalid psTimeType: %d", __LINE__, type); 502 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 503 PS_ERRORTEXT_psTime_TYPE_UNKNOWN, 504 type); 594 505 } 595 506 … … 623 534 624 535 // Error checks 625 if(time == NULL) { 626 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 627 return 0; 628 } else if(time->usec >= 1e6) { 629 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 630 return 0; 631 } 536 PS_PTR_CHECK_NULL(time,NAN); 537 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 632 538 633 539 // Calculate TAI or UTC time based on type of time user passes … … 698 604 699 605 // Error checks 700 if(time == NULL) { 701 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 702 return 0.0; 703 } else if(time->usec >= 1e6) { 704 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 705 return 0.0; 706 } 606 PS_PTR_CHECK_NULL(time,NAN); 607 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 707 608 708 609 return lookupSer7Table(time, 6); … … 717 618 718 619 // Error checks 719 if(time == NULL) 720 { 721 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 722 return NULL; 723 } else if(time->usec >= 1e6) 724 { 725 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 726 return NULL; 727 } 620 PS_PTR_CHECK_NULL(time,NULL); 621 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 728 622 729 623 x = lookupSer7Table((psTime*)time, 4); … … 741 635 742 636 // Error checks 743 if(time == NULL) { 744 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 745 return 0.0; 746 } else if(time->usec >= 1e6) { 747 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 748 return 0.0; 749 } 637 PS_PTR_CHECK_NULL(time,NAN); 638 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 750 639 751 640 return lookupTaiUtcTable(time); … … 758 647 759 648 // Error checks 760 if(time1 == NULL) { 761 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 762 return 0; 763 } else if(time1->usec >= 1e6) { 764 psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time1->usec); 765 return 0; 766 } else if(time2 == NULL) { 767 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 768 return 0; 769 } else if(time2->usec >= 1e6) { 770 psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time2->usec); 771 return 0; 772 } 649 PS_PTR_CHECK_NULL(time1,0); 650 PS_PTR_CHECK_NULL(time2,0); 651 PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0); 652 PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0); 773 653 774 654 diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2)); … … 781 661 double jd = 0.0; 782 662 783 784 // Error checks 785 if(time == NULL) { 786 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 787 return 0.0; 788 } else if(time->usec >= 1e6) { 789 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 790 return 0.0; 791 } 663 // Error checks 664 PS_PTR_CHECK_NULL(time,NAN); 665 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 792 666 793 667 // Julian date conversion … … 807 681 808 682 // Error checks 809 if(time == NULL) { 810 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 811 return 0.0; 812 } else if(time->usec >= 1e6) { 813 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 814 return 0.0; 815 } 683 PS_PTR_CHECK_NULL(time,NAN); 684 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 816 685 817 686 // Modified Julian date conversion … … 835 704 836 705 // Error checks 837 if(time == NULL) { 838 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 839 return NULL; 840 } else if(time->usec >= 1e6) { 841 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 842 return NULL; 843 } 706 PS_PTR_CHECK_NULL(time,NULL); 707 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 844 708 845 709 tempString = psAlloc(MAX_TIME_STRING_LENGTH); … … 854 718 // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form 855 719 if (!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y-%m-%dT%H:%M:%S", tmTime)) { 856 psError(__func__, " : Line %d - Failed strftime conversion", __LINE__); 720 psError(PS_ERR_OS_CALL_FAILED, true, 721 PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED); 857 722 } 858 723 859 724 if (snprintf(timeString, MAX_TIME_STRING_LENGTH, "%s.%3.3dZ", tempString, ms) < 0) { 860 psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__); 725 psError(PS_ERR_OS_CALL_FAILED, true, 726 PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED); 861 727 } 862 728 psFree(tempString); … … 869 735 struct timeval timevalTime; 870 736 871 872 // Error checks 873 if(time == NULL) 874 { 875 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 876 return timevalTime; 877 } else if(time->usec >= 1e6) 878 { 879 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 880 return timevalTime; 881 } 737 timevalTime.tv_sec = 0; 738 timevalTime.tv_usec = 0; 739 740 // Error checks 741 PS_PTR_CHECK_NULL(time,timevalTime); 742 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime); 882 743 883 744 timevalTime.tv_sec = time->sec; … … 901 762 902 763 // Error checks 903 if(time == NULL) 904 { 905 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 906 return NULL; 907 } else if(time->usec >= 1e6) 908 { 909 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 910 return NULL; 911 } 764 PS_PTR_CHECK_NULL(time,NULL); 765 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 912 766 913 767 seconds = time->sec%60; … … 945 799 // Allocate output 946 800 tmTime = (struct tm*)psAlloc(sizeof(struct tm)); 947 if (tmTime == NULL)948 {949 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);950 }951 801 952 802 tmTime->tm_year = year - 1900; … … 982 832 983 833 // Error check 984 if(outTime->usec >= 1e6) { 985 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 986 } 834 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 987 835 988 836 return outTime; … … 1010 858 1011 859 // Error check 1012 if(outTime->usec >= 1e6) { 1013 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1014 } 860 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1015 861 1016 862 return outTime; … … 1020 866 { 1021 867 char tempString[MAX_TIME_STRING_LENGTH]; 1022 psS32 month;1023 psS32 day;1024 psS32 year;1025 psS32 hour;1026 psS32 minute;1027 psS32 second;1028 868 psS32 millisecond; 1029 869 struct tm tmTime; 1030 870 psTime *outTime = NULL; 1031 871 1032 1033 // Preserve input string by creating duplicate1034 strncpy(tempString, time, MAX_TIME_STRING_LENGTH);1035 1036 872 // Convert YYYY-MM-DDThh:mm:ss.sss in string form to tm time 1037 year = atoi(strtok(tempString, "-")); 1038 if (year < 0) { 1039 psError(__func__, "Years less than 0 not allowed. Value: %d", year); 1040 return outTime; 1041 } 1042 1043 month = atoi(strtok(NULL, "-")); 1044 if (month < 1 || month > 12) { 1045 psError(__func__, "Month must have a value from 1 to 12. Value: %d", month); 1046 return outTime; 1047 } 1048 1049 day = atoi(strtok(NULL, "T")); 1050 if (day < 1 || day > 31) { 1051 psError(__func__, "Day must have a value from 1 to 31. Value: %d", day); 1052 return outTime; 1053 } 1054 1055 hour = atoi(strtok(NULL, ":")); 1056 if (hour < 0 || hour > 23) { 1057 psError(__func__, "Hour must have a value from 0 to 23. Value: %d", hour); 1058 return outTime; 1059 } 1060 1061 minute = atoi(strtok(NULL, ":")); 1062 if (minute < 0 || minute > 59) { 1063 psError(__func__, "Minute must have a value from 0 to 59. Value: %d", minute); 1064 return outTime; 1065 } 1066 1067 second = atoi(strtok(NULL, ".")); 1068 if (second < 0 || second > 59) { 1069 psError(__func__, "Second must have a value from 0 to 59. Value: %d", second); 1070 return outTime; 1071 } 1072 1073 millisecond = atoi(strtok(NULL, "Z")); 1074 if (millisecond < 0 || millisecond > 1000) { 1075 psError(__func__, "Millisecond must have a value from 0 to 999. Value: %d", millisecond); 1076 return outTime; 1077 } 1078 1079 tmTime.tm_year = year - 1900; 1080 tmTime.tm_mon = month - 1; 1081 tmTime.tm_mday = day; 1082 tmTime.tm_hour = hour; 1083 tmTime.tm_min = minute; 1084 tmTime.tm_sec = second; 873 if (sscanf(time, "%d-%d-%dT%d:%d:%d.%d", 874 &tmTime.tm_year,&tmTime.tm_mon,&tmTime.tm_mday, 875 &tmTime.tm_hour,&tmTime.tm_min,&tmTime.tm_sec,&millisecond) < 7) { 876 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 877 PS_ERRORTEXT_psTime_ISOTIME_MALFORMED, 878 time); 879 return NULL; 880 } 881 882 PS_INT_CHECK_NON_NEGATIVE(tmTime.tm_year, outTime); 883 PS_INT_CHECK_RANGE(tmTime.tm_mon,1,12,outTime); 884 PS_INT_CHECK_RANGE(tmTime.tm_mday,1,31,outTime); 885 PS_INT_CHECK_RANGE(tmTime.tm_hour,0,23,outTime); 886 PS_INT_CHECK_RANGE(tmTime.tm_min,0,59,outTime); 887 PS_INT_CHECK_RANGE(tmTime.tm_sec,0,59,outTime); 888 PS_INT_CHECK_RANGE(millisecond,0,999,outTime); 889 890 tmTime.tm_year -= 1900; 891 tmTime.tm_mon--; 1085 892 tmTime.tm_isdst = -1; 1086 893 … … 1089 896 outTime->usec = millisecond * 1000; 1090 897 898 return outTime; 899 } 900 901 psTime* psTimeFromTimeval(const struct timeval *time) 902 { 903 psTime *outTime = NULL; 904 905 1091 906 // Error check 1092 if(outTime->usec >= 1e6) { 1093 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1094 } 1095 1096 return outTime; 1097 } 1098 1099 psTime* psTimeFromTimeval(const struct timeval *time) 1100 { 1101 psTime *outTime = NULL; 1102 1103 1104 // Error check 1105 if(time == NULL) 1106 { 1107 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 1108 return NULL; 1109 } 907 PS_PTR_CHECK_NULL(time,NULL); 1110 908 1111 909 // Allocate psTime struct … … 1117 915 1118 916 // Error check 1119 if(outTime->usec >= 1e6) 1120 { 1121 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1122 } 917 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1123 918 1124 919 return outTime; … … 1138 933 1139 934 // Error check 1140 if(time == NULL) 1141 { 1142 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 1143 return NULL; 1144 } 935 PS_PTR_CHECK_NULL(time,NULL); 1145 936 1146 937 // Allocate psTime struct … … 1183 974 1184 975 // Error check 1185 if(outTime->usec >= 1e6) 1186 { 1187 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1188 } 976 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1189 977 1190 978 return outTime; … … 1199 987 1200 988 // Error checks 989 PS_PTR_CHECK_NULL(tai1,NULL); 990 PS_PTR_CHECK_NULL(tai2,NULL); 991 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 992 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 993 1201 994 if(tai1->type != tai2->type) { 1202 psError(__func__, " : Line %d - Argument types inconsistent for time addition", __LINE__); 1203 return NULL; 1204 } else if(tai1 == NULL) { 1205 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1206 return NULL; 1207 } else if(tai1->usec >= 1e6) { 1208 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1209 return NULL; 1210 } else if(tai2 == NULL) { 1211 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1212 return NULL; 1213 } else if(tai2->usec >= 1e6) { 1214 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 995 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 996 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1215 997 return NULL; 1216 998 } … … 1233 1015 1234 1016 // Error check 1235 if(outTime->usec >= 1e6) { 1236 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1237 } 1017 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1238 1018 1239 1019 return outTime; … … 1248 1028 1249 1029 // Error checks 1030 PS_PTR_CHECK_NULL(tai1,NULL); 1031 PS_PTR_CHECK_NULL(tai2,NULL); 1032 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 1033 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 1250 1034 if(tai1->type != tai2->type) { 1251 psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__); 1252 return NULL; 1253 } else if(tai1 == NULL) { 1254 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1255 return NULL; 1256 } else if(tai1->usec >= 1e6) { 1257 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1258 return NULL; 1259 } else if(tai2 == NULL) { 1260 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1261 return NULL; 1262 } else if(tai2->usec >= 1e6) { 1263 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 1035 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1036 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1264 1037 return NULL; 1265 1038 } … … 1294 1067 1295 1068 // Error checks 1069 // Error checks 1070 PS_PTR_CHECK_NULL(tai1,NULL); 1071 PS_PTR_CHECK_NULL(tai2,NULL); 1072 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 1073 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 1296 1074 if(tai1->type != tai2->type) { 1297 psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__); 1298 return NULL; 1299 } else if(tai1 == NULL) { 1300 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1301 return NULL; 1302 } else if(tai1->usec >= 1e6) { 1303 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1304 return NULL; 1305 } else if(tai2 == NULL) { 1306 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1307 return NULL; 1308 } else if(tai2->usec >= 1e6) { 1309 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 1075 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1076 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1310 1077 return NULL; 1311 1078 } -
trunk/psLib/src/astronomy/psAstrometry.c
r2222 r2273 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1. 49$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-27 23:49:00$10 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:04:57 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psError.h" 26 26 #include "psConstants.h" 27 #include "psAstronomyErrors.h" 28 27 29 #include "slalib.h" 28 30 … … 868 870 // generate an error if cell->toTP is not linear. 869 871 if (0 == isProjectionLinear(cell->toTP)) { 870 psError(__func__, "the cell->toTP transfrom is not linear.\n"); 872 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 873 PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM, 874 "cell to tangent plane"); 871 875 } 872 876 -
trunk/psLib/src/astronomy/psAstronomyErrors.dat
r2204 r2273 7 7 # N.B. in code, the ERRORNAME appears as PS_ERRORTEXT_ERRORNAME 8 8 #################################################################### 9 psTime_FILE_NOT_FOUND Failed to open file %s. No %s information is available. 10 psTime_FILE_TOO_MANY_ROWS Too many rows found in file %s. Max number of rows allowed is %d. 11 psTime_TIME_POSTDATES_TABLE Specified psTime postdates (%g) the table of %s information. 12 psTime_TIME_PREDATES_TABLE Specified psTime predates (%g) the table of %s information. 13 psTime_TABLE_DUPLICATE_ROWS The %s table was found to have two rows of the same time value. 14 psTime_TYPE_UNKNOWN Specified type, %d, is not supported. 15 psTime_TYPE_MISMATCH Specified psTime parameters must have same type. 16 psTime_GET_TOD_FAILED Failed to determine the current time from gettimeofday function. 17 psTime_CONVERT_TIME_TO_STRING_FAILED Failed to convert a time via strftime function. 18 psTime_APPEND_MSEC_FAILED Failed to append millisecond to time string with snprintf function. 19 psTime_USEC_INVALID The psTime usec attribute value, %u, is invalid. Must be less than 1e6. 20 psTime_ISOTIME_MALFORMED Specified ISO Time string, '%s', is malformed. Must be in 'YYYY-MM-DDThh:mm:ss.sss' format. 21 # 22 psCoord_PROJECTION_TYPE_UNDEFINED The projection type, %s, is undefined. 23 psCoord_PROJECTION_TYPE_UNKNOWN The projection type, %d, is unknown. 24 psCoord_UNITS_UNKNOWN Specified units, 0x%x, is not supported. 25 psCoord_OFFSET_MODE_UNKNOWN Specified offset mode, 0x%x, is not supported. 26 # 27 psAstrometry_NONLINEAR_TRANSFORM The %s transfrom is not linear. Only linear transforms are supported. 28 # 29 psMetadata_METATYPE_INVALID Specified psMetadataType, %d, is not supported. 30 psMetadata_ADD_LIST_FAILED Failed to add metadata item, %s, to items list. 31 psMetadata_ADD_TABLE_FAILED Failed to add metadata item, %s, to items table. 32 psMetadata_REMOVE_LIST_FAILED Failed to remove metadata item, %s, from metadata list. 33 psMetadata_REMOVE_LIST_INDEX_FAILED Failed to remove metadata item, at index %d, from metadata list. 34 psMetadata_REMOVE_TABLE_FAILED Failed to remove metadata item, %s, from metadata table. 35 psMetadata_ADD_COLLECTION_FAILED Failed to add metadata item, %s, to metadata collection list. 36 psMetadata_ADD_FAILED Failed to add metadata item to metadata collection list. 37 psMetadata_FIND_FAILED Could not find metadata item, %s. 38 psMetadata_FIND_INDEX_FAILED Could not find metadata item at index %d. 39 # 40 psMetadataIO_TYPE_INVALID Specified type, %d, is not supported. 41 psMetadataIO_EXTNUM_NOTPOSITIVE Specified extension number, %d, is invalid. Value must be positive if no extension name is given. 42 psMetadataIO_FITS_METATYPE_INVALID Specified FITS metadata type, %c, is not supported. 43 psMetadataIO_ADD_FAILED Failed to add metadata item, %s. 44 psMetadataIO_FILE_OPEN_FAILED Failed to open file '%s'. Check if it exists and it has the proper permissions. 45 psMetadataIO_FILE_MULTIPLE_CHAR More than one '%c' character not allowed. Found on line %d of %s. 46 psMetadataIO_FILE_ELEMENT_NULL Failed to read a metadata %s on line %d of %s. 47 psMetadataIO_FILE_TYPE_INVALID Metadata type '%s', found on line %d of %s, is not invalid. 48 psMetadataIO_OVERWRITE_ITEM Duplicate Metadata item, %s, found on line %d of %s. Overwrite not allowed. 49 psMetadataIO_PARSE_FAILED Failed to parse the value '%s' of metadata item %s, type %s, on line %d of %s. 50 51 -
trunk/psLib/src/astronomy/psAstronomyErrors.h
r2210 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 19:35:55$9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:04:57 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 31 31 //~Start #define PS_ERRORTEXT_$1 "$2" 32 #define PS_ERRORTEXT_psTime_FILE_NOT_FOUND "Failed to open file %s. No %s information is available." 33 #define PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS "Too many rows found in file %s. Max number of rows allowed is %d." 34 #define PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE "Specified psTime postdates (%g) the table of %s information." 35 #define PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE "Specified psTime predates (%g) the table of %s information." 36 #define PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS "The %s table was found to have two rows of the same time value." 37 #define PS_ERRORTEXT_psTime_TYPE_UNKNOWN "Specified type, %d, is not supported." 38 #define PS_ERRORTEXT_psTime_TYPE_MISMATCH "Specified psTime parameters must have same type." 39 #define PS_ERRORTEXT_psTime_GET_TOD_FAILED "Failed to determine the current time from gettimeofday function." 40 #define PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED "Failed to convert a time via strftime function." 41 #define PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED "Failed to append millisecond to time string with snprintf function." 42 #define PS_ERRORTEXT_psTime_USEC_INVALID "The psTime usec attribute value, %u, is invalid. Must be less than 1e6." 43 #define PS_ERRORTEXT_psTime_ISOTIME_MALFORMED "Specified ISO Time string, '%s', is malformed. Must be in 'YYYY-MM-DDThh:mm:ss.sss' format." 44 #define PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED "The projection type, %s, is undefined." 45 #define PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN "The projection type, %d, is unknown." 46 #define PS_ERRORTEXT_psCoord_UNITS_UNKNOWN "Specified units, 0x%x, is not supported." 47 #define PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN "Specified offset mode, 0x%x, is not supported." 48 #define PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM "The %s transfrom is not linear. Only linear transforms are supported. " 49 #define PS_ERRORTEXT_psMetadata_METATYPE_INVALID "Specified psMetadataType, %d, is not supported." 50 #define PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED "Failed to add metadata item, %s, to items list." 51 #define PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED "Failed to add metadata item, %s, to items table." 52 #define PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED "Failed to remove metadata item, %s, from metadata list." 53 #define PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED "Failed to remove metadata item, at index %d, from metadata list." 54 #define PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED "Failed to remove metadata item, %s, from metadata table." 55 #define PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED "Failed to add metadata item, %s, to metadata collection list." 56 #define PS_ERRORTEXT_psMetadata_ADD_FAILED "Failed to add metadata item to metadata collection list." 57 #define PS_ERRORTEXT_psMetadata_FIND_FAILED "Could not find metadata item, %s." 58 #define PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED "Could not find metadata item at index %d." 59 #define PS_ERRORTEXT_psMetadataIO_TYPE_INVALID "Specified type, %d, is not supported." 60 #define PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE "Specified extension number, %d, is invalid. Value must be positive if no extension name is given." 61 #define PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID "Specified FITS metadata type, %c, is not supported." 62 #define PS_ERRORTEXT_psMetadataIO_ADD_FAILED "Failed to add metadata item, %s." 63 #define PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED "Failed to open file '%s'. Check if it exists and it has the proper permissions." 64 #define PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR "More than one '%c' character not allowed. Found on line %d of %s." 65 #define PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL "Failed to read a metadata %s on line %d of %s." 66 #define PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID "Metadata type '%s', found on line %d of %s, is not invalid." 67 #define PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM "Duplicate Metadata item, %s, found on line %d of %s. Overwrite not allowed." 68 #define PS_ERRORTEXT_psMetadataIO_PARSE_FAILED "Failed to parse the value '%s' of metadata item %s, type %s, on line %d of %s." 32 69 //~End 33 70 -
trunk/psLib/src/astronomy/psCoord.c
r2221 r2273 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 23:31:43$12 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:04:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psConstants.h" 28 28 #include "psError.h" 29 #include "psAstronomyErrors.h" 29 30 #include <math.h> 30 31 #include <float.h> … … 278 279 279 280 } else if (projection->type == PS_PROJ_PAR) { 280 psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 281 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 282 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 283 "PS_PROJ_PAR"); 281 284 282 285 } else if (projection->type == PS_PROJ_GLS) { 283 psError(__func__, "The projection type PS_PROJ_GLS is undefined.\n"); 286 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 287 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 288 "PS_PROJ_GLS"); 284 289 } else { 285 psError(__func__, "Unknown projection type.\n"); 290 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 291 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN, 292 projection->type); 286 293 } 287 294 … … 333 340 334 341 } else if (projection->type == PS_PROJ_PAR) { 335 psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 342 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 343 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 344 "PS_PROJ_PAR"); 336 345 337 346 } else if (projection->type == PS_PROJ_GLS) { 338 psError(__func__, "The projection type PS_PROJ_GLG is undefined.\n"); 347 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 348 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED, 349 "PS_PROJ_GLS"); 339 350 } else { 340 psError(__func__, "Unknown projection type.\n"); 351 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 352 PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN, 353 projection->type); 341 354 } 342 355 … … 407 420 } else if (unit == PS_RADIAN) {} 408 421 else { 409 psError(__func__, "Unknown offset unit: 0x%x\n", unit); 422 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 423 PS_ERRORTEXT_psCoord_UNITS_UNKNOWN, 424 unit); 410 425 } 411 426 … … 413 428 } 414 429 415 psError(__func__, "Unrecognized offset mode\n"); 430 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 431 PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN, 432 mode); 416 433 return (NULL); 417 434 } … … 469 486 tmpD = offset->d; 470 487 } else { 471 psError(__func__, "Unknown offset unit: 0x%x\n", unit); 488 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 489 PS_ERRORTEXT_psCoord_UNITS_UNKNOWN, 490 unit); 472 491 } 473 492 … … 483 502 } 484 503 485 psError(__func__, "Unrecognized offset mode\n"); 504 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 505 PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN, 506 mode); 507 486 508 return (NULL); 487 509 } -
trunk/psLib/src/astronomy/psMetadata.c
r2204 r2273 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:30$14 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:57 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psMetadata.h" 36 36 #include "psString.h" 37 #include "psAstronomyErrors.h" 38 #include "psConstants.h" 37 39 38 40 /******************************************************************************/ … … 123 125 124 126 125 if (name == NULL) { 126 psError(__func__, "Null value for name not allowed"); 127 return NULL; 128 } 127 PS_PTR_CHECK_NULL(name,NULL); 128 129 129 // Allocate metadata item 130 130 metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem)); … … 147 147 // Set metadata item type 148 148 metadataItem->type = type; 149 metadataItem->data.V = NULL; 150 151 // Allocate metadata items with same name. 152 metadataItem->items = psListAlloc(NULL); 153 154 // Allocate and set metadata item name 155 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 156 vsprintf(metadataItem->name, name, argPtr); 149 157 150 158 // Set metadata item value 151 159 switch (type) { 152 160 case PS_META_ITEM_SET: 153 metadataItem->data.V = NULL;154 161 break; 155 162 case PS_META_BOOL: … … 180 187 case PS_META_UNKNOWN: 181 188 default: 182 psError(__func__, "Invalid psMetadataType: %d", type); 183 } 184 185 // Allocate and set metadata item name 186 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 187 vsprintf(metadataItem->name, name, argPtr); 188 189 // Allocate metadata items with same name. 190 metadataItem->items = psListAlloc(NULL); 189 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 190 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 191 type); 192 psFree(metadataItem); 193 metadataItem = NULL; 194 } 191 195 192 196 return metadataItem; … … 224 228 psMetadataType newType = PS_META_ITEM_SET; 225 229 226 if(md == NULL) { 227 psError( __func__, "Null metadata collection not allowed" ); 228 return false; 229 } 230 231 if(metadataItem == NULL) { 232 psError( __func__, "Null metadata item not allowed" ); 233 return false; 234 } 230 PS_PTR_CHECK_NULL(md,NULL); 231 PS_PTR_CHECK_NULL(md->table,NULL); 232 PS_PTR_CHECK_NULL(md->list,NULL); 233 PS_PTR_CHECK_NULL(metadataItem,NULL); 234 PS_PTR_CHECK_NULL(metadataItem->name,NULL); 235 235 236 236 newType = metadataItem->type; 237 238 237 mdTable = md->table; 239 if(mdTable == NULL) {240 psError( __func__, "Null metadata table not allowed" );241 return false;242 }243 244 238 mdList = md->list; 245 if(mdList == NULL) {246 psError( __func__, "Null metadata list not allowed");247 return false;248 }249 250 239 key = metadataItem->name; 251 if(key == NULL) {252 psError(__func__, "Null key item not allowed");253 return false;254 }255 240 256 241 // See if key is already in table … … 262 247 // Add leaf node to existing folder node 263 248 if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) { 264 psError( __func__, "Couldn't add metadata item to items list. Name: %s", 265 metadataItem->name ); 249 psError(PS_ERR_UNKNOWN,false, 250 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 251 metadataItem->name ); 266 252 return false; 267 253 } … … 272 258 273 259 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) { 274 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 260 psError(PS_ERR_UNKNOWN,false, 261 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 262 key); 275 263 psFree(newFolderEntry); 276 264 return false; … … 278 266 279 267 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) { 280 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 268 psError(PS_ERR_UNKNOWN,false, 269 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 270 key); 281 271 psFree(newFolderEntry); 282 272 return false; … … 284 274 285 275 if(!psHashRemove(mdTable, key)) { 286 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 276 psError(PS_ERR_UNKNOWN,false, 277 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 278 key); 287 279 psFree(newFolderEntry); 288 280 return false; … … 290 282 291 283 if(!psHashAdd(mdTable, key, newFolderEntry)) { 292 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 284 psError(PS_ERR_UNKNOWN,false, 285 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 286 key); 293 287 psFree(newFolderEntry); 294 288 return false; … … 301 295 // Folder node replaces leaf or folder node - Put old node into new folder and remove from table 302 296 if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) { 303 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 297 psError(PS_ERR_UNKNOWN,false, 298 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 299 key); 304 300 return false; 305 301 } 306 302 307 303 if(!psHashRemove(mdTable, key)) { 308 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 304 psError(PS_ERR_UNKNOWN,false, 305 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 306 key); 309 307 return false; 310 308 } 311 309 312 310 if(!psHashAdd(mdTable, key, metadataItem)) { 313 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 311 psError(PS_ERR_UNKNOWN,false, 312 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 313 key); 314 314 return false; 315 315 } … … 319 319 // Node doesn't exist - Add new metadata item to metadata collection's hash 320 320 if(!psHashAdd(mdTable, key, metadataItem)) { 321 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 321 psError(PS_ERR_UNKNOWN,false, 322 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 323 key); 322 324 return false; 323 325 } … … 328 330 if(metadataItem->type != PS_META_ITEM_SET) { 329 331 if(!psListAdd(mdList, location, metadataItem)) { 330 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s", 331 metadataItem->name ); 332 psError(PS_ERR_UNKNOWN,false, 333 PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED, 334 key); 332 335 return false; 333 336 } … … 348 351 349 352 if (!psMetadataAddItem(md, metadataItem, where)) { 350 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",351 metadataItem->name);353 psError(PS_ERR_UNKNOWN,false, 354 PS_ERRORTEXT_psMetadata_ADD_FAILED); 352 355 psFree(metadataItem); 353 356 return false; … … 368 371 369 372 370 if (md == NULL) { 371 psError(__func__, "Null metadata collection not allowed"); 372 return false; 373 } 373 PS_PTR_CHECK_NULL(md,NULL); 374 PS_PTR_CHECK_NULL(md->table,NULL); 375 PS_PTR_CHECK_NULL(md->list,NULL); 374 376 375 377 mdList = md->list; 376 if (mdList == NULL) {377 psError(__func__, "Null metadata list not allowed");378 return false;379 }380 381 378 mdTable = md->table; 382 if (mdTable == NULL) { 383 psError(__func__, "Null metadata table not allowed"); 384 return false; 385 } 379 386 380 // Select removal by key or index 387 381 if (key != NULL) { … … 390 384 entry = (psMetadataItem* ) psHashLookup(mdTable, key); 391 385 if (entry == NULL) { 392 psError(__func__, "Couldn't find metadata item. Name: %s", key); 386 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 387 PS_ERRORTEXT_psMetadata_FIND_FAILED, 388 key); 393 389 return false; 394 390 } … … 402 398 while (entryChild != NULL) { 403 399 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) { 404 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 400 psError(PS_ERR_UNKNOWN,false, 401 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 402 key); 405 403 return false; 406 404 } … … 411 409 // Table entry has no children. Remove entry from metadata collection's list 412 410 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) { 413 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 411 psError(PS_ERR_UNKNOWN,false, 412 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 413 key); 414 414 return false; 415 415 } … … 417 417 // Remove entry from metadata collection's table 418 418 if (!psHashRemove(mdTable, key)) { 419 psError(__func__, "Couldn't remove metadata item from table. Name: %s", key); 419 psError(PS_ERR_UNKNOWN,false, 420 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 421 key); 420 422 return false; 421 423 } … … 425 427 entry = psListGet(mdList, where); 426 428 if (entry == NULL) { 427 psError(__func__, "Couldn't find metadata item in list. Index: %d", where); 429 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 430 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 431 where); 428 432 return false; 429 433 } … … 431 435 key = entry->name; 432 436 if (key == NULL) { 433 psError(__func__, "Null key name not allowed. Index: %d", where); 437 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 438 PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED, 439 where); 434 440 return false; 435 441 } … … 447 453 448 454 449 if (md == NULL) { 450 psError(__func__, "Null metadata collection not allowed"); 451 return NULL; 452 } 455 PS_PTR_CHECK_NULL(md,NULL); 456 PS_PTR_CHECK_NULL(md->table,NULL); 457 PS_PTR_CHECK_NULL(key,NULL); 453 458 454 459 mdTable = md->table; 455 if (mdTable == NULL) {456 psError(__func__, "Null metadata table not allowed");457 return NULL;458 }459 460 if (key == NULL) {461 psError(__func__, "Null key name not allowed");462 return NULL;463 }464 460 465 461 entry = (psMetadataItem* ) psHashLookup(mdTable, key); … … 473 469 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where) 474 470 { 471 psMetadataItem* entry = NULL; 472 473 PS_PTR_CHECK_NULL(md,NULL); 474 PS_PTR_CHECK_NULL(md->list,NULL); 475 476 entry = (psMetadataItem* ) psListGet(md->list, where); 477 if (entry == NULL) { 478 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 479 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 480 where); 481 return NULL; 482 } 483 484 return entry; 485 } 486 487 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where) 488 { 489 PS_PTR_CHECK_NULL(md,NULL); 490 PS_PTR_CHECK_NULL(md->list,NULL); 491 492 psListSetIterator(md->list, where); 493 494 return true; 495 } 496 497 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which) 498 { 475 499 psList* mdList = NULL; 476 500 psMetadataItem* entry = NULL; 477 501 478 502 479 if (md == NULL) { 480 psError(__func__, "Null metadata collection not allowed"); 481 return NULL; 482 } 503 PS_PTR_CHECK_NULL(md,NULL); 504 PS_PTR_CHECK_NULL(md->list,NULL); 483 505 484 506 mdList = md->list; 485 if (mdList == NULL) {486 psError(__func__, "Null metadata list not allowed");487 return NULL;488 }489 490 entry = (psMetadataItem* ) psListGet(mdList, where);491 if (entry == NULL) {492 psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);493 return NULL;494 }495 496 return entry;497 }498 499 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)500 {501 psList* mdList = NULL;502 503 if (md == NULL) {504 psError(__func__, "Null metadata collection not allowed");505 return false;506 }507 508 mdList = md->list;509 if (mdList == NULL) {510 psError(__func__, "Null metadata list not allowed");511 return false;512 }513 514 psListSetIterator(mdList, where);515 516 return true;517 }518 519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)520 {521 psList* mdList = NULL;522 psMetadataItem* entry = NULL;523 524 525 if (md == NULL) {526 psError(__func__, "Null metadata collection not allowed");527 return NULL;528 }529 530 mdList = md->list;531 if (mdList == NULL) {532 psError(__func__, "Null metadata list not allowed");533 return NULL;534 }535 507 536 508 psListSetIterator(mdList, which); … … 559 531 560 532 561 if (md == NULL) { 562 psError(__func__, "Null metadata collection not allowed"); 563 return NULL; 564 } 533 PS_PTR_CHECK_NULL(md,NULL); 534 PS_PTR_CHECK_NULL(md->list,NULL); 565 535 566 536 mdList = md->list; 567 if (mdList == NULL) {568 psError(__func__, "Null metadata list not allowed");569 return NULL;570 }571 537 572 538 psListSetIterator(mdList, which); -
trunk/psLib/src/astronomy/psMetadataIO.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 fits_get_errstatus(status, fitsErr); \ 45 psError( __func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \47 psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *status = 1; 283 psError(__func__, "Invalid type: %d", elemType); 285 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 286 PS_ERRORTEXT_psMetadataIO_TYPE_INVALID, 287 elemType); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 304 if (fd == NULL) { 305 psError(__func__, "Null file descriptor not allowed"); 306 return; 307 } 308 309 if (format == NULL) { 310 psError(__func__, "Null format not allowed"); 311 return; 312 } 313 314 if (metadataItem == NULL) { 315 psError(__func__, "Null metadata not allowed"); 316 return; 317 } 308 PS_PTR_CHECK_NULL(fd,); 309 PS_PTR_CHECK_NULL(format,); 310 PS_PTR_CHECK_NULL(metadataItem,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 default: 338 psError(__func__, " Invalid psMetadataType to print: %d", type); 331 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 332 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 333 (int)type); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 371 if (extName == NULL && extNum == 0) { 372 psError(__func__, "Null extName and extNum = 0 not allowed"); 373 return NULL; 374 } else if (extName && (extNum != -1) ) { 375 psError(__func__, "If extName specified, extNum arguments should be -1."); 363 if (extName == NULL && extNum < 1) { 364 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 365 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE, 366 extNum); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 if (!success) { 442 psError(__func__, "Failed to add metadata item. Name: %s", keyName); 435 psError(PS_ERR_UNKNOWN, false, 436 PS_ERRORTEXT_psMetadataIO_ADD_FAILED, 437 keyName); 443 438 return output; 444 439 } … … 471 466 472 467 // Check for nulls 473 if(fileName == NULL) {474 psError(__func__, "Null fileName not allowed");475 return -1;476 } else if((fp=fopen(fileName, "r")) == NULL) {477 psError(__func__, "Couldn't open file. Name: %s",fileName);468 PS_PTR_CHECK_NULL(fileName,-1); 469 if((fp=fopen(fileName, "r")) == NULL) { 470 psError(PS_ERR_IO, true, 471 PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, 472 fileName); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 failedLines++; 506 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 498 psError(PS_ERR_IO, true, 499 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 500 '@', lineCount, fileName); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 failedLines++; 510 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line); 504 psError(PS_ERR_IO, true, 505 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 506 '*', lineCount, fileName); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 failedLines++; 514 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 510 psError(PS_ERR_IO, true, 511 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 512 '~', lineCount, fileName); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 status = 0; 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 521 psError(PS_ERR_IO, true, 522 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 523 "name",lineCount, fileName); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 status = 0; 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 532 psError(PS_ERR_IO, true, 533 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 534 "type",lineCount, fileName); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 failedLines++; 553 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line); 555 psError(PS_ERR_IO, true, 556 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 557 strType, lineCount, fileName); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 status = 0; 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 571 psError(PS_ERR_IO, true, 572 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 573 "value",lineCount, fileName); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 583 psError(PS_ERR_IO, true, 584 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 585 "comment",lineCount, fileName); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 failedLines++; 591 psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName, 592 lineCount, line); 599 psError(PS_ERR_IO, true, 600 PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, 601 strName, lineCount, fileName); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 failedLines++; 610 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 619 psError(PS_ERR_IO, true, 620 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 621 strValue, strName, strType, lineCount, fileName); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 failedLines++; 621 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 632 psError(PS_ERR_IO, true, 633 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 634 strValue, strName, strType, lineCount, fileName); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 failedLines++; 633 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 646 psError(PS_ERR_IO, true, 647 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 648 strValue, strName, strType, lineCount, fileName); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 failedLines++; 647 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 662 psError(PS_ERR_IO, true, 663 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 664 strValue, strName, strType, lineCount, fileName); 648 665 continue; 649 666 } … … 651 668 default: 652 669 failedLines++; 653 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line); 670 psError(PS_ERR_IO, true, 671 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 672 mdType, lineCount, fileName); 654 673 continue; 655 674 } // switch -
trunk/psLib/src/astronomy/psTime.c
r2204 r2273 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:30$13 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psMetadata.h" 32 32 #include "psMetadataIO.h" 33 33 #include "psConstants.h" 34 34 #include "psAstronomyErrors.h" 35 35 … … 151 151 char line[LINESIZE]; 152 152 psS32 j = 0; 153 psS32 maxLines = 100 ;153 psS32 maxLines = 1000; 154 154 psF64 *ptr = NULL; 155 155 psImage *table = NULL; … … 159 159 fd=fopen(fileName, "r"); 160 160 if(fd==NULL) { 161 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName); 161 psError(PS_ERR_IO,true, 162 PS_ERRORTEXT_psTime_FILE_NOT_FOUND, 163 fileName,"Tai-Utc"); 162 164 return NULL; 163 165 } … … 168 170 while(fgets(line, LINESIZE, fd) != NULL) { 169 171 if(j>=maxLines) { 170 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines); 172 psError(PS_ERR_IO,true, 173 PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS, 174 fileName,maxLines); 171 175 return NULL; 172 176 psFree(table); … … 201 205 fd=fopen(fileName, "r"); 202 206 if(fd==NULL) { 203 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName); 207 psError(PS_ERR_IO,true, 208 PS_ERRORTEXT_psTime_FILE_NOT_FOUND, 209 fileName,"Ser7"); 204 210 return NULL ; 205 211 } … … 218 224 219 225 if(j>=maxLines) { 220 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines); 226 psError(PS_ERR_IO,true, 227 PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS, 228 fileName,maxLines); 221 229 return NULL; 222 230 psFree(table); … … 240 248 } 241 249 242 /* Not yet used...243 static psImage* readEopcFile(char *fileName)244 {245 char line[LINESIZE];246 psS32 i = 0;247 psS32 j = 0;248 psS32 maxLines = 2500;249 psImage *table = NULL;250 FILE *fd = NULL;251 252 253 fd=fopen(fileName, "r");254 if(fd==NULL) {255 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);256 return NULL ;257 }258 259 // Table shouldn't be larger than 2500 rows. All columns are read.260 table = psImageAlloc(11, maxLines, PS_TYPE_F64);261 for(i=0; i<3; i++) {262 if((fgets(line, LINESIZE, fd) != NULL)) {263 psError(__func__, " : Line %d - Error reading %s", __LINE__, fileName);264 }265 }266 267 while(fgets(line, LINESIZE, fd) != NULL) {268 if(j>=maxLines) {269 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);270 return NULL;271 psFree(table);272 }273 psF64 *ptr = table->data.F64[j++];274 sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",275 ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10);276 }277 278 *(psU32 *)&table->numRows = j;279 280 return table;281 }282 283 static psImage* readFinalsFile(char *fileName)284 {285 char line[LINESIZE];286 psS32 j = 0;287 psS32 maxLines = 15000;288 psImage *table = NULL;289 FILE *fd = NULL;290 291 292 fd=fopen(fileName, "r");293 if(fd==NULL) {294 psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);295 return NULL ;296 }297 298 // Table shouldn't be larger than 15000 rows. Select columns are read.299 table = psImageAlloc(6, maxLines, PS_TYPE_F64);300 while(fgets(line, LINESIZE, fd) != NULL) {301 if(j>=maxLines) {302 psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);303 return NULL;304 psFree(table);305 }306 307 psF64 *ptr = table->data.F64[j++];308 ptr = table->data.F64[j++];309 310 // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry311 if(*(line+7) == ' ') { // MJD312 *ptr = 0.0;313 } else {314 *ptr = atof(line+7);315 }316 317 if(*(line+18) == ' ') { // Polar motion X318 *(ptr+1) = 0.0;319 } else {320 *(ptr+1) = atof(line+18);321 }322 323 if(*(line+27) == ' ') { // Polar motion X error324 *(ptr+2) = 0.0;325 } else {326 *(ptr+2) = atof(line+27);327 }328 329 if(*(line+37) == ' ') { // Polar motion Y330 *(ptr+3) = 0.0;331 } else {332 *(ptr+3) = atof(line+37);333 }334 335 if(*(line+46) == ' ') { // Polar motion Y error336 *(ptr+4) = 0.0;337 } else {338 *(ptr+4) = atof(line+46);339 }340 341 if(*(line+58) == ' ') { // UT1-UTC342 *(ptr+5) = 0.0;343 } else {344 *(ptr+5) = atof(line+58);345 }346 }347 348 *(psU32 *)&table->numRows = j;349 350 return table;351 }352 */353 250 354 251 static double lookupTaiUtcTable(const psTime *time) … … 389 286 hiIdx++; 390 287 if(hiIdx >= numRows) { 391 psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx); 288 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 289 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 290 jd, "TAI-UTC"); 392 291 return 0.0; 393 292 } … … 395 294 loIdx = hiIdx--; 396 295 if(loIdx < 0) { 397 psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx); 296 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 297 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 298 jd, "TAI-UTC"); 398 299 return 0.0; 399 300 } 400 301 302 // since rows of table can not have same jd, this check is probably not needed. 401 303 denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0]; 402 304 if(fabs(denom) < FLT_EPSILON) { 403 psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__); 305 psError(PS_ERR_UNKNOWN,true, 306 PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS 307 "Ser7"); 404 308 return 0.0; 405 309 } else { 406 407 310 // Interpolate three constants required to calculate TAI-UTC 408 311 const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1]) … … 445 348 mjdUtc = psTimeToMJD(time); 446 349 if(mjdUtc < table->data.F64[0][3]) { // MJD time before start of table 447 psError(__func__, " : Line %d - MJD too small. Value: %d", __LINE__, mjdUtc); 350 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 351 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 352 mjdUtc, "Ser7"); 448 353 449 354 } else if(mjdUtc > table->data.F64[numRows-1][3]) { // MJD time after end of table 450 psError(__func__, " : Line %d - MJD too big. Value: %d", __LINE__, mjdUtc); 355 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 356 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 357 mjdUtc, "Ser7"); 451 358 } else { // All other times..interpolate 452 359 while(mjdUtc > table->data.F64[hiIdx][3]) { 453 360 hiIdx++; 454 361 if(hiIdx >= numRows) { 455 psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx); 362 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 363 PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE, 364 mjdUtc, "Ser7"); 456 365 return 0.0; 457 366 } … … 460 369 loIdx = hiIdx--; 461 370 if(loIdx < 0) { 462 psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx); 371 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 372 PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE, 373 mjdUtc, "Ser7"); 463 374 } 464 375 465 376 denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3]; 466 377 if(fabs(denom) < FLT_EPSILON) { 467 psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__); 378 psError(PS_ERR_UNKNOWN,true, 379 PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS, 380 "Ser7"); 468 381 } else { 469 382 out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col]) … … 525 438 // Error checks 526 439 if(type!=PS_TIME_TAI && type!=PS_TIME_UTC) { 527 psError(__func__, " : Line %d - Incorrect type. Type: %d", __LINE__, type); 440 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 441 PS_ERRORTEXT_psTime_TYPE_UNKNOWN, 442 type); 528 443 return NULL; 529 444 } 530 445 531 446 outTime = (psTime*)psAlloc(sizeof(psTime)); 532 if(outTime == NULL) {533 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);534 }535 447 536 448 outTime->sec = 0; … … 551 463 552 464 if (gettimeofday(&now, (struct timezone *)0) == -1) { 553 psError(__func__, " : Line %d - Failed to get time", __LINE__); 465 psError(PS_ERR_OS_CALL_FAILED, true, 466 PS_ERRORTEXT_psTime_GET_TOD_FAILED); 554 467 return NULL; 555 468 } … … 573 486 574 487 // Error checks 575 if(time == NULL) { 576 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 577 return NULL; 578 } else if(time->usec >= 1e6) { 579 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 580 return NULL; 581 } else if(time->type == type) { 582 psError(__func__, " : Line %d - Time already in correct psTime type. Time type: %d", __LINE__, type); 583 return NULL; 488 PS_PTR_CHECK_NULL(time,NULL); 489 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 490 491 if (time->type == type) { // time already right type. That was easy! 492 return time; 584 493 } 585 494 586 495 delta = psTimeGetTAIDelta(time); 587 496 588 if (type == PS_TIME_UTC) {497 if (type == PS_TIME_UTC) { 589 498 time->sec = time->sec - delta; // User wants UTC time. Subtract leapseconds. 590 499 } else if(type == PS_TIME_TAI) { 591 500 time->sec = time->sec + delta; // User wants TAI time. Add leapseconds. 592 501 } else { 593 psError(__func__, " : Line %d - Invalid psTimeType: %d", __LINE__, type); 502 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 503 PS_ERRORTEXT_psTime_TYPE_UNKNOWN, 504 type); 594 505 } 595 506 … … 623 534 624 535 // Error checks 625 if(time == NULL) { 626 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 627 return 0; 628 } else if(time->usec >= 1e6) { 629 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 630 return 0; 631 } 536 PS_PTR_CHECK_NULL(time,NAN); 537 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 632 538 633 539 // Calculate TAI or UTC time based on type of time user passes … … 698 604 699 605 // Error checks 700 if(time == NULL) { 701 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 702 return 0.0; 703 } else if(time->usec >= 1e6) { 704 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 705 return 0.0; 706 } 606 PS_PTR_CHECK_NULL(time,NAN); 607 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 707 608 708 609 return lookupSer7Table(time, 6); … … 717 618 718 619 // Error checks 719 if(time == NULL) 720 { 721 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 722 return NULL; 723 } else if(time->usec >= 1e6) 724 { 725 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 726 return NULL; 727 } 620 PS_PTR_CHECK_NULL(time,NULL); 621 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 728 622 729 623 x = lookupSer7Table((psTime*)time, 4); … … 741 635 742 636 // Error checks 743 if(time == NULL) { 744 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 745 return 0.0; 746 } else if(time->usec >= 1e6) { 747 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 748 return 0.0; 749 } 637 PS_PTR_CHECK_NULL(time,NAN); 638 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 750 639 751 640 return lookupTaiUtcTable(time); … … 758 647 759 648 // Error checks 760 if(time1 == NULL) { 761 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 762 return 0; 763 } else if(time1->usec >= 1e6) { 764 psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time1->usec); 765 return 0; 766 } else if(time2 == NULL) { 767 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 768 return 0; 769 } else if(time2->usec >= 1e6) { 770 psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time2->usec); 771 return 0; 772 } 649 PS_PTR_CHECK_NULL(time1,0); 650 PS_PTR_CHECK_NULL(time2,0); 651 PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0); 652 PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0); 773 653 774 654 diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2)); … … 781 661 double jd = 0.0; 782 662 783 784 // Error checks 785 if(time == NULL) { 786 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 787 return 0.0; 788 } else if(time->usec >= 1e6) { 789 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 790 return 0.0; 791 } 663 // Error checks 664 PS_PTR_CHECK_NULL(time,NAN); 665 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 792 666 793 667 // Julian date conversion … … 807 681 808 682 // Error checks 809 if(time == NULL) { 810 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 811 return 0.0; 812 } else if(time->usec >= 1e6) { 813 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 814 return 0.0; 815 } 683 PS_PTR_CHECK_NULL(time,NAN); 684 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN); 816 685 817 686 // Modified Julian date conversion … … 835 704 836 705 // Error checks 837 if(time == NULL) { 838 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 839 return NULL; 840 } else if(time->usec >= 1e6) { 841 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 842 return NULL; 843 } 706 PS_PTR_CHECK_NULL(time,NULL); 707 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 844 708 845 709 tempString = psAlloc(MAX_TIME_STRING_LENGTH); … … 854 718 // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form 855 719 if (!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y-%m-%dT%H:%M:%S", tmTime)) { 856 psError(__func__, " : Line %d - Failed strftime conversion", __LINE__); 720 psError(PS_ERR_OS_CALL_FAILED, true, 721 PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED); 857 722 } 858 723 859 724 if (snprintf(timeString, MAX_TIME_STRING_LENGTH, "%s.%3.3dZ", tempString, ms) < 0) { 860 psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__); 725 psError(PS_ERR_OS_CALL_FAILED, true, 726 PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED); 861 727 } 862 728 psFree(tempString); … … 869 735 struct timeval timevalTime; 870 736 871 872 // Error checks 873 if(time == NULL) 874 { 875 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 876 return timevalTime; 877 } else if(time->usec >= 1e6) 878 { 879 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 880 return timevalTime; 881 } 737 timevalTime.tv_sec = 0; 738 timevalTime.tv_usec = 0; 739 740 // Error checks 741 PS_PTR_CHECK_NULL(time,timevalTime); 742 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime); 882 743 883 744 timevalTime.tv_sec = time->sec; … … 901 762 902 763 // Error checks 903 if(time == NULL) 904 { 905 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 906 return NULL; 907 } else if(time->usec >= 1e6) 908 { 909 psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec); 910 return NULL; 911 } 764 PS_PTR_CHECK_NULL(time,NULL); 765 PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL); 912 766 913 767 seconds = time->sec%60; … … 945 799 // Allocate output 946 800 tmTime = (struct tm*)psAlloc(sizeof(struct tm)); 947 if (tmTime == NULL)948 {949 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);950 }951 801 952 802 tmTime->tm_year = year - 1900; … … 982 832 983 833 // Error check 984 if(outTime->usec >= 1e6) { 985 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 986 } 834 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 987 835 988 836 return outTime; … … 1010 858 1011 859 // Error check 1012 if(outTime->usec >= 1e6) { 1013 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1014 } 860 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1015 861 1016 862 return outTime; … … 1020 866 { 1021 867 char tempString[MAX_TIME_STRING_LENGTH]; 1022 psS32 month;1023 psS32 day;1024 psS32 year;1025 psS32 hour;1026 psS32 minute;1027 psS32 second;1028 868 psS32 millisecond; 1029 869 struct tm tmTime; 1030 870 psTime *outTime = NULL; 1031 871 1032 1033 // Preserve input string by creating duplicate1034 strncpy(tempString, time, MAX_TIME_STRING_LENGTH);1035 1036 872 // Convert YYYY-MM-DDThh:mm:ss.sss in string form to tm time 1037 year = atoi(strtok(tempString, "-")); 1038 if (year < 0) { 1039 psError(__func__, "Years less than 0 not allowed. Value: %d", year); 1040 return outTime; 1041 } 1042 1043 month = atoi(strtok(NULL, "-")); 1044 if (month < 1 || month > 12) { 1045 psError(__func__, "Month must have a value from 1 to 12. Value: %d", month); 1046 return outTime; 1047 } 1048 1049 day = atoi(strtok(NULL, "T")); 1050 if (day < 1 || day > 31) { 1051 psError(__func__, "Day must have a value from 1 to 31. Value: %d", day); 1052 return outTime; 1053 } 1054 1055 hour = atoi(strtok(NULL, ":")); 1056 if (hour < 0 || hour > 23) { 1057 psError(__func__, "Hour must have a value from 0 to 23. Value: %d", hour); 1058 return outTime; 1059 } 1060 1061 minute = atoi(strtok(NULL, ":")); 1062 if (minute < 0 || minute > 59) { 1063 psError(__func__, "Minute must have a value from 0 to 59. Value: %d", minute); 1064 return outTime; 1065 } 1066 1067 second = atoi(strtok(NULL, ".")); 1068 if (second < 0 || second > 59) { 1069 psError(__func__, "Second must have a value from 0 to 59. Value: %d", second); 1070 return outTime; 1071 } 1072 1073 millisecond = atoi(strtok(NULL, "Z")); 1074 if (millisecond < 0 || millisecond > 1000) { 1075 psError(__func__, "Millisecond must have a value from 0 to 999. Value: %d", millisecond); 1076 return outTime; 1077 } 1078 1079 tmTime.tm_year = year - 1900; 1080 tmTime.tm_mon = month - 1; 1081 tmTime.tm_mday = day; 1082 tmTime.tm_hour = hour; 1083 tmTime.tm_min = minute; 1084 tmTime.tm_sec = second; 873 if (sscanf(time, "%d-%d-%dT%d:%d:%d.%d", 874 &tmTime.tm_year,&tmTime.tm_mon,&tmTime.tm_mday, 875 &tmTime.tm_hour,&tmTime.tm_min,&tmTime.tm_sec,&millisecond) < 7) { 876 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 877 PS_ERRORTEXT_psTime_ISOTIME_MALFORMED, 878 time); 879 return NULL; 880 } 881 882 PS_INT_CHECK_NON_NEGATIVE(tmTime.tm_year, outTime); 883 PS_INT_CHECK_RANGE(tmTime.tm_mon,1,12,outTime); 884 PS_INT_CHECK_RANGE(tmTime.tm_mday,1,31,outTime); 885 PS_INT_CHECK_RANGE(tmTime.tm_hour,0,23,outTime); 886 PS_INT_CHECK_RANGE(tmTime.tm_min,0,59,outTime); 887 PS_INT_CHECK_RANGE(tmTime.tm_sec,0,59,outTime); 888 PS_INT_CHECK_RANGE(millisecond,0,999,outTime); 889 890 tmTime.tm_year -= 1900; 891 tmTime.tm_mon--; 1085 892 tmTime.tm_isdst = -1; 1086 893 … … 1089 896 outTime->usec = millisecond * 1000; 1090 897 898 return outTime; 899 } 900 901 psTime* psTimeFromTimeval(const struct timeval *time) 902 { 903 psTime *outTime = NULL; 904 905 1091 906 // Error check 1092 if(outTime->usec >= 1e6) { 1093 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1094 } 1095 1096 return outTime; 1097 } 1098 1099 psTime* psTimeFromTimeval(const struct timeval *time) 1100 { 1101 psTime *outTime = NULL; 1102 1103 1104 // Error check 1105 if(time == NULL) 1106 { 1107 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 1108 return NULL; 1109 } 907 PS_PTR_CHECK_NULL(time,NULL); 1110 908 1111 909 // Allocate psTime struct … … 1117 915 1118 916 // Error check 1119 if(outTime->usec >= 1e6) 1120 { 1121 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1122 } 917 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1123 918 1124 919 return outTime; … … 1138 933 1139 934 // Error check 1140 if(time == NULL) 1141 { 1142 psError(__func__, " : Line %d - NULL value not allowed", __LINE__); 1143 return NULL; 1144 } 935 PS_PTR_CHECK_NULL(time,NULL); 1145 936 1146 937 // Allocate psTime struct … … 1183 974 1184 975 // Error check 1185 if(outTime->usec >= 1e6) 1186 { 1187 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1188 } 976 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1189 977 1190 978 return outTime; … … 1199 987 1200 988 // Error checks 989 PS_PTR_CHECK_NULL(tai1,NULL); 990 PS_PTR_CHECK_NULL(tai2,NULL); 991 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 992 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 993 1201 994 if(tai1->type != tai2->type) { 1202 psError(__func__, " : Line %d - Argument types inconsistent for time addition", __LINE__); 1203 return NULL; 1204 } else if(tai1 == NULL) { 1205 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1206 return NULL; 1207 } else if(tai1->usec >= 1e6) { 1208 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1209 return NULL; 1210 } else if(tai2 == NULL) { 1211 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1212 return NULL; 1213 } else if(tai2->usec >= 1e6) { 1214 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 995 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 996 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1215 997 return NULL; 1216 998 } … … 1233 1015 1234 1016 // Error check 1235 if(outTime->usec >= 1e6) { 1236 psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec); 1237 } 1017 PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime); 1238 1018 1239 1019 return outTime; … … 1248 1028 1249 1029 // Error checks 1030 PS_PTR_CHECK_NULL(tai1,NULL); 1031 PS_PTR_CHECK_NULL(tai2,NULL); 1032 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 1033 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 1250 1034 if(tai1->type != tai2->type) { 1251 psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__); 1252 return NULL; 1253 } else if(tai1 == NULL) { 1254 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1255 return NULL; 1256 } else if(tai1->usec >= 1e6) { 1257 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1258 return NULL; 1259 } else if(tai2 == NULL) { 1260 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1261 return NULL; 1262 } else if(tai2->usec >= 1e6) { 1263 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 1035 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1036 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1264 1037 return NULL; 1265 1038 } … … 1294 1067 1295 1068 // Error checks 1069 // Error checks 1070 PS_PTR_CHECK_NULL(tai1,NULL); 1071 PS_PTR_CHECK_NULL(tai2,NULL); 1072 PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL); 1073 PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL); 1296 1074 if(tai1->type != tai2->type) { 1297 psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__); 1298 return NULL; 1299 } else if(tai1 == NULL) { 1300 psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__); 1301 return NULL; 1302 } else if(tai1->usec >= 1e6) { 1303 psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec); 1304 return NULL; 1305 } else if(tai2 == NULL) { 1306 psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__); 1307 return NULL; 1308 } else if(tai2->usec >= 1e6) { 1309 psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec); 1075 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1076 PS_ERRORTEXT_psTime_TYPE_MISMATCH); 1310 1077 return NULL; 1311 1078 } -
trunk/psLib/src/collections/psBitSet.c
r2204 r2273 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 72 72 73 73 if (n < 0) { 74 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc", 75 PS_ERR_BAD_PARAMETER_VALUE, true, 76 PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE, 77 n); 74 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 75 PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE, 76 n); 78 77 return NULL; 79 78 } … … 99 98 100 99 if (inBitSet == NULL) { 101 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet", 102 PS_ERR_BAD_PARAMETER_NULL, true, 103 PS_ERRORTEXT_psBitSet_SET_NULL); 100 psError(PS_ERR_BAD_PARAMETER_NULL, true, 101 PS_ERRORTEXT_psBitSet_SET_NULL); 104 102 return inBitSet; 105 103 } else if ( (bit < 0) || 106 104 (bit > inBitSet->n * 8 - 1) ) { 107 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet", 108 PS_ERR_BAD_PARAMETER_VALUE, true, 109 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 110 bit,inBitSet->n * 8 - 1); 105 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 106 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 107 bit,inBitSet->n * 8 - 1); 111 108 return inBitSet; 112 109 } … … 124 121 125 122 if (inBitSet == NULL) { 126 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear", 127 PS_ERR_BAD_PARAMETER_NULL, true, 128 PS_ERRORTEXT_psBitSet_SET_NULL); 123 psError(PS_ERR_BAD_PARAMETER_NULL, true, 124 PS_ERRORTEXT_psBitSet_SET_NULL); 129 125 return inBitSet; 130 126 } else if ( (bit < 0) || 131 127 (bit > inBitSet->n * 8 - 1) ) { 132 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear", 133 PS_ERR_BAD_PARAMETER_VALUE, true, 134 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 135 bit,inBitSet->n * 8 - 1); 128 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 129 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 130 bit,inBitSet->n * 8 - 1); 136 131 return inBitSet; 137 132 } … … 149 144 150 145 if (inBitSet == NULL) { 151 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest", 152 PS_ERR_BAD_PARAMETER_NULL, true, 153 PS_ERRORTEXT_psBitSet_SET_NULL); 146 psError(PS_ERR_BAD_PARAMETER_NULL, true, 147 PS_ERRORTEXT_psBitSet_SET_NULL); 154 148 return false; 155 149 } else if ( (bit < 0) || 156 150 (bit > inBitSet->n * 8 - 1) ) { 157 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest", 158 PS_ERR_BAD_PARAMETER_VALUE, true, 159 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 160 bit,inBitSet->n * 8 - 1); 151 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 152 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 153 bit,inBitSet->n * 8 - 1); 161 154 return false; 162 155 } … … 180 173 181 174 if (inBitSet1 == NULL) { 182 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 183 PS_ERR_BAD_PARAMETER_NULL, true, 184 PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL); 175 psError(PS_ERR_BAD_PARAMETER_NULL, true, 176 PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL); 185 177 psFree(outBitSet); 186 178 return NULL; … … 189 181 190 182 if (operator == NULL) { 191 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 192 PS_ERR_BAD_PARAMETER_NULL, true, 193 PS_ERRORTEXT_psBitSet_OPERATOR_NULL); 183 psError(PS_ERR_BAD_PARAMETER_NULL, true, 184 PS_ERRORTEXT_psBitSet_OPERATOR_NULL); 194 185 psFree(outBitSet); 195 186 return NULL; … … 217 208 psFree(tempStr); 218 209 psFree(outBitSet); 219 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 220 PS_ERR_BAD_PARAMETER_VALUE, true, 221 PS_ERRORTEXT_psBitSet_OPERATOR_INVALID, 222 operator); 210 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 211 PS_ERRORTEXT_psBitSet_OPERATOR_INVALID, 212 operator); 223 213 return NULL; 224 214 } … … 227 217 if (op != NOT_OP) { 228 218 if (inBitSet2 == NULL) { 229 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 230 PS_ERR_BAD_PARAMETER_NULL, true, 231 PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL); 219 psError(PS_ERR_BAD_PARAMETER_NULL, true, 220 PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL); 232 221 psFree(outBitSet); 233 222 return NULL; … … 235 224 236 225 if (inBitSet1->n != inBitSet2->n) { 237 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 238 PS_ERR_BAD_PARAMETER_SIZE, true, 239 PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER); 226 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 227 PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER); 240 228 psFree(outBitSet); 241 229 return NULL; … … 287 275 { 288 276 if (inBitSet == NULL) { 289 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot", 290 PS_ERR_BAD_PARAMETER_NULL, true, 291 PS_ERRORTEXT_psBitSet_OPERAND_NULL); 277 psError(PS_ERR_BAD_PARAMETER_NULL, true, 278 PS_ERRORTEXT_psBitSet_OPERAND_NULL); 292 279 psFree(outBitSet); 293 280 return NULL; … … 297 284 298 285 if (outBitSet == NULL) { 299 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot", 300 PS_ERR_UNKNOWN, false, 301 PS_ERRORTEXT_psBitSet_NOT_OP_FAILED); 286 psError(PS_ERR_UNKNOWN, false, 287 PS_ERRORTEXT_psBitSet_NOT_OP_FAILED); 302 288 } 303 289 -
trunk/psLib/src/collections/psHash.c
r2221 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 23:31:43$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 // the way this procedure is called. 229 229 if ((table == NULL) || (key == NULL)) { 230 psErrorMsg(PS_ERRORNAME_DOMAIN "doHashWork", 231 PS_ERR_BAD_PARAMETER_NULL, true, 232 PS_ERRORTEXT_psHash_KEY_NULL); 230 psError(PS_ERR_BAD_PARAMETER_NULL, true, 231 PS_ERRORTEXT_psHash_KEY_NULL); 233 232 return NULL; 234 233 } … … 249 248 // anyway. 250 249 if ((hash < 0) || (hash >= table->nbucket)) { 251 psError(__func__, "Internal hash function out of range (%d)", hash); 250 psError(PS_ERR_UNKNOWN, true, 251 "Internal hash function out of range (%d)", hash); 252 252 } 253 253 // ptr will have the correct hash bucket. … … 347 347 { 348 348 if (table == NULL) { 349 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 350 PS_ERR_BAD_PARAMETER_NULL, true, 351 PS_ERRORTEXT_psHash_KEY_NULL); 349 psError(PS_ERR_BAD_PARAMETER_NULL, true, 350 PS_ERRORTEXT_psHash_KEY_NULL); 352 351 return false; 353 352 } 354 353 if (key == NULL) { 355 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 356 PS_ERR_BAD_PARAMETER_NULL, true, 357 PS_ERRORTEXT_psHash_TABLE_NULL); 354 psError(PS_ERR_BAD_PARAMETER_NULL, true, 355 PS_ERRORTEXT_psHash_TABLE_NULL); 358 356 return false; 359 357 } 360 358 if (data == NULL) { 361 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 362 PS_ERR_BAD_PARAMETER_NULL, true, 363 PS_ERRORTEXT_psHash_DATA_NULL); 359 psError(PS_ERR_BAD_PARAMETER_NULL, true, 360 PS_ERRORTEXT_psHash_DATA_NULL); 364 361 } 365 362 … … 382 379 { 383 380 if (table == NULL) { 384 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup", 385 PS_ERR_BAD_PARAMETER_NULL, true, 386 PS_ERRORTEXT_psHash_KEY_NULL); 381 psError(PS_ERR_BAD_PARAMETER_NULL, true, 382 PS_ERRORTEXT_psHash_KEY_NULL); 387 383 return NULL; 388 384 } 389 385 if (key == NULL) { 390 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup", 391 PS_ERR_BAD_PARAMETER_NULL, true, 392 PS_ERRORTEXT_psHash_TABLE_NULL); 386 psError(PS_ERR_BAD_PARAMETER_NULL, true, 387 PS_ERRORTEXT_psHash_TABLE_NULL); 393 388 return NULL; 394 389 } … … 414 409 415 410 if (table == NULL) { 416 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove", 417 PS_ERR_BAD_PARAMETER_NULL, true, 418 PS_ERRORTEXT_psHash_TABLE_NULL); 411 psError(PS_ERR_BAD_PARAMETER_NULL, true, 412 PS_ERRORTEXT_psHash_TABLE_NULL); 419 413 return false; 420 414 } 421 415 if (key == NULL) { 422 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove", 423 PS_ERR_BAD_PARAMETER_NULL, true, 424 PS_ERRORTEXT_psHash_KEY_NULL); 416 psError(PS_ERR_BAD_PARAMETER_NULL, true, 417 PS_ERRORTEXT_psHash_KEY_NULL); 425 418 return false; 426 419 } -
trunk/psLib/src/collections/psList.c
r2204 r2273 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:31$8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 136 136 137 137 if (position == NULL) { 138 psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location); 138 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 139 "Failed to move cursor to specified location (%d)", location); 139 140 position = list->head; // since we no list->size != 0, this must be non-NULL 140 141 } … … 173 174 174 175 if (list == NULL) { 175 psError( __func__, "list parameter found to be NULL in %s", __func__);176 psError(PS_ERR_BAD_PARAMETER_NULL, true, "list parameter found to be NULL."); 176 177 return false; 177 178 } … … 194 195 195 196 if (location == PS_LIST_UNKNOWN) { 196 psError( __func__, "Failed to find item in given psList.");197 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Failed to find item in given psList."); 197 198 pthread_mutex_unlock(&list->lock) 198 199 ; … … 206 207 207 208 if (elem == NULL) { 208 psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location); 209 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 210 "Couldn't position to given index (%d) to remove element from list.", location); 209 211 pthread_mutex_unlock(&list->lock) 210 212 ; … … 257 259 258 260 if (list == NULL) { 259 psError(__func__, "Unexpected null pointer for psList parameter (%s:%d).", __FILE__, __LINE__); 261 psError(PS_ERR_BAD_PARAMETER_NULL, true, 262 "Unexpected null pointer for psList parameter."); 260 263 return; 261 264 } … … 314 317 default: 315 318 if (where <= PS_LIST_HEAD) { // bascially same as PS_LIST_UNKNOWN above 316 psError(__func__, "Can't move to an unknown position. Not moving the iterator position."); 319 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 320 "Can't move to an unknown position. Not moving the iterator position."); 317 321 } else { 318 322 cursor = listGetIterator(list); -
trunk/psLib/src/collections/psMetadata.c
r2204 r2273 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:30$14 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:57 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psMetadata.h" 36 36 #include "psString.h" 37 #include "psAstronomyErrors.h" 38 #include "psConstants.h" 37 39 38 40 /******************************************************************************/ … … 123 125 124 126 125 if (name == NULL) { 126 psError(__func__, "Null value for name not allowed"); 127 return NULL; 128 } 127 PS_PTR_CHECK_NULL(name,NULL); 128 129 129 // Allocate metadata item 130 130 metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem)); … … 147 147 // Set metadata item type 148 148 metadataItem->type = type; 149 metadataItem->data.V = NULL; 150 151 // Allocate metadata items with same name. 152 metadataItem->items = psListAlloc(NULL); 153 154 // Allocate and set metadata item name 155 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 156 vsprintf(metadataItem->name, name, argPtr); 149 157 150 158 // Set metadata item value 151 159 switch (type) { 152 160 case PS_META_ITEM_SET: 153 metadataItem->data.V = NULL;154 161 break; 155 162 case PS_META_BOOL: … … 180 187 case PS_META_UNKNOWN: 181 188 default: 182 psError(__func__, "Invalid psMetadataType: %d", type); 183 } 184 185 // Allocate and set metadata item name 186 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 187 vsprintf(metadataItem->name, name, argPtr); 188 189 // Allocate metadata items with same name. 190 metadataItem->items = psListAlloc(NULL); 189 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 190 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 191 type); 192 psFree(metadataItem); 193 metadataItem = NULL; 194 } 191 195 192 196 return metadataItem; … … 224 228 psMetadataType newType = PS_META_ITEM_SET; 225 229 226 if(md == NULL) { 227 psError( __func__, "Null metadata collection not allowed" ); 228 return false; 229 } 230 231 if(metadataItem == NULL) { 232 psError( __func__, "Null metadata item not allowed" ); 233 return false; 234 } 230 PS_PTR_CHECK_NULL(md,NULL); 231 PS_PTR_CHECK_NULL(md->table,NULL); 232 PS_PTR_CHECK_NULL(md->list,NULL); 233 PS_PTR_CHECK_NULL(metadataItem,NULL); 234 PS_PTR_CHECK_NULL(metadataItem->name,NULL); 235 235 236 236 newType = metadataItem->type; 237 238 237 mdTable = md->table; 239 if(mdTable == NULL) {240 psError( __func__, "Null metadata table not allowed" );241 return false;242 }243 244 238 mdList = md->list; 245 if(mdList == NULL) {246 psError( __func__, "Null metadata list not allowed");247 return false;248 }249 250 239 key = metadataItem->name; 251 if(key == NULL) {252 psError(__func__, "Null key item not allowed");253 return false;254 }255 240 256 241 // See if key is already in table … … 262 247 // Add leaf node to existing folder node 263 248 if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) { 264 psError( __func__, "Couldn't add metadata item to items list. Name: %s", 265 metadataItem->name ); 249 psError(PS_ERR_UNKNOWN,false, 250 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 251 metadataItem->name ); 266 252 return false; 267 253 } … … 272 258 273 259 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) { 274 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 260 psError(PS_ERR_UNKNOWN,false, 261 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 262 key); 275 263 psFree(newFolderEntry); 276 264 return false; … … 278 266 279 267 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) { 280 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 268 psError(PS_ERR_UNKNOWN,false, 269 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 270 key); 281 271 psFree(newFolderEntry); 282 272 return false; … … 284 274 285 275 if(!psHashRemove(mdTable, key)) { 286 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 276 psError(PS_ERR_UNKNOWN,false, 277 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 278 key); 287 279 psFree(newFolderEntry); 288 280 return false; … … 290 282 291 283 if(!psHashAdd(mdTable, key, newFolderEntry)) { 292 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 284 psError(PS_ERR_UNKNOWN,false, 285 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 286 key); 293 287 psFree(newFolderEntry); 294 288 return false; … … 301 295 // Folder node replaces leaf or folder node - Put old node into new folder and remove from table 302 296 if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) { 303 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 297 psError(PS_ERR_UNKNOWN,false, 298 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 299 key); 304 300 return false; 305 301 } 306 302 307 303 if(!psHashRemove(mdTable, key)) { 308 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 304 psError(PS_ERR_UNKNOWN,false, 305 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 306 key); 309 307 return false; 310 308 } 311 309 312 310 if(!psHashAdd(mdTable, key, metadataItem)) { 313 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 311 psError(PS_ERR_UNKNOWN,false, 312 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 313 key); 314 314 return false; 315 315 } … … 319 319 // Node doesn't exist - Add new metadata item to metadata collection's hash 320 320 if(!psHashAdd(mdTable, key, metadataItem)) { 321 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 321 psError(PS_ERR_UNKNOWN,false, 322 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 323 key); 322 324 return false; 323 325 } … … 328 330 if(metadataItem->type != PS_META_ITEM_SET) { 329 331 if(!psListAdd(mdList, location, metadataItem)) { 330 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s", 331 metadataItem->name ); 332 psError(PS_ERR_UNKNOWN,false, 333 PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED, 334 key); 332 335 return false; 333 336 } … … 348 351 349 352 if (!psMetadataAddItem(md, metadataItem, where)) { 350 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",351 metadataItem->name);353 psError(PS_ERR_UNKNOWN,false, 354 PS_ERRORTEXT_psMetadata_ADD_FAILED); 352 355 psFree(metadataItem); 353 356 return false; … … 368 371 369 372 370 if (md == NULL) { 371 psError(__func__, "Null metadata collection not allowed"); 372 return false; 373 } 373 PS_PTR_CHECK_NULL(md,NULL); 374 PS_PTR_CHECK_NULL(md->table,NULL); 375 PS_PTR_CHECK_NULL(md->list,NULL); 374 376 375 377 mdList = md->list; 376 if (mdList == NULL) {377 psError(__func__, "Null metadata list not allowed");378 return false;379 }380 381 378 mdTable = md->table; 382 if (mdTable == NULL) { 383 psError(__func__, "Null metadata table not allowed"); 384 return false; 385 } 379 386 380 // Select removal by key or index 387 381 if (key != NULL) { … … 390 384 entry = (psMetadataItem* ) psHashLookup(mdTable, key); 391 385 if (entry == NULL) { 392 psError(__func__, "Couldn't find metadata item. Name: %s", key); 386 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 387 PS_ERRORTEXT_psMetadata_FIND_FAILED, 388 key); 393 389 return false; 394 390 } … … 402 398 while (entryChild != NULL) { 403 399 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) { 404 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 400 psError(PS_ERR_UNKNOWN,false, 401 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 402 key); 405 403 return false; 406 404 } … … 411 409 // Table entry has no children. Remove entry from metadata collection's list 412 410 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) { 413 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 411 psError(PS_ERR_UNKNOWN,false, 412 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 413 key); 414 414 return false; 415 415 } … … 417 417 // Remove entry from metadata collection's table 418 418 if (!psHashRemove(mdTable, key)) { 419 psError(__func__, "Couldn't remove metadata item from table. Name: %s", key); 419 psError(PS_ERR_UNKNOWN,false, 420 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 421 key); 420 422 return false; 421 423 } … … 425 427 entry = psListGet(mdList, where); 426 428 if (entry == NULL) { 427 psError(__func__, "Couldn't find metadata item in list. Index: %d", where); 429 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 430 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 431 where); 428 432 return false; 429 433 } … … 431 435 key = entry->name; 432 436 if (key == NULL) { 433 psError(__func__, "Null key name not allowed. Index: %d", where); 437 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 438 PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED, 439 where); 434 440 return false; 435 441 } … … 447 453 448 454 449 if (md == NULL) { 450 psError(__func__, "Null metadata collection not allowed"); 451 return NULL; 452 } 455 PS_PTR_CHECK_NULL(md,NULL); 456 PS_PTR_CHECK_NULL(md->table,NULL); 457 PS_PTR_CHECK_NULL(key,NULL); 453 458 454 459 mdTable = md->table; 455 if (mdTable == NULL) {456 psError(__func__, "Null metadata table not allowed");457 return NULL;458 }459 460 if (key == NULL) {461 psError(__func__, "Null key name not allowed");462 return NULL;463 }464 460 465 461 entry = (psMetadataItem* ) psHashLookup(mdTable, key); … … 473 469 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where) 474 470 { 471 psMetadataItem* entry = NULL; 472 473 PS_PTR_CHECK_NULL(md,NULL); 474 PS_PTR_CHECK_NULL(md->list,NULL); 475 476 entry = (psMetadataItem* ) psListGet(md->list, where); 477 if (entry == NULL) { 478 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 479 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 480 where); 481 return NULL; 482 } 483 484 return entry; 485 } 486 487 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where) 488 { 489 PS_PTR_CHECK_NULL(md,NULL); 490 PS_PTR_CHECK_NULL(md->list,NULL); 491 492 psListSetIterator(md->list, where); 493 494 return true; 495 } 496 497 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which) 498 { 475 499 psList* mdList = NULL; 476 500 psMetadataItem* entry = NULL; 477 501 478 502 479 if (md == NULL) { 480 psError(__func__, "Null metadata collection not allowed"); 481 return NULL; 482 } 503 PS_PTR_CHECK_NULL(md,NULL); 504 PS_PTR_CHECK_NULL(md->list,NULL); 483 505 484 506 mdList = md->list; 485 if (mdList == NULL) {486 psError(__func__, "Null metadata list not allowed");487 return NULL;488 }489 490 entry = (psMetadataItem* ) psListGet(mdList, where);491 if (entry == NULL) {492 psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);493 return NULL;494 }495 496 return entry;497 }498 499 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)500 {501 psList* mdList = NULL;502 503 if (md == NULL) {504 psError(__func__, "Null metadata collection not allowed");505 return false;506 }507 508 mdList = md->list;509 if (mdList == NULL) {510 psError(__func__, "Null metadata list not allowed");511 return false;512 }513 514 psListSetIterator(mdList, where);515 516 return true;517 }518 519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)520 {521 psList* mdList = NULL;522 psMetadataItem* entry = NULL;523 524 525 if (md == NULL) {526 psError(__func__, "Null metadata collection not allowed");527 return NULL;528 }529 530 mdList = md->list;531 if (mdList == NULL) {532 psError(__func__, "Null metadata list not allowed");533 return NULL;534 }535 507 536 508 psListSetIterator(mdList, which); … … 559 531 560 532 561 if (md == NULL) { 562 psError(__func__, "Null metadata collection not allowed"); 563 return NULL; 564 } 533 PS_PTR_CHECK_NULL(md,NULL); 534 PS_PTR_CHECK_NULL(md->list,NULL); 565 535 566 536 mdList = md->list; 567 if (mdList == NULL) {568 psError(__func__, "Null metadata list not allowed");569 return NULL;570 }571 537 572 538 psListSetIterator(mdList, which); -
trunk/psLib/src/collections/psMetadataIO.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 fits_get_errstatus(status, fitsErr); \ 45 psError( __func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \47 psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *status = 1; 283 psError(__func__, "Invalid type: %d", elemType); 285 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 286 PS_ERRORTEXT_psMetadataIO_TYPE_INVALID, 287 elemType); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 304 if (fd == NULL) { 305 psError(__func__, "Null file descriptor not allowed"); 306 return; 307 } 308 309 if (format == NULL) { 310 psError(__func__, "Null format not allowed"); 311 return; 312 } 313 314 if (metadataItem == NULL) { 315 psError(__func__, "Null metadata not allowed"); 316 return; 317 } 308 PS_PTR_CHECK_NULL(fd,); 309 PS_PTR_CHECK_NULL(format,); 310 PS_PTR_CHECK_NULL(metadataItem,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 default: 338 psError(__func__, " Invalid psMetadataType to print: %d", type); 331 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 332 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 333 (int)type); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 371 if (extName == NULL && extNum == 0) { 372 psError(__func__, "Null extName and extNum = 0 not allowed"); 373 return NULL; 374 } else if (extName && (extNum != -1) ) { 375 psError(__func__, "If extName specified, extNum arguments should be -1."); 363 if (extName == NULL && extNum < 1) { 364 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 365 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE, 366 extNum); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 if (!success) { 442 psError(__func__, "Failed to add metadata item. Name: %s", keyName); 435 psError(PS_ERR_UNKNOWN, false, 436 PS_ERRORTEXT_psMetadataIO_ADD_FAILED, 437 keyName); 443 438 return output; 444 439 } … … 471 466 472 467 // Check for nulls 473 if(fileName == NULL) {474 psError(__func__, "Null fileName not allowed");475 return -1;476 } else if((fp=fopen(fileName, "r")) == NULL) {477 psError(__func__, "Couldn't open file. Name: %s",fileName);468 PS_PTR_CHECK_NULL(fileName,-1); 469 if((fp=fopen(fileName, "r")) == NULL) { 470 psError(PS_ERR_IO, true, 471 PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, 472 fileName); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 failedLines++; 506 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 498 psError(PS_ERR_IO, true, 499 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 500 '@', lineCount, fileName); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 failedLines++; 510 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line); 504 psError(PS_ERR_IO, true, 505 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 506 '*', lineCount, fileName); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 failedLines++; 514 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 510 psError(PS_ERR_IO, true, 511 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 512 '~', lineCount, fileName); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 status = 0; 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 521 psError(PS_ERR_IO, true, 522 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 523 "name",lineCount, fileName); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 status = 0; 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 532 psError(PS_ERR_IO, true, 533 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 534 "type",lineCount, fileName); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 failedLines++; 553 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line); 555 psError(PS_ERR_IO, true, 556 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 557 strType, lineCount, fileName); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 status = 0; 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 571 psError(PS_ERR_IO, true, 572 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 573 "value",lineCount, fileName); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 583 psError(PS_ERR_IO, true, 584 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 585 "comment",lineCount, fileName); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 failedLines++; 591 psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName, 592 lineCount, line); 599 psError(PS_ERR_IO, true, 600 PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, 601 strName, lineCount, fileName); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 failedLines++; 610 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 619 psError(PS_ERR_IO, true, 620 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 621 strValue, strName, strType, lineCount, fileName); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 failedLines++; 621 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 632 psError(PS_ERR_IO, true, 633 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 634 strValue, strName, strType, lineCount, fileName); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 failedLines++; 633 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 646 psError(PS_ERR_IO, true, 647 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 648 strValue, strName, strType, lineCount, fileName); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 failedLines++; 647 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 662 psError(PS_ERR_IO, true, 663 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 664 strValue, strName, strType, lineCount, fileName); 648 665 continue; 649 666 } … … 651 668 default: 652 669 failedLines++; 653 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line); 670 psError(PS_ERR_IO, true, 671 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 672 mdType, lineCount, fileName); 654 673 continue; 655 674 } // switch -
trunk/psLib/src/collections/psScalar.c
r2055 r2273 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-12 19:32:44$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:04:57 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 break; 71 71 default: 72 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc", 73 PS_ERR_BAD_PARAMETER_TYPE, true, 74 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 75 dataType); 72 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 73 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 74 dataType); 76 75 } 77 76 … … 85 84 86 85 if (scalar == NULL) { 87 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy", 88 PS_ERR_BAD_PARAMETER_NULL, true, 89 PS_ERRORTEXT_psScalar_COPY_NULL); 86 psError(PS_ERR_BAD_PARAMETER_NULL, true, 87 PS_ERRORTEXT_psScalar_COPY_NULL); 90 88 return NULL; 91 89 } … … 130 128 break; 131 129 default: 132 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy", 133 PS_ERR_BAD_PARAMETER_TYPE, true, 134 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 135 dataType); 130 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 131 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 132 dataType); 136 133 } 137 134 -
trunk/psLib/src/collections/psVector.c
r2204 r2273 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:04:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 71 71 if (in == NULL) { 72 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc", 73 PS_ERR_BAD_PARAMETER_NULL, true, 74 PS_ERRORTEXT_psVector_REALLOC_NULL); 72 psError(PS_ERR_BAD_PARAMETER_NULL, true, 73 PS_ERRORTEXT_psVector_REALLOC_NULL); 75 74 return NULL; 76 75 } else if (in->nalloc != nalloc) { // No need to realloc to same size … … 99 98 in->type.dimen != PS_DIMEN_TRANSV) { 100 99 psFree(in); 101 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRecycle", 102 PS_ERR_BAD_PARAMETER_TYPE, true, 103 PS_ERRORTEXT_psVector_NOT_A_VECTOR); 100 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 101 PS_ERRORTEXT_psVector_NOT_A_VECTOR); 104 102 return NULL; 105 103 } … … 122 120 { 123 121 if (in == NULL) { 124 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 125 PS_ERR_BAD_PARAMETER_NULL, true, 126 PS_ERRORTEXT_psVector_SORT_NULL); 122 psError(PS_ERR_BAD_PARAMETER_NULL, true, 123 PS_ERRORTEXT_psVector_SORT_NULL); 127 124 psFree(out); 128 125 return NULL; … … 183 180 char* typeStr; \ 184 181 PS_TYPE_NAME(typeStr,type); \ 185 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \ 186 PS_ERR_BAD_PARAMETER_TYPE, true, \ 187 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 188 typeStr); \ 182 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 183 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 184 typeStr); \ 189 185 psFree(out); \ 190 186 } \ … … 209 205 char* typeStr; 210 206 PS_TYPE_NAME(typeStr,type); 211 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 212 PS_ERR_BAD_PARAMETER_TYPE, true, 213 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 214 typeStr); 207 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 208 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 209 typeStr); 215 210 psFree(out); 216 211 … … 232 227 233 228 if (inVector == NULL) { 234 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 235 PS_ERR_BAD_PARAMETER_NULL, true, 236 PS_ERRORTEXT_psVector_SORT_NULL); 229 psError(PS_ERR_BAD_PARAMETER_NULL, true, 230 PS_ERRORTEXT_psVector_SORT_NULL); 237 231 psFree(outVector); 238 232 return NULL; … … 300 294 break; 301 295 default: 302 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 303 PS_ERR_BAD_PARAMETER_TYPE, true, 304 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 305 inType); 296 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 297 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 298 inType); 306 299 } 307 300 … … 317 310 318 311 if (inVector == NULL) { 319 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex", 320 PS_ERR_BAD_PARAMETER_NULL, true, 321 PS_ERRORTEXT_psVector_SORT_NULL); 312 psError(PS_ERR_BAD_PARAMETER_NULL, true, 313 PS_ERRORTEXT_psVector_SORT_NULL); 322 314 psFree(outVector); 323 315 return NULL; … … 400 392 break; 401 393 default: 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex", 403 PS_ERR_BAD_PARAMETER_TYPE, true, 404 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 405 inType); 394 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 395 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 396 inType); 406 397 } 407 398 -
trunk/psLib/src/dataManip/psConstants.h
r2272 r2273 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-11-0 3 22:58:53$8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 #define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \ 33 33 if (NAME < 0) { \ 34 psError(__func__,"Error: %s is less than 0.", #NAME); \ 34 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 35 "Error: %s is less than 0.", #NAME); \ 35 36 return(RVAL); \ 36 37 } … … 38 39 #define PS_INT_CHECK_POSITIVE(NAME, RVAL) \ 39 40 if (NAME < 1) { \ 40 psError(__func__,"Error: %s is 0 or less.", #NAME); \ 41 return(RVAL); \ 42 } 43 44 // Produce an error if ((NAME1 > NAME2) 41 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 42 "Error: %s is 0 or less.", #NAME); \ 43 return(RVAL); \ 44 } 45 46 #define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \ 47 if ((int)NAME < LOWER || (int)NAME > UPPER) { \ 48 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 49 "Error: %s, %d, is out of range. Must be between %d and %d.", \ 50 #NAME,(int)NAME,LOWER,UPPER); \ 51 return RVAL; \ 52 } 53 54 // Produce an error if (NAME1 > NAME2) 45 55 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \ 46 56 if (NAME1 > NAME2) { \ 47 psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \ 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 58 "Error: (%s > %s) (%d %d).", \ 59 #NAME1, #NAME2, NAME1, NAME2); \ 48 60 return(RVAL); \ 49 61 } … … 53 65 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 54 66 if (NAME1 > NAME2) { \ 55 psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \ 67 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 68 "Error: (%s > %s) (%f %f)", \ 69 #NAME1, #NAME2, NAME1, NAME2); \ 56 70 return(RVAL); \ 57 71 } … … 59 73 #define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \ 60 74 if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \ 61 psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \ 75 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 76 "Error: %s and %s are equal.", \ 77 #NAME1, #NAME2); \ 62 78 return(RVAL); \ 63 79 } … … 67 83 the wrong type. 68 84 *****************************************************************************/ 69 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 85 #define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL) 86 #define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 70 87 if (NAME == NULL) { \ 71 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 72 return(RVAL); \ 88 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 89 "Unallowable operation: %s is NULL.", \ 90 #NAME); \ 91 CLEANUP; \ 73 92 } 74 93 75 94 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 76 95 if (NAME->type.type != TYPE) { \ 77 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 78 return(RVAL); \ 79 } 96 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 97 "Unallowable operation: %s has incorrect type.", \ 98 #NAME); \ 99 return(RVAL); \ 100 } 101 102 #define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL) 103 #define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \ 104 if (NAME->type.dimen != DIMEN) { \ 105 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 106 "Unallowable operation: %s has incorrect dimensionality.", \ 107 #NAME); \ 108 CLEANUP; \ 109 } 110 80 111 81 112 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \ 82 113 if (PTR1->n != PTR2->n) { \ 83 psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \ 84 return(RVAL); \ 85 } 86 87 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \ 114 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 115 "ptr %s has size %d, ptr %s has size %d.", \ 116 #PTR1, PTR1->n, #PTR2, PTR2->n); \ 117 return(RVAL); \ 118 } 119 120 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL) 121 122 #define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \ 88 123 if (PTR1->type.type != PTR2->type.type) { \ 89 psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 90 return(RVAL); \ 124 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 125 "ptr %s has type %d, ptr %s has type %d.", \ 126 #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 127 CLEANUP; \ 91 128 } 92 129 … … 95 132 PS_VECTOR macros: 96 133 *****************************************************************************/ 97 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 134 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL) 135 #define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 98 136 if (NAME == NULL || NAME->data.V == NULL) { \ 99 psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \ 100 return(RVAL); \ 137 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 138 "Unallowable operation: psVector %s or its data is NULL.", \ 139 #NAME); \ 140 CLEANUP; \ 101 141 } \ 102 142 103 143 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 104 144 if (NAME->n < 1) { \ 105 psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \ 145 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 146 "Unallowable operation: psVector %s has no elements.", \ 147 #NAME); \ 106 148 return(RVAL); \ 107 149 } \ … … 109 151 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \ 110 152 if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \ 111 psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \ 153 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 154 "psVector %s: bad type(%d)", \ 155 #NAME, NAME->type.type); \ 112 156 return(RVAL); \ 113 157 } \ … … 115 159 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 116 160 if (NAME->type.type != TYPE) { \ 117 psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \ 161 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 162 "Unallowable operation: psVector %s has incorrect type.", \ 163 #NAME); \ 118 164 return(RVAL); \ 119 165 } … … 121 167 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 122 168 if (VEC1->n != VEC2->n) { \ 123 psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 169 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 170 "psVector %s has size %d, psVector %s has size %d.", \ 171 #VEC1, VEC1->n, #VEC2, VEC2->n); \ 124 172 return(RVAL); \ 125 173 } … … 221 269 #define PS_POLY_CHECK_NULL(NAME, RVAL) \ 222 270 if (NAME == NULL || NAME->coeff == NULL) { \ 223 psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \ 271 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 272 "Unallowable operation: polynomial %s or its coeffs is NULL.", \ 273 #NAME); \ 224 274 return(RVAL); \ 225 275 } \ … … 227 277 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \ 228 278 if (NAME->type != TYPE) { \ 229 psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \ 279 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 280 "Unallowable operation: polynomial %s has wrong type.", #NAME); \ 230 281 return(RVAL); \ 231 282 } \ … … 234 285 PS_IMAGE macros: 235 286 *****************************************************************************/ 236 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \ 287 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL) 288 #define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 237 289 if (NAME == NULL || NAME->data.V == NULL) { \ 238 psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \ 239 return(RVAL); \ 240 } 241 242 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \ 290 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 291 "Unallowable operation: psImage %s or its data is NULL.", \ 292 #NAME); \ 293 CLEANUP; \ 294 } 295 296 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL) 297 #define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \ 243 298 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 244 psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \ 245 NAME->numCols, NAME->numRows); \ 246 return(RVAL); \ 299 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 300 "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \ 301 #NAME, NAME->numCols, NAME->numRows); \ 302 CLEANUP; \ 247 303 } 248 304 249 305 #define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \ 250 306 if (NAME->type.type != TYPE) { \ 251 psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \ 307 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 308 "Unallowable operation: psImage %s has incorrect type.", \ 309 #NAME); \ 252 310 return(RVAL); \ 253 311 } … … 260 318 #define PS_READOUT_CHECK_NULL(NAME, RVAL) \ 261 319 if (NAME == NULL || NAME->image == NULL) { \ 262 psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \ 320 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 321 "Unallowable operation: psReadout %s or its data is NULL.", \ 322 #NAME); \ 263 323 return(RVAL); \ 264 324 } -
trunk/psLib/src/dataManip/psDataManipErrors.dat
r2080 r2273 8 8 #################################################################### 9 9 # 10 psVectorFFT_ IMAGE_TYPE_UNSUPPORTEDInput psVector type, %s, is not supported. Valid data types are psF32 and psC32.10 psVectorFFT_TYPE_NOT_F32_C32 Input psVector type, %s, is not supported. Valid data types are psF32 and psC32. 11 11 psVectorFFT_REVERSE_NOT_COMPLEX Input psVector (%s) is not complex. Reverse FFT operation requires a complex input. 12 12 psVectorFFT_FORWARD_NOT_REAL Input psVector (%s) is not real. Forward FFT operation requires a real input. … … 18 18 psVectorFFT_NONCOMPLEX_NOTSUPPORTED Input psVector type, %s, is required to be either psC32 or psC64. 19 19 psVectorFFT_DIRECTION_NOTSET Must specify the direction as either PS_FFT_FORWARD or PS_FFT_REVERSE. 20 # 21 psStats_NOT_F32_F64 Invalid data type, %s. Only psF32 and psF64 data types are supported. 22 psStats_VECTOR_TYPE_UNSUPPORTED Input psVector type, %s, is not supported. 23 psStats_YVAL_OUT_OF_RANGE Specified yVal, %g, is not within y-range, %g to %g. 24 psStats_ROBUST_QUARTILE_BINS_FAILED Could not determine the robust lower/upper quartile bin numbers. 25 psStats_STATS_FAILED Failed to calculate the specified statistic. 26 # 27 psFunctions_INVALID_POLYNOMIAL_TYPE Unknown polynomial type 0x%x found. Evaluation failed. 28 psFunctions_TYPE_NOT_SUPPORTED Input psVector type, %s, is not supported. 29 psFunctions_NOT_ENOUGH_DATAPOINTS Given vector does not have enough data points for %d-order interpolation. 30 # 31 psMatrix_COUNT_DIFFERS Number of elements inconsistent, %d vs %d. Number of elements must match. 32 psMatrix_IMAGE_SIZE_DIFFERS Specified psImage dimensions differed, %dx%d vs %dx%d. 33 psMatrix_TYPE_MISMATCH Specified data type, %s, is not supported. 34 psMatrix_MIN_COMPLEX_SUPPORT The minimum operation is not supported with complex data. 35 psMatrix_MAX_COMPLEX_SUPPORT The maximum operation is not supported with complex data. 36 psMatrix_OPERATION_UNSUPPORTED Specified operation, %s, is not supported. 37 psMatrix_DIMEN_OTHER_FOUND %s's dimensionality is PS_DIMEN_OTHER, which is not allowed. 38 psMatrix_OUTPUT_VECTOR_NOT_CREATED Couldn't create a proper output psVector. 39 psMatrix_OUTPUT_IMAGE_NOT_CREATED Couldn't create a proper output psImage. 40 psMatrix_DIMEN_INVALID Specified parameter, %s, has invalid dimensionality, %d. 41 psMatrix_VECTOR_EMPTY Input psVector contains no elements. No data to perform operation with. 42 psMatrix_IMAGE_EMPTY Input psImage contains no pixels. No data to perform operation with. -
trunk/psLib/src/dataManip/psDataManipErrors.h
r2080 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-13 20:46:57$9 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:04:59 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 31 31 //~Start #define PS_ERRORTEXT_$1 "$2" 32 #define PS_ERRORTEXT_psVectorFFT_ IMAGE_TYPE_UNSUPPORTED"Input psVector type, %s, is not supported. Valid data types are psF32 and psC32."32 #define PS_ERRORTEXT_psVectorFFT_TYPE_NOT_F32_C32 "Input psVector type, %s, is not supported. Valid data types are psF32 and psC32." 33 33 #define PS_ERRORTEXT_psVectorFFT_REVERSE_NOT_COMPLEX "Input psVector (%s) is not complex. Reverse FFT operation requires a complex input." 34 34 #define PS_ERRORTEXT_psVectorFFT_FORWARD_NOT_REAL "Input psVector (%s) is not real. Forward FFT operation requires a real input." … … 40 40 #define PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED "Input psVector type, %s, is required to be either psC32 or psC64." 41 41 #define PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET "Must specify the direction as either PS_FFT_FORWARD or PS_FFT_REVERSE." 42 #define PS_ERRORTEXT_psStats_NOT_F32_F64 "Invalid data type, %s. Only psF32 and psF64 data types are supported." 43 #define PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED "Input psVector type, %s, is not supported." 44 #define PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE "Specified yVal, %g, is not within y-range, %g to %g." 45 #define PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED "Could not determine the robust lower/upper quartile bin numbers." 46 #define PS_ERRORTEXT_psStats_STATS_FAILED "Failed to calculate the specified statistic." 47 #define PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE "Unknown polynomial type 0x%x found. Evaluation failed." 48 #define PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED "Input psVector type, %s, is not supported." 49 #define PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS "Given vector does not have enough data points for %d-order interpolation." 50 #define PS_ERRORTEXT_psMatrix_COUNT_DIFFERS "Number of elements inconsistent, %d vs %d. Number of elements must match." 51 #define PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS "Specified psImage dimensions differed, %dx%d vs %dx%d." 52 #define PS_ERRORTEXT_psMatrix_TYPE_MISMATCH "Specified data type, %s, is not supported." 53 #define PS_ERRORTEXT_psMatrix_MIN_COMPLEX_SUPPORT "The minimum operation is not supported with complex data." 54 #define PS_ERRORTEXT_psMatrix_MAX_COMPLEX_SUPPORT "The maximum operation is not supported with complex data." 55 #define PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED "Specified operation, %s, is not supported." 56 #define PS_ERRORTEXT_psMatrix_DIMEN_OTHER_FOUND "%s's dimensionality is PS_DIMEN_OTHER, which is not allowed." 57 #define PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED "Couldn't create a proper output psVector." 58 #define PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED "Couldn't create a proper output psImage." 59 #define PS_ERRORTEXT_psMatrix_DIMEN_INVALID "Specified parameter, %s, has invalid dimensionality, %d." 60 #define PS_ERRORTEXT_psMatrix_VECTOR_EMPTY "Input psVector contains no elements. No data to perform operation with." 61 #define PS_ERRORTEXT_psMatrix_IMAGE_EMPTY "Input psImage contains no pixels. No data to perform operation with." 42 62 //~End 43 63 -
trunk/psLib/src/dataManip/psFunctions.c
r2224 r2273 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-28 00:22:53$9 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:04:59 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psFunctions.h" 36 36 #include "psConstants.h" 37 38 #include "psDataManipErrors.h" 39 37 40 /*****************************************************************************/ 38 41 /* DEFINE STATEMENTS */ … … 50 53 static void dPolynomial3DFree(psDPolynomial3D* myPoly); 51 54 static void dPolynomial4DFree(psDPolynomial4D* myPoly); 55 static void spline1DFree(psSpline1D *tmpSpline); 56 static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x); 57 static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x); 52 58 53 59 /*****************************************************************************/ … … 67 73 /*****************************************************************************/ 68 74 75 static void spline1DFree(psSpline1D *tmpSpline) 76 { 77 psS32 i; 78 79 if (tmpSpline == NULL) { 80 return; 81 } 82 83 if (tmpSpline->spline != NULL) { 84 for (i=0;i<tmpSpline->n;i++) { 85 psFree((tmpSpline->spline)[i]); 86 } 87 psFree(tmpSpline->spline); 88 } 89 90 if (tmpSpline->p_psDeriv2 != NULL) { 91 psFree(tmpSpline->p_psDeriv2); 92 } 93 psFree(tmpSpline->domains); 94 95 return; 96 } 97 98 static void polynomial1DFree(psPolynomial1D* myPoly) 99 { 100 psFree(myPoly->coeff); 101 psFree(myPoly->coeffErr); 102 psFree(myPoly->mask); 103 } 104 105 static void polynomial2DFree(psPolynomial2D* myPoly) 106 { 107 psS32 x = 0; 108 109 for (x = 0; x < myPoly->nX; x++) { 110 psFree(myPoly->coeff[x]); 111 psFree(myPoly->coeffErr[x]); 112 psFree(myPoly->mask[x]); 113 } 114 psFree(myPoly->coeff); 115 psFree(myPoly->coeffErr); 116 psFree(myPoly->mask); 117 } 118 119 static void polynomial3DFree(psPolynomial3D* myPoly) 120 { 121 psS32 x = 0; 122 psS32 y = 0; 123 124 for (x = 0; x < myPoly->nX; x++) { 125 for (y = 0; y < myPoly->nY; y++) { 126 psFree(myPoly->coeff[x][y]); 127 psFree(myPoly->coeffErr[x][y]); 128 psFree(myPoly->mask[x][y]); 129 } 130 psFree(myPoly->coeff[x]); 131 psFree(myPoly->coeffErr[x]); 132 psFree(myPoly->mask[x]); 133 } 134 135 psFree(myPoly->coeff); 136 psFree(myPoly->coeffErr); 137 psFree(myPoly->mask); 138 } 139 140 static void polynomial4DFree(psPolynomial4D* myPoly) 141 { 142 psS32 w = 0; 143 psS32 x = 0; 144 psS32 y = 0; 145 146 for (w = 0; w < myPoly->nW; w++) { 147 for (x = 0; x < myPoly->nX; x++) { 148 for (y = 0; y < myPoly->nY; y++) { 149 psFree(myPoly->coeff[w][x][y]); 150 psFree(myPoly->coeffErr[w][x][y]); 151 psFree(myPoly->mask[w][x][y]); 152 } 153 psFree(myPoly->coeff[w][x]); 154 psFree(myPoly->coeffErr[w][x]); 155 psFree(myPoly->mask[w][x]); 156 } 157 psFree(myPoly->coeff[w]); 158 psFree(myPoly->coeffErr[w]); 159 psFree(myPoly->mask[w]); 160 } 161 162 psFree(myPoly->coeff); 163 psFree(myPoly->coeffErr); 164 psFree(myPoly->mask); 165 } 166 167 static void dPolynomial1DFree(psDPolynomial1D* myPoly) 168 { 169 psFree(myPoly->coeff); 170 psFree(myPoly->coeffErr); 171 psFree(myPoly->mask); 172 } 173 174 static void dPolynomial2DFree(psDPolynomial2D* myPoly) 175 { 176 psS32 x = 0; 177 178 for (x = 0; x < myPoly->nX; x++) { 179 psFree(myPoly->coeff[x]); 180 psFree(myPoly->coeffErr[x]); 181 psFree(myPoly->mask[x]); 182 } 183 psFree(myPoly->coeff); 184 psFree(myPoly->coeffErr); 185 psFree(myPoly->mask); 186 } 187 188 static void dPolynomial3DFree(psDPolynomial3D* myPoly) 189 { 190 psS32 x = 0; 191 psS32 y = 0; 192 193 for (x = 0; x < myPoly->nX; x++) { 194 for (y = 0; y < myPoly->nY; y++) { 195 psFree(myPoly->coeff[x][y]); 196 psFree(myPoly->coeffErr[x][y]); 197 psFree(myPoly->mask[x][y]); 198 } 199 psFree(myPoly->coeff[x]); 200 psFree(myPoly->coeffErr[x]); 201 psFree(myPoly->mask[x]); 202 } 203 204 psFree(myPoly->coeff); 205 psFree(myPoly->coeffErr); 206 psFree(myPoly->mask); 207 } 208 209 static void dPolynomial4DFree(psDPolynomial4D* myPoly) 210 { 211 psS32 w = 0; 212 psS32 x = 0; 213 psS32 y = 0; 214 215 for (w = 0; w < myPoly->nW; w++) { 216 for (x = 0; x < myPoly->nX; x++) { 217 for (y = 0; y < myPoly->nY; y++) { 218 psFree(myPoly->coeff[w][x][y]); 219 psFree(myPoly->coeffErr[w][x][y]); 220 psFree(myPoly->mask[w][x][y]); 221 } 222 psFree(myPoly->coeff[w][x]); 223 psFree(myPoly->coeffErr[w][x]); 224 psFree(myPoly->mask[w][x]); 225 } 226 psFree(myPoly->coeff[w]); 227 psFree(myPoly->coeffErr[w]); 228 psFree(myPoly->mask[w]); 229 } 230 231 psFree(myPoly->coeff); 232 psFree(myPoly->coeffErr); 233 psFree(myPoly->mask); 234 } 235 69 236 /***************************************************************************** 70 CreateChebyshevPolys(n): this routine takes as input the required order n,237 createChebyshevPolys(n): this routine takes as input the required order n, 71 238 and returns as output as a pointer to an array of n psPolynomial1D 72 239 structures, corresponding to the first n Chebyshev polynomials. … … 76 243 outer coefficients of the Chebyshev polynomials. 77 244 *****************************************************************************/ 78 static psPolynomial1D ** CreateChebyshevPolys(psS32 maxChebyPoly)245 static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly) 79 246 { 80 247 PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL); … … 103 270 104 271 return (chebPolys); 272 } 273 274 /***************************************************************************** 275 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 276 277 XXX: Should the "coeffErr[]" should be used as well? 278 *****************************************************************************/ 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) 280 { 281 psS32 loop_x = 0; 282 float polySum = 0.0; 283 float xSum = 1.0; 284 285 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 286 "---- Calling ordPolynomial1DEval(%f)\n", x); 287 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 288 "Polynomial order is %d\n", myPoly->n); 289 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 290 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 291 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]); 292 } 293 294 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 295 if (myPoly->mask[loop_x] == 0) { 296 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10, 297 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 298 polySum += xSum * myPoly->coeff[loop_x]; 299 xSum *= x; 300 } 301 } 302 303 return(polySum); 304 } 305 306 // XXX: You can do this without having to psAlloc() vector d. 307 // XXX: How does the mask vector effect Crenshaw's formula? 308 static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly) 309 { 310 psVector *d; 311 psS32 n; 312 psS32 i; 313 float tmp; 314 315 n = myPoly->n; 316 d = psVectorAlloc(n, PS_TYPE_F32); 317 d->data.F32[n-1] = myPoly->coeff[n-1]; 318 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2]; 319 for (i=n-3;i>=1;i--) { 320 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) - 321 (d->data.F32[i+2]) + 322 (myPoly->coeff[i]); 323 } 324 325 tmp = (x * d->data.F32[1]) - 326 (d->data.F32[2]) + 327 (0.5 * myPoly->coeff[0]); 328 329 psFree(d); 330 return(tmp); 331 /* 332 333 psS32 n; 334 psS32 i; 335 float tmp; 336 psPolynomial1D **chebPolys = NULL; 337 338 n = myPoly->n; 339 chebPolys = createChebyshevPolys(n); 340 341 tmp = 0.0; 342 for (i=0;i<myPoly->n;i++) { 343 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 344 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i])); 345 } 346 tmp-= (myPoly->coeff[0]/2.0); 347 348 349 return(tmp); 350 */ 351 } 352 353 static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 354 { 355 PS_POLY_CHECK_NULL(myPoly, NAN); 356 357 psS32 loop_x = 0; 358 psS32 loop_y = 0; 359 float polySum = 0.0; 360 float xSum = 1.0; 361 float ySum = 1.0; 362 363 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 364 ySum = xSum; 365 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 366 if (myPoly->mask[loop_x][loop_y] == 0) { 367 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 368 ySum *= y; 369 } 370 } 371 xSum *= x; 372 } 373 374 return(polySum); 375 } 376 377 static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 378 { 379 PS_POLY_CHECK_NULL(myPoly, NAN); 380 381 psS32 loop_x = 0; 382 psS32 loop_y = 0; 383 psS32 i = 0; 384 float polySum = 0.0; 385 psPolynomial1D* *chebPolys = NULL; 386 psS32 maxChebyPoly = 0; 387 388 // Determine how many Chebyshev polynomials 389 // are needed, then create them. 390 maxChebyPoly = myPoly->nX; 391 if (myPoly->nY > maxChebyPoly) { 392 maxChebyPoly = myPoly->nY; 393 } 394 chebPolys = createChebyshevPolys(maxChebyPoly); 395 396 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 397 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 398 if (myPoly->mask[loop_x][loop_y] == 0) { 399 polySum += myPoly->coeff[loop_x][loop_y] * 400 psPolynomial1DEval(x, chebPolys[loop_x]) * 401 psPolynomial1DEval(y, chebPolys[loop_y]); 402 } 403 } 404 } 405 for (i=0;i<maxChebyPoly;i++) { 406 psFree(chebPolys[i]); 407 } 408 psFree(chebPolys); 409 return(polySum); 410 } 411 412 static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 413 { 414 psS32 loop_x = 0; 415 psS32 loop_y = 0; 416 psS32 loop_z = 0; 417 float polySum = 0.0; 418 float xSum = 1.0; 419 float ySum = 1.0; 420 float zSum = 1.0; 421 422 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 423 ySum = xSum; 424 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 425 zSum = ySum; 426 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 427 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 428 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 429 zSum *= z; 430 } 431 } 432 ySum *= y; 433 } 434 xSum *= x; 435 } 436 437 return(polySum); 438 } 439 440 static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 441 { 442 psS32 loop_x = 0; 443 psS32 loop_y = 0; 444 psS32 loop_z = 0; 445 psS32 i = 0; 446 float polySum = 0.0; 447 psPolynomial1D* *chebPolys = NULL; 448 psS32 maxChebyPoly = 0; 449 450 // Determine how many Chebyshev polynomials 451 // are needed, then create them. 452 maxChebyPoly = myPoly->nX; 453 if (myPoly->nY > maxChebyPoly) { 454 maxChebyPoly = myPoly->nY; 455 } 456 if (myPoly->nZ > maxChebyPoly) { 457 maxChebyPoly = myPoly->nZ; 458 } 459 chebPolys = createChebyshevPolys(maxChebyPoly); 460 461 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 462 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 463 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 464 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 465 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 466 psPolynomial1DEval(x, chebPolys[loop_x]) * 467 psPolynomial1DEval(y, chebPolys[loop_y]) * 468 psPolynomial1DEval(z, chebPolys[loop_z]); 469 } 470 } 471 } 472 } 473 474 for (i=0;i<maxChebyPoly;i++) { 475 psFree(chebPolys[i]); 476 } 477 psFree(chebPolys); 478 return(polySum); 479 } 480 481 static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 482 { 483 psS32 loop_w = 0; 484 psS32 loop_x = 0; 485 psS32 loop_y = 0; 486 psS32 loop_z = 0; 487 float polySum = 0.0; 488 float wSum = 1.0; 489 float xSum = 1.0; 490 float ySum = 1.0; 491 float zSum = 1.0; 492 493 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 494 xSum = wSum; 495 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 496 ySum = xSum; 497 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 498 zSum = ySum; 499 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 500 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 501 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 502 zSum *= z; 503 } 504 } 505 ySum *= y; 506 } 507 xSum *= x; 508 } 509 wSum *= w; 510 } 511 512 return(polySum); 513 } 514 515 static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 516 { 517 psS32 loop_w = 0; 518 psS32 loop_x = 0; 519 psS32 loop_y = 0; 520 psS32 loop_z = 0; 521 psS32 i = 0; 522 float polySum = 0.0; 523 psPolynomial1D* *chebPolys = NULL; 524 psS32 maxChebyPoly = 0; 525 526 // Determine how many Chebyshev polynomials 527 // are needed, then create them. 528 maxChebyPoly = myPoly->nW; 529 if (myPoly->nX > maxChebyPoly) { 530 maxChebyPoly = myPoly->nX; 531 } 532 if (myPoly->nY > maxChebyPoly) { 533 maxChebyPoly = myPoly->nY; 534 } 535 if (myPoly->nZ > maxChebyPoly) { 536 maxChebyPoly = myPoly->nZ; 537 } 538 chebPolys = createChebyshevPolys(maxChebyPoly); 539 540 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 541 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 542 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 543 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 544 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 545 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 546 psPolynomial1DEval(w, chebPolys[loop_w]) * 547 psPolynomial1DEval(x, chebPolys[loop_x]) * 548 psPolynomial1DEval(y, chebPolys[loop_y]) * 549 psPolynomial1DEval(z, chebPolys[loop_z]); 550 } 551 } 552 } 553 } 554 } 555 556 for (i=0;i<maxChebyPoly;i++) { 557 psFree(chebPolys[i]); 558 } 559 psFree(chebPolys); 560 return(polySum); 561 } 562 563 /***************************************************************************** 564 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 565 *****************************************************************************/ 566 static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 567 { 568 psS32 loop_x = 0; 569 double polySum = 0.0; 570 double xSum = 1.0; 571 572 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 573 if (myPoly->mask[loop_x] == 0) { 574 polySum += xSum * myPoly->coeff[loop_x]; 575 xSum *= x; 576 } 577 } 578 579 return(polySum); 580 } 581 582 // XXX: You can do this without having to psAlloc() vector d. 583 // XXX: How does the mask vector effect Crenshaw's formula? 584 static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 585 { 586 psVector *d; 587 psS32 n; 588 psS32 i; 589 double tmp; 590 591 n = myPoly->n; 592 d = psVectorAlloc(n, PS_TYPE_F64); 593 d->data.F64[n-1] = myPoly->coeff[n-1]; 594 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2]; 595 for (i=n-3;i>=1;i--) { 596 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) - 597 (d->data.F64[i+2]) + 598 (myPoly->coeff[i]); 599 } 600 601 tmp = (x * d->data.F64[1]) - 602 (d->data.F64[2]) + 603 (0.5 * myPoly->coeff[0]); 604 605 psFree(d); 606 return(tmp); 607 } 608 609 static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 610 { 611 psS32 loop_x = 0; 612 psS32 loop_y = 0; 613 double polySum = 0.0; 614 double xSum = 1.0; 615 double ySum = 1.0; 616 617 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 618 ySum = xSum; 619 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 620 if (myPoly->mask[loop_x][loop_y] == 0) { 621 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 622 ySum *= y; 623 } 624 } 625 xSum *= x; 626 } 627 628 return(polySum); 629 } 630 631 static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 632 { 633 psS32 loop_x = 0; 634 psS32 loop_y = 0; 635 psS32 i = 0; 636 double polySum = 0.0; 637 psPolynomial1D* *chebPolys = NULL; 638 psS32 maxChebyPoly = 0; 639 640 // Determine how many Chebyshev polynomials 641 // are needed, then create them. 642 maxChebyPoly = myPoly->nX; 643 if (myPoly->nY > maxChebyPoly) { 644 maxChebyPoly = myPoly->nY; 645 } 646 chebPolys = createChebyshevPolys(maxChebyPoly); 647 648 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 649 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 650 if (myPoly->mask[loop_x][loop_y] == 0) { 651 polySum += myPoly->coeff[loop_x][loop_y] * 652 psPolynomial1DEval(x, chebPolys[loop_x]) * 653 psPolynomial1DEval(y, chebPolys[loop_y]); 654 } 655 } 656 } 657 658 for (i=0;i<maxChebyPoly;i++) { 659 psFree(chebPolys[i]); 660 } 661 psFree(chebPolys); 662 return(polySum); 663 } 664 665 static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 666 { 667 psS32 loop_x = 0; 668 psS32 loop_y = 0; 669 psS32 loop_z = 0; 670 double polySum = 0.0; 671 double xSum = 1.0; 672 double ySum = 1.0; 673 double zSum = 1.0; 674 675 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 676 ySum = xSum; 677 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 678 zSum = ySum; 679 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 680 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 681 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 682 zSum *= z; 683 } 684 } 685 ySum *= y; 686 } 687 xSum *= x; 688 } 689 690 return(polySum); 691 } 692 693 static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 694 { 695 psS32 loop_x = 0; 696 psS32 loop_y = 0; 697 psS32 loop_z = 0; 698 psS32 i = 0; 699 double polySum = 0.0; 700 psPolynomial1D* *chebPolys = NULL; 701 psS32 maxChebyPoly = 0; 702 703 // Determine how many Chebyshev polynomials 704 // are needed, then create them. 705 maxChebyPoly = myPoly->nX; 706 if (myPoly->nY > maxChebyPoly) { 707 maxChebyPoly = myPoly->nY; 708 } 709 if (myPoly->nZ > maxChebyPoly) { 710 maxChebyPoly = myPoly->nZ; 711 } 712 chebPolys = createChebyshevPolys(maxChebyPoly); 713 714 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 715 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 716 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 717 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 718 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 719 psPolynomial1DEval(x, chebPolys[loop_x]) * 720 psPolynomial1DEval(y, chebPolys[loop_y]) * 721 psPolynomial1DEval(z, chebPolys[loop_z]); 722 } 723 } 724 } 725 } 726 727 for (i=0;i<maxChebyPoly;i++) { 728 psFree(chebPolys[i]); 729 } 730 psFree(chebPolys); 731 return(polySum); 732 } 733 734 static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 735 { 736 psS32 loop_w = 0; 737 psS32 loop_x = 0; 738 psS32 loop_y = 0; 739 psS32 loop_z = 0; 740 double polySum = 0.0; 741 double wSum = 1.0; 742 double xSum = 1.0; 743 double ySum = 1.0; 744 double zSum = 1.0; 745 746 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 747 xSum = wSum; 748 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 749 ySum = xSum; 750 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 751 zSum = ySum; 752 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 753 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 754 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 755 zSum *= z; 756 } 757 } 758 ySum *= y; 759 } 760 xSum *= x; 761 } 762 wSum *= w; 763 } 764 765 return(polySum); 766 } 767 768 static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 769 { 770 psS32 loop_w = 0; 771 psS32 loop_x = 0; 772 psS32 loop_y = 0; 773 psS32 loop_z = 0; 774 psS32 i = 0; 775 double polySum = 0.0; 776 psPolynomial1D* *chebPolys = NULL; 777 psS32 maxChebyPoly = 0; 778 779 // Determine how many Chebyshev polynomials 780 // are needed, then create them. 781 maxChebyPoly = myPoly->nW; 782 if (myPoly->nX > maxChebyPoly) { 783 maxChebyPoly = myPoly->nX; 784 } 785 if (myPoly->nY > maxChebyPoly) { 786 maxChebyPoly = myPoly->nY; 787 } 788 if (myPoly->nZ > maxChebyPoly) { 789 maxChebyPoly = myPoly->nZ; 790 } 791 chebPolys = createChebyshevPolys(maxChebyPoly); 792 793 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 794 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 795 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 796 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 797 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 798 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 799 psPolynomial1DEval(w, chebPolys[loop_w]) * 800 psPolynomial1DEval(x, chebPolys[loop_x]) * 801 psPolynomial1DEval(y, chebPolys[loop_y]) * 802 psPolynomial1DEval(z, chebPolys[loop_z]); 803 } 804 } 805 } 806 } 807 } 808 809 for (i=0;i<maxChebyPoly;i++) { 810 psFree(chebPolys[i]); 811 } 812 psFree(chebPolys); 813 return(polySum); 814 } 815 816 817 /***************************************************************************** 818 p_psInterpolate1D(): This routine will take as input n-element floating 819 point arrays domain and range, and the x value, assumed to lie with the 820 domain vector. It produces as output the (n-1)-order LaGrange interpolated 821 value of x. 822 823 XXX: do we error check for non-distinct domain values? 824 *****************************************************************************/ 825 static float fullInterpolate1DF32(float *domain, 826 float *range, 827 psS32 n, 828 float x) 829 { 830 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 831 PS_PTR_CHECK_NULL(domain, NAN); 832 PS_PTR_CHECK_NULL(range, NAN); 833 834 psS32 i; 835 psS32 m; 836 static psVector *p = NULL; 837 p = psVectorRecycle(p, n, PS_TYPE_F32); 838 p_psMemSetPersistent(p, true); 839 p_psMemSetPersistent(p->data.F32, true); 840 /* 841 psVector *p = psVectorAlloc(n, PS_TYPE_F32); 842 float tmp; 843 */ 844 845 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 846 "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n); 847 848 for (i=0;i<n;i++) { 849 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 850 "domain/range is (%f %f)\n", domain[i], range[i]); 851 } 852 853 for (i=0;i<n;i++) { 854 p->data.F32[i] = range[i]; 855 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 856 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 857 858 } 859 860 // From NR, during each iteration of the m loop, we are computing the 861 // p_{i ... i+m} terms. 862 for (m=1;m<n;m++) { 863 for (i=0;i<n-m;i++) { 864 // From NR: we are computing P_{i ... i+m} 865 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) + 866 ((domain[i]-x) * p->data.F32[i+1])) / 867 (domain[i] - domain[i+m]); 868 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]); 869 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 870 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 871 } 872 } 873 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 874 "---- fullInterpolate1DF32() end ----\n"); 875 876 /* 877 tmp = p->data.F32[0]; 878 psFree(p); 879 return(tmp); 880 */ 881 return(p->data.F32[0]); 882 } 883 884 885 /***************************************************************************** 886 interpolate1DF32(): this is the base 1-D flat memory routine to perform 887 LaGrange interpolation. 888 *****************************************************************************/ 889 static float interpolate1DF32(float *domain, 890 float *range, 891 psS32 n, 892 psS32 order, 893 float x) 894 { 895 psS32 binNum; 896 psS32 numIntPoints = order+1; 897 psS32 origin; 898 899 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 900 "---- interpolate1DF32() begin ----\n"); 901 902 binNum = vectorBinDisectF32(domain, n, x); 903 904 if (0 == numIntPoints%2) { 905 origin = binNum - ((numIntPoints/2) - 1); 906 } else { 907 origin = binNum - (numIntPoints/2); 908 if ((x-domain[binNum]) > (domain[binNum+1]-x)) { 909 // x is closer to binNum+1. 910 origin = 1 + (binNum - (numIntPoints/2)); 911 } 912 } 913 if (origin < 0) { 914 origin = 0; 915 } 916 if ((origin + numIntPoints) > n) { 917 origin = n - numIntPoints; 918 } 919 920 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 921 "---- interpolate1DF32() end ----\n"); 922 return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x)); 105 923 } 106 924 … … 336 1154 } 337 1155 338 static void polynomial1DFree(psPolynomial1D* myPoly)339 {340 psFree(myPoly->coeff);341 psFree(myPoly->coeffErr);342 psFree(myPoly->mask);343 }344 345 static void polynomial2DFree(psPolynomial2D* myPoly)346 {347 psS32 x = 0;348 349 for (x = 0; x < myPoly->nX; x++) {350 psFree(myPoly->coeff[x]);351 psFree(myPoly->coeffErr[x]);352 psFree(myPoly->mask[x]);353 }354 psFree(myPoly->coeff);355 psFree(myPoly->coeffErr);356 psFree(myPoly->mask);357 }358 359 static void polynomial3DFree(psPolynomial3D* myPoly)360 {361 psS32 x = 0;362 psS32 y = 0;363 364 for (x = 0; x < myPoly->nX; x++) {365 for (y = 0; y < myPoly->nY; y++) {366 psFree(myPoly->coeff[x][y]);367 psFree(myPoly->coeffErr[x][y]);368 psFree(myPoly->mask[x][y]);369 }370 psFree(myPoly->coeff[x]);371 psFree(myPoly->coeffErr[x]);372 psFree(myPoly->mask[x]);373 }374 375 psFree(myPoly->coeff);376 psFree(myPoly->coeffErr);377 psFree(myPoly->mask);378 }379 380 static void polynomial4DFree(psPolynomial4D* myPoly)381 {382 psS32 w = 0;383 psS32 x = 0;384 psS32 y = 0;385 386 for (w = 0; w < myPoly->nW; w++) {387 for (x = 0; x < myPoly->nX; x++) {388 for (y = 0; y < myPoly->nY; y++) {389 psFree(myPoly->coeff[w][x][y]);390 psFree(myPoly->coeffErr[w][x][y]);391 psFree(myPoly->mask[w][x][y]);392 }393 psFree(myPoly->coeff[w][x]);394 psFree(myPoly->coeffErr[w][x]);395 psFree(myPoly->mask[w][x]);396 }397 psFree(myPoly->coeff[w]);398 psFree(myPoly->coeffErr[w]);399 psFree(myPoly->mask[w]);400 }401 402 psFree(myPoly->coeff);403 psFree(myPoly->coeffErr);404 psFree(myPoly->mask);405 }406 407 /*****************************************************************************408 Polynomial coefficients will be accessed in [w][x][y][z] fashion.409 410 XXX: Should the "coeffErr[]" should be used as well?411 *****************************************************************************/412 float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)413 {414 psS32 loop_x = 0;415 float polySum = 0.0;416 float xSum = 1.0;417 418 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,419 "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);420 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,421 "Polynomial order is %d\n", myPoly->n);422 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {423 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,424 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);425 }426 427 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {428 if (myPoly->mask[loop_x] == 0) {429 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,430 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);431 polySum += xSum * myPoly->coeff[loop_x];432 xSum *= x;433 }434 }435 436 return(polySum);437 }438 439 // XXX: You can do this without having to psAlloc() vector d.440 // XXX: How does the mask vector effect Crenshaw's formula?441 float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)442 {443 psVector *d;444 psS32 n;445 psS32 i;446 float tmp;447 448 n = myPoly->n;449 d = psVectorAlloc(n, PS_TYPE_F32);450 d->data.F32[n-1] = myPoly->coeff[n-1];451 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];452 for (i=n-3;i>=1;i--) {453 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -454 (d->data.F32[i+2]) +455 (myPoly->coeff[i]);456 }457 458 tmp = (x * d->data.F32[1]) -459 (d->data.F32[2]) +460 (0.5 * myPoly->coeff[0]);461 462 psFree(d);463 return(tmp);464 /*465 466 psS32 n;467 psS32 i;468 float tmp;469 psPolynomial1D **chebPolys = NULL;470 471 n = myPoly->n;472 chebPolys = CreateChebyshevPolys(n);473 474 tmp = 0.0;475 for (i=0;i<myPoly->n;i++) {476 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));477 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));478 }479 tmp-= (myPoly->coeff[0]/2.0);480 481 482 return(tmp);483 */484 }485 486 1156 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly) 487 1157 { … … 489 1159 490 1160 if (myPoly->type == PS_POLYNOMIAL_ORD) { 491 return( p_psOrdPolynomial1DEval(x, myPoly));1161 return(ordPolynomial1DEval(x, myPoly)); 492 1162 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 493 return( p_psChebPolynomial1DEval(x, myPoly));1163 return(chebPolynomial1DEval(x, myPoly)); 494 1164 } else { 495 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1165 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1166 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1167 myPoly->type); 496 1168 } 497 1169 return(0.0); … … 520 1192 } 521 1193 522 523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 1194 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 524 1195 { 525 1196 PS_POLY_CHECK_NULL(myPoly, NAN); 526 1197 527 psS32 loop_x = 0;528 psS32 loop_y = 0;529 float polySum = 0.0;530 float xSum = 1.0;531 float ySum = 1.0;532 533 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {534 ySum = xSum;535 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {536 if (myPoly->mask[loop_x][loop_y] == 0) {537 polySum += ySum * myPoly->coeff[loop_x][loop_y];538 ySum *= y;539 }540 }541 xSum *= x;542 }543 544 return(polySum);545 }546 547 float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)548 {549 PS_POLY_CHECK_NULL(myPoly, NAN);550 551 psS32 loop_x = 0;552 psS32 loop_y = 0;553 psS32 i = 0;554 float polySum = 0.0;555 psPolynomial1D* *chebPolys = NULL;556 psS32 maxChebyPoly = 0;557 558 // Determine how many Chebyshev polynomials559 // are needed, then create them.560 maxChebyPoly = myPoly->nX;561 if (myPoly->nY > maxChebyPoly) {562 maxChebyPoly = myPoly->nY;563 }564 chebPolys = CreateChebyshevPolys(maxChebyPoly);565 566 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {567 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {568 if (myPoly->mask[loop_x][loop_y] == 0) {569 polySum += myPoly->coeff[loop_x][loop_y] *570 psPolynomial1DEval(x, chebPolys[loop_x]) *571 psPolynomial1DEval(y, chebPolys[loop_y]);572 }573 }574 }575 for (i=0;i<maxChebyPoly;i++) {576 psFree(chebPolys[i]);577 }578 psFree(chebPolys);579 return(polySum);580 }581 582 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)583 {584 PS_POLY_CHECK_NULL(myPoly, NAN);585 586 1198 if (myPoly->type == PS_POLYNOMIAL_ORD) { 587 return( p_psOrdPolynomial2DEval(x, y, myPoly));1199 return(ordPolynomial2DEval(x, y, myPoly)); 588 1200 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 589 return( p_psChebPolynomial2DEval(x, y, myPoly));1201 return(chebPolynomial2DEval(x, y, myPoly)); 590 1202 } else { 591 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1203 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1204 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1205 myPoly->type); 592 1206 } 593 1207 return(0.0); 594 1208 } 595 596 1209 597 1210 psVector *psPolynomial2DEvalVector(const psVector *x, … … 632 1245 } 633 1246 634 635 636 float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)637 {638 psS32 loop_x = 0;639 psS32 loop_y = 0;640 psS32 loop_z = 0;641 float polySum = 0.0;642 float xSum = 1.0;643 float ySum = 1.0;644 float zSum = 1.0;645 646 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {647 ySum = xSum;648 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {649 zSum = ySum;650 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {651 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {652 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];653 zSum *= z;654 }655 }656 ySum *= y;657 }658 xSum *= x;659 }660 661 return(polySum);662 }663 664 float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)665 {666 psS32 loop_x = 0;667 psS32 loop_y = 0;668 psS32 loop_z = 0;669 psS32 i = 0;670 float polySum = 0.0;671 psPolynomial1D* *chebPolys = NULL;672 psS32 maxChebyPoly = 0;673 674 // Determine how many Chebyshev polynomials675 // are needed, then create them.676 maxChebyPoly = myPoly->nX;677 if (myPoly->nY > maxChebyPoly) {678 maxChebyPoly = myPoly->nY;679 }680 if (myPoly->nZ > maxChebyPoly) {681 maxChebyPoly = myPoly->nZ;682 }683 chebPolys = CreateChebyshevPolys(maxChebyPoly);684 685 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {686 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {687 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {688 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {689 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *690 psPolynomial1DEval(x, chebPolys[loop_x]) *691 psPolynomial1DEval(y, chebPolys[loop_y]) *692 psPolynomial1DEval(z, chebPolys[loop_z]);693 }694 }695 }696 }697 698 for (i=0;i<maxChebyPoly;i++) {699 psFree(chebPolys[i]);700 }701 psFree(chebPolys);702 return(polySum);703 }704 705 1247 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 706 1248 { … … 708 1250 709 1251 if (myPoly->type == PS_POLYNOMIAL_ORD) { 710 return( p_psOrdPolynomial3DEval(x, y, z, myPoly));1252 return(ordPolynomial3DEval(x, y, z, myPoly)); 711 1253 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 712 return( p_psChebPolynomial3DEval(x, y, z, myPoly));1254 return(chebPolynomial3DEval(x, y, z, myPoly)); 713 1255 } else { 714 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1256 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1257 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1258 myPoly->type); 715 1259 } 716 1260 return(0.0); … … 765 1309 } 766 1310 767 768 769 770 771 772 float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)773 {774 psS32 loop_w = 0;775 psS32 loop_x = 0;776 psS32 loop_y = 0;777 psS32 loop_z = 0;778 float polySum = 0.0;779 float wSum = 1.0;780 float xSum = 1.0;781 float ySum = 1.0;782 float zSum = 1.0;783 784 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {785 xSum = wSum;786 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {787 ySum = xSum;788 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {789 zSum = ySum;790 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {791 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {792 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];793 zSum *= z;794 }795 }796 ySum *= y;797 }798 xSum *= x;799 }800 wSum *= w;801 }802 803 return(polySum);804 }805 806 float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)807 {808 psS32 loop_w = 0;809 psS32 loop_x = 0;810 psS32 loop_y = 0;811 psS32 loop_z = 0;812 psS32 i = 0;813 float polySum = 0.0;814 psPolynomial1D* *chebPolys = NULL;815 psS32 maxChebyPoly = 0;816 817 // Determine how many Chebyshev polynomials818 // are needed, then create them.819 maxChebyPoly = myPoly->nW;820 if (myPoly->nX > maxChebyPoly) {821 maxChebyPoly = myPoly->nX;822 }823 if (myPoly->nY > maxChebyPoly) {824 maxChebyPoly = myPoly->nY;825 }826 if (myPoly->nZ > maxChebyPoly) {827 maxChebyPoly = myPoly->nZ;828 }829 chebPolys = CreateChebyshevPolys(maxChebyPoly);830 831 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {832 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {833 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {834 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {835 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {836 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *837 psPolynomial1DEval(w, chebPolys[loop_w]) *838 psPolynomial1DEval(x, chebPolys[loop_x]) *839 psPolynomial1DEval(y, chebPolys[loop_y]) *840 psPolynomial1DEval(z, chebPolys[loop_z]);841 }842 }843 }844 }845 }846 847 for (i=0;i<maxChebyPoly;i++) {848 psFree(chebPolys[i]);849 }850 psFree(chebPolys);851 return(polySum);852 }853 854 1311 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 855 1312 { … … 857 1314 858 1315 if (myPoly->type == PS_POLYNOMIAL_ORD) { 859 return( p_psOrdPolynomial4DEval(w,x,y,z, myPoly));1316 return(ordPolynomial4DEval(w,x,y,z, myPoly)); 860 1317 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 861 return( p_psChebPolynomial4DEval(w,x,y,z, myPoly));1318 return(chebPolynomial4DEval(w,x,y,z, myPoly)); 862 1319 } else { 863 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1320 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1321 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1322 myPoly->type); 864 1323 } 865 1324 return(0.0); … … 924 1383 return(tmp); 925 1384 } 926 927 928 929 1385 930 1386 … … 1092 1548 } 1093 1549 1094 static void dPolynomial1DFree(psDPolynomial1D* myPoly)1095 {1096 psFree(myPoly->coeff);1097 psFree(myPoly->coeffErr);1098 psFree(myPoly->mask);1099 }1100 1101 static void dPolynomial2DFree(psDPolynomial2D* myPoly)1102 {1103 psS32 x = 0;1104 1105 for (x = 0; x < myPoly->nX; x++) {1106 psFree(myPoly->coeff[x]);1107 psFree(myPoly->coeffErr[x]);1108 psFree(myPoly->mask[x]);1109 }1110 psFree(myPoly->coeff);1111 psFree(myPoly->coeffErr);1112 psFree(myPoly->mask);1113 }1114 1115 static void dPolynomial3DFree(psDPolynomial3D* myPoly)1116 {1117 psS32 x = 0;1118 psS32 y = 0;1119 1120 for (x = 0; x < myPoly->nX; x++) {1121 for (y = 0; y < myPoly->nY; y++) {1122 psFree(myPoly->coeff[x][y]);1123 psFree(myPoly->coeffErr[x][y]);1124 psFree(myPoly->mask[x][y]);1125 }1126 psFree(myPoly->coeff[x]);1127 psFree(myPoly->coeffErr[x]);1128 psFree(myPoly->mask[x]);1129 }1130 1131 psFree(myPoly->coeff);1132 psFree(myPoly->coeffErr);1133 psFree(myPoly->mask);1134 }1135 1136 static void dPolynomial4DFree(psDPolynomial4D* myPoly)1137 {1138 psS32 w = 0;1139 psS32 x = 0;1140 psS32 y = 0;1141 1142 for (w = 0; w < myPoly->nW; w++) {1143 for (x = 0; x < myPoly->nX; x++) {1144 for (y = 0; y < myPoly->nY; y++) {1145 psFree(myPoly->coeff[w][x][y]);1146 psFree(myPoly->coeffErr[w][x][y]);1147 psFree(myPoly->mask[w][x][y]);1148 }1149 psFree(myPoly->coeff[w][x]);1150 psFree(myPoly->coeffErr[w][x]);1151 psFree(myPoly->mask[w][x]);1152 }1153 psFree(myPoly->coeff[w]);1154 psFree(myPoly->coeffErr[w]);1155 psFree(myPoly->mask[w]);1156 }1157 1158 psFree(myPoly->coeff);1159 psFree(myPoly->coeffErr);1160 psFree(myPoly->mask);1161 }1162 1163 /*****************************************************************************1164 Polynomial coefficients will be accessed in [w][x][y][z] fashion.1165 *****************************************************************************/1166 double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1167 {1168 psS32 loop_x = 0;1169 double polySum = 0.0;1170 double xSum = 1.0;1171 1172 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {1173 if (myPoly->mask[loop_x] == 0) {1174 polySum += xSum * myPoly->coeff[loop_x];1175 xSum *= x;1176 }1177 }1178 1179 return(polySum);1180 }1181 1182 // XXX: You can do this without having to psAlloc() vector d.1183 // XXX: How does the mask vector effect Crenshaw's formula?1184 double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1185 {1186 psVector *d;1187 psS32 n;1188 psS32 i;1189 double tmp;1190 1191 n = myPoly->n;1192 d = psVectorAlloc(n, PS_TYPE_F64);1193 d->data.F64[n-1] = myPoly->coeff[n-1];1194 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];1195 for (i=n-3;i>=1;i--) {1196 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -1197 (d->data.F64[i+2]) +1198 (myPoly->coeff[i]);1199 }1200 1201 tmp = (x * d->data.F64[1]) -1202 (d->data.F64[2]) +1203 (0.5 * myPoly->coeff[0]);1204 1205 psFree(d);1206 return(tmp);1207 }1208 1550 1209 1551 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly) … … 1212 1554 1213 1555 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1214 return( p_psDOrdPolynomial1DEval(x, myPoly));1556 return(dOrdPolynomial1DEval(x, myPoly)); 1215 1557 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1216 return( p_psDChebPolynomial1DEval(x, myPoly));1558 return(dChebPolynomial1DEval(x, myPoly)); 1217 1559 } else { 1218 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1560 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1561 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1562 myPoly->type); 1219 1563 } 1220 1564 return(0.0); … … 1244 1588 1245 1589 1246 1247 double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1248 {1249 psS32 loop_x = 0;1250 psS32 loop_y = 0;1251 double polySum = 0.0;1252 double xSum = 1.0;1253 double ySum = 1.0;1254 1255 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1256 ySum = xSum;1257 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1258 if (myPoly->mask[loop_x][loop_y] == 0) {1259 polySum += ySum * myPoly->coeff[loop_x][loop_y];1260 ySum *= y;1261 }1262 }1263 xSum *= x;1264 }1265 1266 return(polySum);1267 }1268 1269 double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1270 {1271 psS32 loop_x = 0;1272 psS32 loop_y = 0;1273 psS32 i = 0;1274 double polySum = 0.0;1275 psPolynomial1D* *chebPolys = NULL;1276 psS32 maxChebyPoly = 0;1277 1278 // Determine how many Chebyshev polynomials1279 // are needed, then create them.1280 maxChebyPoly = myPoly->nX;1281 if (myPoly->nY > maxChebyPoly) {1282 maxChebyPoly = myPoly->nY;1283 }1284 chebPolys = CreateChebyshevPolys(maxChebyPoly);1285 1286 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1287 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1288 if (myPoly->mask[loop_x][loop_y] == 0) {1289 polySum += myPoly->coeff[loop_x][loop_y] *1290 psPolynomial1DEval(x, chebPolys[loop_x]) *1291 psPolynomial1DEval(y, chebPolys[loop_y]);1292 }1293 }1294 }1295 1296 for (i=0;i<maxChebyPoly;i++) {1297 psFree(chebPolys[i]);1298 }1299 psFree(chebPolys);1300 return(polySum);1301 }1302 1303 1590 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 1304 1591 { … … 1306 1593 1307 1594 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1308 return( p_psDOrdPolynomial2DEval(x, y, myPoly));1595 return(dOrdPolynomial2DEval(x, y, myPoly)); 1309 1596 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1310 return( p_psDChebPolynomial2DEval(x, y, myPoly));1597 return(dChebPolynomial2DEval(x, y, myPoly)); 1311 1598 } else { 1312 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1599 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1600 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1601 myPoly->type); 1313 1602 } 1314 1603 return(0.0); … … 1353 1642 1354 1643 1355 1356 double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1357 {1358 psS32 loop_x = 0;1359 psS32 loop_y = 0;1360 psS32 loop_z = 0;1361 double polySum = 0.0;1362 double xSum = 1.0;1363 double ySum = 1.0;1364 double zSum = 1.0;1365 1366 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1367 ySum = xSum;1368 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1369 zSum = ySum;1370 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1371 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1372 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];1373 zSum *= z;1374 }1375 }1376 ySum *= y;1377 }1378 xSum *= x;1379 }1380 1381 return(polySum);1382 }1383 1384 double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1385 {1386 psS32 loop_x = 0;1387 psS32 loop_y = 0;1388 psS32 loop_z = 0;1389 psS32 i = 0;1390 double polySum = 0.0;1391 psPolynomial1D* *chebPolys = NULL;1392 psS32 maxChebyPoly = 0;1393 1394 // Determine how many Chebyshev polynomials1395 // are needed, then create them.1396 maxChebyPoly = myPoly->nX;1397 if (myPoly->nY > maxChebyPoly) {1398 maxChebyPoly = myPoly->nY;1399 }1400 if (myPoly->nZ > maxChebyPoly) {1401 maxChebyPoly = myPoly->nZ;1402 }1403 chebPolys = CreateChebyshevPolys(maxChebyPoly);1404 1405 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1406 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1407 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1408 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1409 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *1410 psPolynomial1DEval(x, chebPolys[loop_x]) *1411 psPolynomial1DEval(y, chebPolys[loop_y]) *1412 psPolynomial1DEval(z, chebPolys[loop_z]);1413 }1414 }1415 }1416 }1417 1418 for (i=0;i<maxChebyPoly;i++) {1419 psFree(chebPolys[i]);1420 }1421 psFree(chebPolys);1422 return(polySum);1423 }1424 1425 1644 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 1426 1645 { … … 1428 1647 1429 1648 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1430 return( p_psDOrdPolynomial3DEval(x, y, z, myPoly));1649 return(dOrdPolynomial3DEval(x, y, z, myPoly)); 1431 1650 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1432 return( p_psDChebPolynomial3DEval(x, y, z, myPoly));1651 return(dChebPolynomial3DEval(x, y, z, myPoly)); 1433 1652 } else { 1434 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1653 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1654 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1655 myPoly->type); 1435 1656 } 1436 1657 return(0.0); … … 1485 1706 } 1486 1707 1487 1488 1489 1490 1491 1492 1493 1494 double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1495 {1496 psS32 loop_w = 0;1497 psS32 loop_x = 0;1498 psS32 loop_y = 0;1499 psS32 loop_z = 0;1500 double polySum = 0.0;1501 double wSum = 1.0;1502 double xSum = 1.0;1503 double ySum = 1.0;1504 double zSum = 1.0;1505 1506 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1507 xSum = wSum;1508 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1509 ySum = xSum;1510 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1511 zSum = ySum;1512 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1513 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1514 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];1515 zSum *= z;1516 }1517 }1518 ySum *= y;1519 }1520 xSum *= x;1521 }1522 wSum *= w;1523 }1524 1525 return(polySum);1526 }1527 1528 double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1529 {1530 psS32 loop_w = 0;1531 psS32 loop_x = 0;1532 psS32 loop_y = 0;1533 psS32 loop_z = 0;1534 psS32 i = 0;1535 double polySum = 0.0;1536 psPolynomial1D* *chebPolys = NULL;1537 psS32 maxChebyPoly = 0;1538 1539 // Determine how many Chebyshev polynomials1540 // are needed, then create them.1541 maxChebyPoly = myPoly->nW;1542 if (myPoly->nX > maxChebyPoly) {1543 maxChebyPoly = myPoly->nX;1544 }1545 if (myPoly->nY > maxChebyPoly) {1546 maxChebyPoly = myPoly->nY;1547 }1548 if (myPoly->nZ > maxChebyPoly) {1549 maxChebyPoly = myPoly->nZ;1550 }1551 chebPolys = CreateChebyshevPolys(maxChebyPoly);1552 1553 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1554 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1555 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1556 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1557 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1558 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *1559 psPolynomial1DEval(w, chebPolys[loop_w]) *1560 psPolynomial1DEval(x, chebPolys[loop_x]) *1561 psPolynomial1DEval(y, chebPolys[loop_y]) *1562 psPolynomial1DEval(z, chebPolys[loop_z]);1563 }1564 }1565 }1566 }1567 }1568 1569 for (i=0;i<maxChebyPoly;i++) {1570 psFree(chebPolys[i]);1571 }1572 psFree(chebPolys);1573 return(polySum);1574 }1575 1576 1708 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 1577 1709 { … … 1579 1711 1580 1712 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1581 return( p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));1713 return(dOrdPolynomial4DEval(w,x,y,z, myPoly)); 1582 1714 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1583 return( p_psDChebPolynomial4DEval(w,x,y,z, myPoly));1715 return(dChebPolynomial4DEval(w,x,y,z, myPoly)); 1584 1716 } else { 1585 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1717 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1718 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1719 myPoly->type); 1586 1720 } 1587 1721 return(0.0); … … 1699 1833 (tmp->domains)[numSplines] = max; 1700 1834 1835 p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree); 1701 1836 return(tmp); 1702 1837 } 1703 1838 1704 // XXX: Have Robert put the dealocator in the memory file.1705 psS32 p_psSpline1DFree(psSpline1D *tmpSpline)1706 {1707 psS32 i;1708 1709 if (tmpSpline == NULL) {1710 return(0);1711 }1712 1713 if (tmpSpline->spline != NULL) {1714 for (i=0;i<tmpSpline->n;i++) {1715 psFree((tmpSpline->spline)[i]);1716 }1717 psFree(tmpSpline->spline);1718 }1719 1720 if (tmpSpline->p_psDeriv2 != NULL) {1721 psFree(tmpSpline->p_psDeriv2);1722 }1723 psFree(tmpSpline->domains);1724 psFree(tmpSpline);1725 1726 return(0);1727 }1728 1839 1729 1840 /***************************************************************************** … … 1765 1876 1766 1877 /***************************************************************************** 1767 p_psVectorBinDisectF32(): This is a private function which takes as input a1878 vectorBinDisectF32(): This is a private function which takes as input a 1768 1879 vector of floating point data as well as a single floating point values. 1769 1880 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1776 1887 XXX: name since we don't take psVectors as input. 1777 1888 *****************************************************************************/ 1778 psS32 p_psVectorBinDisectF32(float *bins,1779 psS32 numBins,1780 float x)1889 static psS32 vectorBinDisectF32(float *bins, 1890 psS32 numBins, 1891 float x) 1781 1892 { 1782 1893 psS32 min; … … 1784 1895 psS32 mid; 1785 1896 1786 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1787 "---- Calling p_psVectorBinDisectF32(%f)\n", x);1897 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1898 "---- Calling vectorBinDisectF32(%f)\n", x); 1788 1899 1789 1900 if (x < bins[0]) { 1790 1901 psLogMsg(__func__, PS_LOG_WARN, 1791 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1902 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1792 1903 x, bins[0], bins[numBins-1]); 1793 1904 return(-2); … … 1796 1907 if (x > bins[numBins-1]) { 1797 1908 psLogMsg(__func__, PS_LOG_WARN, 1798 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1909 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1799 1910 x, bins[0], bins[numBins-1]); 1800 1911 return(-1); … … 1806 1917 1807 1918 while (min != max) { 1808 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1919 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1809 1920 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1810 1921 min, mid, max, x, bins[mid]); 1811 1922 1812 1923 if (x == bins[mid]) { 1813 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1814 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);1924 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1925 "---- Exiting vectorBinDisectF32(): bin %d\n", mid); 1815 1926 return(mid); 1816 1927 } else if (x < bins[mid]) { … … 1822 1933 } 1823 1934 1824 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1825 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);1935 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1936 "---- Exiting vectorBinDisectF32(): bin %d\n", min); 1826 1937 return(min); 1827 1938 } 1828 1939 1829 1940 /***************************************************************************** 1830 p_psVectorBinDisectS32(): integer version of above.1941 vectorBinDisectS32(): integer version of above. 1831 1942 *****************************************************************************/ 1832 psS32 p_psVectorBinDisectS32(psS32 *bins,1833 psS32 numBins,1834 psS32 x)1943 static psS32 vectorBinDisectS32(psS32 *bins, 1944 psS32 numBins, 1945 psS32 x) 1835 1946 { 1836 1947 psS32 min; … … 1838 1949 psS32 mid; 1839 1950 1840 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1841 "---- Calling p_psVectorBinDisectS32(%f)\n", x);1951 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1952 "---- Calling vectorBinDisectS32(%f)\n", x); 1842 1953 1843 1954 if ((x < bins[0]) || 1844 1955 (x > bins[numBins-1])) { 1845 1956 psLogMsg(__func__, PS_LOG_WARN, 1846 " p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1957 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1847 1958 x, bins[0], bins[numBins-1]); 1848 1959 return(-1); … … 1854 1965 1855 1966 while (min != max) { 1856 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1967 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1857 1968 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1858 1969 min, mid, max, x, bins[mid]); 1859 1970 1860 1971 if (x == bins[mid]) { 1861 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1862 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1972 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1973 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1863 1974 return(min); 1864 1975 } else if (x < bins[mid]) { … … 1870 1981 } 1871 1982 1872 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1873 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1983 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1984 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1874 1985 return(min); 1875 1986 } … … 1884 1995 1885 1996 if (x->type.type == PS_TYPE_S32) { 1886 return( p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1997 return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1887 1998 } else if (x->type.type == PS_TYPE_F32) { 1888 return( p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1999 return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1889 2000 } else { 1890 psError(__func__, "Unallowable data type."); 2001 char* strType; 2002 PS_TYPE_NAME(strType,x->type.type); 2003 psError(PS_ERR_BAD_PARAMETER_TYPE, 2004 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2005 strType); 1891 2006 return(-2); 1892 2007 } 1893 2008 return(-1); 1894 }1895 1896 /*****************************************************************************1897 p_psInterpolate1D(): This routine will take as input n-element floating1898 point arrays domain and range, and the x value, assumed to lie with the1899 domain vector. It produces as output the (n-1)-order LaGrange interpolated1900 value of x.1901 1902 XXX: do we error check for non-distinct domain values?1903 *****************************************************************************/1904 float p_ps1DFullInterpolateF32(float *domain,1905 float *range,1906 psS32 n,1907 float x)1908 {1909 PS_INT_CHECK_NON_NEGATIVE(n, NAN);1910 PS_PTR_CHECK_NULL(domain, NAN);1911 PS_PTR_CHECK_NULL(range, NAN);1912 1913 psS32 i;1914 psS32 m;1915 static psVector *p = NULL;1916 p = psVectorRecycle(p, n, PS_TYPE_F32);1917 p_psMemSetPersistent(p, true);1918 p_psMemSetPersistent(p->data.F32, true);1919 /*1920 psVector *p = psVectorAlloc(n, PS_TYPE_F32);1921 float tmp;1922 */1923 1924 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1925 "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);1926 1927 for (i=0;i<n;i++) {1928 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1929 "domain/range is (%f %f)\n", domain[i], range[i]);1930 }1931 1932 for (i=0;i<n;i++) {1933 p->data.F32[i] = range[i];1934 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1935 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1936 1937 }1938 1939 // From NR, during each iteration of the m loop, we are computing the1940 // p_{i ... i+m} terms.1941 for (m=1;m<n;m++) {1942 for (i=0;i<n-m;i++) {1943 // From NR: we are computing P_{i ... i+m}1944 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +1945 ((domain[i]-x) * p->data.F32[i+1])) /1946 (domain[i] - domain[i+m]);1947 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);1948 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1949 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1950 }1951 }1952 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1953 "---- p_ps1DFullInterpolateF32() end ----\n");1954 1955 /*1956 tmp = p->data.F32[0];1957 psFree(p);1958 return(tmp);1959 */1960 return(p->data.F32[0]);1961 }1962 1963 1964 /*****************************************************************************1965 p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform1966 LaGrange interpolation.1967 *****************************************************************************/1968 float p_ps1DInterpolateF32(float *domain,1969 float *range,1970 psS32 n,1971 psS32 order,1972 float x)1973 {1974 psS32 binNum;1975 psS32 numIntPoints = order+1;1976 psS32 origin;1977 1978 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,1979 "---- p_ps1DInterpolateF32() begin ----\n");1980 1981 binNum = p_psVectorBinDisectF32(domain, n, x);1982 1983 if (0 == numIntPoints%2) {1984 origin = binNum - ((numIntPoints/2) - 1);1985 } else {1986 origin = binNum - (numIntPoints/2);1987 if ((x-domain[binNum]) > (domain[binNum+1]-x)) {1988 // x is closer to binNum+1.1989 origin = 1 + (binNum - (numIntPoints/2));1990 }1991 }1992 if (origin < 0) {1993 origin = 0;1994 }1995 if ((origin + numIntPoints) > n) {1996 origin = n - numIntPoints;1997 }1998 1999 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,2000 "---- p_ps1DInterpolateF32() end ----\n");2001 return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));2002 2009 } 2003 2010 … … 2035 2042 2036 2043 if (order > (domain->n - 1)) { 2037 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2044 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 2045 PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS, 2046 order); 2038 2047 return(NULL); 2039 2048 } … … 2042 2051 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2043 2052 "---- p_psVectorInterpolate() end ----\n"); 2044 return(psScalarAlloc( p_ps1DInterpolateF32(domain->data.F32,2045 range->data.F32,2046 domain->n,2047 order,2048 x->data.F32), PS_TYPE_F32));2053 return(psScalarAlloc(interpolate1DF32(domain->data.F32, 2054 range->data.F32, 2055 domain->n, 2056 order, 2057 x->data.F32), PS_TYPE_F32)); 2049 2058 } else if (x->type.type == PS_TYPE_F64) { 2050 2059 // XXX: use recycled vectors here. … … 2053 2062 2054 2063 psScalar *tmpScalar = psScalarAlloc((double) 2055 p_ps1DInterpolateF32(domain32->data.F32,2056 range32->data.F32,2057 domain32->n,2058 order,2059 (float) x->data.F64), PS_TYPE_F64);2064 interpolate1DF32(domain32->data.F32, 2065 range32->data.F32, 2066 domain32->n, 2067 order, 2068 (float) x->data.F64), PS_TYPE_F64); 2060 2069 psFree(range32); 2061 2070 psFree(domain32); … … 2067 2076 2068 2077 } else { 2069 // XXX psError: type not supported 2070 psError(__func__, "type %d not supported\n", x->type.type); 2078 char* strType; 2079 PS_TYPE_NAME(strType,x->type.type); 2080 psError(PS_ERR_BAD_PARAMETER_TYPE, 2081 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2082 strType); 2071 2083 } 2072 2084 … … 2084 2096 and an independent x value. Each determines which spline that x corresponds 2085 2097 to by doing a bracket disection on the domains of the spline data structure 2086 ( p_psVectorBinDisectF32()). Then it evaluates the spline at that x location2098 (vectorBinDisectF32()). Then it evaluates the spline at that x location 2087 2099 by a call to the 1D polynomial functions. 2088 2100 … … 2100 2112 2101 2113 n = spline->n; 2102 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);2114 binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x); 2103 2115 if (binNum < 0) { 2104 2116 psLogMsg(__func__, PS_LOG_WARN, … … 2139 2151 } 2140 2152 } else { 2141 psError(__func__, "Unknown data type.\n"); 2153 char* strType; 2154 PS_TYPE_NAME(strType,x->type.type); 2155 psError(PS_ERR_BAD_PARAMETER_TYPE, 2156 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2157 strType); 2142 2158 return(NULL); 2143 2159 } -
trunk/psLib/src/dataManip/psFunctions.h
r2269 r2273 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-11-0 3 03:30:30$14 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:59 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 398 398 float max); 399 399 400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);401 402 400 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, 403 401 psS32 order); -
trunk/psLib/src/dataManip/psMatrix.c
r2214 r2273 20 20 * @author Ross Harman, MHPCC 21 21 * 22 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $23 * @date $Date: 2004-1 0-27 20:20:11$22 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2004-11-04 01:04:59 $ 24 24 * 25 25 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 #include "psVector.h" 41 41 #include "psMatrix.h" 42 43 /** Preprocessor macro to generate error a NULL image */ 44 #define PS_VECTOR_CHECK_NULL(NAME, RETURN) \ 45 if (NAME == NULL || NAME->data.V == NULL) { \ 46 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 47 return RETURN; \ 48 } 49 50 /** Preprocessor macro to create vector based on another */ 51 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \ 52 if(NAME == NULL) { \ 53 NAME = psVectorAlloc(SIZE, PS_TYPE); \ 54 } 55 56 /** Preprocessor macro to generate error for zero length vector */ 57 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \ 58 if (NAME->n < 1) { \ 59 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \ 60 return RETURN; \ 61 } 62 63 /** Preprocessor macro to generate error a NULL image */ 64 #define PS_IMAGE_CHECK_NULL(NAME, RETURN) \ 65 if (NAME == NULL || NAME->data.V == NULL) { \ 66 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 67 return RETURN; \ 68 } 69 70 /** Preprocessor macro to create image based on another */ 71 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \ 72 if(NAME == NULL) { \ 73 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \ 74 } 75 76 /** Preprocessor macro to generate error for zero length rows or columns */ 77 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \ 78 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 79 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 80 NAME->numCols, NAME->numRows); \ 81 return RETURN; \ 82 } 42 #include "psConstants.h" 43 44 83 45 84 46 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */ 85 47 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \ 86 48 if (NAME->type.dimen != PS_DIMEN) { \ 87 psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN); \ 49 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 50 "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN); \ 88 51 return RETURN; \ 89 52 } else if(NAME->type.type != PS_TYPE_F64) { \ 90 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \ 53 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 54 "Invalid operation. %s not PS_TYPE_F64.", #NAME); \ 91 55 return RETURN; \ 92 56 } … … 95 59 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \ 96 60 if (NAME1 == NAME2) { \ 97 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 61 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 62 "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 98 63 return RETURN; \ 99 64 } … … 102 67 #define PS_CHECK_SQUARE(NAME, RETURN) \ 103 68 if (NAME->numCols != NAME->numRows) { \ 104 psError(__func__,"Invalid operation: %s not square array.", #NAME); \ 69 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 70 "Invalid operation: %s not square array.", #NAME); \ 105 71 return RETURN; \ 106 72 } … … 126 92 gsl_permutation perm; 127 93 94 #define psMatrixLUD_EXIT { \ 95 psFree(outImage); \ 96 return NULL; \ 97 } 98 128 99 // Error checks 129 100 PS_CHECK_POINTERS(inImage, outImage, outImage); 130 PS_IMAGE_CHECK_NULL(inImage, outImage);131 101 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 132 PS_CHECK_SIZE_IMAGE(inImage, outImage); 133 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 134 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 135 PS_CHECK_SIZE_IMAGE(outImage, outImage); 136 PS_CHECK_ALLOC_VECTOR(outPerm, inImage->numRows, inImage->type.type); 137 PS_VECTOR_CHECK_NULL(outPerm, outImage); 102 103 PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT); 104 PS_VECTOR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT); 105 138 106 PS_CHECK_DIMEN_AND_TYPE(outPerm, PS_DIMEN_VECTOR, outImage); 107 108 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 109 psVectorRecycle(outPerm, inImage->numRows, inImage->type.type); 139 110 140 111 // Initialize data … … 179 150 PS_IMAGE_CHECK_NULL(inImage, outVector); 180 151 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector); 181 PS_CHECK_SIZE_IMAGE(inImage, outVector); 182 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type); 152 PS_IMAGE_CHECK_EMPTY(inImage, outVector); 183 153 PS_VECTOR_CHECK_NULL(outVector, outVector); 184 154 PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector); … … 188 158 PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector); 189 159 160 psVectorRecycle(outVector, inImage->numRows, inImage->type.type); 161 162 190 163 // Initialize data 191 164 numRows = inImage->numRows; … … 226 199 227 200 // Error checks 228 if (det == NULL) { 229 psError(__func__, "Invalid operation: determinant argument is NULL."); 230 return outImage; 231 } 201 PS_PTR_CHECK_NULL(det, outImage); 232 202 PS_CHECK_POINTERS(inImage, outImage, outImage); 233 203 PS_IMAGE_CHECK_NULL(inImage, outImage); 234 204 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 235 PS_CHECK_SIZE_IMAGE(inImage, outImage); 236 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 237 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 238 PS_CHECK_SIZE_IMAGE(outImage, outImage); 205 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 206 207 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 239 208 240 209 // Initialize data … … 282 251 PS_IMAGE_CHECK_NULL(inImage, NULL); 283 252 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL); 284 PS_ CHECK_SIZE_IMAGE(inImage, NULL);253 PS_IMAGE_CHECK_EMPTY(inImage, NULL); 285 254 286 255 // Initialize data … … 325 294 PS_IMAGE_CHECK_NULL(inImage1, outImage); 326 295 PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage); 327 PS_ CHECK_SIZE_IMAGE(inImage1, outImage);296 PS_IMAGE_CHECK_EMPTY(inImage1, outImage); 328 297 PS_IMAGE_CHECK_NULL(inImage2, outImage); 329 298 PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage); 330 PS_CHECK_SIZE_IMAGE(inImage2, outImage); 331 PS_CHECK_ALLOC_IMAGE(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type); 299 PS_IMAGE_CHECK_EMPTY(inImage2, outImage); 332 300 PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage); 333 PS_CHECK_SIZE_IMAGE(outImage, outImage); 301 302 psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type); 334 303 335 304 // Initialize data … … 364 333 PS_IMAGE_CHECK_NULL(inImage, outImage); 365 334 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 366 PS_CHECK_SIZE_IMAGE(inImage, outImage); 367 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 368 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 369 PS_CHECK_SIZE_IMAGE(outImage, outImage); 335 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 336 337 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 370 338 371 339 // Initialize data … … 403 371 PS_IMAGE_CHECK_NULL(inImage, outImage); 404 372 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 405 PS_CHECK_SIZE_IMAGE(inImage, outImage); 406 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 407 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 408 PS_CHECK_SIZE_IMAGE(outImage, outImage); 373 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 374 375 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 409 376 410 377 // Initialize data … … 438 405 psS32 size = 0; 439 406 440 // Error checks 441 PS_IMAGE_CHECK_NULL(inImage, outVector); 407 #define psMatrixToVector_EXIT { \ 408 psFree(outVector); \ 409 return NULL; \ 410 } 411 412 // Error checks 413 PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT); 442 414 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector); 443 PS_ CHECK_SIZE_IMAGE(inImage, outVector);415 PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT); 444 416 445 417 if (inImage->numRows == 1) { 446 418 // Create transposed row vector 447 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);419 psVectorRecycle(outVector, inImage->numCols, inImage->type.type); 448 420 outVector->type.dimen = PS_DIMEN_TRANSV; 449 421 } else if (inImage->numCols == 1) { 450 422 // Create non-transposed column vector 451 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);423 psVectorRecycle(outVector, inImage->numRows, inImage->type.type); 452 424 } else { 453 psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows, 454 inImage->numCols); 425 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 426 "Image does not have dim with 1 col or 1 row: (%d x %d).", 427 inImage->numRows, inImage->numCols); 455 428 return outVector; 456 429 } … … 467 440 468 441 if (outVector->n != inImage->numRows) { 469 psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numRows, outVector->n); 442 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 443 "Image and vector sizes differ: (%d vs %d).", 444 inImage->numRows, outVector->n); 470 445 return outVector; 471 446 } … … 481 456 482 457 if (outVector->n != inImage->numCols) { 483 psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n); 458 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 459 "Image and vector sizes differ: (%d vs %d).", 460 inImage->numCols, outVector->n); 484 461 return outVector; 485 462 } … … 502 479 if (inVector->type.dimen == PS_DIMEN_VECTOR) { 503 480 PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage); 504 PS_ CHECK_SIZE_VECTOR(inVector, outImage);505 PS_CHECK_ALLOC_IMAGE(outImage, 1, inVector->n, PS_TYPE_F64)481 PS_VECTOR_CHECK_EMPTY(inVector, outImage); 482 psImageRecycle(outImage, 1, inVector->n, PS_TYPE_F64); 506 483 // More checks for PS_DIMEN_VECTOR 507 484 if (outImage->numCols > 1) { 508 psError(__func__, "Image has more than 1 column: numCols = %d.", outImage->numCols); 485 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 486 "Image has more than 1 column: numCols = %d.", 487 outImage->numCols); 509 488 return outImage; 510 489 } else if (outImage->numRows != inVector->n) { 511 psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n); 490 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 491 "Image and vector sizes differ: (%d vs %d).", 492 outImage->numRows, inVector->n); 512 493 return outImage; 513 494 } … … 517 498 } else if (inVector->type.dimen == PS_DIMEN_TRANSV) { 518 499 PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage); 519 PS_ CHECK_SIZE_VECTOR(inVector, outImage);520 PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)500 PS_VECTOR_CHECK_EMPTY(inVector, outImage); 501 psImageRecycle(outImage, inVector->n, 1, PS_TYPE_F64); 521 502 // More checks for PS_DIMEN_TRANSV 522 503 if (outImage->numRows > 1) { 523 psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows); 504 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 505 "Image has more than 1 row: numRows = %d.", 506 outImage->numRows); 524 507 return outImage; 525 508 } else if (outImage->numCols != inVector->n) { 526 psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n); 509 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 510 "Image and vector sizes differ: (%d vs %d).", 511 outImage->numCols, inVector->n); 527 512 return outImage; 528 513 } -
trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c
r2204 r2273 29 29 * @author Ross Harman, MHPCC 30 30 * 31 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $32 * @date $Date: 2004-1 0-27 00:57:31$31 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 32 * @date $Date: 2004-11-04 01:04:59 $ 33 33 * 34 34 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 #include "psScalar.h" 49 49 #include "psLogMsg.h" 50 #include "psConstants.h" 51 #include "psDataManipErrors.h" 50 52 51 53 /***************************************************************************** … … 58 60 // Conversion for radians to degrees 59 61 #define R2D 57.29577950924861 /* 180.0/PI */ 60 61 /* IEEE Standards on floating-point makes this function pointless, really.62 // Division with NAN checking63 static complex double psNanDiv(complex double a, complex double b)64 {65 complex double out = 0 + 0i;66 67 out = a / b;68 if (isnan(creal(out)) || isnan(cimag(out))) {69 psError(__func__, ": Divide by zero");70 }71 72 return out;73 }74 */75 62 76 63 // Binary SCALAR_XXXX operations … … 142 129 #define VECTOR_VECTOR(OUT,IN1,OP,IN2,TYPE) \ 143 130 { \ 144 psS32 i = 0; \145 psS32 n1 = 0; \146 psS32 n2 = 0; \131 psS32 i = 0; \ 132 psS32 n1 = 0; \ 133 psS32 n2 = 0; \ 147 134 ps##TYPE *o = NULL; \ 148 135 ps##TYPE *i1 = NULL; \ … … 151 138 n2 = ((psVector* )IN2)->n; \ 152 139 if(n1 != n2) { \ 153 psError(__func__, ": Inconsistent element count: %d vs %d", n1, n2); \ 140 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 141 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 142 n1, n2); \ 154 143 if (OUT != IN1 && OUT != IN2) { \ 155 144 psFree(OUT); \ … … 167 156 #define VECTOR_IMAGE(OUT,IN1,OP,IN2,TYPE) \ 168 157 { \ 169 psS32 i = 0; \170 psS32 j = 0; \171 psS32 n1 = 0; \172 psS32 numRows2 = 0; \173 psS32 numCols2 = 0; \158 psS32 i = 0; \ 159 psS32 j = 0; \ 160 psS32 n1 = 0; \ 161 psS32 numRows2 = 0; \ 162 psS32 numCols2 = 0; \ 174 163 psDimen dim1 = 0; \ 175 164 ps##TYPE *o = NULL; \ … … 181 170 numCols2 = ((psImage* )IN2)->numCols; \ 182 171 \ 183 if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */ \172 if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */ \ 184 173 if(n1!=numRows2) { \ 185 psError(__func__, ": Inconsistent element count: %d vs %d", n1, numRows2); \ 174 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 175 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 176 n1, numRows2); \ 186 177 if (OUT != IN1 && OUT != IN2) { \ 187 178 psFree(OUT); \ … … 200 191 } else { /* Transposed vectors */ \ 201 192 if(n1!=numCols2) { \ 202 psError(__func__, ": Inconsistent element count: %d vs %d", n1, numCols2); \ 193 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 194 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 195 n1, numCols2); \ 203 196 if (OUT != IN1 && OUT != IN2) { \ 204 197 psFree(OUT); \ … … 256 249 numCols1 = ((psImage* )IN1)->numCols; \ 257 250 \ 258 if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */ \251 if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */ \ 259 252 if(n2!=numRows1) { \ 260 psError(__func__, ": Inconsistent element count: %d vs %d", n2, numRows1); \ 253 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 254 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 255 n2, numRows1); \ 261 256 if (OUT != IN1 && OUT != IN2) { \ 262 257 psFree(OUT); \ … … 275 270 } else { /* Transposed vectors */ \ 276 271 if(n2!=numCols1) { \ 277 psError(__func__, ": Inconsistent element count: %d vs %d", n2, numCols1); \ 272 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 273 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 274 n2, numCols1); \ 278 275 if (OUT != IN1) { \ 279 276 psFree(OUT); \ … … 309 306 numCols2 = ((psImage* )IN2)->numCols; \ 310 307 if(numRows1!=numRows2 || numCols1!=numCols2) { \ 311 psError(__func__, ": Inconsistent element count: numRows: %d vs %d numCols: %d vs %d", numRows1, \ 312 numRows2, numCols1, numCols2); \ 308 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 309 PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS, \ 310 numCols1, numRows1, numCols2, numRows2); \ 313 311 if (OUT != IN1 && OUT != IN2) { \ 314 312 psFree(OUT); \ … … 366 364 break; \ 367 365 default: \ 368 psError(__func__, ": Invalid PS_TYPE: %d", IN1->type); \ 366 /* char* strType; \ 367 PS_TYPE_NAME(strType,IN1->type); \ 368 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 369 PS_ERRORTEXT_psMatrix_TYPE_MISMATCH, \ 370 strType); */ \ 369 371 if (OUT != IN1 && OUT != IN2) { \ 370 372 psFree(OUT); \ … … 391 393 } else if(!strncmp(OP, "min", 3)) { \ 392 394 if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) { \ 393 psError(__func__, ": Minimum operation not supported for complex numbers"); \ 395 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 396 PS_ERRORTEXT_psMatrix_MIN_COMPLEX_SUPPORT); \ 394 397 if (OUT != IN1 && OUT != IN2) { \ 395 398 psFree(OUT); \ … … 401 404 } else if(!strncmp(OP, "max", 3)) { \ 402 405 if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) { \ 403 psError(__func__, ": Maximum operation not supported for complex numbers"); \ 406 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 407 PS_ERRORTEXT_psMatrix_MAX_COMPLEX_SUPPORT); \ 404 408 if (OUT != IN1 && OUT != IN2) { \ 405 409 psFree(OUT); \ … … 410 414 } \ 411 415 } else { \ 412 psError(__func__, ": Invalid operation: %s", OP); \ 416 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 417 PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED, \ 418 OP); \ 413 419 if (OUT != IN1 && OUT != IN2) { \ 414 420 psFree(OUT); \ … … 419 425 psPtr psBinaryOp(psPtr out, psPtr in1, char *op, psPtr in2) 420 426 { 421 psDimen dim1 = 0; 422 psDimen dim2 = 0; 423 psElemType elType1 = 0; 424 psElemType elType2 = 0; 425 psType* psType1 = NULL; 426 psType* psType2 = NULL; 427 428 psType1 = (psType* ) in1; 429 if (psType1 == NULL) { 430 psError(__func__, ": Line %d - Null in1 argument", __LINE__); 431 if (out != in1 && out != in2) { 432 psFree(out); 433 } 434 return NULL; 435 } 436 437 psType2 = (psType* ) in2; 438 if (psType2 == NULL) { 439 psError(__func__, ": Line %d - Null in2 argument", __LINE__); 440 if (out != in1 && out != in2) { 441 psFree(out); 442 } 443 return NULL; 444 } 445 446 if (op == NULL) { 447 psError(__func__, ": Line %d - Null op argument", __LINE__); 448 if (out != in1 && out != in2) { 449 psFree(out); 450 } 451 return NULL; 452 } 453 454 dim1 = psType1->dimen; 455 dim2 = psType2->dimen; 456 elType1 = psType1->type; 457 elType2 = psType2->type; 458 459 if (elType1 != elType2) { 460 psError(__func__, ": Line %d - Element types for arguments inconsistent: (%d, %d)", __LINE__, 461 elType1, elType2); 462 if (out != in1 && out != in2) { 463 psFree(out); 464 } 465 return NULL; 466 } 467 468 if (dim1 == PS_DIMEN_OTHER || dim2 == PS_DIMEN_OTHER) { 469 psError(__func__, ": Line %d - PS_DIMEN_OTHER not allowed for arguments: (%d, %d)", __LINE__, 470 dim1, dim2); 471 if (out != in1 && out != in2) { 472 psFree(out); 473 } 474 return NULL; 475 } 427 428 psVector* input1 = (psVector* ) in1; 429 psVector* input2 = (psVector* ) in2; 430 431 #define psBinaryOp_EXIT { \ 432 if (out != in1 && out != in2) { \ 433 psFree(out); \ 434 } \ 435 return NULL; \ 436 } 437 438 PS_PTR_CHECK_NULL_GENERAL(input1, psBinaryOp_EXIT); 439 PS_PTR_CHECK_NULL_GENERAL(input2, psBinaryOp_EXIT); 440 PS_PTR_CHECK_NULL_GENERAL(op, psBinaryOp_EXIT); 441 442 PS_PTR_CHECK_TYPE_EQUAL_GENERAL(input1,input2, psBinaryOp_EXIT); 443 444 PS_PTR_CHECK_DIMEN_GENERAL(input1, PS_DIMEN_OTHER, psBinaryOp_EXIT); 445 PS_PTR_CHECK_DIMEN_GENERAL(input2, PS_DIMEN_OTHER, psBinaryOp_EXIT); 446 447 psType* psType1 = (psType*)in1; 448 psType* psType2 = (psType*)in2; 449 psDimen dim1 = psType1->dimen; 450 psDimen dim2 = psType2->dimen; 451 psElemType elType1 = psType1->type; 452 psElemType elType2 = psType2->type; 476 453 477 454 if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) { 478 455 if (((psVector* ) in1)->n == 0) { 479 psLogMsg(__func__, PS_LOG_WARN, " : Line %d -Vector contains zero elements");456 psLogMsg(__func__, PS_LOG_WARN, "Vector contains zero elements"); 480 457 } 481 458 } else if (dim1 == PS_DIMEN_IMAGE) { 482 459 if (((psImage* ) in1)->numCols == 0 || ((psImage* ) in1)->numRows == 0) { 483 psLogMsg(__func__, PS_LOG_WARN, " : Line %d -Image contains zero length row or cols");460 psLogMsg(__func__, PS_LOG_WARN, "Image contains zero length row or cols"); 484 461 } 485 462 } … … 487 464 if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) { 488 465 if (((psVector* ) in2)->n == 0) { 489 psLogMsg(__func__, PS_LOG_WARN, " : Line %d -Vector contains zero elements");466 psLogMsg(__func__, PS_LOG_WARN, "Vector contains zero elements"); 490 467 } 491 468 } else if (dim2 == PS_DIMEN_IMAGE) { 492 469 if (((psImage* ) in2)->numCols == 0 || ((psImage* ) in2)->numRows == 0) { 493 psLogMsg(__func__, PS_LOG_WARN, " : Line %d -Image contains zero length row or cols");470 psLogMsg(__func__, PS_LOG_WARN, "Image contains zero length row or cols"); 494 471 } 495 472 } … … 513 490 out = psVectorRecycle(out,((psVector*)in2)->n,elType1); 514 491 if (out == NULL) { 515 psError(__func__, "Couldn't create a proper output psVector."); 492 psError(PS_ERR_UNKNOWN, false, 493 PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 516 494 return NULL; 517 495 } … … 520 498 out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows,elType1); 521 499 if (out == NULL) { 522 psError(__func__, "Couldn't create a proper output psImage."); 500 psError(PS_ERR_UNKNOWN, false, 501 PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 523 502 return NULL; 524 503 } 525 504 BINARY_OP(SCALAR, IMAGE, out, psType1, op, psType2); // scalar op image 526 505 } else { 527 psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2); 506 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 507 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 508 "in2",dim2); 509 psBinaryOp_EXIT; 528 510 } 529 511 } else if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) { … … 531 513 out = psVectorRecycle(out,((psVector*)in1)->n,elType1); 532 514 if (out == NULL) { 533 psError(__func__, "Couldn't create a proper output psVector."); 515 psError(PS_ERR_UNKNOWN, false, 516 PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 534 517 return NULL; 535 518 } … … 538 521 out = psVectorRecycle(out,((psVector*)in2)->n,elType2); 539 522 if (out == NULL) { 540 psError(__func__, "Couldn't create a proper output psVector."); 523 psError(PS_ERR_UNKNOWN, false, 524 PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 541 525 return NULL; 542 526 } … … 545 529 out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows, elType2); 546 530 if (out == NULL) { 547 psError(__func__, "Couldn't create a proper output psImage."); 531 psError(PS_ERR_UNKNOWN, false, 532 PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 548 533 return NULL; 549 534 } 550 535 BINARY_OP(VECTOR, IMAGE, out, psType1, op, psType2); // vector op image 551 536 } else { 552 psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2); 537 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 538 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 539 "in2",dim2); 540 psBinaryOp_EXIT; 553 541 } 554 542 } else if (dim1 == PS_DIMEN_IMAGE) { 555 543 out = psImageRecycle(out, ((psImage*)in1)->numCols, ((psImage*)in1)->numRows, elType1); 556 544 if (out == NULL) { 557 psError(__func__, "Couldn't create a proper output psImage."); 545 psError(PS_ERR_UNKNOWN, false, 546 PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 558 547 return NULL; 559 548 } … … 565 554 BINARY_OP(IMAGE, IMAGE, out, psType1, op, psType2); // image op image 566 555 } else { 567 if (out != in1 && out != in2) { 568 psFree(out); 569 } 570 psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2); 571 return NULL; 556 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 557 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 558 "in2",dim2); 559 psBinaryOp_EXIT; 572 560 } 573 561 } else { 574 if (out != in1 && out != in2) { 575 psFree(out); 576 } 577 psError(__func__, ": Line %d - Invalid dimensionality for in1 arg: %d", __LINE__, dim1); 578 return NULL; 562 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 563 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 564 "in1",dim1); 565 psBinaryOp_EXIT; 579 566 } 580 567 … … 605 592 #define VECTOR(OUT,IN,OP,TYPE) \ 606 593 { \ 607 psS32 i = 0; \608 psS32 nIn = 0; \609 psS32 nOut = 0; \594 psS32 i = 0; \ 595 psS32 nIn = 0; \ 596 psS32 nOut = 0; \ 610 597 ps##TYPE *o = NULL; \ 611 598 ps##TYPE *i1 = NULL; \ … … 613 600 nOut = ((psVector* )OUT)->n; \ 614 601 if(nIn != nOut) { \ 615 psError(__func__, ": Inconsistent element count: %d vs %d", nIn, nOut); \ 602 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 603 PS_ERRORTEXT_psMatrix_COUNT_DIFFERS, \ 604 nIn, nOut); \ 616 605 if (OUT != IN) { \ 617 606 psFree(OUT); \ … … 629 618 #define IMAGE(OUT,IN,OP,TYPE) \ 630 619 { \ 631 psS32 i = 0; \632 psS32 j = 0; \633 psS32 numRowsIn = 0; \634 psS32 numColsIn = 0; \635 psS32 numRowsOut = 0; \636 psS32 numColsOut = 0; \620 psS32 i = 0; \ 621 psS32 j = 0; \ 622 psS32 numRowsIn = 0; \ 623 psS32 numColsIn = 0; \ 624 psS32 numRowsOut = 0; \ 625 psS32 numColsOut = 0; \ 637 626 ps##TYPE *o = NULL; \ 638 627 ps##TYPE *i1 = NULL; \ … … 642 631 numColsOut = ((psImage* )OUT)->numCols; \ 643 632 if(numRowsIn!=numRowsOut || numColsIn!=numColsOut) { \ 644 psError(__func__, ": Inconsistent element count: numRows: %d vs %d numCols: %d vs %d", numRowsIn, \ 645 numRowsOut, numColsIn, numColsOut); \ 633 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 634 PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS, \ 635 numColsIn, numRowsIn, numColsOut, numRowsOut); \ 646 636 if (OUT != IN) { \ 647 637 psFree(OUT); \ … … 697 687 DIM(OUT,IN,OP,C32); \ 698 688 break; \ 699 default: \ 700 psError(__func__, ": Invalid PS_TYPE: %d", IN->type); \ 701 if (OUT != IN) { \ 702 psFree(OUT); \ 703 } \ 704 return NULL; \ 689 default: { \ 690 char* strType; \ 691 PS_TYPE_NAME(strType, IN->type); \ 692 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 693 PS_ERRORTEXT_psMatrix_TYPE_MISMATCH, \ 694 strType); \ 695 if (OUT != IN) { \ 696 psFree(OUT); \ 697 } \ 698 return NULL; \ 699 } \ 705 700 } 706 701 … … 815 810 } \ 816 811 } else { \ 817 psError(__func__, ": Invalid operation: %s", OP); \ 812 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 813 PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED, \ 814 OP); \ 818 815 } 819 816 820 817 psPtr psUnaryOp(psPtr out, psPtr in, char *op) 821 818 { 822 psDimen dimIn = 0; 823 psElemType elTypeIn = 0; 824 psType* psTypeIn = NULL; 825 826 psTypeIn = (psType* ) in; 827 if (psTypeIn == NULL) { 828 psError(__func__, ": Line %d - Null in argument", __LINE__); 829 if (out != in) { 830 psFree(out); 831 } 832 return NULL; 833 } 834 835 if (op == NULL) { 836 psError(__func__, ": Line %d - Null op argument", __LINE__); 837 if (out != in) { 838 psFree(out); 839 } 840 return NULL; 841 } 842 843 dimIn = psTypeIn->dimen; 844 elTypeIn = psTypeIn->type; 819 #define psUnaryOp_EXIT { \ 820 if (out != in) { \ 821 psFree(out); \ 822 } \ 823 if(psTypeIn->dimen==PS_DIMEN_SCALAR && in!=out) { \ 824 psFree(in); \ 825 } \ 826 return NULL; \ 827 } 828 829 psType* psTypeIn = (psType* ) in; 830 831 PS_PTR_CHECK_NULL_GENERAL(in, psUnaryOp_EXIT); 832 PS_PTR_CHECK_NULL_GENERAL(op, psUnaryOp_EXIT); 833 834 psDimen dimIn = psTypeIn->dimen; 835 psElemType elTypeIn = psTypeIn->type; 845 836 846 837 switch (dimIn) { … … 857 848 case PS_DIMEN_TRANSV: 858 849 if (((psVector*)in)->n == 0) { 859 if (out != in) { 860 psFree(out); 861 } 862 psError(__func__, ": Line %d - Vector contains zero elements"); 863 return NULL; 850 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 851 PS_ERRORTEXT_psMatrix_VECTOR_EMPTY); 852 psUnaryOp_EXIT; 864 853 } 865 854 … … 868 857 elTypeIn); 869 858 if (out == NULL) { 870 psError(__func__, "Couldn't create a proper output psVector."); 871 return NULL; 859 psError(PS_ERR_UNKNOWN, false, 860 PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED); 861 psUnaryOp_EXIT; 872 862 } 873 863 … … 876 866 case PS_DIMEN_IMAGE: 877 867 if (((psImage* ) in)->numCols == 0 || ((psImage* ) in)->numRows == 0) { 878 if (out != in) { 879 psFree(out); 880 } 881 psError(__func__, ": Line %d - Image contains zero length row or cols"); 882 return NULL; 868 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 869 PS_ERRORTEXT_psMatrix_IMAGE_EMPTY); 870 psUnaryOp_EXIT; 883 871 } 884 872 … … 888 876 elTypeIn); 889 877 if (out == NULL) { 890 psError(__func__, "Couldn't create a proper output psImage."); 891 return NULL; 878 psError(PS_ERR_UNKNOWN, false, 879 PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED); 880 psUnaryOp_EXIT; 892 881 } 893 882 … … 898 887 psFree(out); 899 888 } 900 psError(__func__, ": Line %d - Invalid dimensionality for in arg: %d", __LINE__, dimIn); 901 return NULL; 889 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 890 PS_ERRORTEXT_psMatrix_DIMEN_INVALID, 891 "in", dimIn); 892 psUnaryOp_EXIT; 902 893 } 903 894 -
trunk/psLib/src/dataManip/psMinimize.c
r2269 r2273 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 3 03:30:30$11 * @version $Revision: 1.85 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 291 291 292 292 if (y32->n != (1 + mySpline->n)) { 293 psError(__func__, "data size / spline size mismatch (%d %d)\n", 293 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 294 "data size / spline size mismatch (%d %d)\n", 294 295 y32->n, mySpline->n); 295 296 return(NULL); … … 318 319 // Check if these are cubic splines (n==4). If not, psError. 319 320 if (4 != (mySpline->spline[0])->n) { 320 psError(__func__, "Don't know how to generate %d-order splines.", 321 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 322 "Don't know how to generate %d-order splines.", 321 323 (mySpline->spline[0])->n-1); 322 324 return(NULL); … … 952 954 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 953 955 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 954 p _psNormalizeVectorRange(x64Static, -1.0, 1.0);956 psNormalizeVectorRange(x64Static, -1.0, 1.0); 955 957 } 956 958 x64 = x64Static; … … 968 970 tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64); 969 971 } else { 970 psError(__func__, "unknown polynomial type.\n"); 972 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 973 "unknown polynomial type.\n"); 971 974 return(NULL); 972 975 } … … 1365 1368 bracket = p_psDetermineBracket2(params, line, paramMask, coords, func); 1366 1369 if (bracket == NULL) { 1367 psError(__func__, "(1) Could not bracket minimum."); 1370 psError(PS_ERR_UNKNOWN, false, 1371 "Could not bracket minimum."); 1368 1372 return(NAN); 1369 1373 } … … 1552 1556 func); 1553 1557 if (isnan(mul)) { 1554 psError(__func__, "Could not perform line minimization (1).\n"); 1558 psError(PS_ERR_UNKNOWN, false, 1559 "Could not perform line minimization"); 1555 1560 psFree(v); 1556 1561 return(false); … … 1592 1597 mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func); 1593 1598 if (isnan(mul)) { 1594 psError(__func__, "Could not perform line minimization. (2)\n"); 1599 psError(PS_ERR_UNKNOWN, false, 1600 "Could not perform line minimization."); 1595 1601 psFree(v); 1596 1602 return(false); -
trunk/psLib/src/dataManip/psStats.c
r2269 r2273 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 3 03:30:30$11 * @version $Revision: 1.85 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 #include "psFunctions.h" 35 35 #include "psConstants.h" 36 37 #include "psDataManipErrors.h" 36 38 37 39 /*****************************************************************************/ … … 735 737 736 738 // Ensure that stats->clipIter is within the proper range. 737 if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) { 738 psError(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter); 739 return(-1); 740 } 739 PS_INT_CHECK_RANGE(stats->clipIter,PS_CLIPPED_NUM_ITER_LB,PS_CLIPPED_NUM_ITER_UB,-1); 740 741 741 // Ensure that stats->clipSigma is within the proper range. 742 if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) { 743 psError(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma); 744 return(-1); 745 } 742 PS_INT_CHECK_RANGE(stats->clipSigma,PS_CLIPPED_SIGMA_LB,PS_CLIPPED_SIGMA_UB,-1); 743 746 744 // We allocate a temporary mask vector since during the iterative 747 745 // steps that follow, we will be masking off additional data points. … … 869 867 p_psNormalizeVectorRangeF64(myData, low, high); 870 868 } else { 871 psError(__func__, "Unalowable data type.\n"); 869 char* strType; 870 PS_TYPE_NAME(strType,myData->type.type); 871 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 872 PS_ERRORTEXT_psStats_NOT_F32_F64, 873 strType); 872 874 } 873 875 } … … 954 956 // Ensure that yVal is within the range of the bins we are using. 955 957 if (!((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2]))) { 956 printf("((%f), %f, %f)\n", yVal, y->data.F64[0], y->data.F64[2]); 957 psError(__func__, "yVal not within y-range\n"); 958 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 959 PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE, 960 (double)yVal,y->data.F64[2],y->data.F64[0]); 958 961 } 959 962 yErr->data.F64[0] = 1.0; … … 1113 1116 1114 1117 if ((LQBinNum < 0) || (UQBinNum < 0)) { 1115 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1118 psError(PS_ERR_UNKNOWN, true, 1119 PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED); 1116 1120 return(1); 1117 1121 } 1118 1122 if (medianBinNum < 0) { 1119 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1123 psError(PS_ERR_UNKNOWN, true, 1124 PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED); 1120 1125 return(1); 1121 1126 } … … 1174 1179 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1175 1180 1176 p _psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);1181 psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0); 1177 1182 for (i=0;i<robustHistogramVector->n;i++) { 1178 1183 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); … … 1536 1541 // do nothing 1537 1542 } else { 1538 psError(__func__, "unsupported vector type 0x%x\n", in->type.type); 1543 char* strType; 1544 PS_TYPE_NAME(strType,in->type.type); 1545 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1546 PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED, 1547 strType); 1539 1548 } 1540 1549 return (tmp); … … 1603 1612 (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) { 1604 1613 if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) { 1605 psError(__func__, "p_psVectorRobustStats() failed.\n"); 1614 psError(PS_ERR_UNKNOWN, false, 1615 PS_ERRORTEXT_psStats_STATS_FAILED); 1606 1616 } 1607 1617 } … … 1609 1619 if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) { 1610 1620 if (0 != p_psVectorClippedStats(inF32, mask, maskVal, stats)) { 1611 psError(__func__, "p_psVectorClippedStats() failed.\n"); 1621 psError(PS_ERR_UNKNOWN, false, 1622 "Failed to calculate statistics for input psVector."); 1612 1623 } 1613 1624 } -
trunk/psLib/src/dataManip/psVectorFFT.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:04:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 63 63 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR); 64 64 } else { 65 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT", 66 PS_ERR_BAD_PARAMETER_VALUE, true, 67 PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET); 65 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 66 PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET); 68 67 psFree(out); 69 68 return NULL; … … 72 71 /* check if a plan exists now */ 73 72 if (plan == NULL) { 74 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT", 75 PS_ERR_BAD_PARAMETER_TYPE, true, 76 PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL); 73 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 74 PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL); 77 75 psFree(out); 78 76 return NULL; … … 144 142 char* typeStr; 145 143 PS_TYPE_NAME(typeStr,type); 146 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorReal", 147 PS_ERR_BAD_PARAMETER_TYPE, true, 148 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 149 typeStr); 144 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 145 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 146 typeStr); 150 147 psFree(out); 151 148 return NULL; … … 204 201 char* typeStr; 205 202 PS_TYPE_NAME(typeStr,type); 206 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorImaginary", 207 PS_ERR_BAD_PARAMETER_TYPE, true, 208 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 209 typeStr); 203 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 204 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 205 typeStr); 210 206 psFree(out); 211 207 return NULL; … … 237 233 PS_TYPE_NAME(typeStrReal,type); 238 234 PS_TYPE_NAME(typeStrImag,imag->type.type); 239 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex", 240 PS_ERR_BAD_PARAMETER_TYPE, true, 241 PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH, 242 typeStrReal,typeStrImag); 235 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 236 PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH, 237 typeStrReal,typeStrImag); 243 238 psFree(out); 244 239 return NULL; … … 272 267 char* typeStr; 273 268 PS_TYPE_NAME(typeStr,type); 274 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex", 275 PS_ERR_BAD_PARAMETER_TYPE, true, 276 PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED, 277 typeStr); 269 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 270 PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED, 271 typeStr); 278 272 psFree(out); 279 273 return NULL; … … 333 327 char* typeStr; 334 328 PS_TYPE_NAME(typeStr,type); 335 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorConjugate", 336 PS_ERR_BAD_PARAMETER_TYPE, true, 337 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 338 typeStr); 329 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 330 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 331 typeStr); 339 332 psFree(out); 340 333 return NULL; … … 414 407 char* typeStr; 415 408 PS_TYPE_NAME(typeStr,type); 416 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorPowerSpectrum", 417 PS_ERR_BAD_PARAMETER_TYPE, true, 418 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 419 typeStr); 420 psFree(out); 421 return NULL; 422 } 423 424 return out; 425 426 } 409 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 410 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 411 typeStr); 412 psFree(out); 413 return NULL; 414 } 415 416 return out; 417 418 } -
trunk/psLib/src/fft/psImageFFT.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:05:00 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 if ( ((direction & PS_FFT_FORWARD) != 0) ) { 44 44 if ((direction & PS_FFT_REVERSE) != 0) { 45 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 46 PS_ERR_BAD_PARAMETER_VALUE, true, 47 PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE); 45 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 46 PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE); 48 47 psFree(out); 49 48 return NULL; 50 49 } 51 50 if ((direction & PS_FFT_REAL_RESULT) != 0) { 52 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 53 PS_ERR_BAD_PARAMETER_VALUE, true, 54 PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED); 51 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 52 PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED); 55 53 psFree(out); 56 54 return NULL; 57 55 } 58 56 } else if ((direction & PS_FFT_REVERSE) == 0) { 59 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 60 PS_ERR_BAD_PARAMETER_VALUE, true, 61 PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION); 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 58 PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION); 62 59 psFree(out); 63 60 return NULL; … … 86 83 /* check if a plan exists now -- if not, it is a real problem at this point */ 87 84 if (plan == NULL) { 88 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 89 PS_ERR_BAD_PARAMETER_TYPE, true, 90 PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL); 85 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 86 PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL); 91 87 psFree(out); 92 88 return NULL; … … 163 159 char* typeStr; 164 160 PS_TYPE_NAME(typeStr,type); 165 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal", 166 PS_ERR_BAD_PARAMETER_TYPE, true, 167 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 168 typeStr); 161 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 162 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 163 typeStr); 169 164 170 165 psFree(out); … … 226 221 char* typeStr; 227 222 PS_TYPE_NAME(typeStr,type); 228 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary", 229 PS_ERR_BAD_PARAMETER_TYPE, true, 230 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 231 typeStr); 223 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 224 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 225 typeStr); 232 226 psFree(out); 233 227 return NULL; … … 257 251 PS_TYPE_NAME(typeStrReal,type); 258 252 PS_TYPE_NAME(typeStrImag,imag->type.type); 259 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 260 PS_ERR_BAD_PARAMETER_TYPE, true, 261 PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH, 262 typeStrReal,typeStrImag); 253 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 254 PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH, 255 typeStrReal,typeStrImag); 263 256 psFree(out); 264 257 return NULL; … … 266 259 267 260 if (imag->numCols != numCols || imag->numRows != numRows) { 268 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 269 PS_ERR_BAD_PARAMETER_VALUE, true, 270 PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH, 271 numCols, numRows, imag->numCols, imag->numRows); 261 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 262 PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH, 263 numCols, numRows, imag->numCols, imag->numRows); 272 264 psFree(out); 273 265 return NULL; … … 308 300 char* typeStr; 309 301 PS_TYPE_NAME(typeStr,type); 310 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 311 PS_ERR_BAD_PARAMETER_TYPE, true, 312 PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED, 313 typeStr); 302 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 303 PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED, 304 typeStr); 314 305 psFree(out); 315 306 return NULL; … … 369 360 char* typeStr; 370 361 PS_TYPE_NAME(typeStr,type); 371 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate", 372 PS_ERR_BAD_PARAMETER_TYPE, true, 373 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 374 typeStr); 362 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 363 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 364 typeStr); 375 365 psFree(out); 376 366 return NULL; … … 434 424 char* typeStr; 435 425 PS_TYPE_NAME(typeStr,type); 436 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum", 437 PS_ERR_BAD_PARAMETER_TYPE, true, 438 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 439 typeStr); 440 psFree(out); 441 return NULL; 442 } 443 444 return out; 445 446 } 426 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 427 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 428 typeStr); 429 psFree(out); 430 return NULL; 431 } 432 433 return out; 434 435 } -
trunk/psLib/src/fft/psVectorFFT.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:04:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 63 63 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR); 64 64 } else { 65 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT", 66 PS_ERR_BAD_PARAMETER_VALUE, true, 67 PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET); 65 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 66 PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET); 68 67 psFree(out); 69 68 return NULL; … … 72 71 /* check if a plan exists now */ 73 72 if (plan == NULL) { 74 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT", 75 PS_ERR_BAD_PARAMETER_TYPE, true, 76 PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL); 73 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 74 PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL); 77 75 psFree(out); 78 76 return NULL; … … 144 142 char* typeStr; 145 143 PS_TYPE_NAME(typeStr,type); 146 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorReal", 147 PS_ERR_BAD_PARAMETER_TYPE, true, 148 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 149 typeStr); 144 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 145 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 146 typeStr); 150 147 psFree(out); 151 148 return NULL; … … 204 201 char* typeStr; 205 202 PS_TYPE_NAME(typeStr,type); 206 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorImaginary", 207 PS_ERR_BAD_PARAMETER_TYPE, true, 208 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 209 typeStr); 203 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 204 PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED, 205 typeStr); 210 206 psFree(out); 211 207 return NULL; … … 237 233 PS_TYPE_NAME(typeStrReal,type); 238 234 PS_TYPE_NAME(typeStrImag,imag->type.type); 239 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex", 240 PS_ERR_BAD_PARAMETER_TYPE, true, 241 PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH, 242 typeStrReal,typeStrImag); 235 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 236 PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH, 237 typeStrReal,typeStrImag); 243 238 psFree(out); 244 239 return NULL; … … 272 267 char* typeStr; 273 268 PS_TYPE_NAME(typeStr,type); 274 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex", 275 PS_ERR_BAD_PARAMETER_TYPE, true, 276 PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED, 277 typeStr); 269 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 270 PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED, 271 typeStr); 278 272 psFree(out); 279 273 return NULL; … … 333 327 char* typeStr; 334 328 PS_TYPE_NAME(typeStr,type); 335 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorConjugate", 336 PS_ERR_BAD_PARAMETER_TYPE, true, 337 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 338 typeStr); 329 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 330 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 331 typeStr); 339 332 psFree(out); 340 333 return NULL; … … 414 407 char* typeStr; 415 408 PS_TYPE_NAME(typeStr,type); 416 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorPowerSpectrum", 417 PS_ERR_BAD_PARAMETER_TYPE, true, 418 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 419 typeStr); 420 psFree(out); 421 return NULL; 422 } 423 424 return out; 425 426 } 409 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 410 PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED, 411 typeStr); 412 psFree(out); 413 return NULL; 414 } 415 416 return out; 417 418 } -
trunk/psLib/src/image/psImage.c
r2204 r2273 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.5 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.52 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 41 41 if (area < 1) { 42 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageAlloc", 43 PS_ERR_BAD_PARAMETER_VALUE, true, 44 PS_ERRORTEXT_psImage_AREA_NEGATIVE, 45 numRows, numCols); 42 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 43 PS_ERRORTEXT_psImage_AREA_NEGATIVE, 44 numRows, numCols); 46 45 return NULL; 47 46 } … … 119 118 if (old->type.dimen != PS_DIMEN_IMAGE) { 120 119 psFree(old); 121 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRecycle", 122 PS_ERR_BAD_PARAMETER_TYPE, true, 123 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 120 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 121 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 124 122 return NULL; 125 123 } … … 175 173 176 174 if (input == NULL || input->data.V == NULL) { 177 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 178 PS_ERR_BAD_PARAMETER_NULL, true, 179 PS_ERRORTEXT_psImage_IMAGE_NULL); 175 psError(PS_ERR_BAD_PARAMETER_NULL, true, 176 PS_ERRORTEXT_psImage_IMAGE_NULL); 180 177 psFree(output); 181 178 return NULL; … … 183 180 184 181 if (input == output) { 185 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 186 PS_ERR_BAD_PARAMETER_NULL, true, 187 PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED); 182 psError(PS_ERR_BAD_PARAMETER_NULL, true, 183 PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED); 188 184 psFree(output); 189 185 return NULL; … … 191 187 192 188 if (input->type.dimen != PS_DIMEN_IMAGE) { 193 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 194 PS_ERR_BAD_PARAMETER_TYPE, true, 195 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 189 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 190 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 196 191 psFree(output); 197 192 return NULL; … … 205 200 206 201 if (inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR) { 207 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 208 PS_ERR_BAD_PARAMETER_TYPE, true, 209 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 210 PS_TYPE_PTR_NAME); 202 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 203 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 204 PS_TYPE_PTR_NAME); 211 205 psFree(output); 212 206 return NULL; … … 319 313 char* typeStr; 320 314 PS_TYPE_NAME(typeStr,type); 321 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 322 PS_ERR_BAD_PARAMETER_TYPE, true, 323 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 324 typeStr); 315 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 316 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 317 typeStr); 325 318 psFree(output); 326 319 … … 372 365 373 366 if (input == NULL) { 374 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", 375 PS_ERR_BAD_PARAMETER_NULL,true, 376 PS_ERRORTEXT_psImage_IMAGE_NULL); 367 psError(PS_ERR_BAD_PARAMETER_NULL,true, 368 PS_ERRORTEXT_psImage_IMAGE_NULL); 377 369 return unexposedValue; 378 370 } … … 400 392 break; \ 401 393 default: \ 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", \ 403 PS_ERR_BAD_PARAMETER_VALUE,true, \ 404 PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID, \ 405 mode); \ 394 psError(PS_ERR_BAD_PARAMETER_VALUE,true, \ 395 PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID, \ 396 mode); \ 406 397 } \ 407 398 break … … 423 414 char* typeStr; 424 415 PS_TYPE_NAME(typeStr,input->type.type); 425 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", 426 PS_ERR_BAD_PARAMETER_TYPE,true, 427 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 428 typeStr); 416 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 417 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 418 typeStr); 429 419 } 430 420 } -
trunk/psLib/src/image/psImageConvolve.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:05:00 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 // got non-NULL vectors? 111 111 if (tShifts == NULL || xShifts == NULL || yShifts == NULL) { 112 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 113 PS_ERR_BAD_PARAMETER_NULL, true, 114 PS_ERRORTEXT_psImageConvolve_SHIFT_NULL); 112 psError(PS_ERR_BAD_PARAMETER_NULL, true, 113 PS_ERRORTEXT_psImageConvolve_SHIFT_NULL); 115 114 return NULL; 116 115 } … … 125 124 PS_TYPE_NAME(typeYStr,yShifts->type.type); 126 125 PS_TYPE_NAME(typeTStr,tShifts->type.type); 127 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 128 PS_ERR_BAD_PARAMETER_TYPE, true, 129 PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH, 130 typeTStr, typeXStr, typeYStr); 126 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 127 PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH, 128 typeTStr, typeXStr, typeYStr); 131 129 return NULL; 132 130 } … … 218 216 char* typeStr; 219 217 PS_TYPE_NAME(typeStr,xShifts->type.type); 220 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 221 PS_ERR_BAD_PARAMETER_TYPE, true, 222 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 223 typeStr); 218 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 219 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 220 typeStr); 224 221 } 225 222 } … … 236 233 237 234 if (kernel == NULL) { 238 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 239 PS_ERR_BAD_PARAMETER_NULL, true, 240 PS_ERRORTEXT_psImageConvolve_KERNEL_NULL); 235 psError(PS_ERR_BAD_PARAMETER_NULL, true, 236 PS_ERRORTEXT_psImageConvolve_KERNEL_NULL); 241 237 psFree(out); 242 238 return NULL; … … 297 293 char* typeStr; 298 294 PS_TYPE_NAME(typeStr,in->type.type); 299 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 300 PS_ERR_BAD_PARAMETER_TYPE, true, 301 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 302 typeStr); 295 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 296 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 297 typeStr); 303 298 psFree(out); 304 299 return NULL; … … 317 312 psS32 kCols = kernel->image->numCols; 318 313 if (kRows >= numRows || kCols >= numCols) { 319 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 320 PS_ERR_BAD_PARAMETER_SIZE, true, 321 PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE, 322 kCols,kRows, 323 numCols, numRows); 314 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 315 PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE, 316 kCols,kRows, 317 numCols, numRows); 324 318 psFree(out); 325 319 return NULL; … … 376 370 psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD); 377 371 if (kernelFourier == NULL) { 378 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 379 PS_ERR_UNKNOWN, false, 380 PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED); 372 psError(PS_ERR_UNKNOWN, false, 373 PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED); 381 374 psFree(out); 382 375 return NULL; … … 385 378 psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD); 386 379 if (inFourier == NULL) { 387 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 388 PS_ERR_UNKNOWN, false, 389 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 380 psError(PS_ERR_UNKNOWN, false, 381 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 390 382 psFree(out); 391 383 return NULL; … … 398 390 PS_FFT_REVERSE); 399 391 if (complexOut == NULL) { 400 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 401 PS_ERR_UNKNOWN, false, 402 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 392 psError(PS_ERR_UNKNOWN, false, 393 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 403 394 psFree(out); 404 395 return NULL; -
trunk/psLib/src/image/psImageExtraction.c
r2204 r2273 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:31$11 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 36 36 if (image == NULL || image->data.V == NULL) { 37 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset", 38 PS_ERR_BAD_PARAMETER_NULL, true, 39 PS_ERRORTEXT_psImage_IMAGE_NULL); 37 psError(PS_ERR_BAD_PARAMETER_NULL, true, 38 PS_ERRORTEXT_psImage_IMAGE_NULL); 40 39 return NULL; 41 40 } 42 41 43 42 if (image->type.dimen != PS_DIMEN_IMAGE) { 44 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset", 45 PS_ERR_BAD_PARAMETER_TYPE, true, 46 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 43 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 44 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 47 45 return NULL; 48 46 } … … 61 59 col1 > image->numCols || 62 60 row1 > image->numRows ) { 63 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset", 64 PS_ERR_BAD_PARAMETER_VALUE, true, 65 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 66 col0, col1-1, row0, row1-1, 67 image->numCols-1, image->numRows-1); 61 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 62 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 63 col0, col1-1, row0, row1-1, 64 image->numCols-1, image->numRows-1); 68 65 return NULL; 69 66 } … … 152 149 // section should be of the form '[col0:col1,row0:row1]' 153 150 if (section == NULL) { 154 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection", 155 PS_ERR_BAD_PARAMETER_NULL, true, 156 PS_ERRORTEXT_psImage_SUBSECTION_NULL); 151 psError(PS_ERR_BAD_PARAMETER_NULL, true, 152 PS_ERRORTEXT_psImage_SUBSECTION_NULL); 157 153 return NULL; 158 154 } 159 155 160 156 if (sscanf(section,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) { 161 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection", 162 PS_ERR_BAD_PARAMETER_NULL, true, 163 PS_ERRORTEXT_psImage_SUBSECTION_INVALID, 164 section); 157 psError(PS_ERR_BAD_PARAMETER_NULL, true, 158 PS_ERRORTEXT_psImage_SUBSECTION_INVALID, 159 section); 165 160 return NULL; 166 161 } 167 162 168 163 if (col0 > col1 || row0 > row1) { 169 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection", 170 PS_ERR_BAD_PARAMETER_VALUE, true, 171 PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED, 172 col0,col1,row0,row1); 164 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 165 PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED, 166 col0,col1,row0,row1); 173 167 return NULL; 174 168 } … … 180 174 { 181 175 if (image == NULL || image->data.V == NULL) { 182 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim", 183 PS_ERR_BAD_PARAMETER_NULL, true, 184 PS_ERRORTEXT_psImage_IMAGE_NULL); 176 psError(PS_ERR_BAD_PARAMETER_NULL, true, 177 PS_ERRORTEXT_psImage_IMAGE_NULL); 185 178 return NULL; 186 179 } … … 209 202 col0 >= col1 || 210 203 row0 >= row1 ) { 211 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim", 212 PS_ERR_BAD_PARAMETER_VALUE, true, 213 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 214 col0, col1-1, row0, row1-1, 215 image->numCols-1, image->numRows-1); 204 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 205 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 206 col0, col1-1, row0, row1-1, 207 image->numCols-1, image->numRows-1); 216 208 psFree(image); 217 209 return NULL; … … 267 259 268 260 if (in == NULL || in->data.V == NULL) { 269 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 270 PS_ERR_BAD_PARAMETER_NULL, true, 271 PS_ERRORTEXT_psImage_IMAGE_NULL); 261 psError(PS_ERR_BAD_PARAMETER_NULL, true, 262 PS_ERRORTEXT_psImage_IMAGE_NULL); 272 263 psFree(out); 273 264 return NULL; … … 288 279 col0 >= col1 || 289 280 row0 >= row1) { 290 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 291 PS_ERR_BAD_PARAMETER_VALUE, true, 292 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 293 col0, col1, row0, row1, 294 in->numCols, in->numRows); 281 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 282 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 283 col0, col1, row0, row1, 284 in->numCols, in->numRows); 295 285 psFree(out); 296 286 return NULL; … … 307 297 if (mask != NULL) { 308 298 if (inRows != mask->numRows || inCols != mask->numCols) { 309 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 310 PS_ERR_BAD_PARAMETER_VALUE, true, 311 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 312 mask->numCols,mask->numRows, 313 inCols, inRows); 299 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 300 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 301 mask->numCols,mask->numRows, 302 inCols, inRows); 314 303 psFree(out); 315 304 return NULL; … … 318 307 char* typeStr; 319 308 PS_TYPE_NAME(typeStr,mask->type.type); 320 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 321 PS_ERR_BAD_PARAMETER_TYPE, true, 322 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 323 typeStr, PS_TYPE_MASK_NAME); 309 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 310 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 311 typeStr, PS_TYPE_MASK_NAME); 324 312 psFree(out); 325 313 return NULL; … … 328 316 329 317 if (stats == NULL) { 330 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 331 PS_ERR_BAD_PARAMETER_NULL, true, 332 PS_ERRORTEXT_psImage_STAT_NULL); 318 psError(PS_ERR_BAD_PARAMETER_NULL, true, 319 PS_ERRORTEXT_psImage_STAT_NULL); 333 320 psFree(out); 334 321 return NULL; … … 338 325 // single stats operation 339 326 if (p_psGetStatValue(stats, &statVal) == false) { 340 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 341 PS_ERR_BAD_PARAMETER_VALUE, false, 342 PS_ERRORTEXT_psImage_BAD_STAT,stats->options); 327 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 328 PS_ERRORTEXT_psImage_BAD_STAT,stats->options); 343 329 psFree(out); 344 330 return NULL; … … 423 409 char* typeStr; 424 410 PS_TYPE_NAME(typeStr,type); 425 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 426 PS_ERR_BAD_PARAMETER_TYPE, true, 427 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 428 typeStr); 411 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 412 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 413 typeStr); 429 414 psFree(out); 430 415 out = NULL; … … 485 470 psFree(maskVec); 486 471 } else { // don't know what the direction flag is 487 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice", 488 PS_ERR_BAD_PARAMETER_VALUE, true, 489 PS_ERRORTEXT_psImage_SLICE_DIRECTION_INVALID, 490 direction); 472 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 473 PS_ERRORTEXT_psImage_SLICE_DIRECTION_INVALID, 474 direction); 491 475 psFree(out); 492 476 out = NULL; … … 512 496 { 513 497 if (in == NULL || in->data.V == NULL) { 514 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 515 PS_ERR_BAD_PARAMETER_NULL, true, 516 PS_ERRORTEXT_psImage_IMAGE_NULL); 498 psError(PS_ERR_BAD_PARAMETER_NULL, true, 499 PS_ERRORTEXT_psImage_IMAGE_NULL); 517 500 psFree(out); 518 501 return NULL; … … 522 505 523 506 if (nSamples < 2) { 524 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 525 PS_ERR_BAD_PARAMETER_VALUE, true, 526 PS_ERRORTEXT_psImage_nSamples_TOOSMALL, 527 nSamples); 507 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 508 PS_ERRORTEXT_psImage_nSamples_TOOSMALL, 509 nSamples); 528 510 psFree(out); 529 511 return NULL; … … 534 516 endCol < 0 || endCol >= numCols || 535 517 endRow < 0 || endRow >= numRows) { 536 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 537 PS_ERR_BAD_PARAMETER_VALUE, true, 538 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 539 startCol,startRow,endCol,endRow, 540 numCols-1,numRows-1); 518 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 519 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 520 startCol,startRow,endCol,endRow, 521 numCols-1,numRows-1); 541 522 psFree(out); 542 523 return NULL; … … 544 525 545 526 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) { 546 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 547 PS_ERR_BAD_PARAMETER_VALUE, true, 548 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 549 mode); 527 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 528 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 529 mode); 550 530 psFree(out); 551 531 return NULL; … … 554 534 if (mask != NULL) { 555 535 if (numRows != mask->numRows || numCols != mask->numCols) { 556 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 557 PS_ERR_BAD_PARAMETER_VALUE, true, 558 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 559 mask->numCols,mask->numRows, 560 numCols-1, numRows); 536 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 537 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 538 mask->numCols,mask->numRows, 539 numCols-1, numRows); 561 540 psFree(out); 562 541 return NULL; … … 565 544 char* typeStr; 566 545 PS_TYPE_NAME(typeStr,mask->type.type); 567 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 568 PS_ERR_BAD_PARAMETER_TYPE, true, 569 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 570 typeStr, PS_TYPE_MASK_NAME); 546 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 547 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 548 typeStr, PS_TYPE_MASK_NAME); 571 549 psFree(out); 572 550 return NULL; … … 627 605 char* typeStr; 628 606 PS_TYPE_NAME(typeStr,in->type.type); 629 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 630 PS_ERR_BAD_PARAMETER_TYPE, true, 631 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 632 typeStr); 607 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 608 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 609 typeStr); 633 610 psFree(out); 634 611 out = NULL; … … 653 630 654 631 if (in == NULL || in->data.V == NULL) { 655 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 656 PS_ERR_BAD_PARAMETER_NULL, true, 657 PS_ERRORTEXT_psImage_IMAGE_NULL); 632 psError(PS_ERR_BAD_PARAMETER_NULL, true, 633 PS_ERRORTEXT_psImage_IMAGE_NULL); 658 634 psFree(out); 659 635 return NULL; … … 664 640 if (mask != NULL) { 665 641 if (numRows != mask->numRows || numCols != mask->numCols) { 666 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 667 PS_ERR_BAD_PARAMETER_SIZE, true, 668 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 669 mask->numCols,mask->numRows, 670 numCols, numRows); 642 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 643 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 644 mask->numCols,mask->numRows, 645 numCols, numRows); 671 646 psFree(out); 672 647 return NULL; … … 675 650 char* typeStr; 676 651 PS_TYPE_NAME(typeStr,mask->type.type); 677 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 678 PS_ERR_BAD_PARAMETER_TYPE, true, 679 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 680 typeStr, PS_TYPE_MASK_NAME); 652 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 653 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 654 typeStr, PS_TYPE_MASK_NAME); 681 655 psFree(out); 682 656 return NULL; … … 686 660 if (centerCol < 0 || centerCol >= numCols || 687 661 centerRow < 0 || centerRow >= numRows) { 688 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 689 PS_ERR_BAD_PARAMETER_VALUE, true, 690 PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE, 691 centerCol, centerRow, 692 numCols-1, numRows-1); 662 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 663 PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE, 664 centerCol, centerRow, 665 numCols-1, numRows-1); 693 666 psFree(out); 694 667 return NULL; … … 696 669 697 670 if (radii == NULL) { 698 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 699 PS_ERR_BAD_PARAMETER_NULL, true, 700 PS_ERRORTEXT_psImage_RADII_VECTOR_NULL); 671 psError(PS_ERR_BAD_PARAMETER_NULL, true, 672 PS_ERRORTEXT_psImage_RADII_VECTOR_NULL); 701 673 psFree(out); 702 674 return NULL; … … 704 676 705 677 if (radii->n < 2) { 706 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 707 PS_ERR_BAD_PARAMETER_SIZE, true, 708 PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL, 709 radii->n); 678 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 679 PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL, 680 radii->n); 710 681 psFree(out); 711 682 return NULL; … … 713 684 714 685 if (stats == NULL) { 715 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 716 PS_ERR_BAD_PARAMETER_NULL, true, 717 PS_ERRORTEXT_psImage_STAT_NULL); 686 psError(PS_ERR_BAD_PARAMETER_NULL, true, 687 PS_ERRORTEXT_psImage_STAT_NULL); 718 688 psFree(out); 719 689 return NULL; … … 723 693 // single stats operation 724 694 if (p_psGetStatValue(stats, &statVal) == false) { 725 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 726 PS_ERR_BAD_PARAMETER_VALUE, false, 727 PS_ERRORTEXT_psImage_BAD_STAT, 728 stats->options); 695 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 696 PS_ERRORTEXT_psImage_BAD_STAT, 697 stats->options); 729 698 psFree(out); 730 699 return NULL; -
trunk/psLib/src/image/psImageFFT.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:05:00 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 if ( ((direction & PS_FFT_FORWARD) != 0) ) { 44 44 if ((direction & PS_FFT_REVERSE) != 0) { 45 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 46 PS_ERR_BAD_PARAMETER_VALUE, true, 47 PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE); 45 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 46 PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE); 48 47 psFree(out); 49 48 return NULL; 50 49 } 51 50 if ((direction & PS_FFT_REAL_RESULT) != 0) { 52 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 53 PS_ERR_BAD_PARAMETER_VALUE, true, 54 PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED); 51 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 52 PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED); 55 53 psFree(out); 56 54 return NULL; 57 55 } 58 56 } else if ((direction & PS_FFT_REVERSE) == 0) { 59 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 60 PS_ERR_BAD_PARAMETER_VALUE, true, 61 PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION); 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 58 PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION); 62 59 psFree(out); 63 60 return NULL; … … 86 83 /* check if a plan exists now -- if not, it is a real problem at this point */ 87 84 if (plan == NULL) { 88 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 89 PS_ERR_BAD_PARAMETER_TYPE, true, 90 PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL); 85 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 86 PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL); 91 87 psFree(out); 92 88 return NULL; … … 163 159 char* typeStr; 164 160 PS_TYPE_NAME(typeStr,type); 165 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal", 166 PS_ERR_BAD_PARAMETER_TYPE, true, 167 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 168 typeStr); 161 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 162 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 163 typeStr); 169 164 170 165 psFree(out); … … 226 221 char* typeStr; 227 222 PS_TYPE_NAME(typeStr,type); 228 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary", 229 PS_ERR_BAD_PARAMETER_TYPE, true, 230 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 231 typeStr); 223 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 224 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 225 typeStr); 232 226 psFree(out); 233 227 return NULL; … … 257 251 PS_TYPE_NAME(typeStrReal,type); 258 252 PS_TYPE_NAME(typeStrImag,imag->type.type); 259 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 260 PS_ERR_BAD_PARAMETER_TYPE, true, 261 PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH, 262 typeStrReal,typeStrImag); 253 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 254 PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH, 255 typeStrReal,typeStrImag); 263 256 psFree(out); 264 257 return NULL; … … 266 259 267 260 if (imag->numCols != numCols || imag->numRows != numRows) { 268 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 269 PS_ERR_BAD_PARAMETER_VALUE, true, 270 PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH, 271 numCols, numRows, imag->numCols, imag->numRows); 261 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 262 PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH, 263 numCols, numRows, imag->numCols, imag->numRows); 272 264 psFree(out); 273 265 return NULL; … … 308 300 char* typeStr; 309 301 PS_TYPE_NAME(typeStr,type); 310 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 311 PS_ERR_BAD_PARAMETER_TYPE, true, 312 PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED, 313 typeStr); 302 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 303 PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED, 304 typeStr); 314 305 psFree(out); 315 306 return NULL; … … 369 360 char* typeStr; 370 361 PS_TYPE_NAME(typeStr,type); 371 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate", 372 PS_ERR_BAD_PARAMETER_TYPE, true, 373 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 374 typeStr); 362 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 363 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 364 typeStr); 375 365 psFree(out); 376 366 return NULL; … … 434 424 char* typeStr; 435 425 PS_TYPE_NAME(typeStr,type); 436 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum", 437 PS_ERR_BAD_PARAMETER_TYPE, true, 438 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 439 typeStr); 440 psFree(out); 441 return NULL; 442 } 443 444 return out; 445 446 } 426 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 427 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 428 typeStr); 429 psFree(out); 430 return NULL; 431 } 432 433 return out; 434 435 } -
trunk/psLib/src/image/psImageIO.c
r2210 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 19:35:58$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 47 48 48 if (filename == NULL) { 49 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 50 PS_ERR_BAD_PARAMETER_NULL, true, 51 PS_ERRORTEXT_psImageIO_FILENAME_NULL); 49 psError(PS_ERR_BAD_PARAMETER_NULL, true, 50 PS_ERRORTEXT_psImageIO_FILENAME_NULL); 52 51 psFree(output); 53 52 return NULL; … … 58 57 if (fptr == NULL || status != 0) { 59 58 fits_get_errstatus(status, fitsErr); 60 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 61 PS_ERR_BAD_PARAMETER_VALUE, true, 62 PS_ERRORTEXT_psImageIO_FILENAME_INVALID, 63 filename, fitsErr); 59 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 60 PS_ERRORTEXT_psImageIO_FILENAME_INVALID, 61 filename, fitsErr); 64 62 psFree(output); 65 63 return NULL; … … 72 70 status = 0; 73 71 (void)fits_close_file(fptr, &status); 74 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 75 PS_ERR_LOCATION_INVALID, true, 76 PS_ERRORTEXT_psImageIO_EXTNAME_INVALID, 77 extname, filename, fitsErr); 72 psError(PS_ERR_LOCATION_INVALID, true, 73 PS_ERRORTEXT_psImageIO_EXTNAME_INVALID, 74 extname, filename, fitsErr); 78 75 psFree(output); 79 76 return NULL; … … 84 81 status = 0; 85 82 (void)fits_close_file(fptr, &status); 86 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 87 PS_ERR_LOCATION_INVALID, true, 88 PS_ERRORTEXT_psImageIO_EXTNUM_INVALID, 89 extnum, filename, fitsErr); 83 psError(PS_ERR_LOCATION_INVALID, true, 84 PS_ERRORTEXT_psImageIO_EXTNUM_INVALID, 85 extnum, filename, fitsErr); 90 86 psFree(output); 91 87 return NULL; … … 98 94 status = 0; 99 95 (void)fits_close_file(fptr, &status); 100 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 101 PS_ERR_IO, true, 102 PS_ERRORTEXT_psImageIO_DATATYPE_UNKNOWN, 103 filename, fitsErr); 96 psError(PS_ERR_IO, true, 97 PS_ERRORTEXT_psImageIO_DATATYPE_UNKNOWN, 98 filename, fitsErr); 104 99 psFree(output); 105 100 return NULL; … … 111 106 status = 0; 112 107 (void)fits_close_file(fptr, &status); 113 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 114 PS_ERR_IO, true, 115 PS_ERRORTEXT_psImageIO_IMAGE_DIM_UNKNOWN, 116 filename, fitsErr); 108 psError(PS_ERR_IO, true, 109 PS_ERRORTEXT_psImageIO_IMAGE_DIM_UNKNOWN, 110 filename, fitsErr); 117 111 psFree(output); 118 112 return NULL; … … 123 117 status = 0; 124 118 (void)fits_close_file(fptr, &status); 125 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 126 PS_ERR_IO, true, 127 PS_ERRORTEXT_psImageIO_IMAGE_DIMENSION_UNSUPPORTED, 128 nAxis); 119 psError(PS_ERR_IO, true, 120 PS_ERRORTEXT_psImageIO_IMAGE_DIMENSION_UNSUPPORTED, 121 nAxis); 129 122 psFree(output); 130 123 return NULL; … … 136 129 status = 0; 137 130 (void)fits_close_file(fptr, &status); 138 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 139 PS_ERR_IO, true, 140 PS_ERRORTEXT_psImageIO_IMAGE_SIZE_UNKNOWN, 141 filename, fitsErr); 131 psError(PS_ERR_IO, true, 132 PS_ERRORTEXT_psImageIO_IMAGE_SIZE_UNKNOWN, 133 filename, fitsErr); 142 134 psFree(output); 143 135 return NULL; … … 201 193 break; 202 194 default: 203 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 204 PS_ERR_IO, true, 205 PS_ERRORTEXT_psImageIO_FITS_TYPE_UNSUPPORTED, 206 bitPix, filename); 195 psError(PS_ERR_IO, true, 196 PS_ERRORTEXT_psImageIO_FITS_TYPE_UNSUPPORTED, 197 bitPix, filename); 207 198 psFree(output); 208 199 return NULL; … … 215 206 status = 0; 216 207 (void)fits_close_file(fptr, &status); 217 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection", 218 PS_ERR_IO, true, 219 PS_ERRORTEXT_psImageIO_READ_FAILED, 220 filename, fitsErr); 208 psError(PS_ERR_IO, true, 209 PS_ERRORTEXT_psImageIO_READ_FAILED, 210 filename, fitsErr); 221 211 return NULL; 222 212 } … … 253 243 /* need a valid image to write */ 254 244 if (input == NULL) { 255 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 256 PS_ERR_BAD_PARAMETER_NULL, true, 257 PS_ERRORTEXT_psImage_IMAGE_NULL); 245 psError(PS_ERR_BAD_PARAMETER_NULL, true, 246 PS_ERRORTEXT_psImage_IMAGE_NULL); 258 247 return false; 259 248 } … … 301 290 char* typeStr; 302 291 PS_TYPE_NAME(typeStr,input->type.type); 303 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 304 PS_ERR_BAD_PARAMETER_TYPE, true, 305 PS_ERRORTEXT_psImageIO_TYPE_UNSUPPORTED, 306 typeStr); 292 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 293 PS_ERRORTEXT_psImageIO_TYPE_UNSUPPORTED, 294 typeStr); 307 295 return false; 308 296 } … … 315 303 if (fptr == NULL || status != 0) { 316 304 fits_get_errstatus(status, fitsErr); 317 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 318 PS_ERR_BAD_PARAMETER_VALUE, true, 319 PS_ERRORTEXT_psImageIO_FILENAME_INVALID, 320 filename, fitsErr); 305 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 306 PS_ERRORTEXT_psImageIO_FILENAME_INVALID, 307 filename, fitsErr); 321 308 return false; 322 309 } … … 328 315 status = 0; 329 316 (void)fits_close_file(fptr, &status); 330 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 331 PS_ERR_LOCATION_INVALID, true, 332 PS_ERRORTEXT_psImageIO_EXTNAME_INVALID, 333 extname, filename, fitsErr); 317 psError(PS_ERR_LOCATION_INVALID, true, 318 PS_ERRORTEXT_psImageIO_EXTNAME_INVALID, 319 extname, filename, fitsErr); 334 320 return false; 335 321 } … … 341 327 status = 0; 342 328 (void)fits_close_file(fptr, &status); 343 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 344 PS_ERR_LOCATION_INVALID, true, 345 PS_ERRORTEXT_psImageIO_WRITE_EXTNUM_INVALID, 346 extnum, numHDUs); 329 psError(PS_ERR_LOCATION_INVALID, true, 330 PS_ERRORTEXT_psImageIO_WRITE_EXTNUM_INVALID, 331 extnum, numHDUs); 347 332 return false; 348 333 } else if (numHDUs == extnum) { … … 352 337 status = 0; 353 338 (void)fits_close_file(fptr, &status); 354 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 355 PS_ERR_LOCATION_INVALID, true, 356 PS_ERRORTEXT_psImageIO_EXTNUM_INVALID, 357 extnum, filename, fitsErr); 339 psError(PS_ERR_LOCATION_INVALID, true, 340 PS_ERRORTEXT_psImageIO_EXTNUM_INVALID, 341 extnum, filename, fitsErr); 358 342 return false; 359 343 } … … 368 352 if (fptr == NULL || status != 0) { 369 353 fits_get_errstatus(status, fitsErr); 370 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 371 PS_ERR_IO, true, 372 PS_ERRORTEXT_psImageIO_FILENAME_CREATE_FAILED, 373 filename, fitsErr); 354 psError(PS_ERR_IO, true, 355 PS_ERRORTEXT_psImageIO_FILENAME_CREATE_FAILED, 356 filename, fitsErr); 374 357 return false; 375 358 } … … 386 369 status = 0; 387 370 (void)fits_close_file(fptr, &status); 388 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 389 PS_ERR_IO, true, 390 PS_ERRORTEXT_psImageIO_CREATE_HDU_FAILED, 391 filename, fitsErr); 371 psError(PS_ERR_IO, true, 372 PS_ERRORTEXT_psImageIO_CREATE_HDU_FAILED, 373 filename, fitsErr); 392 374 return false; 393 375 } … … 403 385 status = 0; 404 386 (void)fits_close_file(fptr, &status); 405 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 406 PS_ERR_IO, true, 407 PS_ERRORTEXT_psImageIO_CREATE_EXTENSION_FAILED, 408 filename, fitsErr); 387 psError(PS_ERR_IO, true, 388 PS_ERRORTEXT_psImageIO_CREATE_EXTENSION_FAILED, 389 filename, fitsErr); 409 390 return false; 410 391 } … … 424 405 status = 0; 425 406 (void)fits_close_file(fptr, &status); 426 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection", 427 PS_ERR_IO, true, 428 PS_ERRORTEXT_psImageIO_WRITE_FAILED, 429 filename, fitsErr); 407 psError(PS_ERR_IO, true, 408 PS_ERRORTEXT_psImageIO_WRITE_FAILED, 409 filename, fitsErr); 430 410 return false; 431 411 } -
trunk/psLib/src/image/psImageManip.c
r2204 r2273 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 44 44 if (max < min) { 45 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", 46 PS_ERR_BAD_PARAMETER_VALUE, true, 47 PS_ERRORTEXT_psImageManip_MAXMIN, 48 (double)min,(double)max); 45 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 46 PS_ERRORTEXT_psImageManip_MAXMIN, 47 (double)min,(double)max); 49 48 return 0; 50 49 } … … 58 57 case PS_TYPE_##type: { \ 59 58 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \ 60 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 61 PS_ERR_BAD_PARAMETER_VALUE, true, \ 62 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 63 "vmin",vmin, PS_TYPE_##type##_NAME, \ 64 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 59 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 60 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 61 "vmin",vmin, PS_TYPE_##type##_NAME, \ 62 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 65 63 } \ 66 64 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \ 67 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 68 PS_ERR_BAD_PARAMETER_VALUE, true, \ 69 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 70 "vmax",vmax, PS_TYPE_##type##_NAME, \ 71 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 65 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 66 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 67 "vmax",vmax, PS_TYPE_##type##_NAME, \ 68 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 72 69 } \ 73 70 for (psU32 row = 0;row<numRows;row++) { \ … … 89 86 case PS_TYPE_##type: { \ 90 87 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \ 91 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 92 PS_ERR_BAD_PARAMETER_VALUE, true, \ 93 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 94 "vmin",vmin, PS_TYPE_##type##_NAME, \ 95 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 88 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 89 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 90 "vmin",vmin, PS_TYPE_##type##_NAME, \ 91 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 96 92 } \ 97 93 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \ 98 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \ 99 PS_ERR_BAD_PARAMETER_VALUE, true, \ 100 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 101 "vmax",vmax, PS_TYPE_##type##_NAME, \ 102 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 94 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 95 PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \ 96 "vmax",vmax, PS_TYPE_##type##_NAME, \ 97 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 103 98 } \ 104 99 for (psU32 row = 0;row<numRows;row++) { \ … … 133 128 char* typeStr; 134 129 PS_TYPE_NAME(typeStr,input->type.type); 135 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", 136 PS_ERR_BAD_PARAMETER_TYPE, true, 137 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 138 typeStr); 130 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 131 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 132 typeStr); 139 133 } 140 134 } … … 179 173 char* typeStr; 180 174 PS_TYPE_NAME(typeStr,input->type.type); 181 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipNaN", 182 PS_ERR_BAD_PARAMETER_TYPE, true, 183 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 184 typeStr); 175 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 176 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 177 typeStr); 185 178 } 186 179 } … … 204 197 205 198 if (image == NULL || overlay == NULL) { 206 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 207 PS_ERR_BAD_PARAMETER_NULL, true, 208 PS_ERRORTEXT_psImage_IMAGE_NULL); 199 psError(PS_ERR_BAD_PARAMETER_NULL, true, 200 PS_ERRORTEXT_psImage_IMAGE_NULL); 209 201 return 1; 210 202 } 211 203 212 204 if (op == NULL) { 213 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 214 PS_ERR_BAD_PARAMETER_NULL, true, 215 PS_ERRORTEXT_psImageManip_OPERATION_NULL); 205 psError(PS_ERR_BAD_PARAMETER_NULL, true, 206 PS_ERRORTEXT_psImageManip_OPERATION_NULL); 216 207 return 1; 217 208 } … … 224 215 PS_TYPE_NAME(typeStr,type); 225 216 PS_TYPE_NAME(typeStrOverlay,overlay->type.type); 226 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 227 PS_ERR_BAD_PARAMETER_TYPE, true, 228 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH, 229 typeStrOverlay, typeStr); 217 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 218 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH, 219 typeStrOverlay, typeStr); 230 220 return 2; 231 221 } … … 244 234 imageColLimit > imageNumCols) { 245 235 246 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 247 PS_ERR_BAD_PARAMETER_VALUE, true, 248 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 249 col0, imageColLimit, row0, imageRowLimit, 250 imageNumCols, imageNumRows); 236 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 237 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID, 238 col0, imageColLimit, row0, imageRowLimit, 239 imageNumCols, imageNumRows); 251 240 return 3; 252 241 } … … 277 266 break; \ 278 267 default: \ 279 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", \ 280 PS_ERR_BAD_PARAMETER_VALUE, true, \ 281 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 282 op); \ 268 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 269 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 270 op); \ 283 271 return 5; \ 284 272 } \ … … 303 291 char* typeStr; 304 292 PS_TYPE_NAME(typeStr,type); 305 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", 306 PS_ERR_BAD_PARAMETER_TYPE, true, 307 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 308 typeStr); 293 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 294 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 295 typeStr); 309 296 return 6; 310 297 } … … 329 316 330 317 if (input == NULL) { 331 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 332 PS_ERR_BAD_PARAMETER_NULL, true, 333 PS_ERRORTEXT_psImage_IMAGE_NULL); 318 psError(PS_ERR_BAD_PARAMETER_NULL, true, 319 PS_ERRORTEXT_psImage_IMAGE_NULL); 334 320 return 0; 335 321 } 336 322 337 323 if (realMax < realMin) { 338 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 339 PS_ERR_BAD_PARAMETER_VALUE, true, 340 PS_ERRORTEXT_psImageManip_MAXMIN_REAL, 341 (double)realMin, (double)realMax); 324 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 325 PS_ERRORTEXT_psImageManip_MAXMIN_REAL, 326 (double)realMin, (double)realMax); 342 327 return 0; 343 328 } 344 329 if (imagMax < imagMin) { 345 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 346 PS_ERR_BAD_PARAMETER_VALUE, true, 347 PS_ERRORTEXT_psImageManip_MAXMIN_IMAG, 348 (double)imagMin, (double)imagMax); 330 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 331 PS_ERRORTEXT_psImageManip_MAXMIN_IMAG, 332 (double)imagMin, (double)imagMax); 349 333 return 0; 350 334 } … … 357 341 if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \ 358 342 realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \ 359 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \ 360 PS_ERR_BAD_PARAMETER_VALUE, true, \ 361 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 362 "vmin", creal(vmin), cimag(vmin), \ 363 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 343 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 344 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 345 "vmin", creal(vmin), cimag(vmin), \ 346 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 364 347 break; \ 365 348 } \ 366 349 if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \ 367 350 realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \ 368 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \ 369 PS_ERR_BAD_PARAMETER_VALUE, true, \ 370 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 371 "vmax", creal(vmax), cimag(vmax), \ 372 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 351 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 352 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 353 "vmax", creal(vmax), cimag(vmax), \ 354 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \ 373 355 break; \ 374 356 } \ … … 396 378 char* typeStr; 397 379 PS_TYPE_NAME(typeStr,input->type.type); 398 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", 399 PS_ERR_BAD_PARAMETER_TYPE, true, 400 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 401 typeStr); 380 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 381 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 382 typeStr); 402 383 } 403 384 } … … 424 405 425 406 if (in == NULL) { 426 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 427 PS_ERR_BAD_PARAMETER_NULL, true, 428 PS_ERRORTEXT_psImage_IMAGE_NULL); 407 psError(PS_ERR_BAD_PARAMETER_NULL, true, 408 PS_ERRORTEXT_psImage_IMAGE_NULL); 429 409 psFree(out); 430 410 return NULL; … … 432 412 433 413 if (scale < 1) { 434 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 435 PS_ERR_BAD_PARAMETER_VALUE, true, 436 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 437 scale); 414 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 415 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 416 scale); 438 417 psFree(out); 439 418 return NULL; … … 441 420 442 421 if (stats == NULL) { 443 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 444 PS_ERR_BAD_PARAMETER_NULL, true, 445 PS_ERRORTEXT_psImage_STAT_NULL); 422 psError(PS_ERR_BAD_PARAMETER_NULL, true, 423 PS_ERRORTEXT_psImage_STAT_NULL); 446 424 psFree(out); 447 425 return NULL; … … 449 427 450 428 if (p_psGetStatValue(stats, &statVal) == false) { 451 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 452 PS_ERR_BAD_PARAMETER_VALUE, true, 453 PS_ERRORTEXT_psImage_BAD_STAT, 454 stats->options); 429 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 430 PS_ERRORTEXT_psImage_BAD_STAT, 431 stats->options); 455 432 psFree(out); 456 433 return NULL; … … 463 440 char* typeStr; 464 441 PS_TYPE_NAME(typeStr,mask->type.type); 465 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 466 PS_ERR_BAD_PARAMETER_TYPE, true, 467 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 468 typeStr, PS_TYPE_MASK_NAME); 442 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 443 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 444 typeStr, PS_TYPE_MASK_NAME); 469 445 psFree(out); 470 446 psFree(vec); … … 536 512 char* typeStr; 537 513 PS_TYPE_NAME(typeStr,in->type.type); 538 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin", 539 PS_ERR_BAD_PARAMETER_TYPE, true, 540 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 541 typeStr); 514 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 515 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 516 typeStr); 542 517 psFree(out); 543 518 out = NULL; … … 562 537 563 538 if (in == NULL) { 564 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 565 PS_ERR_BAD_PARAMETER_NULL, true, 566 PS_ERRORTEXT_psImage_IMAGE_NULL); 539 psError(PS_ERR_BAD_PARAMETER_NULL, true, 540 PS_ERRORTEXT_psImage_IMAGE_NULL); 567 541 psFree(out); 568 542 return NULL; … … 570 544 571 545 if (scale < 1) { 572 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 573 PS_ERR_BAD_PARAMETER_VALUE, true, 574 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 575 scale); 546 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 547 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 548 scale); 576 549 psFree(out); 577 550 return NULL; … … 579 552 580 553 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) { 581 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 582 PS_ERR_BAD_PARAMETER_VALUE, true, 583 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 584 mode); 554 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 555 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 556 mode); 585 557 psFree(out); 586 558 return NULL; … … 622 594 char* typeStr; 623 595 PS_TYPE_NAME(typeStr,in->type.type); 624 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 625 PS_ERR_BAD_PARAMETER_TYPE, true, 626 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 627 typeStr); 596 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 597 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 598 typeStr); 628 599 psFree(out); 629 600 out = NULL; … … 644 615 645 616 if (in == NULL) { 646 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRoll", 647 PS_ERR_BAD_PARAMETER_NULL, true, 648 PS_ERRORTEXT_psImage_IMAGE_NULL); 617 psError(PS_ERR_BAD_PARAMETER_NULL, true, 618 PS_ERRORTEXT_psImage_IMAGE_NULL); 649 619 psFree(out); 650 620 return NULL; … … 694 664 { 695 665 if (in == NULL) { 696 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 697 PS_ERR_BAD_PARAMETER_NULL, true, 698 PS_ERRORTEXT_psImage_IMAGE_NULL); 666 psError(PS_ERR_BAD_PARAMETER_NULL, true, 667 PS_ERRORTEXT_psImage_IMAGE_NULL); 699 668 psFree(out); 700 669 return NULL; … … 741 710 char* typeStr; 742 711 PS_TYPE_NAME(typeStr,type); 743 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 744 PS_ERR_BAD_PARAMETER_TYPE, true, 745 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 746 typeStr); 712 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 713 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 714 typeStr); 747 715 psFree(out); 748 716 return NULL; … … 788 756 char* typeStr; 789 757 PS_TYPE_NAME(typeStr,type); 790 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 791 PS_ERR_BAD_PARAMETER_TYPE, true, 792 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 793 typeStr); 758 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 759 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 760 typeStr); 794 761 psFree(out); 795 762 return NULL; … … 834 801 char* typeStr; 835 802 PS_TYPE_NAME(typeStr,type); 836 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 837 PS_ERR_BAD_PARAMETER_TYPE, true, 838 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 839 typeStr); 803 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 804 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 805 typeStr); 840 806 psFree(out); 841 807 return NULL; … … 891 857 cimag(unexposedValue) < PS_MIN_##TYPE || \ 892 858 cimag(unexposedValue) > PS_MAX_##TYPE) { \ 893 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 894 PS_ERR_BAD_PARAMETER_VALUE, true, \ 895 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 896 "unexposedValue", \ 897 creal(unexposedValue),cimag(unexposedValue), \ 898 PS_TYPE_##TYPE##_NAME, \ 899 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 859 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 860 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 861 "unexposedValue", \ 862 creal(unexposedValue),cimag(unexposedValue), \ 863 PS_TYPE_##TYPE##_NAME, \ 864 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 900 865 psFree(out); \ 901 866 out = NULL; \ … … 959 924 char* typeStr; \ 960 925 PS_TYPE_NAME(typeStr,type); \ 961 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 962 PS_ERR_BAD_PARAMETER_TYPE, true, \ 963 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 964 typeStr); \ 926 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 927 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 928 typeStr); \ 965 929 psFree(out); \ 966 930 out = NULL; \ … … 973 937 PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR); 974 938 default: 975 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", 976 PS_ERR_BAD_PARAMETER_VALUE, true, 977 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 978 mode); 939 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 940 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 941 mode); 979 942 psFree(out); 980 943 out = NULL; … … 998 961 999 962 if (in == NULL) { 1000 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", 1001 PS_ERR_BAD_PARAMETER_NULL, true, 1002 PS_ERRORTEXT_psImage_IMAGE_NULL); 963 psError(PS_ERR_BAD_PARAMETER_NULL, true, 964 PS_ERRORTEXT_psImage_IMAGE_NULL); 1003 965 psFree(out); 1004 966 return NULL; … … 1018 980 cimag(unexposedValue) < PS_MIN_##TYPE || \ 1019 981 cimag(unexposedValue) > PS_MAX_##TYPE) { \ 1020 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", \ 1021 PS_ERR_BAD_PARAMETER_VALUE, true, \ 1022 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 1023 "unexposedValue", \ 1024 creal(unexposedValue),cimag(unexposedValue), \ 1025 PS_TYPE_##TYPE##_NAME, \ 1026 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 982 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 983 PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \ 984 "unexposedValue", \ 985 creal(unexposedValue),cimag(unexposedValue), \ 986 PS_TYPE_##TYPE##_NAME, \ 987 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 1027 988 psFree(out); \ 1028 989 out = NULL; \ … … 1058 1019 char* typeStr; \ 1059 1020 PS_TYPE_NAME(typeStr,type); \ 1060 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \ 1061 PS_ERR_BAD_PARAMETER_TYPE, true, \ 1062 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 1063 typeStr); \ 1021 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 1022 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \ 1023 typeStr); \ 1064 1024 psFree(out); \ 1065 1025 out = NULL; \ … … 1073 1033 PSIMAGE_SHIFT_ARBITRARY_CASE(BILINEAR); 1074 1034 default: 1075 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", 1076 PS_ERR_BAD_PARAMETER_VALUE, true, 1077 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 1078 mode); 1035 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 1036 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 1037 mode); 1079 1038 psFree(out); 1080 1039 out = NULL; -
trunk/psLib/src/image/psImageStats.c
r2265 r2273 1 1 /** @file psImageStats.c 2 * \brief Routines for calculating statistics on images.3 * @ingroup ImageStats4 *5 * This file will hold the prototypes for procedures which calculate6 * statistic on images, histograms on images, and fit/evaluate Chebyshev7 * polynomials to images.8 *9 * @author GLG, MHPCC10 *11 * @version $Revision: 1.49$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-02 03:57:21$13 *14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii15 */2 * \brief Routines for calculating statistics on images. 3 * @ingroup ImageStats 4 * 5 * This file will hold the prototypes for procedures which calculate 6 * statistic on images, histograms on images, and fit/evaluate Chebyshev 7 * polynomials to images. 8 * 9 * @author GLG, MHPCC 10 * 11 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 * 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 */ 16 16 17 17 #include <stdlib.h> … … 46 46 47 47 if (stats == NULL) { 48 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 49 PS_ERR_BAD_PARAMETER_NULL, true, 50 PS_ERRORTEXT_psImage_STAT_NULL); 48 psError(PS_ERR_BAD_PARAMETER_NULL, true, 49 PS_ERRORTEXT_psImage_STAT_NULL); 51 50 return NULL; 52 51 } 53 52 54 53 if (in == NULL) { 55 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 56 PS_ERR_BAD_PARAMETER_NULL, true, 57 PS_ERRORTEXT_psImage_IMAGE_NULL); 54 psError(PS_ERR_BAD_PARAMETER_NULL, true, 55 PS_ERRORTEXT_psImage_IMAGE_NULL); 58 56 return NULL; 59 57 } 60 58 61 59 if (stats->options == 0) { 62 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 63 PS_ERR_BAD_PARAMETER_VALUE, true, 64 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS); 60 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 61 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS); 65 62 return stats; 66 63 } … … 76 73 char* typeStr; 77 74 PS_TYPE_NAME(typeStr,mask->type.type); 78 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 79 PS_ERR_BAD_PARAMETER_TYPE, true, 80 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 81 typeStr, PS_TYPE_MASK_NAME); 75 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 76 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 77 typeStr, PS_TYPE_MASK_NAME); 82 78 psFree(junkData); 83 79 return NULL; … … 125 121 char* typeStr; 126 122 PS_TYPE_NAME(typeStr,mask->type.type); 127 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageHistogram", 128 PS_ERR_BAD_PARAMETER_TYPE, true, 129 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 130 typeStr, PS_TYPE_MASK_NAME); 123 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 124 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 125 typeStr, PS_TYPE_MASK_NAME); 131 126 psFree(out); 132 127 psFree(junkData); … … 150 145 151 146 /***************************************************************************** 152 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the147 calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the 153 148 interval [-1.0 : 1.0]. Images typically have sizes of 512x512 or more. In 154 149 order to use Chebyshev polynomials, we must scale the coordinates from … … 156 151 output a vector of evenly spaced floating point values between -1.0:1.0. 157 152 *****************************************************************************/ 158 double *CalcScaleFactors(psS32 n)159 { 160 PS_INT_CHEC _NON_NEGATIVE(n, NULL);153 double* calcScaleFactors(psS32 n) 154 { 155 PS_INT_CHECK_NON_NEGATIVE(n, NULL); 161 156 psS32 i = 0; 162 157 double tmp = 0.0; … … 172 167 } 173 168 174 psVector *Vec CalcScaleFactors(psVector *scalingFactors, psS32 n)169 psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n) 175 170 { 176 171 PS_VECTOR_CHECK_NULL(scalingFactors, NULL); 177 172 PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL); 178 PS_INT_CHEC _NON_NEGATIVE(n, NULL);173 PS_INT_CHECK_NON_NEGATIVE(n, NULL); 179 174 psS32 i = 0; 180 175 double tmp = 0.0; … … 243 238 (input->type.type != PS_TYPE_F32) && 244 239 (input->type.type != PS_TYPE_F64)) { 245 psError(__func__, "Unalowwable image type.\n"); 240 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 241 "Unallowable image type.\n"); 246 242 } 247 243 PS_POLY_CHECK_NULL(coeffs, NULL); … … 259 255 // Check for null inputs 260 256 if (input == NULL) { 261 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial", 262 PS_ERR_BAD_PARAMETER_NULL, true, 263 PS_ERRORTEXT_psImage_IMAGE_NULL); 257 psError(PS_ERR_BAD_PARAMETER_NULL, true, 258 PS_ERRORTEXT_psImage_IMAGE_NULL); 264 259 return NULL; 265 260 } 266 261 267 262 if (coeffs == NULL) { 268 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial", 269 PS_ERR_BAD_PARAMETER_NULL, true, 270 PS_ERRORTEXT_psImage_COEFF_NULL); 263 psError(PS_ERR_BAD_PARAMETER_NULL, true, 264 PS_ERRORTEXT_psImage_COEFF_NULL); 271 265 return NULL; 272 266 } … … 283 277 // We scale the pixel positions to values 284 278 // between -1.0 and 1.0 285 rScalingFactors = CalcScaleFactors(input->numRows);286 cScalingFactors = CalcScaleFactors(input->numCols);279 rScalingFactors = calcScaleFactors(input->numRows); 280 cScalingFactors = calcScaleFactors(input->numCols); 287 281 288 282 // Determine how many Chebyshev polynomials … … 363 357 (input->type.type != PS_TYPE_F32) && 364 358 (input->type.type != PS_TYPE_F64)) { 365 psError(__func__, "Unalowwable image type.\n"); 359 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 360 "Unallowable image type.\n"); 366 361 } 367 362 PS_POLY_CHECK_NULL(coeffs, NULL); … … 376 371 double *cScalingFactors = NULL; 377 372 double *rScalingFactors = NULL; 378 double polySum = 0.0; 379 373 float polySum = 0.0; 374 375 // Check for null inputs 376 if (input == NULL) { 377 psError(PS_ERR_BAD_PARAMETER_NULL, true, 378 PS_ERRORTEXT_psImage_IMAGE_NULL); 379 return NULL; 380 } 381 382 if (coeffs == NULL) { 383 psError(PS_ERR_BAD_PARAMETER_NULL, true, 384 PS_ERRORTEXT_psImage_COEFF_NULL); 385 return NULL; 386 } 380 387 381 388 // We scale the pixel positions to values between -1.0 and 1.0 382 389 // Use static data structures here. 383 rScalingFactors = CalcScaleFactors(input->numRows);384 cScalingFactors = CalcScaleFactors(input->numCols);390 rScalingFactors = calcScaleFactors(input->numRows); 391 cScalingFactors = calcScaleFactors(input->numCols); 385 392 386 393 // Determine how many Chebyshev polynomials -
trunk/psLib/src/imageops/psImageConvolve.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:31$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:05:00 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 // got non-NULL vectors? 111 111 if (tShifts == NULL || xShifts == NULL || yShifts == NULL) { 112 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 113 PS_ERR_BAD_PARAMETER_NULL, true, 114 PS_ERRORTEXT_psImageConvolve_SHIFT_NULL); 112 psError(PS_ERR_BAD_PARAMETER_NULL, true, 113 PS_ERRORTEXT_psImageConvolve_SHIFT_NULL); 115 114 return NULL; 116 115 } … … 125 124 PS_TYPE_NAME(typeYStr,yShifts->type.type); 126 125 PS_TYPE_NAME(typeTStr,tShifts->type.type); 127 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 128 PS_ERR_BAD_PARAMETER_TYPE, true, 129 PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH, 130 typeTStr, typeXStr, typeYStr); 126 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 127 PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH, 128 typeTStr, typeXStr, typeYStr); 131 129 return NULL; 132 130 } … … 218 216 char* typeStr; 219 217 PS_TYPE_NAME(typeStr,xShifts->type.type); 220 psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate", 221 PS_ERR_BAD_PARAMETER_TYPE, true, 222 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 223 typeStr); 218 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 219 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 220 typeStr); 224 221 } 225 222 } … … 236 233 237 234 if (kernel == NULL) { 238 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 239 PS_ERR_BAD_PARAMETER_NULL, true, 240 PS_ERRORTEXT_psImageConvolve_KERNEL_NULL); 235 psError(PS_ERR_BAD_PARAMETER_NULL, true, 236 PS_ERRORTEXT_psImageConvolve_KERNEL_NULL); 241 237 psFree(out); 242 238 return NULL; … … 297 293 char* typeStr; 298 294 PS_TYPE_NAME(typeStr,in->type.type); 299 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 300 PS_ERR_BAD_PARAMETER_TYPE, true, 301 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 302 typeStr); 295 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 296 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 297 typeStr); 303 298 psFree(out); 304 299 return NULL; … … 317 312 psS32 kCols = kernel->image->numCols; 318 313 if (kRows >= numRows || kCols >= numCols) { 319 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 320 PS_ERR_BAD_PARAMETER_SIZE, true, 321 PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE, 322 kCols,kRows, 323 numCols, numRows); 314 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 315 PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE, 316 kCols,kRows, 317 numCols, numRows); 324 318 psFree(out); 325 319 return NULL; … … 376 370 psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD); 377 371 if (kernelFourier == NULL) { 378 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 379 PS_ERR_UNKNOWN, false, 380 PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED); 372 psError(PS_ERR_UNKNOWN, false, 373 PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED); 381 374 psFree(out); 382 375 return NULL; … … 385 378 psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD); 386 379 if (inFourier == NULL) { 387 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 388 PS_ERR_UNKNOWN, false, 389 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 380 psError(PS_ERR_UNKNOWN, false, 381 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 390 382 psFree(out); 391 383 return NULL; … … 398 390 PS_FFT_REVERSE); 399 391 if (complexOut == NULL) { 400 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve", 401 PS_ERR_UNKNOWN, false, 402 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 392 psError(PS_ERR_UNKNOWN, false, 393 PS_ERRORTEXT_psImageConvolve_FFT_FAILED); 403 394 psFree(out); 404 395 return NULL; -
trunk/psLib/src/imageops/psImageStats.c
r2265 r2273 1 1 /** @file psImageStats.c 2 * \brief Routines for calculating statistics on images.3 * @ingroup ImageStats4 *5 * This file will hold the prototypes for procedures which calculate6 * statistic on images, histograms on images, and fit/evaluate Chebyshev7 * polynomials to images.8 *9 * @author GLG, MHPCC10 *11 * @version $Revision: 1.49$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-02 03:57:21$13 *14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii15 */2 * \brief Routines for calculating statistics on images. 3 * @ingroup ImageStats 4 * 5 * This file will hold the prototypes for procedures which calculate 6 * statistic on images, histograms on images, and fit/evaluate Chebyshev 7 * polynomials to images. 8 * 9 * @author GLG, MHPCC 10 * 11 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 * 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 */ 16 16 17 17 #include <stdlib.h> … … 46 46 47 47 if (stats == NULL) { 48 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 49 PS_ERR_BAD_PARAMETER_NULL, true, 50 PS_ERRORTEXT_psImage_STAT_NULL); 48 psError(PS_ERR_BAD_PARAMETER_NULL, true, 49 PS_ERRORTEXT_psImage_STAT_NULL); 51 50 return NULL; 52 51 } 53 52 54 53 if (in == NULL) { 55 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 56 PS_ERR_BAD_PARAMETER_NULL, true, 57 PS_ERRORTEXT_psImage_IMAGE_NULL); 54 psError(PS_ERR_BAD_PARAMETER_NULL, true, 55 PS_ERRORTEXT_psImage_IMAGE_NULL); 58 56 return NULL; 59 57 } 60 58 61 59 if (stats->options == 0) { 62 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 63 PS_ERR_BAD_PARAMETER_VALUE, true, 64 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS); 60 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 61 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS); 65 62 return stats; 66 63 } … … 76 73 char* typeStr; 77 74 PS_TYPE_NAME(typeStr,mask->type.type); 78 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats", 79 PS_ERR_BAD_PARAMETER_TYPE, true, 80 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 81 typeStr, PS_TYPE_MASK_NAME); 75 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 76 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 77 typeStr, PS_TYPE_MASK_NAME); 82 78 psFree(junkData); 83 79 return NULL; … … 125 121 char* typeStr; 126 122 PS_TYPE_NAME(typeStr,mask->type.type); 127 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageHistogram", 128 PS_ERR_BAD_PARAMETER_TYPE, true, 129 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 130 typeStr, PS_TYPE_MASK_NAME); 123 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 124 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 125 typeStr, PS_TYPE_MASK_NAME); 131 126 psFree(out); 132 127 psFree(junkData); … … 150 145 151 146 /***************************************************************************** 152 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the147 calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the 153 148 interval [-1.0 : 1.0]. Images typically have sizes of 512x512 or more. In 154 149 order to use Chebyshev polynomials, we must scale the coordinates from … … 156 151 output a vector of evenly spaced floating point values between -1.0:1.0. 157 152 *****************************************************************************/ 158 double *CalcScaleFactors(psS32 n)159 { 160 PS_INT_CHEC _NON_NEGATIVE(n, NULL);153 double* calcScaleFactors(psS32 n) 154 { 155 PS_INT_CHECK_NON_NEGATIVE(n, NULL); 161 156 psS32 i = 0; 162 157 double tmp = 0.0; … … 172 167 } 173 168 174 psVector *Vec CalcScaleFactors(psVector *scalingFactors, psS32 n)169 psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n) 175 170 { 176 171 PS_VECTOR_CHECK_NULL(scalingFactors, NULL); 177 172 PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL); 178 PS_INT_CHEC _NON_NEGATIVE(n, NULL);173 PS_INT_CHECK_NON_NEGATIVE(n, NULL); 179 174 psS32 i = 0; 180 175 double tmp = 0.0; … … 243 238 (input->type.type != PS_TYPE_F32) && 244 239 (input->type.type != PS_TYPE_F64)) { 245 psError(__func__, "Unalowwable image type.\n"); 240 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 241 "Unallowable image type.\n"); 246 242 } 247 243 PS_POLY_CHECK_NULL(coeffs, NULL); … … 259 255 // Check for null inputs 260 256 if (input == NULL) { 261 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial", 262 PS_ERR_BAD_PARAMETER_NULL, true, 263 PS_ERRORTEXT_psImage_IMAGE_NULL); 257 psError(PS_ERR_BAD_PARAMETER_NULL, true, 258 PS_ERRORTEXT_psImage_IMAGE_NULL); 264 259 return NULL; 265 260 } 266 261 267 262 if (coeffs == NULL) { 268 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial", 269 PS_ERR_BAD_PARAMETER_NULL, true, 270 PS_ERRORTEXT_psImage_COEFF_NULL); 263 psError(PS_ERR_BAD_PARAMETER_NULL, true, 264 PS_ERRORTEXT_psImage_COEFF_NULL); 271 265 return NULL; 272 266 } … … 283 277 // We scale the pixel positions to values 284 278 // between -1.0 and 1.0 285 rScalingFactors = CalcScaleFactors(input->numRows);286 cScalingFactors = CalcScaleFactors(input->numCols);279 rScalingFactors = calcScaleFactors(input->numRows); 280 cScalingFactors = calcScaleFactors(input->numCols); 287 281 288 282 // Determine how many Chebyshev polynomials … … 363 357 (input->type.type != PS_TYPE_F32) && 364 358 (input->type.type != PS_TYPE_F64)) { 365 psError(__func__, "Unalowwable image type.\n"); 359 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 360 "Unallowable image type.\n"); 366 361 } 367 362 PS_POLY_CHECK_NULL(coeffs, NULL); … … 376 371 double *cScalingFactors = NULL; 377 372 double *rScalingFactors = NULL; 378 double polySum = 0.0; 379 373 float polySum = 0.0; 374 375 // Check for null inputs 376 if (input == NULL) { 377 psError(PS_ERR_BAD_PARAMETER_NULL, true, 378 PS_ERRORTEXT_psImage_IMAGE_NULL); 379 return NULL; 380 } 381 382 if (coeffs == NULL) { 383 psError(PS_ERR_BAD_PARAMETER_NULL, true, 384 PS_ERRORTEXT_psImage_COEFF_NULL); 385 return NULL; 386 } 380 387 381 388 // We scale the pixel positions to values between -1.0 and 1.0 382 389 // Use static data structures here. 383 rScalingFactors = CalcScaleFactors(input->numRows);384 cScalingFactors = CalcScaleFactors(input->numCols);390 rScalingFactors = calcScaleFactors(input->numRows); 391 cScalingFactors = calcScaleFactors(input->numCols); 385 392 386 393 // Determine how many Chebyshev polynomials -
trunk/psLib/src/math/psConstants.h
r2272 r2273 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-11-0 3 22:58:53$8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 #define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \ 33 33 if (NAME < 0) { \ 34 psError(__func__,"Error: %s is less than 0.", #NAME); \ 34 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 35 "Error: %s is less than 0.", #NAME); \ 35 36 return(RVAL); \ 36 37 } … … 38 39 #define PS_INT_CHECK_POSITIVE(NAME, RVAL) \ 39 40 if (NAME < 1) { \ 40 psError(__func__,"Error: %s is 0 or less.", #NAME); \ 41 return(RVAL); \ 42 } 43 44 // Produce an error if ((NAME1 > NAME2) 41 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 42 "Error: %s is 0 or less.", #NAME); \ 43 return(RVAL); \ 44 } 45 46 #define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \ 47 if ((int)NAME < LOWER || (int)NAME > UPPER) { \ 48 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 49 "Error: %s, %d, is out of range. Must be between %d and %d.", \ 50 #NAME,(int)NAME,LOWER,UPPER); \ 51 return RVAL; \ 52 } 53 54 // Produce an error if (NAME1 > NAME2) 45 55 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \ 46 56 if (NAME1 > NAME2) { \ 47 psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \ 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 58 "Error: (%s > %s) (%d %d).", \ 59 #NAME1, #NAME2, NAME1, NAME2); \ 48 60 return(RVAL); \ 49 61 } … … 53 65 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \ 54 66 if (NAME1 > NAME2) { \ 55 psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \ 67 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 68 "Error: (%s > %s) (%f %f)", \ 69 #NAME1, #NAME2, NAME1, NAME2); \ 56 70 return(RVAL); \ 57 71 } … … 59 73 #define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \ 60 74 if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \ 61 psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \ 75 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 76 "Error: %s and %s are equal.", \ 77 #NAME1, #NAME2); \ 62 78 return(RVAL); \ 63 79 } … … 67 83 the wrong type. 68 84 *****************************************************************************/ 69 #define PS_PTR_CHECK_NULL(NAME, RVAL) \ 85 #define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL) 86 #define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 70 87 if (NAME == NULL) { \ 71 psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \ 72 return(RVAL); \ 88 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 89 "Unallowable operation: %s is NULL.", \ 90 #NAME); \ 91 CLEANUP; \ 73 92 } 74 93 75 94 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \ 76 95 if (NAME->type.type != TYPE) { \ 77 psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \ 78 return(RVAL); \ 79 } 96 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 97 "Unallowable operation: %s has incorrect type.", \ 98 #NAME); \ 99 return(RVAL); \ 100 } 101 102 #define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL) 103 #define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \ 104 if (NAME->type.dimen != DIMEN) { \ 105 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 106 "Unallowable operation: %s has incorrect dimensionality.", \ 107 #NAME); \ 108 CLEANUP; \ 109 } 110 80 111 81 112 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \ 82 113 if (PTR1->n != PTR2->n) { \ 83 psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \ 84 return(RVAL); \ 85 } 86 87 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \ 114 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 115 "ptr %s has size %d, ptr %s has size %d.", \ 116 #PTR1, PTR1->n, #PTR2, PTR2->n); \ 117 return(RVAL); \ 118 } 119 120 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL) 121 122 #define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \ 88 123 if (PTR1->type.type != PTR2->type.type) { \ 89 psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 90 return(RVAL); \ 124 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 125 "ptr %s has type %d, ptr %s has type %d.", \ 126 #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ 127 CLEANUP; \ 91 128 } 92 129 … … 95 132 PS_VECTOR macros: 96 133 *****************************************************************************/ 97 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \ 134 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL) 135 #define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 98 136 if (NAME == NULL || NAME->data.V == NULL) { \ 99 psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \ 100 return(RVAL); \ 137 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 138 "Unallowable operation: psVector %s or its data is NULL.", \ 139 #NAME); \ 140 CLEANUP; \ 101 141 } \ 102 142 103 143 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \ 104 144 if (NAME->n < 1) { \ 105 psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \ 145 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 146 "Unallowable operation: psVector %s has no elements.", \ 147 #NAME); \ 106 148 return(RVAL); \ 107 149 } \ … … 109 151 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \ 110 152 if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \ 111 psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \ 153 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 154 "psVector %s: bad type(%d)", \ 155 #NAME, NAME->type.type); \ 112 156 return(RVAL); \ 113 157 } \ … … 115 159 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \ 116 160 if (NAME->type.type != TYPE) { \ 117 psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \ 161 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 162 "Unallowable operation: psVector %s has incorrect type.", \ 163 #NAME); \ 118 164 return(RVAL); \ 119 165 } … … 121 167 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \ 122 168 if (VEC1->n != VEC2->n) { \ 123 psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \ 169 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 170 "psVector %s has size %d, psVector %s has size %d.", \ 171 #VEC1, VEC1->n, #VEC2, VEC2->n); \ 124 172 return(RVAL); \ 125 173 } … … 221 269 #define PS_POLY_CHECK_NULL(NAME, RVAL) \ 222 270 if (NAME == NULL || NAME->coeff == NULL) { \ 223 psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \ 271 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 272 "Unallowable operation: polynomial %s or its coeffs is NULL.", \ 273 #NAME); \ 224 274 return(RVAL); \ 225 275 } \ … … 227 277 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \ 228 278 if (NAME->type != TYPE) { \ 229 psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \ 279 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 280 "Unallowable operation: polynomial %s has wrong type.", #NAME); \ 230 281 return(RVAL); \ 231 282 } \ … … 234 285 PS_IMAGE macros: 235 286 *****************************************************************************/ 236 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \ 287 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL) 288 #define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \ 237 289 if (NAME == NULL || NAME->data.V == NULL) { \ 238 psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \ 239 return(RVAL); \ 240 } 241 242 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \ 290 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 291 "Unallowable operation: psImage %s or its data is NULL.", \ 292 #NAME); \ 293 CLEANUP; \ 294 } 295 296 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL) 297 #define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \ 243 298 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 244 psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \ 245 NAME->numCols, NAME->numRows); \ 246 return(RVAL); \ 299 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 300 "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \ 301 #NAME, NAME->numCols, NAME->numRows); \ 302 CLEANUP; \ 247 303 } 248 304 249 305 #define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \ 250 306 if (NAME->type.type != TYPE) { \ 251 psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \ 307 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 308 "Unallowable operation: psImage %s has incorrect type.", \ 309 #NAME); \ 252 310 return(RVAL); \ 253 311 } … … 260 318 #define PS_READOUT_CHECK_NULL(NAME, RVAL) \ 261 319 if (NAME == NULL || NAME->image == NULL) { \ 262 psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \ 320 psError(PS_ERR_BAD_PARAMETER_NULL, true, \ 321 "Unallowable operation: psReadout %s or its data is NULL.", \ 322 #NAME); \ 263 323 return(RVAL); \ 264 324 } -
trunk/psLib/src/math/psMatrix.c
r2214 r2273 20 20 * @author Ross Harman, MHPCC 21 21 * 22 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $23 * @date $Date: 2004-1 0-27 20:20:11$22 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2004-11-04 01:04:59 $ 24 24 * 25 25 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 #include "psVector.h" 41 41 #include "psMatrix.h" 42 43 /** Preprocessor macro to generate error a NULL image */ 44 #define PS_VECTOR_CHECK_NULL(NAME, RETURN) \ 45 if (NAME == NULL || NAME->data.V == NULL) { \ 46 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 47 return RETURN; \ 48 } 49 50 /** Preprocessor macro to create vector based on another */ 51 #define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE) \ 52 if(NAME == NULL) { \ 53 NAME = psVectorAlloc(SIZE, PS_TYPE); \ 54 } 55 56 /** Preprocessor macro to generate error for zero length vector */ 57 #define PS_CHECK_SIZE_VECTOR(NAME, RETURN) \ 58 if (NAME->n < 1) { \ 59 psError(__func__,"Invalid operation: %s has zero n value.", #NAME); \ 60 return RETURN; \ 61 } 62 63 /** Preprocessor macro to generate error a NULL image */ 64 #define PS_IMAGE_CHECK_NULL(NAME, RETURN) \ 65 if (NAME == NULL || NAME->data.V == NULL) { \ 66 psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME); \ 67 return RETURN; \ 68 } 69 70 /** Preprocessor macro to create image based on another */ 71 #define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE) \ 72 if(NAME == NULL) { \ 73 NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE); \ 74 } 75 76 /** Preprocessor macro to generate error for zero length rows or columns */ 77 #define PS_CHECK_SIZE_IMAGE(NAME, RETURN) \ 78 if (NAME->numCols < 1 || NAME->numRows < 1) { \ 79 psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME, \ 80 NAME->numCols, NAME->numRows); \ 81 return RETURN; \ 82 } 42 #include "psConstants.h" 43 44 83 45 84 46 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */ 85 47 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN) \ 86 48 if (NAME->type.dimen != PS_DIMEN) { \ 87 psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN); \ 49 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 50 "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN); \ 88 51 return RETURN; \ 89 52 } else if(NAME->type.type != PS_TYPE_F64) { \ 90 psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME); \ 53 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 54 "Invalid operation. %s not PS_TYPE_F64.", #NAME); \ 91 55 return RETURN; \ 92 56 } … … 95 59 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN) \ 96 60 if (NAME1 == NAME2) { \ 97 psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 61 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 62 "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2); \ 98 63 return RETURN; \ 99 64 } … … 102 67 #define PS_CHECK_SQUARE(NAME, RETURN) \ 103 68 if (NAME->numCols != NAME->numRows) { \ 104 psError(__func__,"Invalid operation: %s not square array.", #NAME); \ 69 psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ 70 "Invalid operation: %s not square array.", #NAME); \ 105 71 return RETURN; \ 106 72 } … … 126 92 gsl_permutation perm; 127 93 94 #define psMatrixLUD_EXIT { \ 95 psFree(outImage); \ 96 return NULL; \ 97 } 98 128 99 // Error checks 129 100 PS_CHECK_POINTERS(inImage, outImage, outImage); 130 PS_IMAGE_CHECK_NULL(inImage, outImage);131 101 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 132 PS_CHECK_SIZE_IMAGE(inImage, outImage); 133 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 134 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 135 PS_CHECK_SIZE_IMAGE(outImage, outImage); 136 PS_CHECK_ALLOC_VECTOR(outPerm, inImage->numRows, inImage->type.type); 137 PS_VECTOR_CHECK_NULL(outPerm, outImage); 102 103 PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT); 104 PS_VECTOR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT); 105 138 106 PS_CHECK_DIMEN_AND_TYPE(outPerm, PS_DIMEN_VECTOR, outImage); 107 108 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 109 psVectorRecycle(outPerm, inImage->numRows, inImage->type.type); 139 110 140 111 // Initialize data … … 179 150 PS_IMAGE_CHECK_NULL(inImage, outVector); 180 151 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector); 181 PS_CHECK_SIZE_IMAGE(inImage, outVector); 182 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type); 152 PS_IMAGE_CHECK_EMPTY(inImage, outVector); 183 153 PS_VECTOR_CHECK_NULL(outVector, outVector); 184 154 PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector); … … 188 158 PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector); 189 159 160 psVectorRecycle(outVector, inImage->numRows, inImage->type.type); 161 162 190 163 // Initialize data 191 164 numRows = inImage->numRows; … … 226 199 227 200 // Error checks 228 if (det == NULL) { 229 psError(__func__, "Invalid operation: determinant argument is NULL."); 230 return outImage; 231 } 201 PS_PTR_CHECK_NULL(det, outImage); 232 202 PS_CHECK_POINTERS(inImage, outImage, outImage); 233 203 PS_IMAGE_CHECK_NULL(inImage, outImage); 234 204 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 235 PS_CHECK_SIZE_IMAGE(inImage, outImage); 236 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 237 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 238 PS_CHECK_SIZE_IMAGE(outImage, outImage); 205 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 206 207 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 239 208 240 209 // Initialize data … … 282 251 PS_IMAGE_CHECK_NULL(inImage, NULL); 283 252 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL); 284 PS_ CHECK_SIZE_IMAGE(inImage, NULL);253 PS_IMAGE_CHECK_EMPTY(inImage, NULL); 285 254 286 255 // Initialize data … … 325 294 PS_IMAGE_CHECK_NULL(inImage1, outImage); 326 295 PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage); 327 PS_ CHECK_SIZE_IMAGE(inImage1, outImage);296 PS_IMAGE_CHECK_EMPTY(inImage1, outImage); 328 297 PS_IMAGE_CHECK_NULL(inImage2, outImage); 329 298 PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage); 330 PS_CHECK_SIZE_IMAGE(inImage2, outImage); 331 PS_CHECK_ALLOC_IMAGE(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type); 299 PS_IMAGE_CHECK_EMPTY(inImage2, outImage); 332 300 PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage); 333 PS_CHECK_SIZE_IMAGE(outImage, outImage); 301 302 psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type); 334 303 335 304 // Initialize data … … 364 333 PS_IMAGE_CHECK_NULL(inImage, outImage); 365 334 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 366 PS_CHECK_SIZE_IMAGE(inImage, outImage); 367 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 368 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 369 PS_CHECK_SIZE_IMAGE(outImage, outImage); 335 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 336 337 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 370 338 371 339 // Initialize data … … 403 371 PS_IMAGE_CHECK_NULL(inImage, outImage); 404 372 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage); 405 PS_CHECK_SIZE_IMAGE(inImage, outImage); 406 PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 407 PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage); 408 PS_CHECK_SIZE_IMAGE(outImage, outImage); 373 PS_IMAGE_CHECK_EMPTY(inImage, outImage); 374 375 psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type); 409 376 410 377 // Initialize data … … 438 405 psS32 size = 0; 439 406 440 // Error checks 441 PS_IMAGE_CHECK_NULL(inImage, outVector); 407 #define psMatrixToVector_EXIT { \ 408 psFree(outVector); \ 409 return NULL; \ 410 } 411 412 // Error checks 413 PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT); 442 414 PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector); 443 PS_ CHECK_SIZE_IMAGE(inImage, outVector);415 PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT); 444 416 445 417 if (inImage->numRows == 1) { 446 418 // Create transposed row vector 447 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);419 psVectorRecycle(outVector, inImage->numCols, inImage->type.type); 448 420 outVector->type.dimen = PS_DIMEN_TRANSV; 449 421 } else if (inImage->numCols == 1) { 450 422 // Create non-transposed column vector 451 PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);423 psVectorRecycle(outVector, inImage->numRows, inImage->type.type); 452 424 } else { 453 psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows, 454 inImage->numCols); 425 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 426 "Image does not have dim with 1 col or 1 row: (%d x %d).", 427 inImage->numRows, inImage->numCols); 455 428 return outVector; 456 429 } … … 467 440 468 441 if (outVector->n != inImage->numRows) { 469 psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numRows, outVector->n); 442 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 443 "Image and vector sizes differ: (%d vs %d).", 444 inImage->numRows, outVector->n); 470 445 return outVector; 471 446 } … … 481 456 482 457 if (outVector->n != inImage->numCols) { 483 psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n); 458 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 459 "Image and vector sizes differ: (%d vs %d).", 460 inImage->numCols, outVector->n); 484 461 return outVector; 485 462 } … … 502 479 if (inVector->type.dimen == PS_DIMEN_VECTOR) { 503 480 PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage); 504 PS_ CHECK_SIZE_VECTOR(inVector, outImage);505 PS_CHECK_ALLOC_IMAGE(outImage, 1, inVector->n, PS_TYPE_F64)481 PS_VECTOR_CHECK_EMPTY(inVector, outImage); 482 psImageRecycle(outImage, 1, inVector->n, PS_TYPE_F64); 506 483 // More checks for PS_DIMEN_VECTOR 507 484 if (outImage->numCols > 1) { 508 psError(__func__, "Image has more than 1 column: numCols = %d.", outImage->numCols); 485 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 486 "Image has more than 1 column: numCols = %d.", 487 outImage->numCols); 509 488 return outImage; 510 489 } else if (outImage->numRows != inVector->n) { 511 psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n); 490 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 491 "Image and vector sizes differ: (%d vs %d).", 492 outImage->numRows, inVector->n); 512 493 return outImage; 513 494 } … … 517 498 } else if (inVector->type.dimen == PS_DIMEN_TRANSV) { 518 499 PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage); 519 PS_ CHECK_SIZE_VECTOR(inVector, outImage);520 PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)500 PS_VECTOR_CHECK_EMPTY(inVector, outImage); 501 psImageRecycle(outImage, inVector->n, 1, PS_TYPE_F64); 521 502 // More checks for PS_DIMEN_TRANSV 522 503 if (outImage->numRows > 1) { 523 psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows); 504 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 505 "Image has more than 1 row: numRows = %d.", 506 outImage->numRows); 524 507 return outImage; 525 508 } else if (outImage->numCols != inVector->n) { 526 psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n); 509 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 510 "Image and vector sizes differ: (%d vs %d).", 511 outImage->numCols, inVector->n); 527 512 return outImage; 528 513 } -
trunk/psLib/src/math/psMinimize.c
r2269 r2273 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 3 03:30:30$11 * @version $Revision: 1.85 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 291 291 292 292 if (y32->n != (1 + mySpline->n)) { 293 psError(__func__, "data size / spline size mismatch (%d %d)\n", 293 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 294 "data size / spline size mismatch (%d %d)\n", 294 295 y32->n, mySpline->n); 295 296 return(NULL); … … 318 319 // Check if these are cubic splines (n==4). If not, psError. 319 320 if (4 != (mySpline->spline[0])->n) { 320 psError(__func__, "Don't know how to generate %d-order splines.", 321 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 322 "Don't know how to generate %d-order splines.", 321 323 (mySpline->spline[0])->n-1); 322 324 return(NULL); … … 952 954 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 953 955 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 954 p _psNormalizeVectorRange(x64Static, -1.0, 1.0);956 psNormalizeVectorRange(x64Static, -1.0, 1.0); 955 957 } 956 958 x64 = x64Static; … … 968 970 tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64); 969 971 } else { 970 psError(__func__, "unknown polynomial type.\n"); 972 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 973 "unknown polynomial type.\n"); 971 974 return(NULL); 972 975 } … … 1365 1368 bracket = p_psDetermineBracket2(params, line, paramMask, coords, func); 1366 1369 if (bracket == NULL) { 1367 psError(__func__, "(1) Could not bracket minimum."); 1370 psError(PS_ERR_UNKNOWN, false, 1371 "Could not bracket minimum."); 1368 1372 return(NAN); 1369 1373 } … … 1552 1556 func); 1553 1557 if (isnan(mul)) { 1554 psError(__func__, "Could not perform line minimization (1).\n"); 1558 psError(PS_ERR_UNKNOWN, false, 1559 "Could not perform line minimization"); 1555 1560 psFree(v); 1556 1561 return(false); … … 1592 1597 mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func); 1593 1598 if (isnan(mul)) { 1594 psError(__func__, "Could not perform line minimization. (2)\n"); 1599 psError(PS_ERR_UNKNOWN, false, 1600 "Could not perform line minimization."); 1595 1601 psFree(v); 1596 1602 return(false); -
trunk/psLib/src/math/psPolynomial.c
r2224 r2273 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-28 00:22:53$9 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:04:59 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psFunctions.h" 36 36 #include "psConstants.h" 37 38 #include "psDataManipErrors.h" 39 37 40 /*****************************************************************************/ 38 41 /* DEFINE STATEMENTS */ … … 50 53 static void dPolynomial3DFree(psDPolynomial3D* myPoly); 51 54 static void dPolynomial4DFree(psDPolynomial4D* myPoly); 55 static void spline1DFree(psSpline1D *tmpSpline); 56 static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x); 57 static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x); 52 58 53 59 /*****************************************************************************/ … … 67 73 /*****************************************************************************/ 68 74 75 static void spline1DFree(psSpline1D *tmpSpline) 76 { 77 psS32 i; 78 79 if (tmpSpline == NULL) { 80 return; 81 } 82 83 if (tmpSpline->spline != NULL) { 84 for (i=0;i<tmpSpline->n;i++) { 85 psFree((tmpSpline->spline)[i]); 86 } 87 psFree(tmpSpline->spline); 88 } 89 90 if (tmpSpline->p_psDeriv2 != NULL) { 91 psFree(tmpSpline->p_psDeriv2); 92 } 93 psFree(tmpSpline->domains); 94 95 return; 96 } 97 98 static void polynomial1DFree(psPolynomial1D* myPoly) 99 { 100 psFree(myPoly->coeff); 101 psFree(myPoly->coeffErr); 102 psFree(myPoly->mask); 103 } 104 105 static void polynomial2DFree(psPolynomial2D* myPoly) 106 { 107 psS32 x = 0; 108 109 for (x = 0; x < myPoly->nX; x++) { 110 psFree(myPoly->coeff[x]); 111 psFree(myPoly->coeffErr[x]); 112 psFree(myPoly->mask[x]); 113 } 114 psFree(myPoly->coeff); 115 psFree(myPoly->coeffErr); 116 psFree(myPoly->mask); 117 } 118 119 static void polynomial3DFree(psPolynomial3D* myPoly) 120 { 121 psS32 x = 0; 122 psS32 y = 0; 123 124 for (x = 0; x < myPoly->nX; x++) { 125 for (y = 0; y < myPoly->nY; y++) { 126 psFree(myPoly->coeff[x][y]); 127 psFree(myPoly->coeffErr[x][y]); 128 psFree(myPoly->mask[x][y]); 129 } 130 psFree(myPoly->coeff[x]); 131 psFree(myPoly->coeffErr[x]); 132 psFree(myPoly->mask[x]); 133 } 134 135 psFree(myPoly->coeff); 136 psFree(myPoly->coeffErr); 137 psFree(myPoly->mask); 138 } 139 140 static void polynomial4DFree(psPolynomial4D* myPoly) 141 { 142 psS32 w = 0; 143 psS32 x = 0; 144 psS32 y = 0; 145 146 for (w = 0; w < myPoly->nW; w++) { 147 for (x = 0; x < myPoly->nX; x++) { 148 for (y = 0; y < myPoly->nY; y++) { 149 psFree(myPoly->coeff[w][x][y]); 150 psFree(myPoly->coeffErr[w][x][y]); 151 psFree(myPoly->mask[w][x][y]); 152 } 153 psFree(myPoly->coeff[w][x]); 154 psFree(myPoly->coeffErr[w][x]); 155 psFree(myPoly->mask[w][x]); 156 } 157 psFree(myPoly->coeff[w]); 158 psFree(myPoly->coeffErr[w]); 159 psFree(myPoly->mask[w]); 160 } 161 162 psFree(myPoly->coeff); 163 psFree(myPoly->coeffErr); 164 psFree(myPoly->mask); 165 } 166 167 static void dPolynomial1DFree(psDPolynomial1D* myPoly) 168 { 169 psFree(myPoly->coeff); 170 psFree(myPoly->coeffErr); 171 psFree(myPoly->mask); 172 } 173 174 static void dPolynomial2DFree(psDPolynomial2D* myPoly) 175 { 176 psS32 x = 0; 177 178 for (x = 0; x < myPoly->nX; x++) { 179 psFree(myPoly->coeff[x]); 180 psFree(myPoly->coeffErr[x]); 181 psFree(myPoly->mask[x]); 182 } 183 psFree(myPoly->coeff); 184 psFree(myPoly->coeffErr); 185 psFree(myPoly->mask); 186 } 187 188 static void dPolynomial3DFree(psDPolynomial3D* myPoly) 189 { 190 psS32 x = 0; 191 psS32 y = 0; 192 193 for (x = 0; x < myPoly->nX; x++) { 194 for (y = 0; y < myPoly->nY; y++) { 195 psFree(myPoly->coeff[x][y]); 196 psFree(myPoly->coeffErr[x][y]); 197 psFree(myPoly->mask[x][y]); 198 } 199 psFree(myPoly->coeff[x]); 200 psFree(myPoly->coeffErr[x]); 201 psFree(myPoly->mask[x]); 202 } 203 204 psFree(myPoly->coeff); 205 psFree(myPoly->coeffErr); 206 psFree(myPoly->mask); 207 } 208 209 static void dPolynomial4DFree(psDPolynomial4D* myPoly) 210 { 211 psS32 w = 0; 212 psS32 x = 0; 213 psS32 y = 0; 214 215 for (w = 0; w < myPoly->nW; w++) { 216 for (x = 0; x < myPoly->nX; x++) { 217 for (y = 0; y < myPoly->nY; y++) { 218 psFree(myPoly->coeff[w][x][y]); 219 psFree(myPoly->coeffErr[w][x][y]); 220 psFree(myPoly->mask[w][x][y]); 221 } 222 psFree(myPoly->coeff[w][x]); 223 psFree(myPoly->coeffErr[w][x]); 224 psFree(myPoly->mask[w][x]); 225 } 226 psFree(myPoly->coeff[w]); 227 psFree(myPoly->coeffErr[w]); 228 psFree(myPoly->mask[w]); 229 } 230 231 psFree(myPoly->coeff); 232 psFree(myPoly->coeffErr); 233 psFree(myPoly->mask); 234 } 235 69 236 /***************************************************************************** 70 CreateChebyshevPolys(n): this routine takes as input the required order n,237 createChebyshevPolys(n): this routine takes as input the required order n, 71 238 and returns as output as a pointer to an array of n psPolynomial1D 72 239 structures, corresponding to the first n Chebyshev polynomials. … … 76 243 outer coefficients of the Chebyshev polynomials. 77 244 *****************************************************************************/ 78 static psPolynomial1D ** CreateChebyshevPolys(psS32 maxChebyPoly)245 static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly) 79 246 { 80 247 PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL); … … 103 270 104 271 return (chebPolys); 272 } 273 274 /***************************************************************************** 275 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 276 277 XXX: Should the "coeffErr[]" should be used as well? 278 *****************************************************************************/ 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) 280 { 281 psS32 loop_x = 0; 282 float polySum = 0.0; 283 float xSum = 1.0; 284 285 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 286 "---- Calling ordPolynomial1DEval(%f)\n", x); 287 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 288 "Polynomial order is %d\n", myPoly->n); 289 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 290 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 291 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]); 292 } 293 294 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 295 if (myPoly->mask[loop_x] == 0) { 296 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10, 297 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 298 polySum += xSum * myPoly->coeff[loop_x]; 299 xSum *= x; 300 } 301 } 302 303 return(polySum); 304 } 305 306 // XXX: You can do this without having to psAlloc() vector d. 307 // XXX: How does the mask vector effect Crenshaw's formula? 308 static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly) 309 { 310 psVector *d; 311 psS32 n; 312 psS32 i; 313 float tmp; 314 315 n = myPoly->n; 316 d = psVectorAlloc(n, PS_TYPE_F32); 317 d->data.F32[n-1] = myPoly->coeff[n-1]; 318 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2]; 319 for (i=n-3;i>=1;i--) { 320 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) - 321 (d->data.F32[i+2]) + 322 (myPoly->coeff[i]); 323 } 324 325 tmp = (x * d->data.F32[1]) - 326 (d->data.F32[2]) + 327 (0.5 * myPoly->coeff[0]); 328 329 psFree(d); 330 return(tmp); 331 /* 332 333 psS32 n; 334 psS32 i; 335 float tmp; 336 psPolynomial1D **chebPolys = NULL; 337 338 n = myPoly->n; 339 chebPolys = createChebyshevPolys(n); 340 341 tmp = 0.0; 342 for (i=0;i<myPoly->n;i++) { 343 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 344 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i])); 345 } 346 tmp-= (myPoly->coeff[0]/2.0); 347 348 349 return(tmp); 350 */ 351 } 352 353 static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 354 { 355 PS_POLY_CHECK_NULL(myPoly, NAN); 356 357 psS32 loop_x = 0; 358 psS32 loop_y = 0; 359 float polySum = 0.0; 360 float xSum = 1.0; 361 float ySum = 1.0; 362 363 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 364 ySum = xSum; 365 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 366 if (myPoly->mask[loop_x][loop_y] == 0) { 367 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 368 ySum *= y; 369 } 370 } 371 xSum *= x; 372 } 373 374 return(polySum); 375 } 376 377 static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 378 { 379 PS_POLY_CHECK_NULL(myPoly, NAN); 380 381 psS32 loop_x = 0; 382 psS32 loop_y = 0; 383 psS32 i = 0; 384 float polySum = 0.0; 385 psPolynomial1D* *chebPolys = NULL; 386 psS32 maxChebyPoly = 0; 387 388 // Determine how many Chebyshev polynomials 389 // are needed, then create them. 390 maxChebyPoly = myPoly->nX; 391 if (myPoly->nY > maxChebyPoly) { 392 maxChebyPoly = myPoly->nY; 393 } 394 chebPolys = createChebyshevPolys(maxChebyPoly); 395 396 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 397 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 398 if (myPoly->mask[loop_x][loop_y] == 0) { 399 polySum += myPoly->coeff[loop_x][loop_y] * 400 psPolynomial1DEval(x, chebPolys[loop_x]) * 401 psPolynomial1DEval(y, chebPolys[loop_y]); 402 } 403 } 404 } 405 for (i=0;i<maxChebyPoly;i++) { 406 psFree(chebPolys[i]); 407 } 408 psFree(chebPolys); 409 return(polySum); 410 } 411 412 static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 413 { 414 psS32 loop_x = 0; 415 psS32 loop_y = 0; 416 psS32 loop_z = 0; 417 float polySum = 0.0; 418 float xSum = 1.0; 419 float ySum = 1.0; 420 float zSum = 1.0; 421 422 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 423 ySum = xSum; 424 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 425 zSum = ySum; 426 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 427 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 428 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 429 zSum *= z; 430 } 431 } 432 ySum *= y; 433 } 434 xSum *= x; 435 } 436 437 return(polySum); 438 } 439 440 static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 441 { 442 psS32 loop_x = 0; 443 psS32 loop_y = 0; 444 psS32 loop_z = 0; 445 psS32 i = 0; 446 float polySum = 0.0; 447 psPolynomial1D* *chebPolys = NULL; 448 psS32 maxChebyPoly = 0; 449 450 // Determine how many Chebyshev polynomials 451 // are needed, then create them. 452 maxChebyPoly = myPoly->nX; 453 if (myPoly->nY > maxChebyPoly) { 454 maxChebyPoly = myPoly->nY; 455 } 456 if (myPoly->nZ > maxChebyPoly) { 457 maxChebyPoly = myPoly->nZ; 458 } 459 chebPolys = createChebyshevPolys(maxChebyPoly); 460 461 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 462 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 463 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 464 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 465 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 466 psPolynomial1DEval(x, chebPolys[loop_x]) * 467 psPolynomial1DEval(y, chebPolys[loop_y]) * 468 psPolynomial1DEval(z, chebPolys[loop_z]); 469 } 470 } 471 } 472 } 473 474 for (i=0;i<maxChebyPoly;i++) { 475 psFree(chebPolys[i]); 476 } 477 psFree(chebPolys); 478 return(polySum); 479 } 480 481 static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 482 { 483 psS32 loop_w = 0; 484 psS32 loop_x = 0; 485 psS32 loop_y = 0; 486 psS32 loop_z = 0; 487 float polySum = 0.0; 488 float wSum = 1.0; 489 float xSum = 1.0; 490 float ySum = 1.0; 491 float zSum = 1.0; 492 493 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 494 xSum = wSum; 495 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 496 ySum = xSum; 497 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 498 zSum = ySum; 499 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 500 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 501 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 502 zSum *= z; 503 } 504 } 505 ySum *= y; 506 } 507 xSum *= x; 508 } 509 wSum *= w; 510 } 511 512 return(polySum); 513 } 514 515 static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 516 { 517 psS32 loop_w = 0; 518 psS32 loop_x = 0; 519 psS32 loop_y = 0; 520 psS32 loop_z = 0; 521 psS32 i = 0; 522 float polySum = 0.0; 523 psPolynomial1D* *chebPolys = NULL; 524 psS32 maxChebyPoly = 0; 525 526 // Determine how many Chebyshev polynomials 527 // are needed, then create them. 528 maxChebyPoly = myPoly->nW; 529 if (myPoly->nX > maxChebyPoly) { 530 maxChebyPoly = myPoly->nX; 531 } 532 if (myPoly->nY > maxChebyPoly) { 533 maxChebyPoly = myPoly->nY; 534 } 535 if (myPoly->nZ > maxChebyPoly) { 536 maxChebyPoly = myPoly->nZ; 537 } 538 chebPolys = createChebyshevPolys(maxChebyPoly); 539 540 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 541 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 542 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 543 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 544 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 545 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 546 psPolynomial1DEval(w, chebPolys[loop_w]) * 547 psPolynomial1DEval(x, chebPolys[loop_x]) * 548 psPolynomial1DEval(y, chebPolys[loop_y]) * 549 psPolynomial1DEval(z, chebPolys[loop_z]); 550 } 551 } 552 } 553 } 554 } 555 556 for (i=0;i<maxChebyPoly;i++) { 557 psFree(chebPolys[i]); 558 } 559 psFree(chebPolys); 560 return(polySum); 561 } 562 563 /***************************************************************************** 564 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 565 *****************************************************************************/ 566 static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 567 { 568 psS32 loop_x = 0; 569 double polySum = 0.0; 570 double xSum = 1.0; 571 572 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 573 if (myPoly->mask[loop_x] == 0) { 574 polySum += xSum * myPoly->coeff[loop_x]; 575 xSum *= x; 576 } 577 } 578 579 return(polySum); 580 } 581 582 // XXX: You can do this without having to psAlloc() vector d. 583 // XXX: How does the mask vector effect Crenshaw's formula? 584 static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 585 { 586 psVector *d; 587 psS32 n; 588 psS32 i; 589 double tmp; 590 591 n = myPoly->n; 592 d = psVectorAlloc(n, PS_TYPE_F64); 593 d->data.F64[n-1] = myPoly->coeff[n-1]; 594 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2]; 595 for (i=n-3;i>=1;i--) { 596 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) - 597 (d->data.F64[i+2]) + 598 (myPoly->coeff[i]); 599 } 600 601 tmp = (x * d->data.F64[1]) - 602 (d->data.F64[2]) + 603 (0.5 * myPoly->coeff[0]); 604 605 psFree(d); 606 return(tmp); 607 } 608 609 static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 610 { 611 psS32 loop_x = 0; 612 psS32 loop_y = 0; 613 double polySum = 0.0; 614 double xSum = 1.0; 615 double ySum = 1.0; 616 617 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 618 ySum = xSum; 619 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 620 if (myPoly->mask[loop_x][loop_y] == 0) { 621 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 622 ySum *= y; 623 } 624 } 625 xSum *= x; 626 } 627 628 return(polySum); 629 } 630 631 static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 632 { 633 psS32 loop_x = 0; 634 psS32 loop_y = 0; 635 psS32 i = 0; 636 double polySum = 0.0; 637 psPolynomial1D* *chebPolys = NULL; 638 psS32 maxChebyPoly = 0; 639 640 // Determine how many Chebyshev polynomials 641 // are needed, then create them. 642 maxChebyPoly = myPoly->nX; 643 if (myPoly->nY > maxChebyPoly) { 644 maxChebyPoly = myPoly->nY; 645 } 646 chebPolys = createChebyshevPolys(maxChebyPoly); 647 648 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 649 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 650 if (myPoly->mask[loop_x][loop_y] == 0) { 651 polySum += myPoly->coeff[loop_x][loop_y] * 652 psPolynomial1DEval(x, chebPolys[loop_x]) * 653 psPolynomial1DEval(y, chebPolys[loop_y]); 654 } 655 } 656 } 657 658 for (i=0;i<maxChebyPoly;i++) { 659 psFree(chebPolys[i]); 660 } 661 psFree(chebPolys); 662 return(polySum); 663 } 664 665 static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 666 { 667 psS32 loop_x = 0; 668 psS32 loop_y = 0; 669 psS32 loop_z = 0; 670 double polySum = 0.0; 671 double xSum = 1.0; 672 double ySum = 1.0; 673 double zSum = 1.0; 674 675 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 676 ySum = xSum; 677 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 678 zSum = ySum; 679 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 680 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 681 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 682 zSum *= z; 683 } 684 } 685 ySum *= y; 686 } 687 xSum *= x; 688 } 689 690 return(polySum); 691 } 692 693 static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 694 { 695 psS32 loop_x = 0; 696 psS32 loop_y = 0; 697 psS32 loop_z = 0; 698 psS32 i = 0; 699 double polySum = 0.0; 700 psPolynomial1D* *chebPolys = NULL; 701 psS32 maxChebyPoly = 0; 702 703 // Determine how many Chebyshev polynomials 704 // are needed, then create them. 705 maxChebyPoly = myPoly->nX; 706 if (myPoly->nY > maxChebyPoly) { 707 maxChebyPoly = myPoly->nY; 708 } 709 if (myPoly->nZ > maxChebyPoly) { 710 maxChebyPoly = myPoly->nZ; 711 } 712 chebPolys = createChebyshevPolys(maxChebyPoly); 713 714 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 715 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 716 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 717 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 718 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 719 psPolynomial1DEval(x, chebPolys[loop_x]) * 720 psPolynomial1DEval(y, chebPolys[loop_y]) * 721 psPolynomial1DEval(z, chebPolys[loop_z]); 722 } 723 } 724 } 725 } 726 727 for (i=0;i<maxChebyPoly;i++) { 728 psFree(chebPolys[i]); 729 } 730 psFree(chebPolys); 731 return(polySum); 732 } 733 734 static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 735 { 736 psS32 loop_w = 0; 737 psS32 loop_x = 0; 738 psS32 loop_y = 0; 739 psS32 loop_z = 0; 740 double polySum = 0.0; 741 double wSum = 1.0; 742 double xSum = 1.0; 743 double ySum = 1.0; 744 double zSum = 1.0; 745 746 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 747 xSum = wSum; 748 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 749 ySum = xSum; 750 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 751 zSum = ySum; 752 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 753 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 754 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 755 zSum *= z; 756 } 757 } 758 ySum *= y; 759 } 760 xSum *= x; 761 } 762 wSum *= w; 763 } 764 765 return(polySum); 766 } 767 768 static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 769 { 770 psS32 loop_w = 0; 771 psS32 loop_x = 0; 772 psS32 loop_y = 0; 773 psS32 loop_z = 0; 774 psS32 i = 0; 775 double polySum = 0.0; 776 psPolynomial1D* *chebPolys = NULL; 777 psS32 maxChebyPoly = 0; 778 779 // Determine how many Chebyshev polynomials 780 // are needed, then create them. 781 maxChebyPoly = myPoly->nW; 782 if (myPoly->nX > maxChebyPoly) { 783 maxChebyPoly = myPoly->nX; 784 } 785 if (myPoly->nY > maxChebyPoly) { 786 maxChebyPoly = myPoly->nY; 787 } 788 if (myPoly->nZ > maxChebyPoly) { 789 maxChebyPoly = myPoly->nZ; 790 } 791 chebPolys = createChebyshevPolys(maxChebyPoly); 792 793 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 794 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 795 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 796 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 797 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 798 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 799 psPolynomial1DEval(w, chebPolys[loop_w]) * 800 psPolynomial1DEval(x, chebPolys[loop_x]) * 801 psPolynomial1DEval(y, chebPolys[loop_y]) * 802 psPolynomial1DEval(z, chebPolys[loop_z]); 803 } 804 } 805 } 806 } 807 } 808 809 for (i=0;i<maxChebyPoly;i++) { 810 psFree(chebPolys[i]); 811 } 812 psFree(chebPolys); 813 return(polySum); 814 } 815 816 817 /***************************************************************************** 818 p_psInterpolate1D(): This routine will take as input n-element floating 819 point arrays domain and range, and the x value, assumed to lie with the 820 domain vector. It produces as output the (n-1)-order LaGrange interpolated 821 value of x. 822 823 XXX: do we error check for non-distinct domain values? 824 *****************************************************************************/ 825 static float fullInterpolate1DF32(float *domain, 826 float *range, 827 psS32 n, 828 float x) 829 { 830 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 831 PS_PTR_CHECK_NULL(domain, NAN); 832 PS_PTR_CHECK_NULL(range, NAN); 833 834 psS32 i; 835 psS32 m; 836 static psVector *p = NULL; 837 p = psVectorRecycle(p, n, PS_TYPE_F32); 838 p_psMemSetPersistent(p, true); 839 p_psMemSetPersistent(p->data.F32, true); 840 /* 841 psVector *p = psVectorAlloc(n, PS_TYPE_F32); 842 float tmp; 843 */ 844 845 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 846 "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n); 847 848 for (i=0;i<n;i++) { 849 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 850 "domain/range is (%f %f)\n", domain[i], range[i]); 851 } 852 853 for (i=0;i<n;i++) { 854 p->data.F32[i] = range[i]; 855 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 856 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 857 858 } 859 860 // From NR, during each iteration of the m loop, we are computing the 861 // p_{i ... i+m} terms. 862 for (m=1;m<n;m++) { 863 for (i=0;i<n-m;i++) { 864 // From NR: we are computing P_{i ... i+m} 865 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) + 866 ((domain[i]-x) * p->data.F32[i+1])) / 867 (domain[i] - domain[i+m]); 868 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]); 869 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 870 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 871 } 872 } 873 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 874 "---- fullInterpolate1DF32() end ----\n"); 875 876 /* 877 tmp = p->data.F32[0]; 878 psFree(p); 879 return(tmp); 880 */ 881 return(p->data.F32[0]); 882 } 883 884 885 /***************************************************************************** 886 interpolate1DF32(): this is the base 1-D flat memory routine to perform 887 LaGrange interpolation. 888 *****************************************************************************/ 889 static float interpolate1DF32(float *domain, 890 float *range, 891 psS32 n, 892 psS32 order, 893 float x) 894 { 895 psS32 binNum; 896 psS32 numIntPoints = order+1; 897 psS32 origin; 898 899 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 900 "---- interpolate1DF32() begin ----\n"); 901 902 binNum = vectorBinDisectF32(domain, n, x); 903 904 if (0 == numIntPoints%2) { 905 origin = binNum - ((numIntPoints/2) - 1); 906 } else { 907 origin = binNum - (numIntPoints/2); 908 if ((x-domain[binNum]) > (domain[binNum+1]-x)) { 909 // x is closer to binNum+1. 910 origin = 1 + (binNum - (numIntPoints/2)); 911 } 912 } 913 if (origin < 0) { 914 origin = 0; 915 } 916 if ((origin + numIntPoints) > n) { 917 origin = n - numIntPoints; 918 } 919 920 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 921 "---- interpolate1DF32() end ----\n"); 922 return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x)); 105 923 } 106 924 … … 336 1154 } 337 1155 338 static void polynomial1DFree(psPolynomial1D* myPoly)339 {340 psFree(myPoly->coeff);341 psFree(myPoly->coeffErr);342 psFree(myPoly->mask);343 }344 345 static void polynomial2DFree(psPolynomial2D* myPoly)346 {347 psS32 x = 0;348 349 for (x = 0; x < myPoly->nX; x++) {350 psFree(myPoly->coeff[x]);351 psFree(myPoly->coeffErr[x]);352 psFree(myPoly->mask[x]);353 }354 psFree(myPoly->coeff);355 psFree(myPoly->coeffErr);356 psFree(myPoly->mask);357 }358 359 static void polynomial3DFree(psPolynomial3D* myPoly)360 {361 psS32 x = 0;362 psS32 y = 0;363 364 for (x = 0; x < myPoly->nX; x++) {365 for (y = 0; y < myPoly->nY; y++) {366 psFree(myPoly->coeff[x][y]);367 psFree(myPoly->coeffErr[x][y]);368 psFree(myPoly->mask[x][y]);369 }370 psFree(myPoly->coeff[x]);371 psFree(myPoly->coeffErr[x]);372 psFree(myPoly->mask[x]);373 }374 375 psFree(myPoly->coeff);376 psFree(myPoly->coeffErr);377 psFree(myPoly->mask);378 }379 380 static void polynomial4DFree(psPolynomial4D* myPoly)381 {382 psS32 w = 0;383 psS32 x = 0;384 psS32 y = 0;385 386 for (w = 0; w < myPoly->nW; w++) {387 for (x = 0; x < myPoly->nX; x++) {388 for (y = 0; y < myPoly->nY; y++) {389 psFree(myPoly->coeff[w][x][y]);390 psFree(myPoly->coeffErr[w][x][y]);391 psFree(myPoly->mask[w][x][y]);392 }393 psFree(myPoly->coeff[w][x]);394 psFree(myPoly->coeffErr[w][x]);395 psFree(myPoly->mask[w][x]);396 }397 psFree(myPoly->coeff[w]);398 psFree(myPoly->coeffErr[w]);399 psFree(myPoly->mask[w]);400 }401 402 psFree(myPoly->coeff);403 psFree(myPoly->coeffErr);404 psFree(myPoly->mask);405 }406 407 /*****************************************************************************408 Polynomial coefficients will be accessed in [w][x][y][z] fashion.409 410 XXX: Should the "coeffErr[]" should be used as well?411 *****************************************************************************/412 float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)413 {414 psS32 loop_x = 0;415 float polySum = 0.0;416 float xSum = 1.0;417 418 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,419 "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);420 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,421 "Polynomial order is %d\n", myPoly->n);422 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {423 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,424 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);425 }426 427 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {428 if (myPoly->mask[loop_x] == 0) {429 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,430 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);431 polySum += xSum * myPoly->coeff[loop_x];432 xSum *= x;433 }434 }435 436 return(polySum);437 }438 439 // XXX: You can do this without having to psAlloc() vector d.440 // XXX: How does the mask vector effect Crenshaw's formula?441 float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)442 {443 psVector *d;444 psS32 n;445 psS32 i;446 float tmp;447 448 n = myPoly->n;449 d = psVectorAlloc(n, PS_TYPE_F32);450 d->data.F32[n-1] = myPoly->coeff[n-1];451 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];452 for (i=n-3;i>=1;i--) {453 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -454 (d->data.F32[i+2]) +455 (myPoly->coeff[i]);456 }457 458 tmp = (x * d->data.F32[1]) -459 (d->data.F32[2]) +460 (0.5 * myPoly->coeff[0]);461 462 psFree(d);463 return(tmp);464 /*465 466 psS32 n;467 psS32 i;468 float tmp;469 psPolynomial1D **chebPolys = NULL;470 471 n = myPoly->n;472 chebPolys = CreateChebyshevPolys(n);473 474 tmp = 0.0;475 for (i=0;i<myPoly->n;i++) {476 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));477 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));478 }479 tmp-= (myPoly->coeff[0]/2.0);480 481 482 return(tmp);483 */484 }485 486 1156 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly) 487 1157 { … … 489 1159 490 1160 if (myPoly->type == PS_POLYNOMIAL_ORD) { 491 return( p_psOrdPolynomial1DEval(x, myPoly));1161 return(ordPolynomial1DEval(x, myPoly)); 492 1162 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 493 return( p_psChebPolynomial1DEval(x, myPoly));1163 return(chebPolynomial1DEval(x, myPoly)); 494 1164 } else { 495 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1165 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1166 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1167 myPoly->type); 496 1168 } 497 1169 return(0.0); … … 520 1192 } 521 1193 522 523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 1194 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 524 1195 { 525 1196 PS_POLY_CHECK_NULL(myPoly, NAN); 526 1197 527 psS32 loop_x = 0;528 psS32 loop_y = 0;529 float polySum = 0.0;530 float xSum = 1.0;531 float ySum = 1.0;532 533 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {534 ySum = xSum;535 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {536 if (myPoly->mask[loop_x][loop_y] == 0) {537 polySum += ySum * myPoly->coeff[loop_x][loop_y];538 ySum *= y;539 }540 }541 xSum *= x;542 }543 544 return(polySum);545 }546 547 float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)548 {549 PS_POLY_CHECK_NULL(myPoly, NAN);550 551 psS32 loop_x = 0;552 psS32 loop_y = 0;553 psS32 i = 0;554 float polySum = 0.0;555 psPolynomial1D* *chebPolys = NULL;556 psS32 maxChebyPoly = 0;557 558 // Determine how many Chebyshev polynomials559 // are needed, then create them.560 maxChebyPoly = myPoly->nX;561 if (myPoly->nY > maxChebyPoly) {562 maxChebyPoly = myPoly->nY;563 }564 chebPolys = CreateChebyshevPolys(maxChebyPoly);565 566 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {567 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {568 if (myPoly->mask[loop_x][loop_y] == 0) {569 polySum += myPoly->coeff[loop_x][loop_y] *570 psPolynomial1DEval(x, chebPolys[loop_x]) *571 psPolynomial1DEval(y, chebPolys[loop_y]);572 }573 }574 }575 for (i=0;i<maxChebyPoly;i++) {576 psFree(chebPolys[i]);577 }578 psFree(chebPolys);579 return(polySum);580 }581 582 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)583 {584 PS_POLY_CHECK_NULL(myPoly, NAN);585 586 1198 if (myPoly->type == PS_POLYNOMIAL_ORD) { 587 return( p_psOrdPolynomial2DEval(x, y, myPoly));1199 return(ordPolynomial2DEval(x, y, myPoly)); 588 1200 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 589 return( p_psChebPolynomial2DEval(x, y, myPoly));1201 return(chebPolynomial2DEval(x, y, myPoly)); 590 1202 } else { 591 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1203 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1204 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1205 myPoly->type); 592 1206 } 593 1207 return(0.0); 594 1208 } 595 596 1209 597 1210 psVector *psPolynomial2DEvalVector(const psVector *x, … … 632 1245 } 633 1246 634 635 636 float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)637 {638 psS32 loop_x = 0;639 psS32 loop_y = 0;640 psS32 loop_z = 0;641 float polySum = 0.0;642 float xSum = 1.0;643 float ySum = 1.0;644 float zSum = 1.0;645 646 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {647 ySum = xSum;648 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {649 zSum = ySum;650 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {651 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {652 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];653 zSum *= z;654 }655 }656 ySum *= y;657 }658 xSum *= x;659 }660 661 return(polySum);662 }663 664 float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)665 {666 psS32 loop_x = 0;667 psS32 loop_y = 0;668 psS32 loop_z = 0;669 psS32 i = 0;670 float polySum = 0.0;671 psPolynomial1D* *chebPolys = NULL;672 psS32 maxChebyPoly = 0;673 674 // Determine how many Chebyshev polynomials675 // are needed, then create them.676 maxChebyPoly = myPoly->nX;677 if (myPoly->nY > maxChebyPoly) {678 maxChebyPoly = myPoly->nY;679 }680 if (myPoly->nZ > maxChebyPoly) {681 maxChebyPoly = myPoly->nZ;682 }683 chebPolys = CreateChebyshevPolys(maxChebyPoly);684 685 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {686 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {687 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {688 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {689 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *690 psPolynomial1DEval(x, chebPolys[loop_x]) *691 psPolynomial1DEval(y, chebPolys[loop_y]) *692 psPolynomial1DEval(z, chebPolys[loop_z]);693 }694 }695 }696 }697 698 for (i=0;i<maxChebyPoly;i++) {699 psFree(chebPolys[i]);700 }701 psFree(chebPolys);702 return(polySum);703 }704 705 1247 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 706 1248 { … … 708 1250 709 1251 if (myPoly->type == PS_POLYNOMIAL_ORD) { 710 return( p_psOrdPolynomial3DEval(x, y, z, myPoly));1252 return(ordPolynomial3DEval(x, y, z, myPoly)); 711 1253 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 712 return( p_psChebPolynomial3DEval(x, y, z, myPoly));1254 return(chebPolynomial3DEval(x, y, z, myPoly)); 713 1255 } else { 714 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1256 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1257 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1258 myPoly->type); 715 1259 } 716 1260 return(0.0); … … 765 1309 } 766 1310 767 768 769 770 771 772 float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)773 {774 psS32 loop_w = 0;775 psS32 loop_x = 0;776 psS32 loop_y = 0;777 psS32 loop_z = 0;778 float polySum = 0.0;779 float wSum = 1.0;780 float xSum = 1.0;781 float ySum = 1.0;782 float zSum = 1.0;783 784 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {785 xSum = wSum;786 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {787 ySum = xSum;788 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {789 zSum = ySum;790 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {791 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {792 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];793 zSum *= z;794 }795 }796 ySum *= y;797 }798 xSum *= x;799 }800 wSum *= w;801 }802 803 return(polySum);804 }805 806 float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)807 {808 psS32 loop_w = 0;809 psS32 loop_x = 0;810 psS32 loop_y = 0;811 psS32 loop_z = 0;812 psS32 i = 0;813 float polySum = 0.0;814 psPolynomial1D* *chebPolys = NULL;815 psS32 maxChebyPoly = 0;816 817 // Determine how many Chebyshev polynomials818 // are needed, then create them.819 maxChebyPoly = myPoly->nW;820 if (myPoly->nX > maxChebyPoly) {821 maxChebyPoly = myPoly->nX;822 }823 if (myPoly->nY > maxChebyPoly) {824 maxChebyPoly = myPoly->nY;825 }826 if (myPoly->nZ > maxChebyPoly) {827 maxChebyPoly = myPoly->nZ;828 }829 chebPolys = CreateChebyshevPolys(maxChebyPoly);830 831 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {832 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {833 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {834 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {835 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {836 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *837 psPolynomial1DEval(w, chebPolys[loop_w]) *838 psPolynomial1DEval(x, chebPolys[loop_x]) *839 psPolynomial1DEval(y, chebPolys[loop_y]) *840 psPolynomial1DEval(z, chebPolys[loop_z]);841 }842 }843 }844 }845 }846 847 for (i=0;i<maxChebyPoly;i++) {848 psFree(chebPolys[i]);849 }850 psFree(chebPolys);851 return(polySum);852 }853 854 1311 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 855 1312 { … … 857 1314 858 1315 if (myPoly->type == PS_POLYNOMIAL_ORD) { 859 return( p_psOrdPolynomial4DEval(w,x,y,z, myPoly));1316 return(ordPolynomial4DEval(w,x,y,z, myPoly)); 860 1317 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 861 return( p_psChebPolynomial4DEval(w,x,y,z, myPoly));1318 return(chebPolynomial4DEval(w,x,y,z, myPoly)); 862 1319 } else { 863 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1320 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1321 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1322 myPoly->type); 864 1323 } 865 1324 return(0.0); … … 924 1383 return(tmp); 925 1384 } 926 927 928 929 1385 930 1386 … … 1092 1548 } 1093 1549 1094 static void dPolynomial1DFree(psDPolynomial1D* myPoly)1095 {1096 psFree(myPoly->coeff);1097 psFree(myPoly->coeffErr);1098 psFree(myPoly->mask);1099 }1100 1101 static void dPolynomial2DFree(psDPolynomial2D* myPoly)1102 {1103 psS32 x = 0;1104 1105 for (x = 0; x < myPoly->nX; x++) {1106 psFree(myPoly->coeff[x]);1107 psFree(myPoly->coeffErr[x]);1108 psFree(myPoly->mask[x]);1109 }1110 psFree(myPoly->coeff);1111 psFree(myPoly->coeffErr);1112 psFree(myPoly->mask);1113 }1114 1115 static void dPolynomial3DFree(psDPolynomial3D* myPoly)1116 {1117 psS32 x = 0;1118 psS32 y = 0;1119 1120 for (x = 0; x < myPoly->nX; x++) {1121 for (y = 0; y < myPoly->nY; y++) {1122 psFree(myPoly->coeff[x][y]);1123 psFree(myPoly->coeffErr[x][y]);1124 psFree(myPoly->mask[x][y]);1125 }1126 psFree(myPoly->coeff[x]);1127 psFree(myPoly->coeffErr[x]);1128 psFree(myPoly->mask[x]);1129 }1130 1131 psFree(myPoly->coeff);1132 psFree(myPoly->coeffErr);1133 psFree(myPoly->mask);1134 }1135 1136 static void dPolynomial4DFree(psDPolynomial4D* myPoly)1137 {1138 psS32 w = 0;1139 psS32 x = 0;1140 psS32 y = 0;1141 1142 for (w = 0; w < myPoly->nW; w++) {1143 for (x = 0; x < myPoly->nX; x++) {1144 for (y = 0; y < myPoly->nY; y++) {1145 psFree(myPoly->coeff[w][x][y]);1146 psFree(myPoly->coeffErr[w][x][y]);1147 psFree(myPoly->mask[w][x][y]);1148 }1149 psFree(myPoly->coeff[w][x]);1150 psFree(myPoly->coeffErr[w][x]);1151 psFree(myPoly->mask[w][x]);1152 }1153 psFree(myPoly->coeff[w]);1154 psFree(myPoly->coeffErr[w]);1155 psFree(myPoly->mask[w]);1156 }1157 1158 psFree(myPoly->coeff);1159 psFree(myPoly->coeffErr);1160 psFree(myPoly->mask);1161 }1162 1163 /*****************************************************************************1164 Polynomial coefficients will be accessed in [w][x][y][z] fashion.1165 *****************************************************************************/1166 double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1167 {1168 psS32 loop_x = 0;1169 double polySum = 0.0;1170 double xSum = 1.0;1171 1172 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {1173 if (myPoly->mask[loop_x] == 0) {1174 polySum += xSum * myPoly->coeff[loop_x];1175 xSum *= x;1176 }1177 }1178 1179 return(polySum);1180 }1181 1182 // XXX: You can do this without having to psAlloc() vector d.1183 // XXX: How does the mask vector effect Crenshaw's formula?1184 double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1185 {1186 psVector *d;1187 psS32 n;1188 psS32 i;1189 double tmp;1190 1191 n = myPoly->n;1192 d = psVectorAlloc(n, PS_TYPE_F64);1193 d->data.F64[n-1] = myPoly->coeff[n-1];1194 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];1195 for (i=n-3;i>=1;i--) {1196 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -1197 (d->data.F64[i+2]) +1198 (myPoly->coeff[i]);1199 }1200 1201 tmp = (x * d->data.F64[1]) -1202 (d->data.F64[2]) +1203 (0.5 * myPoly->coeff[0]);1204 1205 psFree(d);1206 return(tmp);1207 }1208 1550 1209 1551 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly) … … 1212 1554 1213 1555 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1214 return( p_psDOrdPolynomial1DEval(x, myPoly));1556 return(dOrdPolynomial1DEval(x, myPoly)); 1215 1557 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1216 return( p_psDChebPolynomial1DEval(x, myPoly));1558 return(dChebPolynomial1DEval(x, myPoly)); 1217 1559 } else { 1218 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1560 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1561 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1562 myPoly->type); 1219 1563 } 1220 1564 return(0.0); … … 1244 1588 1245 1589 1246 1247 double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1248 {1249 psS32 loop_x = 0;1250 psS32 loop_y = 0;1251 double polySum = 0.0;1252 double xSum = 1.0;1253 double ySum = 1.0;1254 1255 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1256 ySum = xSum;1257 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1258 if (myPoly->mask[loop_x][loop_y] == 0) {1259 polySum += ySum * myPoly->coeff[loop_x][loop_y];1260 ySum *= y;1261 }1262 }1263 xSum *= x;1264 }1265 1266 return(polySum);1267 }1268 1269 double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1270 {1271 psS32 loop_x = 0;1272 psS32 loop_y = 0;1273 psS32 i = 0;1274 double polySum = 0.0;1275 psPolynomial1D* *chebPolys = NULL;1276 psS32 maxChebyPoly = 0;1277 1278 // Determine how many Chebyshev polynomials1279 // are needed, then create them.1280 maxChebyPoly = myPoly->nX;1281 if (myPoly->nY > maxChebyPoly) {1282 maxChebyPoly = myPoly->nY;1283 }1284 chebPolys = CreateChebyshevPolys(maxChebyPoly);1285 1286 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1287 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1288 if (myPoly->mask[loop_x][loop_y] == 0) {1289 polySum += myPoly->coeff[loop_x][loop_y] *1290 psPolynomial1DEval(x, chebPolys[loop_x]) *1291 psPolynomial1DEval(y, chebPolys[loop_y]);1292 }1293 }1294 }1295 1296 for (i=0;i<maxChebyPoly;i++) {1297 psFree(chebPolys[i]);1298 }1299 psFree(chebPolys);1300 return(polySum);1301 }1302 1303 1590 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 1304 1591 { … … 1306 1593 1307 1594 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1308 return( p_psDOrdPolynomial2DEval(x, y, myPoly));1595 return(dOrdPolynomial2DEval(x, y, myPoly)); 1309 1596 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1310 return( p_psDChebPolynomial2DEval(x, y, myPoly));1597 return(dChebPolynomial2DEval(x, y, myPoly)); 1311 1598 } else { 1312 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1599 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1600 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1601 myPoly->type); 1313 1602 } 1314 1603 return(0.0); … … 1353 1642 1354 1643 1355 1356 double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1357 {1358 psS32 loop_x = 0;1359 psS32 loop_y = 0;1360 psS32 loop_z = 0;1361 double polySum = 0.0;1362 double xSum = 1.0;1363 double ySum = 1.0;1364 double zSum = 1.0;1365 1366 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1367 ySum = xSum;1368 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1369 zSum = ySum;1370 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1371 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1372 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];1373 zSum *= z;1374 }1375 }1376 ySum *= y;1377 }1378 xSum *= x;1379 }1380 1381 return(polySum);1382 }1383 1384 double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1385 {1386 psS32 loop_x = 0;1387 psS32 loop_y = 0;1388 psS32 loop_z = 0;1389 psS32 i = 0;1390 double polySum = 0.0;1391 psPolynomial1D* *chebPolys = NULL;1392 psS32 maxChebyPoly = 0;1393 1394 // Determine how many Chebyshev polynomials1395 // are needed, then create them.1396 maxChebyPoly = myPoly->nX;1397 if (myPoly->nY > maxChebyPoly) {1398 maxChebyPoly = myPoly->nY;1399 }1400 if (myPoly->nZ > maxChebyPoly) {1401 maxChebyPoly = myPoly->nZ;1402 }1403 chebPolys = CreateChebyshevPolys(maxChebyPoly);1404 1405 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1406 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1407 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1408 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1409 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *1410 psPolynomial1DEval(x, chebPolys[loop_x]) *1411 psPolynomial1DEval(y, chebPolys[loop_y]) *1412 psPolynomial1DEval(z, chebPolys[loop_z]);1413 }1414 }1415 }1416 }1417 1418 for (i=0;i<maxChebyPoly;i++) {1419 psFree(chebPolys[i]);1420 }1421 psFree(chebPolys);1422 return(polySum);1423 }1424 1425 1644 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 1426 1645 { … … 1428 1647 1429 1648 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1430 return( p_psDOrdPolynomial3DEval(x, y, z, myPoly));1649 return(dOrdPolynomial3DEval(x, y, z, myPoly)); 1431 1650 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1432 return( p_psDChebPolynomial3DEval(x, y, z, myPoly));1651 return(dChebPolynomial3DEval(x, y, z, myPoly)); 1433 1652 } else { 1434 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1653 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1654 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1655 myPoly->type); 1435 1656 } 1436 1657 return(0.0); … … 1485 1706 } 1486 1707 1487 1488 1489 1490 1491 1492 1493 1494 double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1495 {1496 psS32 loop_w = 0;1497 psS32 loop_x = 0;1498 psS32 loop_y = 0;1499 psS32 loop_z = 0;1500 double polySum = 0.0;1501 double wSum = 1.0;1502 double xSum = 1.0;1503 double ySum = 1.0;1504 double zSum = 1.0;1505 1506 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1507 xSum = wSum;1508 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1509 ySum = xSum;1510 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1511 zSum = ySum;1512 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1513 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1514 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];1515 zSum *= z;1516 }1517 }1518 ySum *= y;1519 }1520 xSum *= x;1521 }1522 wSum *= w;1523 }1524 1525 return(polySum);1526 }1527 1528 double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1529 {1530 psS32 loop_w = 0;1531 psS32 loop_x = 0;1532 psS32 loop_y = 0;1533 psS32 loop_z = 0;1534 psS32 i = 0;1535 double polySum = 0.0;1536 psPolynomial1D* *chebPolys = NULL;1537 psS32 maxChebyPoly = 0;1538 1539 // Determine how many Chebyshev polynomials1540 // are needed, then create them.1541 maxChebyPoly = myPoly->nW;1542 if (myPoly->nX > maxChebyPoly) {1543 maxChebyPoly = myPoly->nX;1544 }1545 if (myPoly->nY > maxChebyPoly) {1546 maxChebyPoly = myPoly->nY;1547 }1548 if (myPoly->nZ > maxChebyPoly) {1549 maxChebyPoly = myPoly->nZ;1550 }1551 chebPolys = CreateChebyshevPolys(maxChebyPoly);1552 1553 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1554 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1555 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1556 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1557 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1558 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *1559 psPolynomial1DEval(w, chebPolys[loop_w]) *1560 psPolynomial1DEval(x, chebPolys[loop_x]) *1561 psPolynomial1DEval(y, chebPolys[loop_y]) *1562 psPolynomial1DEval(z, chebPolys[loop_z]);1563 }1564 }1565 }1566 }1567 }1568 1569 for (i=0;i<maxChebyPoly;i++) {1570 psFree(chebPolys[i]);1571 }1572 psFree(chebPolys);1573 return(polySum);1574 }1575 1576 1708 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 1577 1709 { … … 1579 1711 1580 1712 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1581 return( p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));1713 return(dOrdPolynomial4DEval(w,x,y,z, myPoly)); 1582 1714 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1583 return( p_psDChebPolynomial4DEval(w,x,y,z, myPoly));1715 return(dChebPolynomial4DEval(w,x,y,z, myPoly)); 1584 1716 } else { 1585 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1717 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1718 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1719 myPoly->type); 1586 1720 } 1587 1721 return(0.0); … … 1699 1833 (tmp->domains)[numSplines] = max; 1700 1834 1835 p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree); 1701 1836 return(tmp); 1702 1837 } 1703 1838 1704 // XXX: Have Robert put the dealocator in the memory file.1705 psS32 p_psSpline1DFree(psSpline1D *tmpSpline)1706 {1707 psS32 i;1708 1709 if (tmpSpline == NULL) {1710 return(0);1711 }1712 1713 if (tmpSpline->spline != NULL) {1714 for (i=0;i<tmpSpline->n;i++) {1715 psFree((tmpSpline->spline)[i]);1716 }1717 psFree(tmpSpline->spline);1718 }1719 1720 if (tmpSpline->p_psDeriv2 != NULL) {1721 psFree(tmpSpline->p_psDeriv2);1722 }1723 psFree(tmpSpline->domains);1724 psFree(tmpSpline);1725 1726 return(0);1727 }1728 1839 1729 1840 /***************************************************************************** … … 1765 1876 1766 1877 /***************************************************************************** 1767 p_psVectorBinDisectF32(): This is a private function which takes as input a1878 vectorBinDisectF32(): This is a private function which takes as input a 1768 1879 vector of floating point data as well as a single floating point values. 1769 1880 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1776 1887 XXX: name since we don't take psVectors as input. 1777 1888 *****************************************************************************/ 1778 psS32 p_psVectorBinDisectF32(float *bins,1779 psS32 numBins,1780 float x)1889 static psS32 vectorBinDisectF32(float *bins, 1890 psS32 numBins, 1891 float x) 1781 1892 { 1782 1893 psS32 min; … … 1784 1895 psS32 mid; 1785 1896 1786 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1787 "---- Calling p_psVectorBinDisectF32(%f)\n", x);1897 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1898 "---- Calling vectorBinDisectF32(%f)\n", x); 1788 1899 1789 1900 if (x < bins[0]) { 1790 1901 psLogMsg(__func__, PS_LOG_WARN, 1791 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1902 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1792 1903 x, bins[0], bins[numBins-1]); 1793 1904 return(-2); … … 1796 1907 if (x > bins[numBins-1]) { 1797 1908 psLogMsg(__func__, PS_LOG_WARN, 1798 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1909 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1799 1910 x, bins[0], bins[numBins-1]); 1800 1911 return(-1); … … 1806 1917 1807 1918 while (min != max) { 1808 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1919 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1809 1920 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1810 1921 min, mid, max, x, bins[mid]); 1811 1922 1812 1923 if (x == bins[mid]) { 1813 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1814 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);1924 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1925 "---- Exiting vectorBinDisectF32(): bin %d\n", mid); 1815 1926 return(mid); 1816 1927 } else if (x < bins[mid]) { … … 1822 1933 } 1823 1934 1824 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1825 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);1935 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1936 "---- Exiting vectorBinDisectF32(): bin %d\n", min); 1826 1937 return(min); 1827 1938 } 1828 1939 1829 1940 /***************************************************************************** 1830 p_psVectorBinDisectS32(): integer version of above.1941 vectorBinDisectS32(): integer version of above. 1831 1942 *****************************************************************************/ 1832 psS32 p_psVectorBinDisectS32(psS32 *bins,1833 psS32 numBins,1834 psS32 x)1943 static psS32 vectorBinDisectS32(psS32 *bins, 1944 psS32 numBins, 1945 psS32 x) 1835 1946 { 1836 1947 psS32 min; … … 1838 1949 psS32 mid; 1839 1950 1840 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1841 "---- Calling p_psVectorBinDisectS32(%f)\n", x);1951 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1952 "---- Calling vectorBinDisectS32(%f)\n", x); 1842 1953 1843 1954 if ((x < bins[0]) || 1844 1955 (x > bins[numBins-1])) { 1845 1956 psLogMsg(__func__, PS_LOG_WARN, 1846 " p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1957 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1847 1958 x, bins[0], bins[numBins-1]); 1848 1959 return(-1); … … 1854 1965 1855 1966 while (min != max) { 1856 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1967 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1857 1968 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1858 1969 min, mid, max, x, bins[mid]); 1859 1970 1860 1971 if (x == bins[mid]) { 1861 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1862 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1972 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1973 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1863 1974 return(min); 1864 1975 } else if (x < bins[mid]) { … … 1870 1981 } 1871 1982 1872 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1873 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1983 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1984 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1874 1985 return(min); 1875 1986 } … … 1884 1995 1885 1996 if (x->type.type == PS_TYPE_S32) { 1886 return( p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1997 return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1887 1998 } else if (x->type.type == PS_TYPE_F32) { 1888 return( p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1999 return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1889 2000 } else { 1890 psError(__func__, "Unallowable data type."); 2001 char* strType; 2002 PS_TYPE_NAME(strType,x->type.type); 2003 psError(PS_ERR_BAD_PARAMETER_TYPE, 2004 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2005 strType); 1891 2006 return(-2); 1892 2007 } 1893 2008 return(-1); 1894 }1895 1896 /*****************************************************************************1897 p_psInterpolate1D(): This routine will take as input n-element floating1898 point arrays domain and range, and the x value, assumed to lie with the1899 domain vector. It produces as output the (n-1)-order LaGrange interpolated1900 value of x.1901 1902 XXX: do we error check for non-distinct domain values?1903 *****************************************************************************/1904 float p_ps1DFullInterpolateF32(float *domain,1905 float *range,1906 psS32 n,1907 float x)1908 {1909 PS_INT_CHECK_NON_NEGATIVE(n, NAN);1910 PS_PTR_CHECK_NULL(domain, NAN);1911 PS_PTR_CHECK_NULL(range, NAN);1912 1913 psS32 i;1914 psS32 m;1915 static psVector *p = NULL;1916 p = psVectorRecycle(p, n, PS_TYPE_F32);1917 p_psMemSetPersistent(p, true);1918 p_psMemSetPersistent(p->data.F32, true);1919 /*1920 psVector *p = psVectorAlloc(n, PS_TYPE_F32);1921 float tmp;1922 */1923 1924 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1925 "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);1926 1927 for (i=0;i<n;i++) {1928 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1929 "domain/range is (%f %f)\n", domain[i], range[i]);1930 }1931 1932 for (i=0;i<n;i++) {1933 p->data.F32[i] = range[i];1934 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1935 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1936 1937 }1938 1939 // From NR, during each iteration of the m loop, we are computing the1940 // p_{i ... i+m} terms.1941 for (m=1;m<n;m++) {1942 for (i=0;i<n-m;i++) {1943 // From NR: we are computing P_{i ... i+m}1944 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +1945 ((domain[i]-x) * p->data.F32[i+1])) /1946 (domain[i] - domain[i+m]);1947 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);1948 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1949 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1950 }1951 }1952 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1953 "---- p_ps1DFullInterpolateF32() end ----\n");1954 1955 /*1956 tmp = p->data.F32[0];1957 psFree(p);1958 return(tmp);1959 */1960 return(p->data.F32[0]);1961 }1962 1963 1964 /*****************************************************************************1965 p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform1966 LaGrange interpolation.1967 *****************************************************************************/1968 float p_ps1DInterpolateF32(float *domain,1969 float *range,1970 psS32 n,1971 psS32 order,1972 float x)1973 {1974 psS32 binNum;1975 psS32 numIntPoints = order+1;1976 psS32 origin;1977 1978 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,1979 "---- p_ps1DInterpolateF32() begin ----\n");1980 1981 binNum = p_psVectorBinDisectF32(domain, n, x);1982 1983 if (0 == numIntPoints%2) {1984 origin = binNum - ((numIntPoints/2) - 1);1985 } else {1986 origin = binNum - (numIntPoints/2);1987 if ((x-domain[binNum]) > (domain[binNum+1]-x)) {1988 // x is closer to binNum+1.1989 origin = 1 + (binNum - (numIntPoints/2));1990 }1991 }1992 if (origin < 0) {1993 origin = 0;1994 }1995 if ((origin + numIntPoints) > n) {1996 origin = n - numIntPoints;1997 }1998 1999 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,2000 "---- p_ps1DInterpolateF32() end ----\n");2001 return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));2002 2009 } 2003 2010 … … 2035 2042 2036 2043 if (order > (domain->n - 1)) { 2037 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2044 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 2045 PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS, 2046 order); 2038 2047 return(NULL); 2039 2048 } … … 2042 2051 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2043 2052 "---- p_psVectorInterpolate() end ----\n"); 2044 return(psScalarAlloc( p_ps1DInterpolateF32(domain->data.F32,2045 range->data.F32,2046 domain->n,2047 order,2048 x->data.F32), PS_TYPE_F32));2053 return(psScalarAlloc(interpolate1DF32(domain->data.F32, 2054 range->data.F32, 2055 domain->n, 2056 order, 2057 x->data.F32), PS_TYPE_F32)); 2049 2058 } else if (x->type.type == PS_TYPE_F64) { 2050 2059 // XXX: use recycled vectors here. … … 2053 2062 2054 2063 psScalar *tmpScalar = psScalarAlloc((double) 2055 p_ps1DInterpolateF32(domain32->data.F32,2056 range32->data.F32,2057 domain32->n,2058 order,2059 (float) x->data.F64), PS_TYPE_F64);2064 interpolate1DF32(domain32->data.F32, 2065 range32->data.F32, 2066 domain32->n, 2067 order, 2068 (float) x->data.F64), PS_TYPE_F64); 2060 2069 psFree(range32); 2061 2070 psFree(domain32); … … 2067 2076 2068 2077 } else { 2069 // XXX psError: type not supported 2070 psError(__func__, "type %d not supported\n", x->type.type); 2078 char* strType; 2079 PS_TYPE_NAME(strType,x->type.type); 2080 psError(PS_ERR_BAD_PARAMETER_TYPE, 2081 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2082 strType); 2071 2083 } 2072 2084 … … 2084 2096 and an independent x value. Each determines which spline that x corresponds 2085 2097 to by doing a bracket disection on the domains of the spline data structure 2086 ( p_psVectorBinDisectF32()). Then it evaluates the spline at that x location2098 (vectorBinDisectF32()). Then it evaluates the spline at that x location 2087 2099 by a call to the 1D polynomial functions. 2088 2100 … … 2100 2112 2101 2113 n = spline->n; 2102 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);2114 binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x); 2103 2115 if (binNum < 0) { 2104 2116 psLogMsg(__func__, PS_LOG_WARN, … … 2139 2151 } 2140 2152 } else { 2141 psError(__func__, "Unknown data type.\n"); 2153 char* strType; 2154 PS_TYPE_NAME(strType,x->type.type); 2155 psError(PS_ERR_BAD_PARAMETER_TYPE, 2156 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2157 strType); 2142 2158 return(NULL); 2143 2159 } -
trunk/psLib/src/math/psPolynomial.h
r2269 r2273 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-11-0 3 03:30:30$14 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:59 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 398 398 float max); 399 399 400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);401 402 400 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, 403 401 psS32 order); -
trunk/psLib/src/math/psSpline.c
r2224 r2273 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-28 00:22:53$9 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:04:59 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psFunctions.h" 36 36 #include "psConstants.h" 37 38 #include "psDataManipErrors.h" 39 37 40 /*****************************************************************************/ 38 41 /* DEFINE STATEMENTS */ … … 50 53 static void dPolynomial3DFree(psDPolynomial3D* myPoly); 51 54 static void dPolynomial4DFree(psDPolynomial4D* myPoly); 55 static void spline1DFree(psSpline1D *tmpSpline); 56 static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x); 57 static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x); 52 58 53 59 /*****************************************************************************/ … … 67 73 /*****************************************************************************/ 68 74 75 static void spline1DFree(psSpline1D *tmpSpline) 76 { 77 psS32 i; 78 79 if (tmpSpline == NULL) { 80 return; 81 } 82 83 if (tmpSpline->spline != NULL) { 84 for (i=0;i<tmpSpline->n;i++) { 85 psFree((tmpSpline->spline)[i]); 86 } 87 psFree(tmpSpline->spline); 88 } 89 90 if (tmpSpline->p_psDeriv2 != NULL) { 91 psFree(tmpSpline->p_psDeriv2); 92 } 93 psFree(tmpSpline->domains); 94 95 return; 96 } 97 98 static void polynomial1DFree(psPolynomial1D* myPoly) 99 { 100 psFree(myPoly->coeff); 101 psFree(myPoly->coeffErr); 102 psFree(myPoly->mask); 103 } 104 105 static void polynomial2DFree(psPolynomial2D* myPoly) 106 { 107 psS32 x = 0; 108 109 for (x = 0; x < myPoly->nX; x++) { 110 psFree(myPoly->coeff[x]); 111 psFree(myPoly->coeffErr[x]); 112 psFree(myPoly->mask[x]); 113 } 114 psFree(myPoly->coeff); 115 psFree(myPoly->coeffErr); 116 psFree(myPoly->mask); 117 } 118 119 static void polynomial3DFree(psPolynomial3D* myPoly) 120 { 121 psS32 x = 0; 122 psS32 y = 0; 123 124 for (x = 0; x < myPoly->nX; x++) { 125 for (y = 0; y < myPoly->nY; y++) { 126 psFree(myPoly->coeff[x][y]); 127 psFree(myPoly->coeffErr[x][y]); 128 psFree(myPoly->mask[x][y]); 129 } 130 psFree(myPoly->coeff[x]); 131 psFree(myPoly->coeffErr[x]); 132 psFree(myPoly->mask[x]); 133 } 134 135 psFree(myPoly->coeff); 136 psFree(myPoly->coeffErr); 137 psFree(myPoly->mask); 138 } 139 140 static void polynomial4DFree(psPolynomial4D* myPoly) 141 { 142 psS32 w = 0; 143 psS32 x = 0; 144 psS32 y = 0; 145 146 for (w = 0; w < myPoly->nW; w++) { 147 for (x = 0; x < myPoly->nX; x++) { 148 for (y = 0; y < myPoly->nY; y++) { 149 psFree(myPoly->coeff[w][x][y]); 150 psFree(myPoly->coeffErr[w][x][y]); 151 psFree(myPoly->mask[w][x][y]); 152 } 153 psFree(myPoly->coeff[w][x]); 154 psFree(myPoly->coeffErr[w][x]); 155 psFree(myPoly->mask[w][x]); 156 } 157 psFree(myPoly->coeff[w]); 158 psFree(myPoly->coeffErr[w]); 159 psFree(myPoly->mask[w]); 160 } 161 162 psFree(myPoly->coeff); 163 psFree(myPoly->coeffErr); 164 psFree(myPoly->mask); 165 } 166 167 static void dPolynomial1DFree(psDPolynomial1D* myPoly) 168 { 169 psFree(myPoly->coeff); 170 psFree(myPoly->coeffErr); 171 psFree(myPoly->mask); 172 } 173 174 static void dPolynomial2DFree(psDPolynomial2D* myPoly) 175 { 176 psS32 x = 0; 177 178 for (x = 0; x < myPoly->nX; x++) { 179 psFree(myPoly->coeff[x]); 180 psFree(myPoly->coeffErr[x]); 181 psFree(myPoly->mask[x]); 182 } 183 psFree(myPoly->coeff); 184 psFree(myPoly->coeffErr); 185 psFree(myPoly->mask); 186 } 187 188 static void dPolynomial3DFree(psDPolynomial3D* myPoly) 189 { 190 psS32 x = 0; 191 psS32 y = 0; 192 193 for (x = 0; x < myPoly->nX; x++) { 194 for (y = 0; y < myPoly->nY; y++) { 195 psFree(myPoly->coeff[x][y]); 196 psFree(myPoly->coeffErr[x][y]); 197 psFree(myPoly->mask[x][y]); 198 } 199 psFree(myPoly->coeff[x]); 200 psFree(myPoly->coeffErr[x]); 201 psFree(myPoly->mask[x]); 202 } 203 204 psFree(myPoly->coeff); 205 psFree(myPoly->coeffErr); 206 psFree(myPoly->mask); 207 } 208 209 static void dPolynomial4DFree(psDPolynomial4D* myPoly) 210 { 211 psS32 w = 0; 212 psS32 x = 0; 213 psS32 y = 0; 214 215 for (w = 0; w < myPoly->nW; w++) { 216 for (x = 0; x < myPoly->nX; x++) { 217 for (y = 0; y < myPoly->nY; y++) { 218 psFree(myPoly->coeff[w][x][y]); 219 psFree(myPoly->coeffErr[w][x][y]); 220 psFree(myPoly->mask[w][x][y]); 221 } 222 psFree(myPoly->coeff[w][x]); 223 psFree(myPoly->coeffErr[w][x]); 224 psFree(myPoly->mask[w][x]); 225 } 226 psFree(myPoly->coeff[w]); 227 psFree(myPoly->coeffErr[w]); 228 psFree(myPoly->mask[w]); 229 } 230 231 psFree(myPoly->coeff); 232 psFree(myPoly->coeffErr); 233 psFree(myPoly->mask); 234 } 235 69 236 /***************************************************************************** 70 CreateChebyshevPolys(n): this routine takes as input the required order n,237 createChebyshevPolys(n): this routine takes as input the required order n, 71 238 and returns as output as a pointer to an array of n psPolynomial1D 72 239 structures, corresponding to the first n Chebyshev polynomials. … … 76 243 outer coefficients of the Chebyshev polynomials. 77 244 *****************************************************************************/ 78 static psPolynomial1D ** CreateChebyshevPolys(psS32 maxChebyPoly)245 static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly) 79 246 { 80 247 PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL); … … 103 270 104 271 return (chebPolys); 272 } 273 274 /***************************************************************************** 275 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 276 277 XXX: Should the "coeffErr[]" should be used as well? 278 *****************************************************************************/ 279 static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly) 280 { 281 psS32 loop_x = 0; 282 float polySum = 0.0; 283 float xSum = 1.0; 284 285 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 286 "---- Calling ordPolynomial1DEval(%f)\n", x); 287 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 288 "Polynomial order is %d\n", myPoly->n); 289 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 290 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4, 291 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]); 292 } 293 294 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 295 if (myPoly->mask[loop_x] == 0) { 296 psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10, 297 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 298 polySum += xSum * myPoly->coeff[loop_x]; 299 xSum *= x; 300 } 301 } 302 303 return(polySum); 304 } 305 306 // XXX: You can do this without having to psAlloc() vector d. 307 // XXX: How does the mask vector effect Crenshaw's formula? 308 static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly) 309 { 310 psVector *d; 311 psS32 n; 312 psS32 i; 313 float tmp; 314 315 n = myPoly->n; 316 d = psVectorAlloc(n, PS_TYPE_F32); 317 d->data.F32[n-1] = myPoly->coeff[n-1]; 318 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2]; 319 for (i=n-3;i>=1;i--) { 320 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) - 321 (d->data.F32[i+2]) + 322 (myPoly->coeff[i]); 323 } 324 325 tmp = (x * d->data.F32[1]) - 326 (d->data.F32[2]) + 327 (0.5 * myPoly->coeff[0]); 328 329 psFree(d); 330 return(tmp); 331 /* 332 333 psS32 n; 334 psS32 i; 335 float tmp; 336 psPolynomial1D **chebPolys = NULL; 337 338 n = myPoly->n; 339 chebPolys = createChebyshevPolys(n); 340 341 tmp = 0.0; 342 for (i=0;i<myPoly->n;i++) { 343 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i])); 344 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i])); 345 } 346 tmp-= (myPoly->coeff[0]/2.0); 347 348 349 return(tmp); 350 */ 351 } 352 353 static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 354 { 355 PS_POLY_CHECK_NULL(myPoly, NAN); 356 357 psS32 loop_x = 0; 358 psS32 loop_y = 0; 359 float polySum = 0.0; 360 float xSum = 1.0; 361 float ySum = 1.0; 362 363 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 364 ySum = xSum; 365 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 366 if (myPoly->mask[loop_x][loop_y] == 0) { 367 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 368 ySum *= y; 369 } 370 } 371 xSum *= x; 372 } 373 374 return(polySum); 375 } 376 377 static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 378 { 379 PS_POLY_CHECK_NULL(myPoly, NAN); 380 381 psS32 loop_x = 0; 382 psS32 loop_y = 0; 383 psS32 i = 0; 384 float polySum = 0.0; 385 psPolynomial1D* *chebPolys = NULL; 386 psS32 maxChebyPoly = 0; 387 388 // Determine how many Chebyshev polynomials 389 // are needed, then create them. 390 maxChebyPoly = myPoly->nX; 391 if (myPoly->nY > maxChebyPoly) { 392 maxChebyPoly = myPoly->nY; 393 } 394 chebPolys = createChebyshevPolys(maxChebyPoly); 395 396 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 397 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 398 if (myPoly->mask[loop_x][loop_y] == 0) { 399 polySum += myPoly->coeff[loop_x][loop_y] * 400 psPolynomial1DEval(x, chebPolys[loop_x]) * 401 psPolynomial1DEval(y, chebPolys[loop_y]); 402 } 403 } 404 } 405 for (i=0;i<maxChebyPoly;i++) { 406 psFree(chebPolys[i]); 407 } 408 psFree(chebPolys); 409 return(polySum); 410 } 411 412 static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 413 { 414 psS32 loop_x = 0; 415 psS32 loop_y = 0; 416 psS32 loop_z = 0; 417 float polySum = 0.0; 418 float xSum = 1.0; 419 float ySum = 1.0; 420 float zSum = 1.0; 421 422 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 423 ySum = xSum; 424 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 425 zSum = ySum; 426 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 427 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 428 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 429 zSum *= z; 430 } 431 } 432 ySum *= y; 433 } 434 xSum *= x; 435 } 436 437 return(polySum); 438 } 439 440 static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 441 { 442 psS32 loop_x = 0; 443 psS32 loop_y = 0; 444 psS32 loop_z = 0; 445 psS32 i = 0; 446 float polySum = 0.0; 447 psPolynomial1D* *chebPolys = NULL; 448 psS32 maxChebyPoly = 0; 449 450 // Determine how many Chebyshev polynomials 451 // are needed, then create them. 452 maxChebyPoly = myPoly->nX; 453 if (myPoly->nY > maxChebyPoly) { 454 maxChebyPoly = myPoly->nY; 455 } 456 if (myPoly->nZ > maxChebyPoly) { 457 maxChebyPoly = myPoly->nZ; 458 } 459 chebPolys = createChebyshevPolys(maxChebyPoly); 460 461 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 462 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 463 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 464 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 465 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 466 psPolynomial1DEval(x, chebPolys[loop_x]) * 467 psPolynomial1DEval(y, chebPolys[loop_y]) * 468 psPolynomial1DEval(z, chebPolys[loop_z]); 469 } 470 } 471 } 472 } 473 474 for (i=0;i<maxChebyPoly;i++) { 475 psFree(chebPolys[i]); 476 } 477 psFree(chebPolys); 478 return(polySum); 479 } 480 481 static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 482 { 483 psS32 loop_w = 0; 484 psS32 loop_x = 0; 485 psS32 loop_y = 0; 486 psS32 loop_z = 0; 487 float polySum = 0.0; 488 float wSum = 1.0; 489 float xSum = 1.0; 490 float ySum = 1.0; 491 float zSum = 1.0; 492 493 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 494 xSum = wSum; 495 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 496 ySum = xSum; 497 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 498 zSum = ySum; 499 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 500 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 501 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 502 zSum *= z; 503 } 504 } 505 ySum *= y; 506 } 507 xSum *= x; 508 } 509 wSum *= w; 510 } 511 512 return(polySum); 513 } 514 515 static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 516 { 517 psS32 loop_w = 0; 518 psS32 loop_x = 0; 519 psS32 loop_y = 0; 520 psS32 loop_z = 0; 521 psS32 i = 0; 522 float polySum = 0.0; 523 psPolynomial1D* *chebPolys = NULL; 524 psS32 maxChebyPoly = 0; 525 526 // Determine how many Chebyshev polynomials 527 // are needed, then create them. 528 maxChebyPoly = myPoly->nW; 529 if (myPoly->nX > maxChebyPoly) { 530 maxChebyPoly = myPoly->nX; 531 } 532 if (myPoly->nY > maxChebyPoly) { 533 maxChebyPoly = myPoly->nY; 534 } 535 if (myPoly->nZ > maxChebyPoly) { 536 maxChebyPoly = myPoly->nZ; 537 } 538 chebPolys = createChebyshevPolys(maxChebyPoly); 539 540 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 541 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 542 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 543 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 544 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 545 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 546 psPolynomial1DEval(w, chebPolys[loop_w]) * 547 psPolynomial1DEval(x, chebPolys[loop_x]) * 548 psPolynomial1DEval(y, chebPolys[loop_y]) * 549 psPolynomial1DEval(z, chebPolys[loop_z]); 550 } 551 } 552 } 553 } 554 } 555 556 for (i=0;i<maxChebyPoly;i++) { 557 psFree(chebPolys[i]); 558 } 559 psFree(chebPolys); 560 return(polySum); 561 } 562 563 /***************************************************************************** 564 Polynomial coefficients will be accessed in [w][x][y][z] fashion. 565 *****************************************************************************/ 566 static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 567 { 568 psS32 loop_x = 0; 569 double polySum = 0.0; 570 double xSum = 1.0; 571 572 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 573 if (myPoly->mask[loop_x] == 0) { 574 polySum += xSum * myPoly->coeff[loop_x]; 575 xSum *= x; 576 } 577 } 578 579 return(polySum); 580 } 581 582 // XXX: You can do this without having to psAlloc() vector d. 583 // XXX: How does the mask vector effect Crenshaw's formula? 584 static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 585 { 586 psVector *d; 587 psS32 n; 588 psS32 i; 589 double tmp; 590 591 n = myPoly->n; 592 d = psVectorAlloc(n, PS_TYPE_F64); 593 d->data.F64[n-1] = myPoly->coeff[n-1]; 594 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2]; 595 for (i=n-3;i>=1;i--) { 596 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) - 597 (d->data.F64[i+2]) + 598 (myPoly->coeff[i]); 599 } 600 601 tmp = (x * d->data.F64[1]) - 602 (d->data.F64[2]) + 603 (0.5 * myPoly->coeff[0]); 604 605 psFree(d); 606 return(tmp); 607 } 608 609 static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 610 { 611 psS32 loop_x = 0; 612 psS32 loop_y = 0; 613 double polySum = 0.0; 614 double xSum = 1.0; 615 double ySum = 1.0; 616 617 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 618 ySum = xSum; 619 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 620 if (myPoly->mask[loop_x][loop_y] == 0) { 621 polySum += ySum * myPoly->coeff[loop_x][loop_y]; 622 ySum *= y; 623 } 624 } 625 xSum *= x; 626 } 627 628 return(polySum); 629 } 630 631 static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 632 { 633 psS32 loop_x = 0; 634 psS32 loop_y = 0; 635 psS32 i = 0; 636 double polySum = 0.0; 637 psPolynomial1D* *chebPolys = NULL; 638 psS32 maxChebyPoly = 0; 639 640 // Determine how many Chebyshev polynomials 641 // are needed, then create them. 642 maxChebyPoly = myPoly->nX; 643 if (myPoly->nY > maxChebyPoly) { 644 maxChebyPoly = myPoly->nY; 645 } 646 chebPolys = createChebyshevPolys(maxChebyPoly); 647 648 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 649 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 650 if (myPoly->mask[loop_x][loop_y] == 0) { 651 polySum += myPoly->coeff[loop_x][loop_y] * 652 psPolynomial1DEval(x, chebPolys[loop_x]) * 653 psPolynomial1DEval(y, chebPolys[loop_y]); 654 } 655 } 656 } 657 658 for (i=0;i<maxChebyPoly;i++) { 659 psFree(chebPolys[i]); 660 } 661 psFree(chebPolys); 662 return(polySum); 663 } 664 665 static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 666 { 667 psS32 loop_x = 0; 668 psS32 loop_y = 0; 669 psS32 loop_z = 0; 670 double polySum = 0.0; 671 double xSum = 1.0; 672 double ySum = 1.0; 673 double zSum = 1.0; 674 675 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 676 ySum = xSum; 677 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 678 zSum = ySum; 679 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 680 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 681 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z]; 682 zSum *= z; 683 } 684 } 685 ySum *= y; 686 } 687 xSum *= x; 688 } 689 690 return(polySum); 691 } 692 693 static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 694 { 695 psS32 loop_x = 0; 696 psS32 loop_y = 0; 697 psS32 loop_z = 0; 698 psS32 i = 0; 699 double polySum = 0.0; 700 psPolynomial1D* *chebPolys = NULL; 701 psS32 maxChebyPoly = 0; 702 703 // Determine how many Chebyshev polynomials 704 // are needed, then create them. 705 maxChebyPoly = myPoly->nX; 706 if (myPoly->nY > maxChebyPoly) { 707 maxChebyPoly = myPoly->nY; 708 } 709 if (myPoly->nZ > maxChebyPoly) { 710 maxChebyPoly = myPoly->nZ; 711 } 712 chebPolys = createChebyshevPolys(maxChebyPoly); 713 714 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 715 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 716 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 717 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) { 718 polySum += myPoly->coeff[loop_x][loop_y][loop_z] * 719 psPolynomial1DEval(x, chebPolys[loop_x]) * 720 psPolynomial1DEval(y, chebPolys[loop_y]) * 721 psPolynomial1DEval(z, chebPolys[loop_z]); 722 } 723 } 724 } 725 } 726 727 for (i=0;i<maxChebyPoly;i++) { 728 psFree(chebPolys[i]); 729 } 730 psFree(chebPolys); 731 return(polySum); 732 } 733 734 static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 735 { 736 psS32 loop_w = 0; 737 psS32 loop_x = 0; 738 psS32 loop_y = 0; 739 psS32 loop_z = 0; 740 double polySum = 0.0; 741 double wSum = 1.0; 742 double xSum = 1.0; 743 double ySum = 1.0; 744 double zSum = 1.0; 745 746 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 747 xSum = wSum; 748 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 749 ySum = xSum; 750 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 751 zSum = ySum; 752 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 753 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 754 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z]; 755 zSum *= z; 756 } 757 } 758 ySum *= y; 759 } 760 xSum *= x; 761 } 762 wSum *= w; 763 } 764 765 return(polySum); 766 } 767 768 static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 769 { 770 psS32 loop_w = 0; 771 psS32 loop_x = 0; 772 psS32 loop_y = 0; 773 psS32 loop_z = 0; 774 psS32 i = 0; 775 double polySum = 0.0; 776 psPolynomial1D* *chebPolys = NULL; 777 psS32 maxChebyPoly = 0; 778 779 // Determine how many Chebyshev polynomials 780 // are needed, then create them. 781 maxChebyPoly = myPoly->nW; 782 if (myPoly->nX > maxChebyPoly) { 783 maxChebyPoly = myPoly->nX; 784 } 785 if (myPoly->nY > maxChebyPoly) { 786 maxChebyPoly = myPoly->nY; 787 } 788 if (myPoly->nZ > maxChebyPoly) { 789 maxChebyPoly = myPoly->nZ; 790 } 791 chebPolys = createChebyshevPolys(maxChebyPoly); 792 793 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) { 794 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) { 795 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) { 796 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) { 797 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) { 798 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] * 799 psPolynomial1DEval(w, chebPolys[loop_w]) * 800 psPolynomial1DEval(x, chebPolys[loop_x]) * 801 psPolynomial1DEval(y, chebPolys[loop_y]) * 802 psPolynomial1DEval(z, chebPolys[loop_z]); 803 } 804 } 805 } 806 } 807 } 808 809 for (i=0;i<maxChebyPoly;i++) { 810 psFree(chebPolys[i]); 811 } 812 psFree(chebPolys); 813 return(polySum); 814 } 815 816 817 /***************************************************************************** 818 p_psInterpolate1D(): This routine will take as input n-element floating 819 point arrays domain and range, and the x value, assumed to lie with the 820 domain vector. It produces as output the (n-1)-order LaGrange interpolated 821 value of x. 822 823 XXX: do we error check for non-distinct domain values? 824 *****************************************************************************/ 825 static float fullInterpolate1DF32(float *domain, 826 float *range, 827 psS32 n, 828 float x) 829 { 830 PS_INT_CHECK_NON_NEGATIVE(n, NAN); 831 PS_PTR_CHECK_NULL(domain, NAN); 832 PS_PTR_CHECK_NULL(range, NAN); 833 834 psS32 i; 835 psS32 m; 836 static psVector *p = NULL; 837 p = psVectorRecycle(p, n, PS_TYPE_F32); 838 p_psMemSetPersistent(p, true); 839 p_psMemSetPersistent(p->data.F32, true); 840 /* 841 psVector *p = psVectorAlloc(n, PS_TYPE_F32); 842 float tmp; 843 */ 844 845 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 846 "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n); 847 848 for (i=0;i<n;i++) { 849 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 850 "domain/range is (%f %f)\n", domain[i], range[i]); 851 } 852 853 for (i=0;i<n;i++) { 854 p->data.F32[i] = range[i]; 855 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 856 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 857 858 } 859 860 // From NR, during each iteration of the m loop, we are computing the 861 // p_{i ... i+m} terms. 862 for (m=1;m<n;m++) { 863 for (i=0;i<n-m;i++) { 864 // From NR: we are computing P_{i ... i+m} 865 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) + 866 ((domain[i]-x) * p->data.F32[i+1])) / 867 (domain[i] - domain[i+m]); 868 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]); 869 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6, 870 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 871 } 872 } 873 psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4, 874 "---- fullInterpolate1DF32() end ----\n"); 875 876 /* 877 tmp = p->data.F32[0]; 878 psFree(p); 879 return(tmp); 880 */ 881 return(p->data.F32[0]); 882 } 883 884 885 /***************************************************************************** 886 interpolate1DF32(): this is the base 1-D flat memory routine to perform 887 LaGrange interpolation. 888 *****************************************************************************/ 889 static float interpolate1DF32(float *domain, 890 float *range, 891 psS32 n, 892 psS32 order, 893 float x) 894 { 895 psS32 binNum; 896 psS32 numIntPoints = order+1; 897 psS32 origin; 898 899 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 900 "---- interpolate1DF32() begin ----\n"); 901 902 binNum = vectorBinDisectF32(domain, n, x); 903 904 if (0 == numIntPoints%2) { 905 origin = binNum - ((numIntPoints/2) - 1); 906 } else { 907 origin = binNum - (numIntPoints/2); 908 if ((x-domain[binNum]) > (domain[binNum+1]-x)) { 909 // x is closer to binNum+1. 910 origin = 1 + (binNum - (numIntPoints/2)); 911 } 912 } 913 if (origin < 0) { 914 origin = 0; 915 } 916 if ((origin + numIntPoints) > n) { 917 origin = n - numIntPoints; 918 } 919 920 psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4, 921 "---- interpolate1DF32() end ----\n"); 922 return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x)); 105 923 } 106 924 … … 336 1154 } 337 1155 338 static void polynomial1DFree(psPolynomial1D* myPoly)339 {340 psFree(myPoly->coeff);341 psFree(myPoly->coeffErr);342 psFree(myPoly->mask);343 }344 345 static void polynomial2DFree(psPolynomial2D* myPoly)346 {347 psS32 x = 0;348 349 for (x = 0; x < myPoly->nX; x++) {350 psFree(myPoly->coeff[x]);351 psFree(myPoly->coeffErr[x]);352 psFree(myPoly->mask[x]);353 }354 psFree(myPoly->coeff);355 psFree(myPoly->coeffErr);356 psFree(myPoly->mask);357 }358 359 static void polynomial3DFree(psPolynomial3D* myPoly)360 {361 psS32 x = 0;362 psS32 y = 0;363 364 for (x = 0; x < myPoly->nX; x++) {365 for (y = 0; y < myPoly->nY; y++) {366 psFree(myPoly->coeff[x][y]);367 psFree(myPoly->coeffErr[x][y]);368 psFree(myPoly->mask[x][y]);369 }370 psFree(myPoly->coeff[x]);371 psFree(myPoly->coeffErr[x]);372 psFree(myPoly->mask[x]);373 }374 375 psFree(myPoly->coeff);376 psFree(myPoly->coeffErr);377 psFree(myPoly->mask);378 }379 380 static void polynomial4DFree(psPolynomial4D* myPoly)381 {382 psS32 w = 0;383 psS32 x = 0;384 psS32 y = 0;385 386 for (w = 0; w < myPoly->nW; w++) {387 for (x = 0; x < myPoly->nX; x++) {388 for (y = 0; y < myPoly->nY; y++) {389 psFree(myPoly->coeff[w][x][y]);390 psFree(myPoly->coeffErr[w][x][y]);391 psFree(myPoly->mask[w][x][y]);392 }393 psFree(myPoly->coeff[w][x]);394 psFree(myPoly->coeffErr[w][x]);395 psFree(myPoly->mask[w][x]);396 }397 psFree(myPoly->coeff[w]);398 psFree(myPoly->coeffErr[w]);399 psFree(myPoly->mask[w]);400 }401 402 psFree(myPoly->coeff);403 psFree(myPoly->coeffErr);404 psFree(myPoly->mask);405 }406 407 /*****************************************************************************408 Polynomial coefficients will be accessed in [w][x][y][z] fashion.409 410 XXX: Should the "coeffErr[]" should be used as well?411 *****************************************************************************/412 float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)413 {414 psS32 loop_x = 0;415 float polySum = 0.0;416 float xSum = 1.0;417 418 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,419 "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);420 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,421 "Polynomial order is %d\n", myPoly->n);422 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {423 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,424 "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);425 }426 427 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {428 if (myPoly->mask[loop_x] == 0) {429 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,430 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);431 polySum += xSum * myPoly->coeff[loop_x];432 xSum *= x;433 }434 }435 436 return(polySum);437 }438 439 // XXX: You can do this without having to psAlloc() vector d.440 // XXX: How does the mask vector effect Crenshaw's formula?441 float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)442 {443 psVector *d;444 psS32 n;445 psS32 i;446 float tmp;447 448 n = myPoly->n;449 d = psVectorAlloc(n, PS_TYPE_F32);450 d->data.F32[n-1] = myPoly->coeff[n-1];451 d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];452 for (i=n-3;i>=1;i--) {453 d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -454 (d->data.F32[i+2]) +455 (myPoly->coeff[i]);456 }457 458 tmp = (x * d->data.F32[1]) -459 (d->data.F32[2]) +460 (0.5 * myPoly->coeff[0]);461 462 psFree(d);463 return(tmp);464 /*465 466 psS32 n;467 psS32 i;468 float tmp;469 psPolynomial1D **chebPolys = NULL;470 471 n = myPoly->n;472 chebPolys = CreateChebyshevPolys(n);473 474 tmp = 0.0;475 for (i=0;i<myPoly->n;i++) {476 tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));477 // printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));478 }479 tmp-= (myPoly->coeff[0]/2.0);480 481 482 return(tmp);483 */484 }485 486 1156 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly) 487 1157 { … … 489 1159 490 1160 if (myPoly->type == PS_POLYNOMIAL_ORD) { 491 return( p_psOrdPolynomial1DEval(x, myPoly));1161 return(ordPolynomial1DEval(x, myPoly)); 492 1162 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 493 return( p_psChebPolynomial1DEval(x, myPoly));1163 return(chebPolynomial1DEval(x, myPoly)); 494 1164 } else { 495 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1165 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1166 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1167 myPoly->type); 496 1168 } 497 1169 return(0.0); … … 520 1192 } 521 1193 522 523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 1194 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 524 1195 { 525 1196 PS_POLY_CHECK_NULL(myPoly, NAN); 526 1197 527 psS32 loop_x = 0;528 psS32 loop_y = 0;529 float polySum = 0.0;530 float xSum = 1.0;531 float ySum = 1.0;532 533 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {534 ySum = xSum;535 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {536 if (myPoly->mask[loop_x][loop_y] == 0) {537 polySum += ySum * myPoly->coeff[loop_x][loop_y];538 ySum *= y;539 }540 }541 xSum *= x;542 }543 544 return(polySum);545 }546 547 float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)548 {549 PS_POLY_CHECK_NULL(myPoly, NAN);550 551 psS32 loop_x = 0;552 psS32 loop_y = 0;553 psS32 i = 0;554 float polySum = 0.0;555 psPolynomial1D* *chebPolys = NULL;556 psS32 maxChebyPoly = 0;557 558 // Determine how many Chebyshev polynomials559 // are needed, then create them.560 maxChebyPoly = myPoly->nX;561 if (myPoly->nY > maxChebyPoly) {562 maxChebyPoly = myPoly->nY;563 }564 chebPolys = CreateChebyshevPolys(maxChebyPoly);565 566 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {567 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {568 if (myPoly->mask[loop_x][loop_y] == 0) {569 polySum += myPoly->coeff[loop_x][loop_y] *570 psPolynomial1DEval(x, chebPolys[loop_x]) *571 psPolynomial1DEval(y, chebPolys[loop_y]);572 }573 }574 }575 for (i=0;i<maxChebyPoly;i++) {576 psFree(chebPolys[i]);577 }578 psFree(chebPolys);579 return(polySum);580 }581 582 float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)583 {584 PS_POLY_CHECK_NULL(myPoly, NAN);585 586 1198 if (myPoly->type == PS_POLYNOMIAL_ORD) { 587 return( p_psOrdPolynomial2DEval(x, y, myPoly));1199 return(ordPolynomial2DEval(x, y, myPoly)); 588 1200 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 589 return( p_psChebPolynomial2DEval(x, y, myPoly));1201 return(chebPolynomial2DEval(x, y, myPoly)); 590 1202 } else { 591 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1203 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1204 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1205 myPoly->type); 592 1206 } 593 1207 return(0.0); 594 1208 } 595 596 1209 597 1210 psVector *psPolynomial2DEvalVector(const psVector *x, … … 632 1245 } 633 1246 634 635 636 float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)637 {638 psS32 loop_x = 0;639 psS32 loop_y = 0;640 psS32 loop_z = 0;641 float polySum = 0.0;642 float xSum = 1.0;643 float ySum = 1.0;644 float zSum = 1.0;645 646 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {647 ySum = xSum;648 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {649 zSum = ySum;650 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {651 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {652 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];653 zSum *= z;654 }655 }656 ySum *= y;657 }658 xSum *= x;659 }660 661 return(polySum);662 }663 664 float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)665 {666 psS32 loop_x = 0;667 psS32 loop_y = 0;668 psS32 loop_z = 0;669 psS32 i = 0;670 float polySum = 0.0;671 psPolynomial1D* *chebPolys = NULL;672 psS32 maxChebyPoly = 0;673 674 // Determine how many Chebyshev polynomials675 // are needed, then create them.676 maxChebyPoly = myPoly->nX;677 if (myPoly->nY > maxChebyPoly) {678 maxChebyPoly = myPoly->nY;679 }680 if (myPoly->nZ > maxChebyPoly) {681 maxChebyPoly = myPoly->nZ;682 }683 chebPolys = CreateChebyshevPolys(maxChebyPoly);684 685 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {686 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {687 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {688 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {689 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *690 psPolynomial1DEval(x, chebPolys[loop_x]) *691 psPolynomial1DEval(y, chebPolys[loop_y]) *692 psPolynomial1DEval(z, chebPolys[loop_z]);693 }694 }695 }696 }697 698 for (i=0;i<maxChebyPoly;i++) {699 psFree(chebPolys[i]);700 }701 psFree(chebPolys);702 return(polySum);703 }704 705 1247 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 706 1248 { … … 708 1250 709 1251 if (myPoly->type == PS_POLYNOMIAL_ORD) { 710 return( p_psOrdPolynomial3DEval(x, y, z, myPoly));1252 return(ordPolynomial3DEval(x, y, z, myPoly)); 711 1253 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 712 return( p_psChebPolynomial3DEval(x, y, z, myPoly));1254 return(chebPolynomial3DEval(x, y, z, myPoly)); 713 1255 } else { 714 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1256 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1257 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1258 myPoly->type); 715 1259 } 716 1260 return(0.0); … … 765 1309 } 766 1310 767 768 769 770 771 772 float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)773 {774 psS32 loop_w = 0;775 psS32 loop_x = 0;776 psS32 loop_y = 0;777 psS32 loop_z = 0;778 float polySum = 0.0;779 float wSum = 1.0;780 float xSum = 1.0;781 float ySum = 1.0;782 float zSum = 1.0;783 784 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {785 xSum = wSum;786 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {787 ySum = xSum;788 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {789 zSum = ySum;790 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {791 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {792 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];793 zSum *= z;794 }795 }796 ySum *= y;797 }798 xSum *= x;799 }800 wSum *= w;801 }802 803 return(polySum);804 }805 806 float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)807 {808 psS32 loop_w = 0;809 psS32 loop_x = 0;810 psS32 loop_y = 0;811 psS32 loop_z = 0;812 psS32 i = 0;813 float polySum = 0.0;814 psPolynomial1D* *chebPolys = NULL;815 psS32 maxChebyPoly = 0;816 817 // Determine how many Chebyshev polynomials818 // are needed, then create them.819 maxChebyPoly = myPoly->nW;820 if (myPoly->nX > maxChebyPoly) {821 maxChebyPoly = myPoly->nX;822 }823 if (myPoly->nY > maxChebyPoly) {824 maxChebyPoly = myPoly->nY;825 }826 if (myPoly->nZ > maxChebyPoly) {827 maxChebyPoly = myPoly->nZ;828 }829 chebPolys = CreateChebyshevPolys(maxChebyPoly);830 831 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {832 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {833 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {834 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {835 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {836 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *837 psPolynomial1DEval(w, chebPolys[loop_w]) *838 psPolynomial1DEval(x, chebPolys[loop_x]) *839 psPolynomial1DEval(y, chebPolys[loop_y]) *840 psPolynomial1DEval(z, chebPolys[loop_z]);841 }842 }843 }844 }845 }846 847 for (i=0;i<maxChebyPoly;i++) {848 psFree(chebPolys[i]);849 }850 psFree(chebPolys);851 return(polySum);852 }853 854 1311 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 855 1312 { … … 857 1314 858 1315 if (myPoly->type == PS_POLYNOMIAL_ORD) { 859 return( p_psOrdPolynomial4DEval(w,x,y,z, myPoly));1316 return(ordPolynomial4DEval(w,x,y,z, myPoly)); 860 1317 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 861 return( p_psChebPolynomial4DEval(w,x,y,z, myPoly));1318 return(chebPolynomial4DEval(w,x,y,z, myPoly)); 862 1319 } else { 863 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1320 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1321 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1322 myPoly->type); 864 1323 } 865 1324 return(0.0); … … 924 1383 return(tmp); 925 1384 } 926 927 928 929 1385 930 1386 … … 1092 1548 } 1093 1549 1094 static void dPolynomial1DFree(psDPolynomial1D* myPoly)1095 {1096 psFree(myPoly->coeff);1097 psFree(myPoly->coeffErr);1098 psFree(myPoly->mask);1099 }1100 1101 static void dPolynomial2DFree(psDPolynomial2D* myPoly)1102 {1103 psS32 x = 0;1104 1105 for (x = 0; x < myPoly->nX; x++) {1106 psFree(myPoly->coeff[x]);1107 psFree(myPoly->coeffErr[x]);1108 psFree(myPoly->mask[x]);1109 }1110 psFree(myPoly->coeff);1111 psFree(myPoly->coeffErr);1112 psFree(myPoly->mask);1113 }1114 1115 static void dPolynomial3DFree(psDPolynomial3D* myPoly)1116 {1117 psS32 x = 0;1118 psS32 y = 0;1119 1120 for (x = 0; x < myPoly->nX; x++) {1121 for (y = 0; y < myPoly->nY; y++) {1122 psFree(myPoly->coeff[x][y]);1123 psFree(myPoly->coeffErr[x][y]);1124 psFree(myPoly->mask[x][y]);1125 }1126 psFree(myPoly->coeff[x]);1127 psFree(myPoly->coeffErr[x]);1128 psFree(myPoly->mask[x]);1129 }1130 1131 psFree(myPoly->coeff);1132 psFree(myPoly->coeffErr);1133 psFree(myPoly->mask);1134 }1135 1136 static void dPolynomial4DFree(psDPolynomial4D* myPoly)1137 {1138 psS32 w = 0;1139 psS32 x = 0;1140 psS32 y = 0;1141 1142 for (w = 0; w < myPoly->nW; w++) {1143 for (x = 0; x < myPoly->nX; x++) {1144 for (y = 0; y < myPoly->nY; y++) {1145 psFree(myPoly->coeff[w][x][y]);1146 psFree(myPoly->coeffErr[w][x][y]);1147 psFree(myPoly->mask[w][x][y]);1148 }1149 psFree(myPoly->coeff[w][x]);1150 psFree(myPoly->coeffErr[w][x]);1151 psFree(myPoly->mask[w][x]);1152 }1153 psFree(myPoly->coeff[w]);1154 psFree(myPoly->coeffErr[w]);1155 psFree(myPoly->mask[w]);1156 }1157 1158 psFree(myPoly->coeff);1159 psFree(myPoly->coeffErr);1160 psFree(myPoly->mask);1161 }1162 1163 /*****************************************************************************1164 Polynomial coefficients will be accessed in [w][x][y][z] fashion.1165 *****************************************************************************/1166 double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1167 {1168 psS32 loop_x = 0;1169 double polySum = 0.0;1170 double xSum = 1.0;1171 1172 for (loop_x = 0; loop_x < myPoly->n; loop_x++) {1173 if (myPoly->mask[loop_x] == 0) {1174 polySum += xSum * myPoly->coeff[loop_x];1175 xSum *= x;1176 }1177 }1178 1179 return(polySum);1180 }1181 1182 // XXX: You can do this without having to psAlloc() vector d.1183 // XXX: How does the mask vector effect Crenshaw's formula?1184 double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)1185 {1186 psVector *d;1187 psS32 n;1188 psS32 i;1189 double tmp;1190 1191 n = myPoly->n;1192 d = psVectorAlloc(n, PS_TYPE_F64);1193 d->data.F64[n-1] = myPoly->coeff[n-1];1194 d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];1195 for (i=n-3;i>=1;i--) {1196 d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -1197 (d->data.F64[i+2]) +1198 (myPoly->coeff[i]);1199 }1200 1201 tmp = (x * d->data.F64[1]) -1202 (d->data.F64[2]) +1203 (0.5 * myPoly->coeff[0]);1204 1205 psFree(d);1206 return(tmp);1207 }1208 1550 1209 1551 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly) … … 1212 1554 1213 1555 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1214 return( p_psDOrdPolynomial1DEval(x, myPoly));1556 return(dOrdPolynomial1DEval(x, myPoly)); 1215 1557 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1216 return( p_psDChebPolynomial1DEval(x, myPoly));1558 return(dChebPolynomial1DEval(x, myPoly)); 1217 1559 } else { 1218 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1560 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1561 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1562 myPoly->type); 1219 1563 } 1220 1564 return(0.0); … … 1244 1588 1245 1589 1246 1247 double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1248 {1249 psS32 loop_x = 0;1250 psS32 loop_y = 0;1251 double polySum = 0.0;1252 double xSum = 1.0;1253 double ySum = 1.0;1254 1255 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1256 ySum = xSum;1257 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1258 if (myPoly->mask[loop_x][loop_y] == 0) {1259 polySum += ySum * myPoly->coeff[loop_x][loop_y];1260 ySum *= y;1261 }1262 }1263 xSum *= x;1264 }1265 1266 return(polySum);1267 }1268 1269 double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)1270 {1271 psS32 loop_x = 0;1272 psS32 loop_y = 0;1273 psS32 i = 0;1274 double polySum = 0.0;1275 psPolynomial1D* *chebPolys = NULL;1276 psS32 maxChebyPoly = 0;1277 1278 // Determine how many Chebyshev polynomials1279 // are needed, then create them.1280 maxChebyPoly = myPoly->nX;1281 if (myPoly->nY > maxChebyPoly) {1282 maxChebyPoly = myPoly->nY;1283 }1284 chebPolys = CreateChebyshevPolys(maxChebyPoly);1285 1286 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1287 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1288 if (myPoly->mask[loop_x][loop_y] == 0) {1289 polySum += myPoly->coeff[loop_x][loop_y] *1290 psPolynomial1DEval(x, chebPolys[loop_x]) *1291 psPolynomial1DEval(y, chebPolys[loop_y]);1292 }1293 }1294 }1295 1296 for (i=0;i<maxChebyPoly;i++) {1297 psFree(chebPolys[i]);1298 }1299 psFree(chebPolys);1300 return(polySum);1301 }1302 1303 1590 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 1304 1591 { … … 1306 1593 1307 1594 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1308 return( p_psDOrdPolynomial2DEval(x, y, myPoly));1595 return(dOrdPolynomial2DEval(x, y, myPoly)); 1309 1596 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1310 return( p_psDChebPolynomial2DEval(x, y, myPoly));1597 return(dChebPolynomial2DEval(x, y, myPoly)); 1311 1598 } else { 1312 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1599 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1600 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1601 myPoly->type); 1313 1602 } 1314 1603 return(0.0); … … 1353 1642 1354 1643 1355 1356 double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1357 {1358 psS32 loop_x = 0;1359 psS32 loop_y = 0;1360 psS32 loop_z = 0;1361 double polySum = 0.0;1362 double xSum = 1.0;1363 double ySum = 1.0;1364 double zSum = 1.0;1365 1366 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1367 ySum = xSum;1368 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1369 zSum = ySum;1370 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1371 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1372 polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];1373 zSum *= z;1374 }1375 }1376 ySum *= y;1377 }1378 xSum *= x;1379 }1380 1381 return(polySum);1382 }1383 1384 double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)1385 {1386 psS32 loop_x = 0;1387 psS32 loop_y = 0;1388 psS32 loop_z = 0;1389 psS32 i = 0;1390 double polySum = 0.0;1391 psPolynomial1D* *chebPolys = NULL;1392 psS32 maxChebyPoly = 0;1393 1394 // Determine how many Chebyshev polynomials1395 // are needed, then create them.1396 maxChebyPoly = myPoly->nX;1397 if (myPoly->nY > maxChebyPoly) {1398 maxChebyPoly = myPoly->nY;1399 }1400 if (myPoly->nZ > maxChebyPoly) {1401 maxChebyPoly = myPoly->nZ;1402 }1403 chebPolys = CreateChebyshevPolys(maxChebyPoly);1404 1405 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1406 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1407 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1408 if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {1409 polySum += myPoly->coeff[loop_x][loop_y][loop_z] *1410 psPolynomial1DEval(x, chebPolys[loop_x]) *1411 psPolynomial1DEval(y, chebPolys[loop_y]) *1412 psPolynomial1DEval(z, chebPolys[loop_z]);1413 }1414 }1415 }1416 }1417 1418 for (i=0;i<maxChebyPoly;i++) {1419 psFree(chebPolys[i]);1420 }1421 psFree(chebPolys);1422 return(polySum);1423 }1424 1425 1644 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 1426 1645 { … … 1428 1647 1429 1648 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1430 return( p_psDOrdPolynomial3DEval(x, y, z, myPoly));1649 return(dOrdPolynomial3DEval(x, y, z, myPoly)); 1431 1650 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1432 return( p_psDChebPolynomial3DEval(x, y, z, myPoly));1651 return(dChebPolynomial3DEval(x, y, z, myPoly)); 1433 1652 } else { 1434 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1653 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1654 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1655 myPoly->type); 1435 1656 } 1436 1657 return(0.0); … … 1485 1706 } 1486 1707 1487 1488 1489 1490 1491 1492 1493 1494 double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1495 {1496 psS32 loop_w = 0;1497 psS32 loop_x = 0;1498 psS32 loop_y = 0;1499 psS32 loop_z = 0;1500 double polySum = 0.0;1501 double wSum = 1.0;1502 double xSum = 1.0;1503 double ySum = 1.0;1504 double zSum = 1.0;1505 1506 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1507 xSum = wSum;1508 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1509 ySum = xSum;1510 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1511 zSum = ySum;1512 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1513 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1514 polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];1515 zSum *= z;1516 }1517 }1518 ySum *= y;1519 }1520 xSum *= x;1521 }1522 wSum *= w;1523 }1524 1525 return(polySum);1526 }1527 1528 double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)1529 {1530 psS32 loop_w = 0;1531 psS32 loop_x = 0;1532 psS32 loop_y = 0;1533 psS32 loop_z = 0;1534 psS32 i = 0;1535 double polySum = 0.0;1536 psPolynomial1D* *chebPolys = NULL;1537 psS32 maxChebyPoly = 0;1538 1539 // Determine how many Chebyshev polynomials1540 // are needed, then create them.1541 maxChebyPoly = myPoly->nW;1542 if (myPoly->nX > maxChebyPoly) {1543 maxChebyPoly = myPoly->nX;1544 }1545 if (myPoly->nY > maxChebyPoly) {1546 maxChebyPoly = myPoly->nY;1547 }1548 if (myPoly->nZ > maxChebyPoly) {1549 maxChebyPoly = myPoly->nZ;1550 }1551 chebPolys = CreateChebyshevPolys(maxChebyPoly);1552 1553 for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {1554 for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {1555 for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {1556 for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {1557 if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {1558 polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *1559 psPolynomial1DEval(w, chebPolys[loop_w]) *1560 psPolynomial1DEval(x, chebPolys[loop_x]) *1561 psPolynomial1DEval(y, chebPolys[loop_y]) *1562 psPolynomial1DEval(z, chebPolys[loop_z]);1563 }1564 }1565 }1566 }1567 }1568 1569 for (i=0;i<maxChebyPoly;i++) {1570 psFree(chebPolys[i]);1571 }1572 psFree(chebPolys);1573 return(polySum);1574 }1575 1576 1708 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 1577 1709 { … … 1579 1711 1580 1712 if (myPoly->type == PS_POLYNOMIAL_ORD) { 1581 return( p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));1713 return(dOrdPolynomial4DEval(w,x,y,z, myPoly)); 1582 1714 } else if (myPoly->type == PS_POLYNOMIAL_CHEB) { 1583 return( p_psDChebPolynomial4DEval(w,x,y,z, myPoly));1715 return(dChebPolynomial4DEval(w,x,y,z, myPoly)); 1584 1716 } else { 1585 psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type); 1717 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1718 PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE, 1719 myPoly->type); 1586 1720 } 1587 1721 return(0.0); … … 1699 1833 (tmp->domains)[numSplines] = max; 1700 1834 1835 p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree); 1701 1836 return(tmp); 1702 1837 } 1703 1838 1704 // XXX: Have Robert put the dealocator in the memory file.1705 psS32 p_psSpline1DFree(psSpline1D *tmpSpline)1706 {1707 psS32 i;1708 1709 if (tmpSpline == NULL) {1710 return(0);1711 }1712 1713 if (tmpSpline->spline != NULL) {1714 for (i=0;i<tmpSpline->n;i++) {1715 psFree((tmpSpline->spline)[i]);1716 }1717 psFree(tmpSpline->spline);1718 }1719 1720 if (tmpSpline->p_psDeriv2 != NULL) {1721 psFree(tmpSpline->p_psDeriv2);1722 }1723 psFree(tmpSpline->domains);1724 psFree(tmpSpline);1725 1726 return(0);1727 }1728 1839 1729 1840 /***************************************************************************** … … 1765 1876 1766 1877 /***************************************************************************** 1767 p_psVectorBinDisectF32(): This is a private function which takes as input a1878 vectorBinDisectF32(): This is a private function which takes as input a 1768 1879 vector of floating point data as well as a single floating point values. 1769 1880 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1776 1887 XXX: name since we don't take psVectors as input. 1777 1888 *****************************************************************************/ 1778 psS32 p_psVectorBinDisectF32(float *bins,1779 psS32 numBins,1780 float x)1889 static psS32 vectorBinDisectF32(float *bins, 1890 psS32 numBins, 1891 float x) 1781 1892 { 1782 1893 psS32 min; … … 1784 1895 psS32 mid; 1785 1896 1786 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1787 "---- Calling p_psVectorBinDisectF32(%f)\n", x);1897 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1898 "---- Calling vectorBinDisectF32(%f)\n", x); 1788 1899 1789 1900 if (x < bins[0]) { 1790 1901 psLogMsg(__func__, PS_LOG_WARN, 1791 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1902 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1792 1903 x, bins[0], bins[numBins-1]); 1793 1904 return(-2); … … 1796 1907 if (x > bins[numBins-1]) { 1797 1908 psLogMsg(__func__, PS_LOG_WARN, 1798 " p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1909 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1799 1910 x, bins[0], bins[numBins-1]); 1800 1911 return(-1); … … 1806 1917 1807 1918 while (min != max) { 1808 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1919 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1809 1920 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1810 1921 min, mid, max, x, bins[mid]); 1811 1922 1812 1923 if (x == bins[mid]) { 1813 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1814 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);1924 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1925 "---- Exiting vectorBinDisectF32(): bin %d\n", mid); 1815 1926 return(mid); 1816 1927 } else if (x < bins[mid]) { … … 1822 1933 } 1823 1934 1824 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectF32", 4,1825 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);1935 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4, 1936 "---- Exiting vectorBinDisectF32(): bin %d\n", min); 1826 1937 return(min); 1827 1938 } 1828 1939 1829 1940 /***************************************************************************** 1830 p_psVectorBinDisectS32(): integer version of above.1941 vectorBinDisectS32(): integer version of above. 1831 1942 *****************************************************************************/ 1832 psS32 p_psVectorBinDisectS32(psS32 *bins,1833 psS32 numBins,1834 psS32 x)1943 static psS32 vectorBinDisectS32(psS32 *bins, 1944 psS32 numBins, 1945 psS32 x) 1835 1946 { 1836 1947 psS32 min; … … 1838 1949 psS32 mid; 1839 1950 1840 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1841 "---- Calling p_psVectorBinDisectS32(%f)\n", x);1951 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1952 "---- Calling vectorBinDisectS32(%f)\n", x); 1842 1953 1843 1954 if ((x < bins[0]) || 1844 1955 (x > bins[numBins-1])) { 1845 1956 psLogMsg(__func__, PS_LOG_WARN, 1846 " p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1957 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1847 1958 x, bins[0], bins[numBins-1]); 1848 1959 return(-1); … … 1854 1965 1855 1966 while (min != max) { 1856 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1967 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1857 1968 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1858 1969 min, mid, max, x, bins[mid]); 1859 1970 1860 1971 if (x == bins[mid]) { 1861 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1862 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1972 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1973 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1863 1974 return(min); 1864 1975 } else if (x < bins[mid]) { … … 1870 1981 } 1871 1982 1872 psTrace(".psLib.dataManip.psFunctions. p_psVectorBinDisectS32", 4,1873 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);1983 psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4, 1984 "---- Exiting vectorBinDisectS32(): bin %d\n", min); 1874 1985 return(min); 1875 1986 } … … 1884 1995 1885 1996 if (x->type.type == PS_TYPE_S32) { 1886 return( p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1997 return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1887 1998 } else if (x->type.type == PS_TYPE_F32) { 1888 return( p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1999 return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1889 2000 } else { 1890 psError(__func__, "Unallowable data type."); 2001 char* strType; 2002 PS_TYPE_NAME(strType,x->type.type); 2003 psError(PS_ERR_BAD_PARAMETER_TYPE, 2004 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2005 strType); 1891 2006 return(-2); 1892 2007 } 1893 2008 return(-1); 1894 }1895 1896 /*****************************************************************************1897 p_psInterpolate1D(): This routine will take as input n-element floating1898 point arrays domain and range, and the x value, assumed to lie with the1899 domain vector. It produces as output the (n-1)-order LaGrange interpolated1900 value of x.1901 1902 XXX: do we error check for non-distinct domain values?1903 *****************************************************************************/1904 float p_ps1DFullInterpolateF32(float *domain,1905 float *range,1906 psS32 n,1907 float x)1908 {1909 PS_INT_CHECK_NON_NEGATIVE(n, NAN);1910 PS_PTR_CHECK_NULL(domain, NAN);1911 PS_PTR_CHECK_NULL(range, NAN);1912 1913 psS32 i;1914 psS32 m;1915 static psVector *p = NULL;1916 p = psVectorRecycle(p, n, PS_TYPE_F32);1917 p_psMemSetPersistent(p, true);1918 p_psMemSetPersistent(p->data.F32, true);1919 /*1920 psVector *p = psVectorAlloc(n, PS_TYPE_F32);1921 float tmp;1922 */1923 1924 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1925 "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);1926 1927 for (i=0;i<n;i++) {1928 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1929 "domain/range is (%f %f)\n", domain[i], range[i]);1930 }1931 1932 for (i=0;i<n;i++) {1933 p->data.F32[i] = range[i];1934 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1935 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1936 1937 }1938 1939 // From NR, during each iteration of the m loop, we are computing the1940 // p_{i ... i+m} terms.1941 for (m=1;m<n;m++) {1942 for (i=0;i<n-m;i++) {1943 // From NR: we are computing P_{i ... i+m}1944 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +1945 ((domain[i]-x) * p->data.F32[i+1])) /1946 (domain[i] - domain[i+m]);1947 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);1948 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,1949 "p->data.F32[%d] is %f\n", i, p->data.F32[i]);1950 }1951 }1952 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,1953 "---- p_ps1DFullInterpolateF32() end ----\n");1954 1955 /*1956 tmp = p->data.F32[0];1957 psFree(p);1958 return(tmp);1959 */1960 return(p->data.F32[0]);1961 }1962 1963 1964 /*****************************************************************************1965 p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform1966 LaGrange interpolation.1967 *****************************************************************************/1968 float p_ps1DInterpolateF32(float *domain,1969 float *range,1970 psS32 n,1971 psS32 order,1972 float x)1973 {1974 psS32 binNum;1975 psS32 numIntPoints = order+1;1976 psS32 origin;1977 1978 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,1979 "---- p_ps1DInterpolateF32() begin ----\n");1980 1981 binNum = p_psVectorBinDisectF32(domain, n, x);1982 1983 if (0 == numIntPoints%2) {1984 origin = binNum - ((numIntPoints/2) - 1);1985 } else {1986 origin = binNum - (numIntPoints/2);1987 if ((x-domain[binNum]) > (domain[binNum+1]-x)) {1988 // x is closer to binNum+1.1989 origin = 1 + (binNum - (numIntPoints/2));1990 }1991 }1992 if (origin < 0) {1993 origin = 0;1994 }1995 if ((origin + numIntPoints) > n) {1996 origin = n - numIntPoints;1997 }1998 1999 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,2000 "---- p_ps1DInterpolateF32() end ----\n");2001 return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));2002 2009 } 2003 2010 … … 2035 2042 2036 2043 if (order > (domain->n - 1)) { 2037 psError(__func__, "not enough data points for %d-order interpolation.\n", order); 2044 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 2045 PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS, 2046 order); 2038 2047 return(NULL); 2039 2048 } … … 2042 2051 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 2043 2052 "---- p_psVectorInterpolate() end ----\n"); 2044 return(psScalarAlloc( p_ps1DInterpolateF32(domain->data.F32,2045 range->data.F32,2046 domain->n,2047 order,2048 x->data.F32), PS_TYPE_F32));2053 return(psScalarAlloc(interpolate1DF32(domain->data.F32, 2054 range->data.F32, 2055 domain->n, 2056 order, 2057 x->data.F32), PS_TYPE_F32)); 2049 2058 } else if (x->type.type == PS_TYPE_F64) { 2050 2059 // XXX: use recycled vectors here. … … 2053 2062 2054 2063 psScalar *tmpScalar = psScalarAlloc((double) 2055 p_ps1DInterpolateF32(domain32->data.F32,2056 range32->data.F32,2057 domain32->n,2058 order,2059 (float) x->data.F64), PS_TYPE_F64);2064 interpolate1DF32(domain32->data.F32, 2065 range32->data.F32, 2066 domain32->n, 2067 order, 2068 (float) x->data.F64), PS_TYPE_F64); 2060 2069 psFree(range32); 2061 2070 psFree(domain32); … … 2067 2076 2068 2077 } else { 2069 // XXX psError: type not supported 2070 psError(__func__, "type %d not supported\n", x->type.type); 2078 char* strType; 2079 PS_TYPE_NAME(strType,x->type.type); 2080 psError(PS_ERR_BAD_PARAMETER_TYPE, 2081 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2082 strType); 2071 2083 } 2072 2084 … … 2084 2096 and an independent x value. Each determines which spline that x corresponds 2085 2097 to by doing a bracket disection on the domains of the spline data structure 2086 ( p_psVectorBinDisectF32()). Then it evaluates the spline at that x location2098 (vectorBinDisectF32()). Then it evaluates the spline at that x location 2087 2099 by a call to the 1D polynomial functions. 2088 2100 … … 2100 2112 2101 2113 n = spline->n; 2102 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);2114 binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x); 2103 2115 if (binNum < 0) { 2104 2116 psLogMsg(__func__, PS_LOG_WARN, … … 2139 2151 } 2140 2152 } else { 2141 psError(__func__, "Unknown data type.\n"); 2153 char* strType; 2154 PS_TYPE_NAME(strType,x->type.type); 2155 psError(PS_ERR_BAD_PARAMETER_TYPE, 2156 PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED, 2157 strType); 2142 2158 return(NULL); 2143 2159 } -
trunk/psLib/src/math/psSpline.h
r2269 r2273 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-11-0 3 03:30:30$14 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:59 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 398 398 float max); 399 399 400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);401 402 400 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, 403 401 psS32 order); -
trunk/psLib/src/math/psStats.c
r2269 r2273 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 3 03:30:30$11 * @version $Revision: 1.85 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 #include "psFunctions.h" 35 35 #include "psConstants.h" 36 37 #include "psDataManipErrors.h" 36 38 37 39 /*****************************************************************************/ … … 735 737 736 738 // Ensure that stats->clipIter is within the proper range. 737 if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) { 738 psError(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter); 739 return(-1); 740 } 739 PS_INT_CHECK_RANGE(stats->clipIter,PS_CLIPPED_NUM_ITER_LB,PS_CLIPPED_NUM_ITER_UB,-1); 740 741 741 // Ensure that stats->clipSigma is within the proper range. 742 if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) { 743 psError(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma); 744 return(-1); 745 } 742 PS_INT_CHECK_RANGE(stats->clipSigma,PS_CLIPPED_SIGMA_LB,PS_CLIPPED_SIGMA_UB,-1); 743 746 744 // We allocate a temporary mask vector since during the iterative 747 745 // steps that follow, we will be masking off additional data points. … … 869 867 p_psNormalizeVectorRangeF64(myData, low, high); 870 868 } else { 871 psError(__func__, "Unalowable data type.\n"); 869 char* strType; 870 PS_TYPE_NAME(strType,myData->type.type); 871 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 872 PS_ERRORTEXT_psStats_NOT_F32_F64, 873 strType); 872 874 } 873 875 } … … 954 956 // Ensure that yVal is within the range of the bins we are using. 955 957 if (!((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2]))) { 956 printf("((%f), %f, %f)\n", yVal, y->data.F64[0], y->data.F64[2]); 957 psError(__func__, "yVal not within y-range\n"); 958 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 959 PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE, 960 (double)yVal,y->data.F64[2],y->data.F64[0]); 958 961 } 959 962 yErr->data.F64[0] = 1.0; … … 1113 1116 1114 1117 if ((LQBinNum < 0) || (UQBinNum < 0)) { 1115 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1118 psError(PS_ERR_UNKNOWN, true, 1119 PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED); 1116 1120 return(1); 1117 1121 } 1118 1122 if (medianBinNum < 0) { 1119 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1123 psError(PS_ERR_UNKNOWN, true, 1124 PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED); 1120 1125 return(1); 1121 1126 } … … 1174 1179 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1175 1180 1176 p _psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);1181 psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0); 1177 1182 for (i=0;i<robustHistogramVector->n;i++) { 1178 1183 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); … … 1536 1541 // do nothing 1537 1542 } else { 1538 psError(__func__, "unsupported vector type 0x%x\n", in->type.type); 1543 char* strType; 1544 PS_TYPE_NAME(strType,in->type.type); 1545 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1546 PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED, 1547 strType); 1539 1548 } 1540 1549 return (tmp); … … 1603 1612 (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) { 1604 1613 if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) { 1605 psError(__func__, "p_psVectorRobustStats() failed.\n"); 1614 psError(PS_ERR_UNKNOWN, false, 1615 PS_ERRORTEXT_psStats_STATS_FAILED); 1606 1616 } 1607 1617 } … … 1609 1619 if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) { 1610 1620 if (0 != p_psVectorClippedStats(inF32, mask, maskVal, stats)) { 1611 psError(__func__, "p_psVectorClippedStats() failed.\n"); 1621 psError(PS_ERR_UNKNOWN, false, 1622 "Failed to calculate statistics for input psVector."); 1612 1623 } 1613 1624 } -
trunk/psLib/src/mathtypes/psImage.c
r2204 r2273 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.5 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.52 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 41 41 if (area < 1) { 42 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageAlloc", 43 PS_ERR_BAD_PARAMETER_VALUE, true, 44 PS_ERRORTEXT_psImage_AREA_NEGATIVE, 45 numRows, numCols); 42 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 43 PS_ERRORTEXT_psImage_AREA_NEGATIVE, 44 numRows, numCols); 46 45 return NULL; 47 46 } … … 119 118 if (old->type.dimen != PS_DIMEN_IMAGE) { 120 119 psFree(old); 121 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRecycle", 122 PS_ERR_BAD_PARAMETER_TYPE, true, 123 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 120 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 121 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 124 122 return NULL; 125 123 } … … 175 173 176 174 if (input == NULL || input->data.V == NULL) { 177 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 178 PS_ERR_BAD_PARAMETER_NULL, true, 179 PS_ERRORTEXT_psImage_IMAGE_NULL); 175 psError(PS_ERR_BAD_PARAMETER_NULL, true, 176 PS_ERRORTEXT_psImage_IMAGE_NULL); 180 177 psFree(output); 181 178 return NULL; … … 183 180 184 181 if (input == output) { 185 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 186 PS_ERR_BAD_PARAMETER_NULL, true, 187 PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED); 182 psError(PS_ERR_BAD_PARAMETER_NULL, true, 183 PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED); 188 184 psFree(output); 189 185 return NULL; … … 191 187 192 188 if (input->type.dimen != PS_DIMEN_IMAGE) { 193 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 194 PS_ERR_BAD_PARAMETER_TYPE, true, 195 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 189 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 190 PS_ERRORTEXT_psImage_NOT_AN_IMAGE); 196 191 psFree(output); 197 192 return NULL; … … 205 200 206 201 if (inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR) { 207 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 208 PS_ERR_BAD_PARAMETER_TYPE, true, 209 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 210 PS_TYPE_PTR_NAME); 202 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 203 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 204 PS_TYPE_PTR_NAME); 211 205 psFree(output); 212 206 return NULL; … … 319 313 char* typeStr; 320 314 PS_TYPE_NAME(typeStr,type); 321 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 322 PS_ERR_BAD_PARAMETER_TYPE, true, 323 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 324 typeStr); 315 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 316 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 317 typeStr); 325 318 psFree(output); 326 319 … … 372 365 373 366 if (input == NULL) { 374 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", 375 PS_ERR_BAD_PARAMETER_NULL,true, 376 PS_ERRORTEXT_psImage_IMAGE_NULL); 367 psError(PS_ERR_BAD_PARAMETER_NULL,true, 368 PS_ERRORTEXT_psImage_IMAGE_NULL); 377 369 return unexposedValue; 378 370 } … … 400 392 break; \ 401 393 default: \ 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", \ 403 PS_ERR_BAD_PARAMETER_VALUE,true, \ 404 PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID, \ 405 mode); \ 394 psError(PS_ERR_BAD_PARAMETER_VALUE,true, \ 395 PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID, \ 396 mode); \ 406 397 } \ 407 398 break … … 423 414 char* typeStr; 424 415 PS_TYPE_NAME(typeStr,input->type.type); 425 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate", 426 PS_ERR_BAD_PARAMETER_TYPE,true, 427 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 428 typeStr); 416 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 417 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 418 typeStr); 429 419 } 430 420 } -
trunk/psLib/src/mathtypes/psScalar.c
r2055 r2273 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-12 19:32:44$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:04:57 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 break; 71 71 default: 72 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc", 73 PS_ERR_BAD_PARAMETER_TYPE, true, 74 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 75 dataType); 72 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 73 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 74 dataType); 76 75 } 77 76 … … 85 84 86 85 if (scalar == NULL) { 87 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy", 88 PS_ERR_BAD_PARAMETER_NULL, true, 89 PS_ERRORTEXT_psScalar_COPY_NULL); 86 psError(PS_ERR_BAD_PARAMETER_NULL, true, 87 PS_ERRORTEXT_psScalar_COPY_NULL); 90 88 return NULL; 91 89 } … … 130 128 break; 131 129 default: 132 psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy", 133 PS_ERR_BAD_PARAMETER_TYPE, true, 134 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 135 dataType); 130 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 131 PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE, 132 dataType); 136 133 } 137 134 -
trunk/psLib/src/mathtypes/psVector.c
r2204 r2273 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:04:57 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 70 70 71 71 if (in == NULL) { 72 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc", 73 PS_ERR_BAD_PARAMETER_NULL, true, 74 PS_ERRORTEXT_psVector_REALLOC_NULL); 72 psError(PS_ERR_BAD_PARAMETER_NULL, true, 73 PS_ERRORTEXT_psVector_REALLOC_NULL); 75 74 return NULL; 76 75 } else if (in->nalloc != nalloc) { // No need to realloc to same size … … 99 98 in->type.dimen != PS_DIMEN_TRANSV) { 100 99 psFree(in); 101 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRecycle", 102 PS_ERR_BAD_PARAMETER_TYPE, true, 103 PS_ERRORTEXT_psVector_NOT_A_VECTOR); 100 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 101 PS_ERRORTEXT_psVector_NOT_A_VECTOR); 104 102 return NULL; 105 103 } … … 122 120 { 123 121 if (in == NULL) { 124 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 125 PS_ERR_BAD_PARAMETER_NULL, true, 126 PS_ERRORTEXT_psVector_SORT_NULL); 122 psError(PS_ERR_BAD_PARAMETER_NULL, true, 123 PS_ERRORTEXT_psVector_SORT_NULL); 127 124 psFree(out); 128 125 return NULL; … … 183 180 char* typeStr; \ 184 181 PS_TYPE_NAME(typeStr,type); \ 185 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \ 186 PS_ERR_BAD_PARAMETER_TYPE, true, \ 187 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 188 typeStr); \ 182 psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ 183 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 184 typeStr); \ 189 185 psFree(out); \ 190 186 } \ … … 209 205 char* typeStr; 210 206 PS_TYPE_NAME(typeStr,type); 211 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 212 PS_ERR_BAD_PARAMETER_TYPE, true, 213 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 214 typeStr); 207 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 208 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 209 typeStr); 215 210 psFree(out); 216 211 … … 232 227 233 228 if (inVector == NULL) { 234 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 235 PS_ERR_BAD_PARAMETER_NULL, true, 236 PS_ERRORTEXT_psVector_SORT_NULL); 229 psError(PS_ERR_BAD_PARAMETER_NULL, true, 230 PS_ERRORTEXT_psVector_SORT_NULL); 237 231 psFree(outVector); 238 232 return NULL; … … 300 294 break; 301 295 default: 302 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 303 PS_ERR_BAD_PARAMETER_TYPE, true, 304 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 305 inType); 296 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 297 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 298 inType); 306 299 } 307 300 … … 317 310 318 311 if (inVector == NULL) { 319 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex", 320 PS_ERR_BAD_PARAMETER_NULL, true, 321 PS_ERRORTEXT_psVector_SORT_NULL); 312 psError(PS_ERR_BAD_PARAMETER_NULL, true, 313 PS_ERRORTEXT_psVector_SORT_NULL); 322 314 psFree(outVector); 323 315 return NULL; … … 400 392 break; 401 393 default: 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex", 403 PS_ERR_BAD_PARAMETER_TYPE, true, 404 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 405 inType); 394 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 395 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 396 inType); 406 397 } 407 398 -
trunk/psLib/src/psErrorCodes.dat
r1818 r2273 17 17 BAD_PARAMETER_SIZE size of parameter's data is outside of acceptable range. 18 18 UNEXPECTED_NULL unexpected NULL found 19 OS_CALL_FAILED unexpected result from an OS standard library call. -
trunk/psLib/src/sys/psError.c
r2204 r2273 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 67 67 } 68 68 69 void psError(const char *name, const char *fmt, ...) 69 psErrorCode p_psError(const char* file, 70 int lineno, 71 const char* func, 72 psErrorCode code, 73 psBool new, 74 const char* fmt, 75 ...) 70 76 { 71 va_list argPtr; // variable list arguement pointer 77 char errMsg[2048]; 78 psErr* err; 79 char msgName[256]; 72 80 73 // Get the variable list parameters to pass to logging function 74 va_start(argPtr, fmt); 75 76 // Call logging function with PS_LOG_ERROR level 77 psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr); 78 79 // Clean up stack after variable argument has been used 80 va_end(argPtr); 81 } 82 83 void psErrorClear() 84 { 85 pthread_mutex_lock(&lockErrorStack); 86 for (psS32 lcv=0;lcv<errorStackSize;lcv++) { 87 p_psMemSetPersistent(errorStack[lcv]->msg,false); 88 p_psMemSetPersistent(errorStack[lcv]->name,false); 89 p_psMemSetPersistent(errorStack[lcv],false); 90 psFree(errorStack[lcv]); 91 } 92 errorStackSize = 0; 93 pthread_mutex_unlock(&lockErrorStack); 94 } 95 96 psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...) 97 { 98 char errMsg[1024]; 99 psErr* err; 100 char* msgName; 101 102 // Check for null pointer and if found set to empty string; 103 if ( name == NULL ) { 104 msgName = ""; 105 } else { 106 msgName = (char*)name; 107 } 81 snprintf(msgName,256,"%s (%s:%d)",func,file,lineno); 108 82 109 83 va_list argPtr; // variable list arguement pointer … … 116 90 va_start(argPtr, fmt); 117 91 118 vsnprintf(errMsg, 1024,fmt,argPtr);92 vsnprintf(errMsg,2048,fmt,argPtr); 119 93 err = psErrAlloc(msgName,code,errMsg); 120 94 pushErrorStack(err); … … 160 134 } 161 135 136 void psErrorClear(void) 137 { 138 pthread_mutex_lock(&lockErrorStack); 139 140 for (int lcv=0;lcv < errorStackSize; lcv++) { 141 p_psMemSetPersistent(errorStack[lcv],false); 142 p_psMemSetPersistent(errorStack[lcv]->msg,false); 143 p_psMemSetPersistent(errorStack[lcv]->name,false); 144 psFree(errorStack[lcv]); 145 } 146 errorStackSize = 0; 147 148 pthread_mutex_unlock(&lockErrorStack); 149 150 } 162 151 void psErrorStackPrint(FILE *fd, const char *fmt, ...) 163 152 { -
trunk/psLib/src/sys/psError.h
r2204 r2273 12 12 * @author Eric Van Alst, MHPCC 13 13 * 14 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:31$14 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:05:00 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 104 104 * log message. 105 105 * 106 * This function modifies the error stack. 107 * 108 * @return psErrorCode the given error code 106 109 */ 107 void psError( 108 const char *name, ///< Source of error such as file or function detected 109 const char *fmt, ///< A printf style formatting statement defining msg 110 psErrorCode p_psError( 111 const char* file, 112 int lineno, 113 const char* func, 114 psErrorCode code, ///< Error class code 115 psBool new, ///< true if error originates at this location 116 const char* fmt, 110 117 ... 111 118 ); 112 119 113 /** Reports an error message to the logging facility 114 * 115 * This function will invoke the psLogMsg function with a level of 116 * PS_LOG_ERROR and pass the parameters name and fmt to generate a proper 117 * log message. 118 * 119 */ 120 psErrorCode psErrorMsg( 121 const char *name, ///< Name of error in the form aaa.bbb.ccc 122 psErrorCode code, ///< Error class code 123 psBool new, ///< true if error originates at this location 124 const char* fmt, ///< printf style formatting statement defining error message 125 ... 126 ); 120 #define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__) 127 121 128 122 /** Create a new psErr struct -
trunk/psLib/src/sys/psErrorCodes.c
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 46 46 {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"}, 47 47 {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"}, 49 {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"}, 49 50 //~End 50 51 {PS_ERR_N_ERR_CLASSES,"error classes end marker"} … … 132 133 133 134 if (errors == NULL) { 134 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 135 PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 135 psError(PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 137 137 return; 138 138 } … … 152 152 err) ) { 153 153 154 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 155 PS_ERR_UNKNOWN, false, 156 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 157 i); 154 psError(PS_ERR_UNKNOWN, false, 155 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 156 i); 158 157 } 159 158 p_psMemSetPersistent(dynamicErrorCodes->head,true); -
trunk/psLib/src/sys/psErrorCodes.h
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 PS_ERR_BAD_PARAMETER_NULL, ///< parameter is null 53 53 PS_ERR_BAD_PARAMETER_SIZE, ///< size of parameter's data is outside of acceptable range. 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL foun 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL found 55 PS_ERR_OS_CALL_FAILED, ///< unexpected result from an OS standard library call 55 56 //~End 56 57 PS_ERR_N_ERR_CLASSES ///< end marker - should not be used as a true error -
trunk/psLib/src/sys/psLogMsg.c
r2204 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:05:00 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 111 111 if (sscanf(dest, "%4s:%256s", protocol, location) < 2) { 112 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,114 dest);112 psError(PS_ERR_LOCATION_INVALID, true, 113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED, 114 dest); 115 115 return false; 116 116 } … … 131 131 return true; 132 132 } 133 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,135 location);133 psError(PS_ERR_LOCATION_INVALID, true, 134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID, 135 location); 136 136 return 1; 137 137 } else if (strcmp(protocol, "file") == 0) { … … 139 139 140 140 if (file == NULL) { 141 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,143 location);141 psError(PS_ERR_IO, true, 142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED, 143 location); 144 144 return false; 145 145 } … … 151 151 } 152 152 153 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,155 protocol);153 psError(PS_ERR_LOCATION_INVALID, true, 154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL, 155 protocol); 156 156 return false; 157 157 } … … 215 215 break; 216 216 default: 217 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);217 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr); 219 219 break; 220 220 } -
trunk/psLib/src/sys/psMemory.c
r2210 r2273 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-27 19:35:59$10 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:05:00 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 100 100 { 101 101 if (ptr->refCounter < 1) { 102 psError Msg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,104 ptr->id, ptr->file, ptr->lineno, file, lineno);102 psError(PS_ERR_MEMORY_CORRUPTION, false, 103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 104 ptr->id, ptr->file, ptr->lineno, file, lineno); 105 105 } 106 106 … … 228 228 229 229 if (m == NULL) { 230 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,231 PS_ERRORTEXT_psMemory_NULL_BLOCK);230 psError(PS_ERR_MEMORY_CORRUPTION, true, 231 PS_ERRORTEXT_psMemory_NULL_BLOCK); 232 232 return 1; 233 233 } … … 235 235 if (m->refCounter == 0) { 236 236 // using an unreferenced block of memory, are you? 237 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,239 m->id);237 psError(PS_ERR_MEMORY_CORRUPTION, true, 238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE, 239 m->id); 240 240 return 1; 241 241 } 242 242 243 243 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 244 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,245 PS_ERRORTEXT_psMemory_UNDERFLOW,246 m->id);244 psError(PS_ERR_MEMORY_CORRUPTION, true, 245 PS_ERRORTEXT_psMemory_UNDERFLOW, 246 m->id); 247 247 return 1; 248 248 } 249 249 if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) { 250 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,251 PS_ERRORTEXT_psMemory_OVERFLOW,252 m->id);250 psError(PS_ERR_MEMORY_CORRUPTION, true, 251 PS_ERRORTEXT_psMemory_OVERFLOW, 252 m->id); 253 253 return 1; 254 254 } … … 431 431 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 432 432 433 psError Msg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,435 ptr->id, ptr->file, ptr->lineno, file, lineno);433 psError(PS_ERR_MEMORY_DEREF_USAGE,true, 434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 435 ptr->id, ptr->file, ptr->lineno, file, lineno); 436 436 437 437 return; -
trunk/psLib/src/sys/psString.c
r2204 r2273 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:31$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 if (nChar < 0) { 39 39 // Log error message and return NULL 40 psError Msg(PS_ERRORNAME_DOMAIN "psStringNCopy",PS_ERR_BAD_PARAMETER_VALUE, true,41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE,42 nChar);40 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE, 42 nChar); 43 43 return NULL; 44 44 } -
trunk/psLib/src/sys/psTrace.c
r2221 r2273 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 23:31:44$11 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 161 161 // XXX: Verify that this is the correct behavior. 162 162 if (strcmp("", addNodeName) == 0) { 163 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);163 psError(PS_ERR_BAD_PARAMETER_NULL,true, 164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT); 165 165 return false; 166 166 } … … 173 173 174 174 if (addNodeName[0] != '.') { 175 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,177 addNodeName);175 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME, 177 addNodeName); 178 178 return false; 179 179 } … … 262 262 // Add the new component to the component tree. 263 263 if ( !componentAdd(compName, level) ) { 264 psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel", 265 PS_ERR_UNKNOWN, 266 false, 267 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 268 level, 269 compName); 264 psError(PS_ERR_UNKNOWN, false, 265 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 266 level, 267 compName); 270 268 271 269 if (comp[0] != '.') { … … 482 480 483 481 if (NULL == comp) { 484 psError Msg(PS_ERRORNAME_DOMAIN "psTrace",PS_ERR_BAD_PARAMETER_NULL, true,485 PS_ERRORTEXT_psTrace_NULL_TRACETREE,486 __func__);482 psError(PS_ERR_BAD_PARAMETER_NULL, true, 483 PS_ERRORTEXT_psTrace_NULL_TRACETREE, 484 __func__); 487 485 return; 488 486 } -
trunk/psLib/src/sysUtils/psError.c
r2204 r2273 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 67 67 } 68 68 69 void psError(const char *name, const char *fmt, ...) 69 psErrorCode p_psError(const char* file, 70 int lineno, 71 const char* func, 72 psErrorCode code, 73 psBool new, 74 const char* fmt, 75 ...) 70 76 { 71 va_list argPtr; // variable list arguement pointer 77 char errMsg[2048]; 78 psErr* err; 79 char msgName[256]; 72 80 73 // Get the variable list parameters to pass to logging function 74 va_start(argPtr, fmt); 75 76 // Call logging function with PS_LOG_ERROR level 77 psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr); 78 79 // Clean up stack after variable argument has been used 80 va_end(argPtr); 81 } 82 83 void psErrorClear() 84 { 85 pthread_mutex_lock(&lockErrorStack); 86 for (psS32 lcv=0;lcv<errorStackSize;lcv++) { 87 p_psMemSetPersistent(errorStack[lcv]->msg,false); 88 p_psMemSetPersistent(errorStack[lcv]->name,false); 89 p_psMemSetPersistent(errorStack[lcv],false); 90 psFree(errorStack[lcv]); 91 } 92 errorStackSize = 0; 93 pthread_mutex_unlock(&lockErrorStack); 94 } 95 96 psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...) 97 { 98 char errMsg[1024]; 99 psErr* err; 100 char* msgName; 101 102 // Check for null pointer and if found set to empty string; 103 if ( name == NULL ) { 104 msgName = ""; 105 } else { 106 msgName = (char*)name; 107 } 81 snprintf(msgName,256,"%s (%s:%d)",func,file,lineno); 108 82 109 83 va_list argPtr; // variable list arguement pointer … … 116 90 va_start(argPtr, fmt); 117 91 118 vsnprintf(errMsg, 1024,fmt,argPtr);92 vsnprintf(errMsg,2048,fmt,argPtr); 119 93 err = psErrAlloc(msgName,code,errMsg); 120 94 pushErrorStack(err); … … 160 134 } 161 135 136 void psErrorClear(void) 137 { 138 pthread_mutex_lock(&lockErrorStack); 139 140 for (int lcv=0;lcv < errorStackSize; lcv++) { 141 p_psMemSetPersistent(errorStack[lcv],false); 142 p_psMemSetPersistent(errorStack[lcv]->msg,false); 143 p_psMemSetPersistent(errorStack[lcv]->name,false); 144 psFree(errorStack[lcv]); 145 } 146 errorStackSize = 0; 147 148 pthread_mutex_unlock(&lockErrorStack); 149 150 } 162 151 void psErrorStackPrint(FILE *fd, const char *fmt, ...) 163 152 { -
trunk/psLib/src/sysUtils/psError.h
r2204 r2273 12 12 * @author Eric Van Alst, MHPCC 13 13 * 14 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:31$14 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:05:00 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 104 104 * log message. 105 105 * 106 * This function modifies the error stack. 107 * 108 * @return psErrorCode the given error code 106 109 */ 107 void psError( 108 const char *name, ///< Source of error such as file or function detected 109 const char *fmt, ///< A printf style formatting statement defining msg 110 psErrorCode p_psError( 111 const char* file, 112 int lineno, 113 const char* func, 114 psErrorCode code, ///< Error class code 115 psBool new, ///< true if error originates at this location 116 const char* fmt, 110 117 ... 111 118 ); 112 119 113 /** Reports an error message to the logging facility 114 * 115 * This function will invoke the psLogMsg function with a level of 116 * PS_LOG_ERROR and pass the parameters name and fmt to generate a proper 117 * log message. 118 * 119 */ 120 psErrorCode psErrorMsg( 121 const char *name, ///< Name of error in the form aaa.bbb.ccc 122 psErrorCode code, ///< Error class code 123 psBool new, ///< true if error originates at this location 124 const char* fmt, ///< printf style formatting statement defining error message 125 ... 126 ); 120 #define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__) 127 121 128 122 /** Create a new psErr struct -
trunk/psLib/src/sysUtils/psErrorCodes.c
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 46 46 {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"}, 47 47 {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"}, 49 {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"}, 49 50 //~End 50 51 {PS_ERR_N_ERR_CLASSES,"error classes end marker"} … … 132 133 133 134 if (errors == NULL) { 134 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 135 PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 135 psError(PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 137 137 return; 138 138 } … … 152 152 err) ) { 153 153 154 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 155 PS_ERR_UNKNOWN, false, 156 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 157 i); 154 psError(PS_ERR_UNKNOWN, false, 155 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 156 i); 158 157 } 159 158 p_psMemSetPersistent(dynamicErrorCodes->head,true); -
trunk/psLib/src/sysUtils/psErrorCodes.h
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 PS_ERR_BAD_PARAMETER_NULL, ///< parameter is null 53 53 PS_ERR_BAD_PARAMETER_SIZE, ///< size of parameter's data is outside of acceptable range. 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL foun 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL found 55 PS_ERR_OS_CALL_FAILED, ///< unexpected result from an OS standard library call 55 56 //~End 56 57 PS_ERR_N_ERR_CLASSES ///< end marker - should not be used as a true error -
trunk/psLib/src/sysUtils/psLogMsg.c
r2204 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:05:00 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 111 111 if (sscanf(dest, "%4s:%256s", protocol, location) < 2) { 112 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,114 dest);112 psError(PS_ERR_LOCATION_INVALID, true, 113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED, 114 dest); 115 115 return false; 116 116 } … … 131 131 return true; 132 132 } 133 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,135 location);133 psError(PS_ERR_LOCATION_INVALID, true, 134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID, 135 location); 136 136 return 1; 137 137 } else if (strcmp(protocol, "file") == 0) { … … 139 139 140 140 if (file == NULL) { 141 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,143 location);141 psError(PS_ERR_IO, true, 142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED, 143 location); 144 144 return false; 145 145 } … … 151 151 } 152 152 153 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,155 protocol);153 psError(PS_ERR_LOCATION_INVALID, true, 154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL, 155 protocol); 156 156 return false; 157 157 } … … 215 215 break; 216 216 default: 217 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);217 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr); 219 219 break; 220 220 } -
trunk/psLib/src/sysUtils/psMemory.c
r2210 r2273 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-27 19:35:59$10 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:05:00 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 100 100 { 101 101 if (ptr->refCounter < 1) { 102 psError Msg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,104 ptr->id, ptr->file, ptr->lineno, file, lineno);102 psError(PS_ERR_MEMORY_CORRUPTION, false, 103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 104 ptr->id, ptr->file, ptr->lineno, file, lineno); 105 105 } 106 106 … … 228 228 229 229 if (m == NULL) { 230 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,231 PS_ERRORTEXT_psMemory_NULL_BLOCK);230 psError(PS_ERR_MEMORY_CORRUPTION, true, 231 PS_ERRORTEXT_psMemory_NULL_BLOCK); 232 232 return 1; 233 233 } … … 235 235 if (m->refCounter == 0) { 236 236 // using an unreferenced block of memory, are you? 237 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,239 m->id);237 psError(PS_ERR_MEMORY_CORRUPTION, true, 238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE, 239 m->id); 240 240 return 1; 241 241 } 242 242 243 243 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 244 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,245 PS_ERRORTEXT_psMemory_UNDERFLOW,246 m->id);244 psError(PS_ERR_MEMORY_CORRUPTION, true, 245 PS_ERRORTEXT_psMemory_UNDERFLOW, 246 m->id); 247 247 return 1; 248 248 } 249 249 if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) { 250 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,251 PS_ERRORTEXT_psMemory_OVERFLOW,252 m->id);250 psError(PS_ERR_MEMORY_CORRUPTION, true, 251 PS_ERRORTEXT_psMemory_OVERFLOW, 252 m->id); 253 253 return 1; 254 254 } … … 431 431 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 432 432 433 psError Msg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,435 ptr->id, ptr->file, ptr->lineno, file, lineno);433 psError(PS_ERR_MEMORY_DEREF_USAGE,true, 434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 435 ptr->id, ptr->file, ptr->lineno, file, lineno); 436 436 437 437 return; -
trunk/psLib/src/sysUtils/psString.c
r2204 r2273 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:31$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 if (nChar < 0) { 39 39 // Log error message and return NULL 40 psError Msg(PS_ERRORNAME_DOMAIN "psStringNCopy",PS_ERR_BAD_PARAMETER_VALUE, true,41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE,42 nChar);40 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE, 42 nChar); 43 43 return NULL; 44 44 } -
trunk/psLib/src/sysUtils/psTrace.c
r2221 r2273 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 23:31:44$11 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 161 161 // XXX: Verify that this is the correct behavior. 162 162 if (strcmp("", addNodeName) == 0) { 163 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);163 psError(PS_ERR_BAD_PARAMETER_NULL,true, 164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT); 165 165 return false; 166 166 } … … 173 173 174 174 if (addNodeName[0] != '.') { 175 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,177 addNodeName);175 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME, 177 addNodeName); 178 178 return false; 179 179 } … … 262 262 // Add the new component to the component tree. 263 263 if ( !componentAdd(compName, level) ) { 264 psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel", 265 PS_ERR_UNKNOWN, 266 false, 267 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 268 level, 269 compName); 264 psError(PS_ERR_UNKNOWN, false, 265 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 266 level, 267 compName); 270 268 271 269 if (comp[0] != '.') { … … 482 480 483 481 if (NULL == comp) { 484 psError Msg(PS_ERRORNAME_DOMAIN "psTrace",PS_ERR_BAD_PARAMETER_NULL, true,485 PS_ERRORTEXT_psTrace_NULL_TRACETREE,486 __func__);482 psError(PS_ERR_BAD_PARAMETER_NULL, true, 483 PS_ERRORTEXT_psTrace_NULL_TRACETREE, 484 __func__); 487 485 return; 488 486 } -
trunk/psLib/src/types/psBitSet.c
r2204 r2273 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 72 72 73 73 if (n < 0) { 74 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc", 75 PS_ERR_BAD_PARAMETER_VALUE, true, 76 PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE, 77 n); 74 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 75 PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE, 76 n); 78 77 return NULL; 79 78 } … … 99 98 100 99 if (inBitSet == NULL) { 101 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet", 102 PS_ERR_BAD_PARAMETER_NULL, true, 103 PS_ERRORTEXT_psBitSet_SET_NULL); 100 psError(PS_ERR_BAD_PARAMETER_NULL, true, 101 PS_ERRORTEXT_psBitSet_SET_NULL); 104 102 return inBitSet; 105 103 } else if ( (bit < 0) || 106 104 (bit > inBitSet->n * 8 - 1) ) { 107 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet", 108 PS_ERR_BAD_PARAMETER_VALUE, true, 109 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 110 bit,inBitSet->n * 8 - 1); 105 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 106 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 107 bit,inBitSet->n * 8 - 1); 111 108 return inBitSet; 112 109 } … … 124 121 125 122 if (inBitSet == NULL) { 126 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear", 127 PS_ERR_BAD_PARAMETER_NULL, true, 128 PS_ERRORTEXT_psBitSet_SET_NULL); 123 psError(PS_ERR_BAD_PARAMETER_NULL, true, 124 PS_ERRORTEXT_psBitSet_SET_NULL); 129 125 return inBitSet; 130 126 } else if ( (bit < 0) || 131 127 (bit > inBitSet->n * 8 - 1) ) { 132 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear", 133 PS_ERR_BAD_PARAMETER_VALUE, true, 134 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 135 bit,inBitSet->n * 8 - 1); 128 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 129 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 130 bit,inBitSet->n * 8 - 1); 136 131 return inBitSet; 137 132 } … … 149 144 150 145 if (inBitSet == NULL) { 151 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest", 152 PS_ERR_BAD_PARAMETER_NULL, true, 153 PS_ERRORTEXT_psBitSet_SET_NULL); 146 psError(PS_ERR_BAD_PARAMETER_NULL, true, 147 PS_ERRORTEXT_psBitSet_SET_NULL); 154 148 return false; 155 149 } else if ( (bit < 0) || 156 150 (bit > inBitSet->n * 8 - 1) ) { 157 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest", 158 PS_ERR_BAD_PARAMETER_VALUE, true, 159 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 160 bit,inBitSet->n * 8 - 1); 151 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 152 PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE, 153 bit,inBitSet->n * 8 - 1); 161 154 return false; 162 155 } … … 180 173 181 174 if (inBitSet1 == NULL) { 182 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 183 PS_ERR_BAD_PARAMETER_NULL, true, 184 PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL); 175 psError(PS_ERR_BAD_PARAMETER_NULL, true, 176 PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL); 185 177 psFree(outBitSet); 186 178 return NULL; … … 189 181 190 182 if (operator == NULL) { 191 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 192 PS_ERR_BAD_PARAMETER_NULL, true, 193 PS_ERRORTEXT_psBitSet_OPERATOR_NULL); 183 psError(PS_ERR_BAD_PARAMETER_NULL, true, 184 PS_ERRORTEXT_psBitSet_OPERATOR_NULL); 194 185 psFree(outBitSet); 195 186 return NULL; … … 217 208 psFree(tempStr); 218 209 psFree(outBitSet); 219 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 220 PS_ERR_BAD_PARAMETER_VALUE, true, 221 PS_ERRORTEXT_psBitSet_OPERATOR_INVALID, 222 operator); 210 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 211 PS_ERRORTEXT_psBitSet_OPERATOR_INVALID, 212 operator); 223 213 return NULL; 224 214 } … … 227 217 if (op != NOT_OP) { 228 218 if (inBitSet2 == NULL) { 229 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 230 PS_ERR_BAD_PARAMETER_NULL, true, 231 PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL); 219 psError(PS_ERR_BAD_PARAMETER_NULL, true, 220 PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL); 232 221 psFree(outBitSet); 233 222 return NULL; … … 235 224 236 225 if (inBitSet1->n != inBitSet2->n) { 237 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp", 238 PS_ERR_BAD_PARAMETER_SIZE, true, 239 PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER); 226 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 227 PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER); 240 228 psFree(outBitSet); 241 229 return NULL; … … 287 275 { 288 276 if (inBitSet == NULL) { 289 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot", 290 PS_ERR_BAD_PARAMETER_NULL, true, 291 PS_ERRORTEXT_psBitSet_OPERAND_NULL); 277 psError(PS_ERR_BAD_PARAMETER_NULL, true, 278 PS_ERRORTEXT_psBitSet_OPERAND_NULL); 292 279 psFree(outBitSet); 293 280 return NULL; … … 297 284 298 285 if (outBitSet == NULL) { 299 psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot", 300 PS_ERR_UNKNOWN, false, 301 PS_ERRORTEXT_psBitSet_NOT_OP_FAILED); 286 psError(PS_ERR_UNKNOWN, false, 287 PS_ERRORTEXT_psBitSet_NOT_OP_FAILED); 302 288 } 303 289 -
trunk/psLib/src/types/psHash.c
r2221 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 23:31:43$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:04:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 228 228 // the way this procedure is called. 229 229 if ((table == NULL) || (key == NULL)) { 230 psErrorMsg(PS_ERRORNAME_DOMAIN "doHashWork", 231 PS_ERR_BAD_PARAMETER_NULL, true, 232 PS_ERRORTEXT_psHash_KEY_NULL); 230 psError(PS_ERR_BAD_PARAMETER_NULL, true, 231 PS_ERRORTEXT_psHash_KEY_NULL); 233 232 return NULL; 234 233 } … … 249 248 // anyway. 250 249 if ((hash < 0) || (hash >= table->nbucket)) { 251 psError(__func__, "Internal hash function out of range (%d)", hash); 250 psError(PS_ERR_UNKNOWN, true, 251 "Internal hash function out of range (%d)", hash); 252 252 } 253 253 // ptr will have the correct hash bucket. … … 347 347 { 348 348 if (table == NULL) { 349 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 350 PS_ERR_BAD_PARAMETER_NULL, true, 351 PS_ERRORTEXT_psHash_KEY_NULL); 349 psError(PS_ERR_BAD_PARAMETER_NULL, true, 350 PS_ERRORTEXT_psHash_KEY_NULL); 352 351 return false; 353 352 } 354 353 if (key == NULL) { 355 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 356 PS_ERR_BAD_PARAMETER_NULL, true, 357 PS_ERRORTEXT_psHash_TABLE_NULL); 354 psError(PS_ERR_BAD_PARAMETER_NULL, true, 355 PS_ERRORTEXT_psHash_TABLE_NULL); 358 356 return false; 359 357 } 360 358 if (data == NULL) { 361 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd", 362 PS_ERR_BAD_PARAMETER_NULL, true, 363 PS_ERRORTEXT_psHash_DATA_NULL); 359 psError(PS_ERR_BAD_PARAMETER_NULL, true, 360 PS_ERRORTEXT_psHash_DATA_NULL); 364 361 } 365 362 … … 382 379 { 383 380 if (table == NULL) { 384 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup", 385 PS_ERR_BAD_PARAMETER_NULL, true, 386 PS_ERRORTEXT_psHash_KEY_NULL); 381 psError(PS_ERR_BAD_PARAMETER_NULL, true, 382 PS_ERRORTEXT_psHash_KEY_NULL); 387 383 return NULL; 388 384 } 389 385 if (key == NULL) { 390 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup", 391 PS_ERR_BAD_PARAMETER_NULL, true, 392 PS_ERRORTEXT_psHash_TABLE_NULL); 386 psError(PS_ERR_BAD_PARAMETER_NULL, true, 387 PS_ERRORTEXT_psHash_TABLE_NULL); 393 388 return NULL; 394 389 } … … 414 409 415 410 if (table == NULL) { 416 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove", 417 PS_ERR_BAD_PARAMETER_NULL, true, 418 PS_ERRORTEXT_psHash_TABLE_NULL); 411 psError(PS_ERR_BAD_PARAMETER_NULL, true, 412 PS_ERRORTEXT_psHash_TABLE_NULL); 419 413 return false; 420 414 } 421 415 if (key == NULL) { 422 psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove", 423 PS_ERR_BAD_PARAMETER_NULL, true, 424 PS_ERRORTEXT_psHash_KEY_NULL); 416 psError(PS_ERR_BAD_PARAMETER_NULL, true, 417 PS_ERRORTEXT_psHash_KEY_NULL); 425 418 return false; 426 419 } -
trunk/psLib/src/types/psList.c
r2204 r2273 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:31$8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:04:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 136 136 137 137 if (position == NULL) { 138 psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location); 138 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 139 "Failed to move cursor to specified location (%d)", location); 139 140 position = list->head; // since we no list->size != 0, this must be non-NULL 140 141 } … … 173 174 174 175 if (list == NULL) { 175 psError( __func__, "list parameter found to be NULL in %s", __func__);176 psError(PS_ERR_BAD_PARAMETER_NULL, true, "list parameter found to be NULL."); 176 177 return false; 177 178 } … … 194 195 195 196 if (location == PS_LIST_UNKNOWN) { 196 psError( __func__, "Failed to find item in given psList.");197 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Failed to find item in given psList."); 197 198 pthread_mutex_unlock(&list->lock) 198 199 ; … … 206 207 207 208 if (elem == NULL) { 208 psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location); 209 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 210 "Couldn't position to given index (%d) to remove element from list.", location); 209 211 pthread_mutex_unlock(&list->lock) 210 212 ; … … 257 259 258 260 if (list == NULL) { 259 psError(__func__, "Unexpected null pointer for psList parameter (%s:%d).", __FILE__, __LINE__); 261 psError(PS_ERR_BAD_PARAMETER_NULL, true, 262 "Unexpected null pointer for psList parameter."); 260 263 return; 261 264 } … … 314 317 default: 315 318 if (where <= PS_LIST_HEAD) { // bascially same as PS_LIST_UNKNOWN above 316 psError(__func__, "Can't move to an unknown position. Not moving the iterator position."); 319 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 320 "Can't move to an unknown position. Not moving the iterator position."); 317 321 } else { 318 322 cursor = listGetIterator(list); -
trunk/psLib/src/types/psMetadata.c
r2204 r2273 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:30$14 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:04:57 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "psMetadata.h" 36 36 #include "psString.h" 37 #include "psAstronomyErrors.h" 38 #include "psConstants.h" 37 39 38 40 /******************************************************************************/ … … 123 125 124 126 125 if (name == NULL) { 126 psError(__func__, "Null value for name not allowed"); 127 return NULL; 128 } 127 PS_PTR_CHECK_NULL(name,NULL); 128 129 129 // Allocate metadata item 130 130 metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem)); … … 147 147 // Set metadata item type 148 148 metadataItem->type = type; 149 metadataItem->data.V = NULL; 150 151 // Allocate metadata items with same name. 152 metadataItem->items = psListAlloc(NULL); 153 154 // Allocate and set metadata item name 155 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 156 vsprintf(metadataItem->name, name, argPtr); 149 157 150 158 // Set metadata item value 151 159 switch (type) { 152 160 case PS_META_ITEM_SET: 153 metadataItem->data.V = NULL;154 161 break; 155 162 case PS_META_BOOL: … … 180 187 case PS_META_UNKNOWN: 181 188 default: 182 psError(__func__, "Invalid psMetadataType: %d", type); 183 } 184 185 // Allocate and set metadata item name 186 metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH); 187 vsprintf(metadataItem->name, name, argPtr); 188 189 // Allocate metadata items with same name. 190 metadataItem->items = psListAlloc(NULL); 189 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 190 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 191 type); 192 psFree(metadataItem); 193 metadataItem = NULL; 194 } 191 195 192 196 return metadataItem; … … 224 228 psMetadataType newType = PS_META_ITEM_SET; 225 229 226 if(md == NULL) { 227 psError( __func__, "Null metadata collection not allowed" ); 228 return false; 229 } 230 231 if(metadataItem == NULL) { 232 psError( __func__, "Null metadata item not allowed" ); 233 return false; 234 } 230 PS_PTR_CHECK_NULL(md,NULL); 231 PS_PTR_CHECK_NULL(md->table,NULL); 232 PS_PTR_CHECK_NULL(md->list,NULL); 233 PS_PTR_CHECK_NULL(metadataItem,NULL); 234 PS_PTR_CHECK_NULL(metadataItem->name,NULL); 235 235 236 236 newType = metadataItem->type; 237 238 237 mdTable = md->table; 239 if(mdTable == NULL) {240 psError( __func__, "Null metadata table not allowed" );241 return false;242 }243 244 238 mdList = md->list; 245 if(mdList == NULL) {246 psError( __func__, "Null metadata list not allowed");247 return false;248 }249 250 239 key = metadataItem->name; 251 if(key == NULL) {252 psError(__func__, "Null key item not allowed");253 return false;254 }255 240 256 241 // See if key is already in table … … 262 247 // Add leaf node to existing folder node 263 248 if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) { 264 psError( __func__, "Couldn't add metadata item to items list. Name: %s", 265 metadataItem->name ); 249 psError(PS_ERR_UNKNOWN,false, 250 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 251 metadataItem->name ); 266 252 return false; 267 253 } … … 272 258 273 259 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) { 274 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 260 psError(PS_ERR_UNKNOWN,false, 261 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 262 key); 275 263 psFree(newFolderEntry); 276 264 return false; … … 278 266 279 267 if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) { 280 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 268 psError(PS_ERR_UNKNOWN,false, 269 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 270 key); 281 271 psFree(newFolderEntry); 282 272 return false; … … 284 274 285 275 if(!psHashRemove(mdTable, key)) { 286 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 276 psError(PS_ERR_UNKNOWN,false, 277 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 278 key); 287 279 psFree(newFolderEntry); 288 280 return false; … … 290 282 291 283 if(!psHashAdd(mdTable, key, newFolderEntry)) { 292 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 284 psError(PS_ERR_UNKNOWN,false, 285 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 286 key); 293 287 psFree(newFolderEntry); 294 288 return false; … … 301 295 // Folder node replaces leaf or folder node - Put old node into new folder and remove from table 302 296 if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) { 303 psError( __func__, "Couldn't add metadata item to items list. Name: %s", key); 297 psError(PS_ERR_UNKNOWN,false, 298 PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED, 299 key); 304 300 return false; 305 301 } 306 302 307 303 if(!psHashRemove(mdTable, key)) { 308 psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key); 304 psError(PS_ERR_UNKNOWN,false, 305 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 306 key); 309 307 return false; 310 308 } 311 309 312 310 if(!psHashAdd(mdTable, key, metadataItem)) { 313 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 311 psError(PS_ERR_UNKNOWN,false, 312 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 313 key); 314 314 return false; 315 315 } … … 319 319 // Node doesn't exist - Add new metadata item to metadata collection's hash 320 320 if(!psHashAdd(mdTable, key, metadataItem)) { 321 psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key); 321 psError(PS_ERR_UNKNOWN,false, 322 PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED, 323 key); 322 324 return false; 323 325 } … … 328 330 if(metadataItem->type != PS_META_ITEM_SET) { 329 331 if(!psListAdd(mdList, location, metadataItem)) { 330 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s", 331 metadataItem->name ); 332 psError(PS_ERR_UNKNOWN,false, 333 PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED, 334 key); 332 335 return false; 333 336 } … … 348 351 349 352 if (!psMetadataAddItem(md, metadataItem, where)) { 350 psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",351 metadataItem->name);353 psError(PS_ERR_UNKNOWN,false, 354 PS_ERRORTEXT_psMetadata_ADD_FAILED); 352 355 psFree(metadataItem); 353 356 return false; … … 368 371 369 372 370 if (md == NULL) { 371 psError(__func__, "Null metadata collection not allowed"); 372 return false; 373 } 373 PS_PTR_CHECK_NULL(md,NULL); 374 PS_PTR_CHECK_NULL(md->table,NULL); 375 PS_PTR_CHECK_NULL(md->list,NULL); 374 376 375 377 mdList = md->list; 376 if (mdList == NULL) {377 psError(__func__, "Null metadata list not allowed");378 return false;379 }380 381 378 mdTable = md->table; 382 if (mdTable == NULL) { 383 psError(__func__, "Null metadata table not allowed"); 384 return false; 385 } 379 386 380 // Select removal by key or index 387 381 if (key != NULL) { … … 390 384 entry = (psMetadataItem* ) psHashLookup(mdTable, key); 391 385 if (entry == NULL) { 392 psError(__func__, "Couldn't find metadata item. Name: %s", key); 386 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 387 PS_ERRORTEXT_psMetadata_FIND_FAILED, 388 key); 393 389 return false; 394 390 } … … 402 398 while (entryChild != NULL) { 403 399 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) { 404 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 400 psError(PS_ERR_UNKNOWN,false, 401 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 402 key); 405 403 return false; 406 404 } … … 411 409 // Table entry has no children. Remove entry from metadata collection's list 412 410 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) { 413 psError(__func__, "Couldn't remove metadata item from list. Name: %s", key); 411 psError(PS_ERR_UNKNOWN,false, 412 PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED, 413 key); 414 414 return false; 415 415 } … … 417 417 // Remove entry from metadata collection's table 418 418 if (!psHashRemove(mdTable, key)) { 419 psError(__func__, "Couldn't remove metadata item from table. Name: %s", key); 419 psError(PS_ERR_UNKNOWN,false, 420 PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED, 421 key); 420 422 return false; 421 423 } … … 425 427 entry = psListGet(mdList, where); 426 428 if (entry == NULL) { 427 psError(__func__, "Couldn't find metadata item in list. Index: %d", where); 429 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 430 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 431 where); 428 432 return false; 429 433 } … … 431 435 key = entry->name; 432 436 if (key == NULL) { 433 psError(__func__, "Null key name not allowed. Index: %d", where); 437 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 438 PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED, 439 where); 434 440 return false; 435 441 } … … 447 453 448 454 449 if (md == NULL) { 450 psError(__func__, "Null metadata collection not allowed"); 451 return NULL; 452 } 455 PS_PTR_CHECK_NULL(md,NULL); 456 PS_PTR_CHECK_NULL(md->table,NULL); 457 PS_PTR_CHECK_NULL(key,NULL); 453 458 454 459 mdTable = md->table; 455 if (mdTable == NULL) {456 psError(__func__, "Null metadata table not allowed");457 return NULL;458 }459 460 if (key == NULL) {461 psError(__func__, "Null key name not allowed");462 return NULL;463 }464 460 465 461 entry = (psMetadataItem* ) psHashLookup(mdTable, key); … … 473 469 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where) 474 470 { 471 psMetadataItem* entry = NULL; 472 473 PS_PTR_CHECK_NULL(md,NULL); 474 PS_PTR_CHECK_NULL(md->list,NULL); 475 476 entry = (psMetadataItem* ) psListGet(md->list, where); 477 if (entry == NULL) { 478 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 479 PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED, 480 where); 481 return NULL; 482 } 483 484 return entry; 485 } 486 487 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where) 488 { 489 PS_PTR_CHECK_NULL(md,NULL); 490 PS_PTR_CHECK_NULL(md->list,NULL); 491 492 psListSetIterator(md->list, where); 493 494 return true; 495 } 496 497 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which) 498 { 475 499 psList* mdList = NULL; 476 500 psMetadataItem* entry = NULL; 477 501 478 502 479 if (md == NULL) { 480 psError(__func__, "Null metadata collection not allowed"); 481 return NULL; 482 } 503 PS_PTR_CHECK_NULL(md,NULL); 504 PS_PTR_CHECK_NULL(md->list,NULL); 483 505 484 506 mdList = md->list; 485 if (mdList == NULL) {486 psError(__func__, "Null metadata list not allowed");487 return NULL;488 }489 490 entry = (psMetadataItem* ) psListGet(mdList, where);491 if (entry == NULL) {492 psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);493 return NULL;494 }495 496 return entry;497 }498 499 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)500 {501 psList* mdList = NULL;502 503 if (md == NULL) {504 psError(__func__, "Null metadata collection not allowed");505 return false;506 }507 508 mdList = md->list;509 if (mdList == NULL) {510 psError(__func__, "Null metadata list not allowed");511 return false;512 }513 514 psListSetIterator(mdList, where);515 516 return true;517 }518 519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)520 {521 psList* mdList = NULL;522 psMetadataItem* entry = NULL;523 524 525 if (md == NULL) {526 psError(__func__, "Null metadata collection not allowed");527 return NULL;528 }529 530 mdList = md->list;531 if (mdList == NULL) {532 psError(__func__, "Null metadata list not allowed");533 return NULL;534 }535 507 536 508 psListSetIterator(mdList, which); … … 559 531 560 532 561 if (md == NULL) { 562 psError(__func__, "Null metadata collection not allowed"); 563 return NULL; 564 } 533 PS_PTR_CHECK_NULL(md,NULL); 534 PS_PTR_CHECK_NULL(md->list,NULL); 565 535 566 536 mdList = md->list; 567 if (mdList == NULL) {568 psError(__func__, "Null metadata list not allowed");569 return NULL;570 }571 537 572 538 psListSetIterator(mdList, which); -
trunk/psLib/src/types/psMetadataConfig.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 fits_get_errstatus(status, fitsErr); \ 45 psError( __func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \47 psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *status = 1; 283 psError(__func__, "Invalid type: %d", elemType); 285 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 286 PS_ERRORTEXT_psMetadataIO_TYPE_INVALID, 287 elemType); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 304 if (fd == NULL) { 305 psError(__func__, "Null file descriptor not allowed"); 306 return; 307 } 308 309 if (format == NULL) { 310 psError(__func__, "Null format not allowed"); 311 return; 312 } 313 314 if (metadataItem == NULL) { 315 psError(__func__, "Null metadata not allowed"); 316 return; 317 } 308 PS_PTR_CHECK_NULL(fd,); 309 PS_PTR_CHECK_NULL(format,); 310 PS_PTR_CHECK_NULL(metadataItem,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 default: 338 psError(__func__, " Invalid psMetadataType to print: %d", type); 331 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 332 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 333 (int)type); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 371 if (extName == NULL && extNum == 0) { 372 psError(__func__, "Null extName and extNum = 0 not allowed"); 373 return NULL; 374 } else if (extName && (extNum != -1) ) { 375 psError(__func__, "If extName specified, extNum arguments should be -1."); 363 if (extName == NULL && extNum < 1) { 364 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 365 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE, 366 extNum); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 if (!success) { 442 psError(__func__, "Failed to add metadata item. Name: %s", keyName); 435 psError(PS_ERR_UNKNOWN, false, 436 PS_ERRORTEXT_psMetadataIO_ADD_FAILED, 437 keyName); 443 438 return output; 444 439 } … … 471 466 472 467 // Check for nulls 473 if(fileName == NULL) {474 psError(__func__, "Null fileName not allowed");475 return -1;476 } else if((fp=fopen(fileName, "r")) == NULL) {477 psError(__func__, "Couldn't open file. Name: %s",fileName);468 PS_PTR_CHECK_NULL(fileName,-1); 469 if((fp=fopen(fileName, "r")) == NULL) { 470 psError(PS_ERR_IO, true, 471 PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, 472 fileName); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 failedLines++; 506 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 498 psError(PS_ERR_IO, true, 499 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 500 '@', lineCount, fileName); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 failedLines++; 510 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line); 504 psError(PS_ERR_IO, true, 505 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 506 '*', lineCount, fileName); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 failedLines++; 514 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 510 psError(PS_ERR_IO, true, 511 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 512 '~', lineCount, fileName); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 status = 0; 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 521 psError(PS_ERR_IO, true, 522 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 523 "name",lineCount, fileName); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 status = 0; 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 532 psError(PS_ERR_IO, true, 533 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 534 "type",lineCount, fileName); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 failedLines++; 553 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line); 555 psError(PS_ERR_IO, true, 556 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 557 strType, lineCount, fileName); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 status = 0; 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 571 psError(PS_ERR_IO, true, 572 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 573 "value",lineCount, fileName); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 583 psError(PS_ERR_IO, true, 584 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 585 "comment",lineCount, fileName); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 failedLines++; 591 psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName, 592 lineCount, line); 599 psError(PS_ERR_IO, true, 600 PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, 601 strName, lineCount, fileName); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 failedLines++; 610 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 619 psError(PS_ERR_IO, true, 620 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 621 strValue, strName, strType, lineCount, fileName); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 failedLines++; 621 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 632 psError(PS_ERR_IO, true, 633 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 634 strValue, strName, strType, lineCount, fileName); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 failedLines++; 633 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 646 psError(PS_ERR_IO, true, 647 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 648 strValue, strName, strType, lineCount, fileName); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 failedLines++; 647 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 662 psError(PS_ERR_IO, true, 663 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 664 strValue, strName, strType, lineCount, fileName); 648 665 continue; 649 666 } … … 651 668 default: 652 669 failedLines++; 653 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line); 670 psError(PS_ERR_IO, true, 671 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 672 mdType, lineCount, fileName); 654 673 continue; 655 674 } // switch -
trunk/psLib/src/xml/psXML.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 fits_get_errstatus(status, fitsErr); \ 45 psError( __func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \47 psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *status = 1; 283 psError(__func__, "Invalid type: %d", elemType); 285 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 286 PS_ERRORTEXT_psMetadataIO_TYPE_INVALID, 287 elemType); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 304 if (fd == NULL) { 305 psError(__func__, "Null file descriptor not allowed"); 306 return; 307 } 308 309 if (format == NULL) { 310 psError(__func__, "Null format not allowed"); 311 return; 312 } 313 314 if (metadataItem == NULL) { 315 psError(__func__, "Null metadata not allowed"); 316 return; 317 } 308 PS_PTR_CHECK_NULL(fd,); 309 PS_PTR_CHECK_NULL(format,); 310 PS_PTR_CHECK_NULL(metadataItem,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 default: 338 psError(__func__, " Invalid psMetadataType to print: %d", type); 331 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 332 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 333 (int)type); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 371 if (extName == NULL && extNum == 0) { 372 psError(__func__, "Null extName and extNum = 0 not allowed"); 373 return NULL; 374 } else if (extName && (extNum != -1) ) { 375 psError(__func__, "If extName specified, extNum arguments should be -1."); 363 if (extName == NULL && extNum < 1) { 364 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 365 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE, 366 extNum); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 if (!success) { 442 psError(__func__, "Failed to add metadata item. Name: %s", keyName); 435 psError(PS_ERR_UNKNOWN, false, 436 PS_ERRORTEXT_psMetadataIO_ADD_FAILED, 437 keyName); 443 438 return output; 444 439 } … … 471 466 472 467 // Check for nulls 473 if(fileName == NULL) {474 psError(__func__, "Null fileName not allowed");475 return -1;476 } else if((fp=fopen(fileName, "r")) == NULL) {477 psError(__func__, "Couldn't open file. Name: %s",fileName);468 PS_PTR_CHECK_NULL(fileName,-1); 469 if((fp=fopen(fileName, "r")) == NULL) { 470 psError(PS_ERR_IO, true, 471 PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, 472 fileName); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 failedLines++; 506 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 498 psError(PS_ERR_IO, true, 499 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 500 '@', lineCount, fileName); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 failedLines++; 510 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line); 504 psError(PS_ERR_IO, true, 505 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 506 '*', lineCount, fileName); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 failedLines++; 514 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 510 psError(PS_ERR_IO, true, 511 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 512 '~', lineCount, fileName); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 status = 0; 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 521 psError(PS_ERR_IO, true, 522 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 523 "name",lineCount, fileName); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 status = 0; 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 532 psError(PS_ERR_IO, true, 533 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 534 "type",lineCount, fileName); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 failedLines++; 553 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line); 555 psError(PS_ERR_IO, true, 556 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 557 strType, lineCount, fileName); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 status = 0; 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 571 psError(PS_ERR_IO, true, 572 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 573 "value",lineCount, fileName); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 583 psError(PS_ERR_IO, true, 584 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 585 "comment",lineCount, fileName); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 failedLines++; 591 psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName, 592 lineCount, line); 599 psError(PS_ERR_IO, true, 600 PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, 601 strName, lineCount, fileName); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 failedLines++; 610 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 619 psError(PS_ERR_IO, true, 620 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 621 strValue, strName, strType, lineCount, fileName); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 failedLines++; 621 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 632 psError(PS_ERR_IO, true, 633 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 634 strValue, strName, strType, lineCount, fileName); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 failedLines++; 633 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 646 psError(PS_ERR_IO, true, 647 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 648 strValue, strName, strType, lineCount, fileName); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 failedLines++; 647 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 662 psError(PS_ERR_IO, true, 663 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 664 strValue, strName, strType, lineCount, fileName); 648 665 continue; 649 666 } … … 651 668 default: 652 669 failedLines++; 653 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line); 670 psError(PS_ERR_IO, true, 671 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 672 mdType, lineCount, fileName); 654 673 continue; 655 674 } // switch -
trunk/psLib/test/astronomy/tst_psMetadata_01.c
r2204 r2273 17 17 * @author Ross Harman, MHPCC 18 18 * 19 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $20 * @date $Date: 2004-1 0-27 00:57:33$19 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 20 * @date $Date: 2004-11-04 01:05:00 $ 21 21 * 22 22 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 227 227 metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits"); 228 228 if (metadata1 != NULL ) { 229 psError( __func__,"psMetadataReadHeader did not return null when invalid ext given.");229 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null when invalid ext given."); 230 230 return 10; 231 231 } … … 238 238 metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits"); 239 239 if (metadata1 != NULL ) { 240 psError( __func__,"psMetadataReadHeader did not return null invalid extname give.");240 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null invalid extname give."); 241 241 return 11; 242 242 } … … 249 249 metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits"); 250 250 if (metadata1 != NULL ) { 251 psError( __func__,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");251 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum"); 252 252 return 12; 253 253 } -
trunk/psLib/test/astronomy/tst_psMetadata_02.c
r2204 r2273 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-1 0-27 00:57:33$16 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-11-04 01:05:00 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 92 92 badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD"); 93 93 if (badItem != NULL) { 94 psError( __func__,"psMetadataItemAlloc did not return null with null name item.");94 psError(PS_ERR_UNKNOWN, true,"psMetadataItemAlloc did not return null with null name item."); 95 95 return 10; 96 96 } -
trunk/psLib/test/astronomy/tst_psMetadata_03.c
r2204 r2273 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-1 0-27 00:57:33$16 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-11-04 01:05:00 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 91 91 printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name"); 92 92 if( ! psMetadataAddItem(metadata, item1, PS_LIST_HEAD) ) { 93 psError( __func__,"psMetadataAddItem did not return true when adding by name.");93 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name."); 94 94 return 10; 95 95 } 96 96 if( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem2",PS_META_S32,"I am S32 integer",77) ) { 97 psError( __func__,"psMetadataAddItem did not return true when adding by name.");97 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name."); 98 98 return 11; 99 99 } 100 100 if ( ! psMetadataRemove(metadata, 0, "myItem1" ) ) { 101 psError( __func__,"psMetadataRemove did not return true when removing by name.");101 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name."); 102 102 return 12; 103 103 } 104 104 if ( ! psMetadataRemove(metadata, 0, "myItem2" ) ) { 105 psError( __func__,"psMetadataRemove did not return true when removing by name.");105 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name."); 106 106 return 13; 107 107 } … … 112 112 printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index"); 113 113 if ( ! psMetadataAddItem(metadata, item3, PS_LIST_HEAD) ) { 114 psError( __func__,"psMetadataAddItem did not return true when adding by index.");114 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index."); 115 115 return 14; 116 116 } 117 117 if ( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem4",PS_META_S32,"I am S32 integer",88) ) { 118 psError( __func__,"psMetadataAddItem did not return true when adding by index.");118 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index."); 119 119 return 15; 120 120 } 121 121 if( ! psMetadataRemove(metadata, 0, NULL) ) { 122 psError( __func__,"psMetadataRemove did not return true when removing by index.");122 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index."); 123 123 return 16; 124 124 } 125 125 if ( ! psMetadataRemove(metadata, 0, NULL ) ) { 126 psError( __func__,"psMetadataRemove did not return true when removing by index.");126 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index."); 127 127 return 17; 128 128 } … … 134 134 "Null metadata collection not allowed", 0); 135 135 if ( psMetadataRemove(NULL, 0, NULL) ) { 136 psError( __func__,"psMetadataRemove did not return false when removing from null metadata.");136 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing from null metadata."); 137 137 return 18; 138 138 } … … 144 144 "Couldn't find metadata item. Name: AARGH", 0); 145 145 if( psMetadataRemove(metadata, 0, "AARGH") ) { 146 psError( __func__,"psMetadataRemove did not return false when removing non-existant item.");146 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item."); 147 147 return 19; 148 148 } … … 154 154 "Couldn't find metadata item in list. Index: 22", 0); 155 155 if( psMetadataRemove(metadata, 22, NULL) ) { 156 psError( __func__,"psMetadataRemove did not return false when removing non-existant item.");156 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item."); 157 157 return 20; 158 158 } … … 167 167 errMetadata->table = NULL; 168 168 if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) { 169 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");169 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table."); 170 170 return 21; 171 171 } 172 172 if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) { 173 psError( __func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");173 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table."); 174 174 return 31; 175 175 } … … 183 183 errMetadata->list = NULL; 184 184 if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) { 185 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");185 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list."); 186 186 return 22; 187 187 } 188 188 if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) { 189 psError( __func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");189 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list."); 190 190 return 32; 191 191 } … … 199 199 errItem->name = NULL; 200 200 if ( psMetadataAddItem(errMetadata, errItem, PS_LIST_HEAD) ) { 201 psError( __func__,"psMetadataAddItem did not return false with item with null name.");201 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false with item with null name."); 202 202 return 23; 203 203 } … … 211 211 errMetadata->table = NULL; 212 212 if ( psMetadataAdd(errMetadata, PS_LIST_HEAD, "errItem", PS_META_S32,"Integer",22) ) { 213 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");213 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table."); 214 214 return 24; 215 215 } … … 227 227 psFree(errMetadata); 228 228 if( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 229 psError( __func__,"Memory leaks detected.");229 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 230 230 return 25; 231 231 } -
trunk/psLib/test/astronomy/tst_psMetadata_04.c
r2204 r2273 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $21 * @date $Date: 2004-1 0-27 00:57:33$20 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2004-11-04 01:05:00 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 108 108 "Null metadata collection not allowed", 0); 109 109 if ( psMetadataLookup(NULL, "myItem2") != NULL ) { 110 psError( __func__,"psMetadataLookup did not return NULL with null metadata.");110 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return NULL with null metadata."); 111 111 return 11; 112 112 } … … 118 118 "Null key name not allowed", 0); 119 119 if ( psMetadataLookup(metadata, NULL) != NULL ) { 120 psError( __func__,"psMetadata did not return NULL with null key.");120 psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with null key."); 121 121 return 12; 122 122 } … … 128 128 "Couldn't find metadata item. Name: AARGH", 0); 129 129 if ( psMetadataLookup(metadata, "AARGH") != NULL ) { 130 psError( __func__,"psMetadata did not return NULL with a non-existant item.");130 psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with a non-existant item."); 131 131 return 13; 132 132 } … … 150 150 item = psMetadataGet(NULL, 0); 151 151 if ( item != NULL ) { 152 psError( __func__,"psMetadataGet did not return NULL with null metadata structure.");152 psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with null metadata structure."); 153 153 return 15; 154 154 } … … 160 160 "Couldn't find metadata item with given index. Index: 22", 0); 161 161 if ( psMetadataGet(metadata, 22) != NULL ) { 162 psError( __func__,"psMetadataGet did not return NULL with non-existant metadata item.");162 psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with non-existant metadata item."); 163 163 return 16; 164 164 } … … 171 171 metadata->table = NULL; 172 172 if ( psMetadataLookup(metadata,"myItem2") != NULL ) { 173 psError( __func__,"psMetadataLookup did not return null for invalid metadata object.");173 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object."); 174 174 return 20; 175 175 } … … 183 183 metadata->list = NULL; 184 184 if ( psMetadataGet(metadata,0) != NULL ) { 185 psError( __func__,"psMetadataLookup did not return null for invalid metadata object.");185 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object."); 186 186 return 20; 187 187 } … … 197 197 psFree(item4); 198 198 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 199 psError( __func__,"memory leaks detected.");199 psError(PS_ERR_UNKNOWN, true,"memory leaks detected."); 200 200 return 20; 201 201 } -
trunk/psLib/test/astronomy/tst_psMetadata_05.c
r2204 r2273 22 22 * @author Ross Harman, MHPCC 23 23 * 24 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $25 * @date $Date: 2004-1 0-27 00:57:33$24 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 25 * @date $Date: 2004-11-04 01:05:00 $ 26 26 * 27 27 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 145 145 } 146 146 if( psMetadataGetPrevious(metadata,"myItem3",1) == NULL) { 147 psError( __func__,"psMetadataGetPrevious did not return an item from metadata.");147 psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return an item from metadata."); 148 148 return 45; 149 149 } … … 151 151 metadata->list = NULL; 152 152 if ( psMetadataGetPrevious(metadata,NULL,1) != NULL) { 153 psError( __func__,"psMetadataGetPrevious did not return null for invalid metadata.");153 psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return null for invalid metadata."); 154 154 return 50; 155 155 } … … 213 213 "Null metadata collection not allowed", 0); 214 214 if( psMetadataGetNext(NULL, "myItem2", 0) != NULL ) { 215 psError( __func__,"psMetadataGetNext did not return null for null metadata.");215 psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for null metadata."); 216 216 return 40; 217 217 } … … 219 219 metadata->list = NULL; 220 220 if ( psMetadataGetNext(metadata, "myItem2", 0) != NULL ) { 221 psError( __func__,"psMetadataGetNext did not return null for invalid metadata.");221 psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for invalid metadata."); 222 222 return 41; 223 223 } … … 267 267 psFree(item8); 268 268 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 269 psError( __func__,"Memory leaks detected.");269 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 270 270 return 50; 271 271 } -
trunk/psLib/test/astronomy/tst_psMetadata_06.c
r2204 r2273 13 13 * @author Ross Harman, MHPCC 14 14 * 15 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-1 0-27 00:57:33$15 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-11-04 01:05:00 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node"); 89 89 if( ! psMetadataAddItem(metadata, item1a, PS_LIST_HEAD) ) { 90 psError( __func__,"psMetadataAddItem returned false for adding a node top.");90 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top."); 91 91 return 20; 92 92 } 93 93 if ( ! psMetadataAddItem(metadata, item1b, PS_LIST_HEAD) ) { 94 psError( __func__,"psMetadataAddItem returned false for adding a node top.");94 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top."); 95 95 return 21; 96 96 } … … 102 102 printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node"); 103 103 if ( ! psMetadataAddItem(metadata, item1c, PS_LIST_HEAD) ) { 104 psError( __func__,"psMetadataAddItem return false for adding a not to existing node.");104 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem return false for adding a not to existing node."); 105 105 return 22; 106 106 } … … 111 111 printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node"); 112 112 if ( ! psMetadataAddItem(metadata, item2a, PS_LIST_HEAD) ) { 113 psError( __func__,"psMetadataAddItem returned false for adding a node to existing leaf node.");113 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node to existing leaf node."); 114 114 return 23; 115 115 } 116 116 if ( ! psMetadataAddItem(metadata, item2b, PS_LIST_HEAD) ) { 117 psError( __func__,"psMetadataAddItem returned false for adding a nod to existing leaf node.");117 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a nod to existing leaf node."); 118 118 return 24; 119 119 } … … 130 130 psFree(metadata); 131 131 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 132 psError( __func__,"Memory leaks detected.");132 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 133 133 return 25; 134 134 } -
trunk/psLib/test/collections/tst_psArray.c
r2204 r2273 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:33$14 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:05:00 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 psArray *psArr = psArrayAlloc(5); 44 44 if (psArr->nalloc != 5) { 45 psError( __func__,"psArray didn't have proper number of elements.");45 psError(PS_ERR_UNKNOWN, true,"psArray didn't have proper number of elements."); 46 46 return 1; 47 47 } … … 64 64 printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y); 65 65 if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) { 66 psError( __func__,"Couldn't properly get elements from array.");66 psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array."); 67 67 return 2; 68 68 } … … 70 70 printf("array size = %d\n", psArr->nalloc); 71 71 if (psArr->nalloc != 5) { 72 psError( __func__,"Array Size wrong");72 psError(PS_ERR_UNKNOWN, true,"Array Size wrong"); 73 73 return 3; 74 74 } 75 75 printf("array population = %d\n", psArr->n); 76 76 if (psArr->n != 5) { 77 psError( __func__,"Array population wrong");77 psError(PS_ERR_UNKNOWN, true,"Array population wrong"); 78 78 return 4; 79 79 } … … 98 98 printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y); 99 99 if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) { 100 psError( __func__,"Couldn't properly get elements from array.");100 psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array."); 101 101 return 5; 102 102 } … … 104 104 printf("array size = %d\n", psArr->nalloc); 105 105 if (psArr->nalloc != 10) { 106 psError( __func__,"Array Size wrong");106 psError(PS_ERR_UNKNOWN, true,"Array Size wrong"); 107 107 return 6; 108 108 } 109 109 printf("array population = %d\n", psArr->n); 110 110 if (psArr->n != 10) { 111 psError( __func__,"Array Population wrong");111 psError(PS_ERR_UNKNOWN, true,"Array Population wrong"); 112 112 return 7; 113 113 } … … 122 122 printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y); 123 123 if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) { 124 psError( __func__,"Couldn't properly get elements from array.");124 psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array."); 125 125 return 8; 126 126 } … … 128 128 printf("array size = %d\n", psArr->nalloc); 129 129 if (psArr->nalloc != 3) { 130 psError( __func__,"Array Size wrong");130 psError(PS_ERR_UNKNOWN, true,"Array Size wrong"); 131 131 return 9; 132 132 } 133 133 printf("array population = %d\n", psArr->n); 134 134 if (psArr->n != 3) { 135 psError( __func__,"Array Population wrong");135 psError(PS_ERR_UNKNOWN, true,"Array Population wrong"); 136 136 return 10; 137 137 } -
trunk/psLib/test/collections/tst_psList.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 45 45 if (! runTestSuite(stderr,"psList",tests,argc,argv) ) { 46 psError( __FILE__,"One or more tests failed");46 psError(PS_ERR_UNKNOWN,true,"One or more tests failed"); 47 47 return 1; 48 48 } … … 66 66 list = psListAlloc(NULL); 67 67 if (list == NULL) { 68 psError( __func__,"psListAlloc failed to return a list.");68 psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list."); 69 69 return 1; 70 70 } 71 71 72 72 if (list->head != NULL || list->tail != NULL) { 73 psError( __func__,"head and/or tail was not NULL for empty list.");73 psError(PS_ERR_UNKNOWN, true,"head and/or tail was not NULL for empty list."); 74 74 return 2; 75 75 } 76 76 77 77 if (list->size != 0) { 78 psError( __func__,"size of list wasn't zero for empty list.");78 psError(PS_ERR_UNKNOWN, true,"size of list wasn't zero for empty list."); 79 79 return 3; 80 80 } … … 84 84 list = psListAlloc(data); 85 85 if (list == NULL) { 86 psError( __func__,"psListAlloc failed to return a list.");86 psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list."); 87 87 return 4; 88 88 } 89 89 90 90 if (list->head == NULL || list->tail == NULL) { 91 psError( __func__,"head and/or tail was NULL for one-element new list.");91 psError(PS_ERR_UNKNOWN, true,"head and/or tail was NULL for one-element new list."); 92 92 return 5; 93 93 } 94 94 95 95 if (list->head->data != data || list->tail->data != data) { 96 psError( __func__,"head and/or tail didn't point to data's node for one-element new list.");96 psError(PS_ERR_UNKNOWN, true,"head and/or tail didn't point to data's node for one-element new list."); 97 97 return 6; 98 98 } 99 99 100 100 if (list->size != 1) { 101 psError( __func__,"size of list wasn't correctly set for new, one-element list.");101 psError(PS_ERR_UNKNOWN, true,"size of list wasn't correctly set for new, one-element list."); 102 102 return 7; 103 103 } … … 105 105 ref = psMemGetRefCounter(data); 106 106 if (ref != 2) { 107 psError( __func__,"psList didn't increment reference count of data (%d.",ref);107 psError(PS_ERR_UNKNOWN, true,"psList didn't increment reference count of data (%d.",ref); 108 108 return 8; 109 109 } … … 139 139 // 1. list is NULL (error) 140 140 if (psListAdd(NULL,PS_LIST_HEAD,data)) { 141 psError( __func__,"psListAdd was given a NULL list, but returned a true/success.");141 psError(PS_ERR_UNKNOWN, true,"psListAdd was given a NULL list, but returned a true/success."); 142 142 return 1; 143 143 } … … 146 146 psFree(data); 147 147 if (list->size != 1) { 148 psError( __func__,"psListAlloc didn't create a list properly.");148 psError(PS_ERR_UNKNOWN, true,"psListAlloc didn't create a list properly."); 149 149 return 2; 150 150 } … … 152 152 // 2. data is NULL (error, list should not grow) 153 153 if (psListAdd(list, PS_LIST_HEAD,NULL)) { 154 psError( __func__,"psListAdd successfully added a NULL data item?");154 psError(PS_ERR_UNKNOWN, true,"psListAdd successfully added a NULL data item?"); 155 155 return 40; 156 156 } 157 157 if ( list->size != 1) { 158 psError( __func__,"psListAdd with a NULL data element changed the list size or returned success.");158 psError(PS_ERR_UNKNOWN, true,"psListAdd with a NULL data element changed the list size or returned success."); 159 159 return 3; 160 160 } … … 164 164 *data = 2; 165 165 if ( ! psListAdd(list,PS_LIST_HEAD,data) ) { 166 psError( __func__,"psListAdd failed to add a data item to head.");166 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add a data item to head."); 167 167 return 21; 168 168 } 169 169 170 170 if (psMemGetRefCounter(data) != 2) { 171 psError( __func__,"psListAdd didn't increment the data reference count.");171 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 172 172 return 20; 173 173 } … … 176 176 // verify that the size incremented 177 177 if (list->size != 2) { 178 psError( __func__,"psListAdd didn't increment the size by one");178 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the size by one"); 179 179 return 4; 180 180 } … … 182 182 // verify that the head is the inserted data item 183 183 if (*(psS32*)list->head->data != 2) { 184 psError( __func__,"psListAdd with PS_LIST_HEAD didn't insert at the head.");184 psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_HEAD didn't insert at the head."); 185 185 return 5; 186 186 } … … 189 189 *data = 3; 190 190 if ( ! psListAdd(list,PS_LIST_TAIL,data) ) { 191 psError( __func__,"psListAdd failed to add a data item to tail.");191 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add a data item to tail."); 192 192 return 21; 193 193 } 194 194 195 195 if (psMemGetRefCounter(data) != 2) { 196 psError( __func__,"psListAdd didn't increment the data reference count.");196 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 197 197 return 22; 198 198 } … … 200 200 // verify that the size incremented 201 201 if (list->size != 3) { 202 psError( __func__,"psListAdd didn't increment the size by 1");202 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the size by 1"); 203 203 return 6; 204 204 } … … 206 206 // verify that the head is still the same 207 207 if (*(psS32*)list->head->data != 2) { 208 psError( __func__,"psListAdd with PS_LIST_TAIL modified the head.");208 psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_TAIL modified the head."); 209 209 return 7; 210 210 } … … 212 212 // verify that the tail is the data item inserted 213 213 if (*(psS32*)list->tail->data != 3) { 214 psError( __func__,"psListAdd with PS_LIST_TAIL didn't insert at the tail.");214 psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_TAIL didn't insert at the tail."); 215 215 return 8; 216 216 } … … 223 223 224 224 if ( psListAdd(list,-10,data) ) { 225 psError( __func__,"psListAdd successfully added data to a -10 position?");225 psError(PS_ERR_UNKNOWN, true,"psListAdd successfully added data to a -10 position?"); 226 226 return 30; 227 227 } 228 228 if (psMemGetRefCounter(data) != 1) { 229 psError( __func__,"psListAdd incremented the data reference count.");229 psError(PS_ERR_UNKNOWN, true,"psListAdd incremented the data reference count."); 230 230 return 24; 231 231 } … … 234 234 if (list->size != 3) { 235 235 printListInt(list); 236 psError( __func__,"psListAdd didn't insert to head when where was invalid.");236 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to head when where was invalid."); 237 237 return 9; 238 238 } … … 243 243 244 244 if ( ! psListAdd(list,1,data) ) { 245 psError( __func__,"psListAdd failed to add data to 1 position.");245 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 1 position."); 246 246 return 30; 247 247 } 248 248 249 249 if (psMemGetRefCounter(data) != 2) { 250 psError( __func__,"psListAdd didn't increment the data reference count.");250 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 251 251 return 25; 252 252 } … … 255 255 if (list->size != 4 || *(psS32*)list->head->next->data != 5) { 256 256 printListInt(list); 257 psError( __func__,"psListAdd didn't insert to position #1.");257 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #1."); 258 258 return 10; 259 259 } … … 262 262 *data = 6; 263 263 if ( ! psListAdd(list,3,data) ) { 264 psError( __func__,"psListAdd failed to add data to 4 position.");264 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 4 position."); 265 265 return 31; 266 266 } 267 267 if (psMemGetRefCounter(data) != 2) { 268 psError( __func__,"psListAdd didn't increment the data reference count.");268 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 269 269 return 26; 270 270 } … … 273 273 if (list->size != 5 || *(psS32 *)list->head->next->next->next->data != 6) { 274 274 printListInt(list); 275 psError( __func__,"psListAdd didn't insert to position #4.");275 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #4."); 276 276 return 50; 277 277 } … … 280 280 *data = 7; 281 281 if ( ! psListAdd(list,2,data) ) { 282 psError( __func__,"psListAdd failed to add data to 2 position.");282 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 2 position."); 283 283 return 32; 284 284 } 285 285 if (psMemGetRefCounter(data) != 2) { 286 psError( __func__,"psListAdd didn't increment the data reference count.");286 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 287 287 return 28; 288 288 } … … 291 291 if (list->size != 6 || *(psS32 *)list->head->next->next->data != 7) { 292 292 printListInt(list); 293 psError( __func__,"psListAdd didn't insert to position #2.");293 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #2."); 294 294 return 11; 295 295 } … … 300 300 301 301 if ( ! psListAdd(list,9,data) ) { 302 psError( __func__,"psListAdd failed to add data to a 9 position?");302 psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to a 9 position?"); 303 303 return 30; 304 304 } 305 305 306 306 if (psMemGetRefCounter(data) != 2) { 307 psError( __func__,"psListAdd didn't increment the data reference count.");307 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count."); 308 308 return 29; 309 309 } … … 314 314 if (list->size != 7) { 315 315 printListInt(list); 316 psError( __func__,"psListAdd didn't insert to position #9.");316 psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #9."); 317 317 return 12; 318 318 } … … 366 366 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error"); 367 367 if (psListGet(list,PS_LIST_HEAD) != NULL) { 368 psError( __func__,"psListGet didn't return NULL given a NULL list.");368 psError(PS_ERR_UNKNOWN, true,"psListGet didn't return NULL given a NULL list."); 369 369 return 1; 370 370 }; … … 394 394 data = (psS32*)psListGet(list,3); 395 395 if (data == NULL || *data != 3) { 396 psError( __func__,"psListGet failed with which=3");396 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=3"); 397 397 return 2; 398 398 } 399 399 data = (psS32*)psListGet(list,1); 400 400 if (data == NULL || *data != 1) { 401 psError( __func__,"psListGet failed with which=1");401 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=1"); 402 402 return 3; 403 403 } … … 406 406 data = (psS32*)psListGet(list,5); 407 407 if (data != NULL) { 408 psError( __func__,"psListGet failed with which=5");408 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=5"); 409 409 return 4; 410 410 } 411 411 data = (psS32*)psListGet(list,4); 412 412 if (data != NULL) { 413 psError( __func__,"psListGet failed with which=4");413 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=4"); 414 414 return 5; 415 415 } … … 418 418 data = (psS32*)psListGet(list,PS_LIST_HEAD); 419 419 if (data == NULL || *data != 0) { 420 psError( __func__,"psListGet failed with which=PS_LIST_HEAD");420 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_HEAD"); 421 421 return 6; 422 422 } … … 425 425 data = (psS32*)psListGet(list,PS_LIST_NEXT); 426 426 if (data == NULL || *data != 1) { 427 psError( __func__,"psListGet failed with which=PS_LIST_NEXT");427 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_NEXT"); 428 428 return 7; 429 429 } … … 432 432 data = (psS32*)psListGet(list,PS_LIST_TAIL); 433 433 if (data == NULL || *data != 3) { 434 psError( __func__,"psListGet failed with which=PS_LIST_TAIL");434 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_TAIL"); 435 435 return 8; 436 436 } … … 439 439 data = (psS32*)psListGet(list,PS_LIST_PREVIOUS); 440 440 if (data == NULL || *data != 2) { 441 psError( __func__,"psListGet failed with which=PS_LIST_PREV");441 psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_PREV"); 442 442 return 9; 443 443 } … … 473 473 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error"); 474 474 if (psListRemove(list,PS_LIST_HEAD,NULL)) { 475 psError( __func__,"psListRemove didn't return false given a NULL list.");475 psError(PS_ERR_UNKNOWN, true,"psListRemove didn't return false given a NULL list."); 476 476 return 1; 477 477 }; … … 493 493 (psListGet(list,PS_LIST_HEAD) == data) ) { 494 494 printListInt(list); 495 psError( __func__,"Failed to remove PS_LIST_HEAD");495 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_HEAD"); 496 496 return 1; 497 497 } … … 499 499 if (list->size != 14) { 500 500 printListInt(list); 501 psError( __func__,"Didn't decrement size properly to 14.");501 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 14."); 502 502 return 1; 503 503 } … … 508 508 (psListGet(list,PS_LIST_TAIL) == data) ) { 509 509 printListInt(list); 510 psError( __func__,"Failed to remove PS_LIST_TAIL");510 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_TAIL"); 511 511 return 1; 512 512 } … … 514 514 if (list->size != 13) { 515 515 printListInt(list); 516 psError( __func__,"Didn't decrement size properly to 13.");516 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 13."); 517 517 return 1; 518 518 } … … 522 522 if (! psListRemove(list,PS_LIST_NEXT,NULL)) { 523 523 printListInt(list); 524 psError( __func__,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD");524 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD"); 525 525 return 1; 526 526 } … … 528 528 if (list->size != 12) { 529 529 printListInt(list); 530 psError( __func__,"Didn't decrement size properly to 12.");530 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 12."); 531 531 return 1; 532 532 } … … 536 536 if (psListRemove(list,PS_LIST_NEXT,NULL)) { 537 537 printListInt(list); 538 psError( __func__,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL");538 psError(PS_ERR_UNKNOWN, true,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL"); 539 539 return 1; 540 540 } … … 545 545 ( psListGet(list,3) == data) ) { 546 546 printListInt(list); 547 psError( __func__,"Failed to remove PS_LIST_NEXT @ which=2");547 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_NEXT @ which=2"); 548 548 return 1; 549 549 } … … 551 551 if (list->size != 11) { 552 552 printListInt(list); 553 psError( __func__,"Didn't decrement size properly to 11.");553 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 11."); 554 554 return 1; 555 555 } … … 560 560 if (psListRemove(list,PS_LIST_PREVIOUS,NULL)) { 561 561 printListInt(list); 562 psError( __func__,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD");562 psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD"); 563 563 return 1; 564 564 } … … 569 569 (psListGet(list,9) == data) ) { 570 570 printListInt(list); 571 psError( __func__,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL");571 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL"); 572 572 return 1; 573 573 } … … 575 575 if (list->size != 10) { 576 576 printListInt(list); 577 psError( __func__,"Didn't decrement size properly to 10.");577 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 10."); 578 578 return 1; 579 579 } … … 584 584 ( psListGet(list,1) == data) ) { 585 585 printListInt(list); 586 psError( __func__,"Failed to remove PS_LIST_PREVIOUS @ which=2");586 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_PREVIOUS @ which=2"); 587 587 return 1; 588 588 } … … 590 590 if (list->size != 9) { 591 591 printListInt(list); 592 psError( __func__,"Didn't decrement size properly to 9.");592 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 9."); 593 593 return 1; 594 594 } … … 598 598 if (psListRemove(list,PS_LIST_UNKNOWN,NULL)) { 599 599 printListInt(list); 600 psError( __func__,"removed something for PS_LIST_UNKNOWN with data=NULL");600 psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_UNKNOWN with data=NULL"); 601 601 return 1; 602 602 } … … 607 607 (psListGet(list,PS_LIST_HEAD) == data) ) { 608 608 printListInt(list); 609 psError( __func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD");609 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD"); 610 610 return 1; 611 611 } … … 613 613 if (list->size != 8) { 614 614 printListInt(list); 615 psError( __func__,"Didn't decrement size properly to 8.");615 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 8."); 616 616 return 1; 617 617 } … … 621 621 (psListGet(list,PS_LIST_TAIL) == data) ) { 622 622 printListInt(list); 623 psError( __func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL");623 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL"); 624 624 return 1; 625 625 } … … 627 627 if (list->size != 7) { 628 628 printListInt(list); 629 psError( __func__,"Didn't decrement size properly to 7.");629 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 7."); 630 630 return 1; 631 631 } … … 637 637 (psListGet(list,1) == data) ) { 638 638 printListInt(list); 639 psError( __func__,"Failed to remove PS_LIST_UNKNOWN @ which=1");639 psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ which=1"); 640 640 return 1; 641 641 } … … 643 643 if (list->size != 6) { 644 644 printListInt(list); 645 psError( __func__,"Didn't decrement size properly to 6.");645 psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 6."); 646 646 return 1; 647 647 } … … 651 651 if ( psListRemove(list,PS_LIST_UNKNOWN,data) ) { 652 652 printListInt(list); 653 psError( __func__,"removed something for PS_LIST_UNKNOWN with previously removed item");653 psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_UNKNOWN with previously removed item"); 654 654 return 1; 655 655 } … … 666 666 (psListGet(list,PS_LIST_HEAD) == data) ) { 667 667 printListInt(list); 668 psError( __func__,"Failed to remove last element");668 psError(PS_ERR_UNKNOWN, true,"Failed to remove last element"); 669 669 return 1; 670 670 } … … 672 672 if (list->size != 0) { 673 673 printListInt(list); 674 psError( __func__,"Didn't remove all the elements.");674 psError(PS_ERR_UNKNOWN, true,"Didn't remove all the elements."); 675 675 return 1; 676 676 } … … 709 709 710 710 if (arr->n != 15 || list->size != 15) { 711 psError( __func__,"The created array didn't have the proper size");711 psError(PS_ERR_UNKNOWN, true,"The created array didn't have the proper size"); 712 712 return 1; 713 713 } 714 714 for (psS32 i=0;i<arr->n;i++) { 715 715 if (i != *(psS32*)arr->data[i]) { 716 psError( __func__,"Element %d of array is incorrect (%d).",716 psError(PS_ERR_UNKNOWN, true,"Element %d of array is incorrect (%d).", 717 717 i,*(psS32*)arr->data[i]); 718 718 return 1; 719 719 } 720 720 if (i != *(psS32*)psListGet(list,i)) { 721 psError( __func__,"Element %d of list is incorrect (%d).",721 psError(PS_ERR_UNKNOWN, true,"Element %d of list is incorrect (%d).", 722 722 i,*(psS32*)arr->data[i]); 723 723 return 1; 724 724 } 725 725 if (psMemGetRefCounter(arr->data[i]) != 2) { 726 psError( __func__,"Element %d had wrong reference count (%d).",726 psError(PS_ERR_UNKNOWN, true,"Element %d had wrong reference count (%d).", 727 727 i,psMemGetRefCounter(arr->data[i])); 728 728 return 1; … … 747 747 748 748 if (arr->n != 15 || list->size != 15) { 749 psError( __func__,"The created array didn't have the proper size");749 psError(PS_ERR_UNKNOWN, true,"The created array didn't have the proper size"); 750 750 return 1; 751 751 } 752 752 for (psS32 i=0;i<arr->n;i++) { 753 753 if (i != *(psS32*)arr->data[i]) { 754 psError( __func__,"Element %d of array is incorrect (%d).",754 psError(PS_ERR_UNKNOWN, true,"Element %d of array is incorrect (%d).", 755 755 i,*(psS32*)arr->data[i]); 756 756 return 1; 757 757 } 758 758 if (i != *(psS32*)psListGet(list,i)) { 759 psError( __func__,"Element %d of list is incorrect (%d).",759 psError(PS_ERR_UNKNOWN, true,"Element %d of list is incorrect (%d).", 760 760 i,*(psS32*)arr->data[i]); 761 761 return 1; 762 762 } 763 763 if (psMemGetRefCounter(arr->data[i]) != 2) { 764 psError( __func__,"Element %d had wrong reference count (%d).",764 psError(PS_ERR_UNKNOWN, true,"Element %d had wrong reference count (%d).", 765 765 i,psMemGetRefCounter(arr->data[i])); 766 766 return 1; … … 775 775 arr = psListToArray(NULL); 776 776 if (arr != NULL) { 777 psError( __func__,"psListToArray didn't return NULL when given NULL");777 psError(PS_ERR_UNKNOWN, true,"psListToArray didn't return NULL when given NULL"); 778 778 return 1; 779 779 } … … 781 781 list = psArrayToList(NULL); 782 782 if (list != NULL) { 783 psError( __func__,"psArrayToList didn't return NULL when given NULL");783 psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't return NULL when given NULL"); 784 784 return 1; 785 785 } … … 790 790 list = psArrayToList(arr); 791 791 if (list == NULL) { 792 psError( __func__,"psArrayToList didn't create an empty list from an "792 psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't create an empty list from an " 793 793 "empty array."); 794 794 return 1; … … 800 800 arr = psListToArray(list); 801 801 if (arr == NULL) { 802 psError( __func__,"psArrayToList didn't create an empty array from an "802 psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't create an empty array from an " 803 803 "empty list."); 804 804 return 1; … … 853 853 psListSetIterator(list,PS_LIST_TAIL); 854 854 if (*(psS32*)psListGetCurrent(list) != 14) { 855 psError( __func__,"Didn't successfully move cursor to tail.");855 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to tail."); 856 856 return 1; 857 857 } … … 860 860 psListSetIterator(list,PS_LIST_HEAD); 861 861 if (*(psS32*)psListGetCurrent(list) != 0) { 862 psError( __func__,"Didn't successfully move cursor to head.");862 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to head."); 863 863 return 2; 864 864 } … … 867 867 psListSetIterator(list,PS_LIST_NEXT); 868 868 if (*(psS32*)psListGetCurrent(list) != 1) { 869 psError( __func__,"Didn't successfully move cursor to next.");869 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to next."); 870 870 return 3; 871 871 } 872 872 psListSetIterator(list,PS_LIST_NEXT); 873 873 if (*(psS32*)psListGetCurrent(list) != 2) { 874 psError( __func__,"Didn't successfully move cursor to next twice.");874 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to next twice."); 875 875 return 4; 876 876 } … … 879 879 psListSetIterator(list,PS_LIST_PREVIOUS); 880 880 if (*(psS32*)psListGetCurrent(list) != 1) { 881 psError( __func__,"Didn't successfully move cursor to previous.");881 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to previous."); 882 882 return 5; 883 883 } 884 884 psListSetIterator(list,PS_LIST_PREVIOUS); 885 885 if (*(psS32*)psListGetCurrent(list) != 0) { 886 psError( __func__,"Didn't successfully move cursor to previous twice.");886 psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to previous twice."); 887 887 return 6; 888 888 } … … 893 893 psListSetIterator(list,PS_LIST_UNKNOWN); 894 894 if (*(psS32*)psListGetCurrent(list) != 1) { 895 psError( __func__,"PS_LIST_UNKNOWN moved cursor.");895 psError(PS_ERR_UNKNOWN, true,"PS_LIST_UNKNOWN moved cursor."); 896 896 return 7; 897 897 } 898 898 psListSetIterator(list,PS_LIST_CURRENT); 899 899 if (*(psS32*)psListGetCurrent(list) != 1) { 900 psError( __func__,"PS_LIST_CURRENT moved cursor.");900 psError(PS_ERR_UNKNOWN, true,"PS_LIST_CURRENT moved cursor."); 901 901 return 8; 902 902 } … … 904 904 // test psListGetPrevious/Next 905 905 if (*(psS32*)psListGetNext(list) != 2) { 906 psError( __func__,"psListGetNext didn't move cursor to next.");906 psError(PS_ERR_UNKNOWN, true,"psListGetNext didn't move cursor to next."); 907 907 return 9; 908 908 } 909 909 if (*(psS32*)psListGetNext(list) != 3) { 910 psError( __func__,"psListGetNext didn't move cursor to next.");910 psError(PS_ERR_UNKNOWN, true,"psListGetNext didn't move cursor to next."); 911 911 return 10; 912 912 } 913 913 if (*(psS32*)psListGetPrevious(list) != 2) { 914 psError( __func__,"psListGetPrevious didn't move cursor to previous.");914 psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous."); 915 915 return 11; 916 916 } 917 917 if (*(psS32*)psListGetPrevious(list) != 1) { 918 psError( __func__,"psListGetPrevious didn't move cursor to previous.");918 psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous."); 919 919 return 12; 920 920 } 921 921 if (*(psS32*)psListGetPrevious(list) != 0) { 922 psError( __func__,"psListGetPrevious didn't move cursor to previous..");922 psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous.."); 923 923 return 13; 924 924 } 925 925 if (psListGetPrevious(list) != NULL) { 926 psError( __func__,"psListGetPrevious moved cursor beyond head.");926 psError(PS_ERR_UNKNOWN, true,"psListGetPrevious moved cursor beyond head."); 927 927 return 14; 928 928 } … … 930 930 psListSetIterator(list,PS_LIST_TAIL); // works according to an above test 931 931 if (psListGetNext(list) != NULL) { 932 psError( __func__,"psListGetNext moved cursor beyond tail.");932 psError(PS_ERR_UNKNOWN, true,"psListGetNext moved cursor beyond tail."); 933 933 return 15; 934 934 } … … 959 959 psListAdd(list,PS_LIST_TAIL,data[lcv]); 960 960 if (psMemGetRefCounter(data[lcv]) != 2) { 961 psError( __func__,"Reference counter for data was not incremented");961 psError(PS_ERR_UNKNOWN, true,"Reference counter for data was not incremented"); 962 962 return 1; 963 963 } … … 969 969 */ 970 970 if (list->size != 15) { 971 psError( __func__,"List wasn't populated as expected?");971 psError(PS_ERR_UNKNOWN, true,"List wasn't populated as expected?"); 972 972 return 2; 973 973 } … … 989 989 for (psS32 i=0;i<15;i++) { 990 990 if (psMemGetRefCounter(data[i]) != 1) { 991 psError( __func__,"pslistFree didn't decrement the data item's reference counter");991 psError(PS_ERR_UNKNOWN, true,"pslistFree didn't decrement the data item's reference counter"); 992 992 return 3; 993 993 } … … 1039 1039 iter = psListGet(list,PS_LIST_NEXT)) { 1040 1040 if (*prevValue > *iter) { 1041 psError( __func__,"Hey, the list wasn't sorted!?");1041 psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?"); 1042 1042 return 1; 1043 1043 } … … 1059 1059 iter = psListGet(list,PS_LIST_NEXT)) { 1060 1060 if (*prevValue < *iter) { 1061 psError( __func__,"Hey, the list wasn't sorted!?");1061 psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?"); 1062 1062 return 1; 1063 1063 } … … 1105 1105 iter = psListGet(list,PS_LIST_NEXT)) { 1106 1106 if (*prev > *iter) { 1107 psError( __func__,"Hey, the list wasn't sorted!?");1107 psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?"); 1108 1108 return 1; 1109 1109 } … … 1125 1125 iter = psListGet(list,PS_LIST_NEXT)) { 1126 1126 if (*prev < *iter) { 1127 psError( __func__,"Hey, the list wasn't sorted!?");1127 psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?"); 1128 1128 return 1; 1129 1129 } -
trunk/psLib/test/collections/tst_psMetadata_01.c
r2204 r2273 17 17 * @author Ross Harman, MHPCC 18 18 * 19 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $20 * @date $Date: 2004-1 0-27 00:57:33$19 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 20 * @date $Date: 2004-11-04 01:05:00 $ 21 21 * 22 22 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 227 227 metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits"); 228 228 if (metadata1 != NULL ) { 229 psError( __func__,"psMetadataReadHeader did not return null when invalid ext given.");229 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null when invalid ext given."); 230 230 return 10; 231 231 } … … 238 238 metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits"); 239 239 if (metadata1 != NULL ) { 240 psError( __func__,"psMetadataReadHeader did not return null invalid extname give.");240 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null invalid extname give."); 241 241 return 11; 242 242 } … … 249 249 metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits"); 250 250 if (metadata1 != NULL ) { 251 psError( __func__,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");251 psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum"); 252 252 return 12; 253 253 } -
trunk/psLib/test/collections/tst_psMetadata_02.c
r2204 r2273 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-1 0-27 00:57:33$16 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-11-04 01:05:00 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 92 92 badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD"); 93 93 if (badItem != NULL) { 94 psError( __func__,"psMetadataItemAlloc did not return null with null name item.");94 psError(PS_ERR_UNKNOWN, true,"psMetadataItemAlloc did not return null with null name item."); 95 95 return 10; 96 96 } -
trunk/psLib/test/collections/tst_psMetadata_03.c
r2204 r2273 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-1 0-27 00:57:33$16 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-11-04 01:05:00 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 91 91 printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name"); 92 92 if( ! psMetadataAddItem(metadata, item1, PS_LIST_HEAD) ) { 93 psError( __func__,"psMetadataAddItem did not return true when adding by name.");93 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name."); 94 94 return 10; 95 95 } 96 96 if( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem2",PS_META_S32,"I am S32 integer",77) ) { 97 psError( __func__,"psMetadataAddItem did not return true when adding by name.");97 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name."); 98 98 return 11; 99 99 } 100 100 if ( ! psMetadataRemove(metadata, 0, "myItem1" ) ) { 101 psError( __func__,"psMetadataRemove did not return true when removing by name.");101 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name."); 102 102 return 12; 103 103 } 104 104 if ( ! psMetadataRemove(metadata, 0, "myItem2" ) ) { 105 psError( __func__,"psMetadataRemove did not return true when removing by name.");105 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name."); 106 106 return 13; 107 107 } … … 112 112 printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index"); 113 113 if ( ! psMetadataAddItem(metadata, item3, PS_LIST_HEAD) ) { 114 psError( __func__,"psMetadataAddItem did not return true when adding by index.");114 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index."); 115 115 return 14; 116 116 } 117 117 if ( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem4",PS_META_S32,"I am S32 integer",88) ) { 118 psError( __func__,"psMetadataAddItem did not return true when adding by index.");118 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index."); 119 119 return 15; 120 120 } 121 121 if( ! psMetadataRemove(metadata, 0, NULL) ) { 122 psError( __func__,"psMetadataRemove did not return true when removing by index.");122 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index."); 123 123 return 16; 124 124 } 125 125 if ( ! psMetadataRemove(metadata, 0, NULL ) ) { 126 psError( __func__,"psMetadataRemove did not return true when removing by index.");126 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index."); 127 127 return 17; 128 128 } … … 134 134 "Null metadata collection not allowed", 0); 135 135 if ( psMetadataRemove(NULL, 0, NULL) ) { 136 psError( __func__,"psMetadataRemove did not return false when removing from null metadata.");136 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing from null metadata."); 137 137 return 18; 138 138 } … … 144 144 "Couldn't find metadata item. Name: AARGH", 0); 145 145 if( psMetadataRemove(metadata, 0, "AARGH") ) { 146 psError( __func__,"psMetadataRemove did not return false when removing non-existant item.");146 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item."); 147 147 return 19; 148 148 } … … 154 154 "Couldn't find metadata item in list. Index: 22", 0); 155 155 if( psMetadataRemove(metadata, 22, NULL) ) { 156 psError( __func__,"psMetadataRemove did not return false when removing non-existant item.");156 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item."); 157 157 return 20; 158 158 } … … 167 167 errMetadata->table = NULL; 168 168 if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) { 169 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");169 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table."); 170 170 return 21; 171 171 } 172 172 if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) { 173 psError( __func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");173 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table."); 174 174 return 31; 175 175 } … … 183 183 errMetadata->list = NULL; 184 184 if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) { 185 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");185 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list."); 186 186 return 22; 187 187 } 188 188 if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) { 189 psError( __func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");189 psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list."); 190 190 return 32; 191 191 } … … 199 199 errItem->name = NULL; 200 200 if ( psMetadataAddItem(errMetadata, errItem, PS_LIST_HEAD) ) { 201 psError( __func__,"psMetadataAddItem did not return false with item with null name.");201 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false with item with null name."); 202 202 return 23; 203 203 } … … 211 211 errMetadata->table = NULL; 212 212 if ( psMetadataAdd(errMetadata, PS_LIST_HEAD, "errItem", PS_META_S32,"Integer",22) ) { 213 psError( __func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");213 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table."); 214 214 return 24; 215 215 } … … 227 227 psFree(errMetadata); 228 228 if( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 229 psError( __func__,"Memory leaks detected.");229 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 230 230 return 25; 231 231 } -
trunk/psLib/test/collections/tst_psMetadata_04.c
r2204 r2273 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $21 * @date $Date: 2004-1 0-27 00:57:33$20 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2004-11-04 01:05:00 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 108 108 "Null metadata collection not allowed", 0); 109 109 if ( psMetadataLookup(NULL, "myItem2") != NULL ) { 110 psError( __func__,"psMetadataLookup did not return NULL with null metadata.");110 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return NULL with null metadata."); 111 111 return 11; 112 112 } … … 118 118 "Null key name not allowed", 0); 119 119 if ( psMetadataLookup(metadata, NULL) != NULL ) { 120 psError( __func__,"psMetadata did not return NULL with null key.");120 psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with null key."); 121 121 return 12; 122 122 } … … 128 128 "Couldn't find metadata item. Name: AARGH", 0); 129 129 if ( psMetadataLookup(metadata, "AARGH") != NULL ) { 130 psError( __func__,"psMetadata did not return NULL with a non-existant item.");130 psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with a non-existant item."); 131 131 return 13; 132 132 } … … 150 150 item = psMetadataGet(NULL, 0); 151 151 if ( item != NULL ) { 152 psError( __func__,"psMetadataGet did not return NULL with null metadata structure.");152 psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with null metadata structure."); 153 153 return 15; 154 154 } … … 160 160 "Couldn't find metadata item with given index. Index: 22", 0); 161 161 if ( psMetadataGet(metadata, 22) != NULL ) { 162 psError( __func__,"psMetadataGet did not return NULL with non-existant metadata item.");162 psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with non-existant metadata item."); 163 163 return 16; 164 164 } … … 171 171 metadata->table = NULL; 172 172 if ( psMetadataLookup(metadata,"myItem2") != NULL ) { 173 psError( __func__,"psMetadataLookup did not return null for invalid metadata object.");173 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object."); 174 174 return 20; 175 175 } … … 183 183 metadata->list = NULL; 184 184 if ( psMetadataGet(metadata,0) != NULL ) { 185 psError( __func__,"psMetadataLookup did not return null for invalid metadata object.");185 psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object."); 186 186 return 20; 187 187 } … … 197 197 psFree(item4); 198 198 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 199 psError( __func__,"memory leaks detected.");199 psError(PS_ERR_UNKNOWN, true,"memory leaks detected."); 200 200 return 20; 201 201 } -
trunk/psLib/test/collections/tst_psMetadata_05.c
r2204 r2273 22 22 * @author Ross Harman, MHPCC 23 23 * 24 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $25 * @date $Date: 2004-1 0-27 00:57:33$24 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 25 * @date $Date: 2004-11-04 01:05:00 $ 26 26 * 27 27 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 145 145 } 146 146 if( psMetadataGetPrevious(metadata,"myItem3",1) == NULL) { 147 psError( __func__,"psMetadataGetPrevious did not return an item from metadata.");147 psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return an item from metadata."); 148 148 return 45; 149 149 } … … 151 151 metadata->list = NULL; 152 152 if ( psMetadataGetPrevious(metadata,NULL,1) != NULL) { 153 psError( __func__,"psMetadataGetPrevious did not return null for invalid metadata.");153 psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return null for invalid metadata."); 154 154 return 50; 155 155 } … … 213 213 "Null metadata collection not allowed", 0); 214 214 if( psMetadataGetNext(NULL, "myItem2", 0) != NULL ) { 215 psError( __func__,"psMetadataGetNext did not return null for null metadata.");215 psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for null metadata."); 216 216 return 40; 217 217 } … … 219 219 metadata->list = NULL; 220 220 if ( psMetadataGetNext(metadata, "myItem2", 0) != NULL ) { 221 psError( __func__,"psMetadataGetNext did not return null for invalid metadata.");221 psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for invalid metadata."); 222 222 return 41; 223 223 } … … 267 267 psFree(item8); 268 268 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 269 psError( __func__,"Memory leaks detected.");269 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 270 270 return 50; 271 271 } -
trunk/psLib/test/collections/tst_psMetadata_06.c
r2204 r2273 13 13 * @author Ross Harman, MHPCC 14 14 * 15 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-1 0-27 00:57:33$15 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-11-04 01:05:00 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node"); 89 89 if( ! psMetadataAddItem(metadata, item1a, PS_LIST_HEAD) ) { 90 psError( __func__,"psMetadataAddItem returned false for adding a node top.");90 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top."); 91 91 return 20; 92 92 } 93 93 if ( ! psMetadataAddItem(metadata, item1b, PS_LIST_HEAD) ) { 94 psError( __func__,"psMetadataAddItem returned false for adding a node top.");94 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top."); 95 95 return 21; 96 96 } … … 102 102 printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node"); 103 103 if ( ! psMetadataAddItem(metadata, item1c, PS_LIST_HEAD) ) { 104 psError( __func__,"psMetadataAddItem return false for adding a not to existing node.");104 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem return false for adding a not to existing node."); 105 105 return 22; 106 106 } … … 111 111 printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node"); 112 112 if ( ! psMetadataAddItem(metadata, item2a, PS_LIST_HEAD) ) { 113 psError( __func__,"psMetadataAddItem returned false for adding a node to existing leaf node.");113 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node to existing leaf node."); 114 114 return 23; 115 115 } 116 116 if ( ! psMetadataAddItem(metadata, item2b, PS_LIST_HEAD) ) { 117 psError( __func__,"psMetadataAddItem returned false for adding a nod to existing leaf node.");117 psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a nod to existing leaf node."); 118 118 return 24; 119 119 } … … 130 130 psFree(metadata); 131 131 if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) { 132 psError( __func__,"Memory leaks detected.");132 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); 133 133 return 25; 134 134 } -
trunk/psLib/test/dataManip/tst_psFunc02.c
r2204 r2273 64 64 } 65 65 66 p _psSpline1DFree(tmpSpline);66 psFree(tmpSpline); 67 67 psMemCheckCorruption(1); 68 68 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); … … 90 90 } 91 91 92 p _psSpline1DFree(tmpSpline);92 psFree(tmpSpline); 93 93 psMemCheckCorruption(1); 94 94 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); … … 144 144 } 145 145 146 p _psSpline1DFree(tmpSpline);146 psFree(tmpSpline); 147 147 psMemCheckCorruption(1); 148 148 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); … … 198 198 } 199 199 200 p _psSpline1DFree(tmpSpline);200 psFree(tmpSpline); 201 201 psMemCheckCorruption(1); 202 202 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); … … 224 224 } 225 225 226 p _psSpline1DFree(tmpSpline);226 psFree(tmpSpline); 227 227 psMemCheckCorruption(1); 228 228 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); … … 278 278 } 279 279 280 p _psSpline1DFree(tmpSpline);280 psFree(tmpSpline); 281 281 psMemCheckCorruption(1); 282 282 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); -
trunk/psLib/test/dataManip/tst_psFunc03.c
r2204 r2273 72 72 } 73 73 74 p _psSpline1DFree(tmpSpline);74 psFree(tmpSpline); 75 75 psFree(bounds); 76 76 psMemCheckCorruption(1); … … 132 132 } 133 133 134 p _psSpline1DFree(tmpSpline);134 psFree(tmpSpline); 135 135 psFree(bounds); 136 136 psMemCheckCorruption(1); -
trunk/psLib/test/dataManip/tst_psFunc04.c
r2204 r2273 53 53 } 54 54 55 p _psSpline1DFree(tmpSpline);55 psFree(tmpSpline); 56 56 psMemCheckCorruption(1); 57 57 psFree(data); … … 105 105 } 106 106 107 p _psSpline1DFree(tmpSpline);107 psFree(tmpSpline); 108 108 psMemCheckCorruption(1); 109 109 psFree(data); -
trunk/psLib/test/dataManip/tst_psFunc05.c
r2204 r2273 59 59 } 60 60 61 p _psSpline1DFree(tmpSpline);61 psFree(tmpSpline); 62 62 63 63 psFree(x); -
trunk/psLib/test/dataManip/tst_psFunc07.c
r2223 r2273 83 83 psFree(newX); 84 84 psFree(y); 85 p _psSpline1DFree(tmpSpline);85 psFree(tmpSpline); 86 86 psFree(newY); 87 87 … … 152 152 psFree(newX); 153 153 psFree(y); 154 p _psSpline1DFree(tmpSpline);154 psFree(tmpSpline); 155 155 psFree(newY); 156 156 -
trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c
r2204 r2273 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:33$12 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 #define CHECK_MEMORY \ 84 84 if( psMemCheckLeaks(0, NULL, stdout) != 0 ) { \ 85 psError( __func__,"Memory leaks detected."); \85 psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); \ 86 86 return 50; \ 87 87 } \ 88 88 psS32 nBad = psMemCheckCorruption(0); \ 89 89 if(nBad) { \ 90 psError( __func__,"ERROR: Found %d bad memory blocks\n", nBad); \90 psError(PS_ERR_UNKNOWN, true,"ERROR: Found %d bad memory blocks\n", nBad); \ 91 91 return 51; \ 92 92 } -
trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c
r2204 r2273 15 15 * @author Ross Harman, MHPCC 16 16 * 17 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $18 * @date $Date: 2004-1 0-27 00:57:33$17 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2004-11-04 01:05:00 $ 19 19 * 20 20 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 221 221 CREATE_AND_SET_VECTOR(vector6,F64,0,3); 222 222 if ( psBinaryOp(vector6,vector4,"+",NULL) != NULL ) { 223 psError( __func__,"psBinaryOp should return null when out and in1 valid but in2 null.");223 psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when out and in1 valid but in2 null."); 224 224 return 10; 225 225 } … … 228 228 vector4->type.dimen = PS_DIMEN_OTHER; 229 229 if ( psBinaryOp(NULL,vector4,"+",vector5) != NULL) { 230 psError( __func__,"psBinaryOp should return null when input dimen PS_DIMEN_OTHER.");230 psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when input dimen PS_DIMEN_OTHER."); 231 231 return 11; 232 232 } … … 236 236 CREATE_AND_SET_IMAGE(image10,F64,0,3,3); 237 237 if ( psBinaryOp(image10,inScalar,"+",vector4) == NULL ) { 238 psError( __func__,"psBinaryOp should not return null when input/out dimension don't match.");238 psError(PS_ERR_UNKNOWN, true,"psBinaryOp should not return null when input/out dimension don't match."); 239 239 return 12; 240 240 } -
trunk/psLib/test/dataManip/tst_psMinimize04.c
r2204 r2273 237 237 myPoly = psVectorFitPolynomial1D(NULL, NULL, NULL, NULL); 238 238 if ( myPoly != NULL ) { 239 psError( __func__,"A null polynomial should have returned a null pointer.");239 psError(PS_ERR_UNKNOWN, true,"A null polynomial should have returned a null pointer."); 240 240 testStatus = false; 241 241 } -
trunk/psLib/test/dataManip/tst_psMinimize04b.c
r2204 r2273 47 47 yErr->data.F64[i] = 1.0; 48 48 } 49 p _psNormalizeVectorF64(x);49 psNormalizeVectorRange(x,0.0,1.0); 50 50 51 51 printPositiveTestHeader(stdout, … … 113 113 y->data.F64[i] = setData(x->data.F64[i]); 114 114 } 115 p _psNormalizeVectorF64(x);115 psNormalizeVectorRange(x,0.0,1.0); 116 116 117 117 printPositiveTestHeader(stdout, … … 173 173 y->data.F64[i] = setData(x->data.F64[i]); 174 174 } 175 p _psNormalizeVectorF64(x);175 psNormalizeVectorRange(x,0.0,1.0); 176 176 177 177 printPositiveTestHeader(stdout, -
trunk/psLib/test/dataManip/tst_psMinimize04b_F32.c
r2204 r2273 47 47 yErr->data.F32[i] = 1.0; 48 48 } 49 p _psNormalizeVector(x);49 psNormalizeVectorRange(x,0.0f,1.0f); 50 50 51 51 printPositiveTestHeader(stdout, … … 113 113 y->data.F32[i] = setData(x->data.F32[i]); 114 114 } 115 p _psNormalizeVector(x);115 psNormalizeVectorRange(x,0.0f,1.0f); 116 116 117 117 printPositiveTestHeader(stdout, … … 173 173 y->data.F32[i] = setData(x->data.F32[i]); 174 174 } 175 p _psNormalizeVector(x);175 psNormalizeVectorRange(x,0.0,1.0); 176 176 177 177 printPositiveTestHeader(stdout, -
trunk/psLib/test/dataManip/tst_psMinimize06.c
r2204 r2273 35 35 if (myDeriv == NULL) { 36 36 myDeriv = psImageAlloc(myParams->n, myCoords->n, PS_TYPE_F32); 37 psError( __func__, "myDeriv is NULL.\n");37 psError(PS_ERR_UNKNOWN, true, "myDeriv is NULL.\n"); 38 38 } 39 39 -
trunk/psLib/test/dataManip/tst_psVectorFFT.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 85 85 vec2 = psVectorFFT( NULL, vec, PS_FFT_FORWARD ); 86 86 if ( vec2->type.type != PS_TYPE_C32 ) { 87 psError( __func__, "FFT didn't produce complex values?" );87 psError(PS_ERR_UNKNOWN,true, "FFT didn't produce complex values?" ); 88 88 return 1; 89 89 } … … 94 94 if ( n == 1 || n == 99 ) { 95 95 if ( fabsf( cabsf( vec2->data.C32[ n ] ) - 50.0f ) > 0.1f ) { 96 psError( __func__, "FFT didn't work for vector (n=%d)", n );96 psError(PS_ERR_UNKNOWN,true, "FFT didn't work for vector (n=%d)", n ); 97 97 return 2; 98 98 } 99 99 } else { 100 100 if ( fabsf( cabsf( vec2->data.C32[ n ] ) ) > 0.1f ) { 101 psError( __func__, "FFT didn't work for vector (n=%d)", n );101 psError(PS_ERR_UNKNOWN,true, "FFT didn't work for vector (n=%d)", n ); 102 102 return 3; 103 103 } … … 108 108 vec3 = psVectorFFT( NULL, vec2, PS_FFT_REVERSE ); 109 109 if ( vec3->type.type != PS_TYPE_C32 ) { 110 psError( __func__, "FFT didn't produce complex values?" );110 psError(PS_ERR_UNKNOWN,true, "FFT didn't produce complex values?" ); 111 111 return 4; 112 112 } … … 115 115 psF32 vecVal = crealf( vec3->data.C32[ n ] ) / 100; 116 116 if ( fabsf( vecVal - val ) > 0.1f ) { 117 psError( __func__, "Reverse FFT didn't give me the original vector back (n=%d) (%.2f vs %.2f)",118 n, vecVal, val );117 psError(PS_ERR_UNKNOWN,true, "Reverse FFT didn't give me the original vector back (n=%d) (%.2f vs %.2f)", 118 n, vecVal, val ); 119 119 return 5; 120 120 } … … 150 150 vec2 = psVectorReal( vec2, vec ); 151 151 if ( vec2 == NULL ) { 152 psError( __func__, "psVectorReal returned a NULL?" );152 psError(PS_ERR_UNKNOWN,true, "psVectorReal returned a NULL?" ); 153 153 return 1; 154 154 } 155 155 if ( vec2->type.type != PS_TYPE_F32 ) { 156 psError( __func__, "psVectorReal returned a wrong type (%d)?",157 vec2->type.type );156 psError(PS_ERR_UNKNOWN,true, "psVectorReal returned a wrong type (%d)?", 157 vec2->type.type ); 158 158 return 2; 159 159 } … … 161 161 vec3 = psVectorImaginary( vec3, vec ); 162 162 if ( vec3 == NULL ) { 163 psError( __func__, "psVectorImaginary returned a NULL?" );163 psError(PS_ERR_UNKNOWN,true, "psVectorImaginary returned a NULL?" ); 164 164 return 3; 165 165 } 166 166 if ( vec3->type.type != PS_TYPE_F32 ) { 167 psError( __func__, "psVectorImaginary returned a wrong type (%d)?",168 vec3->type.type );167 psError(PS_ERR_UNKNOWN,true, "psVectorImaginary returned a wrong type (%d)?", 168 vec3->type.type ); 169 169 return 4; 170 170 } … … 175 175 psF32 i = ( n * 2 ); 176 176 if ( fabsf( vec2->data.F32[ n ] - r ) > FLT_EPSILON ) { 177 psError( __func__, "psVectorReal didn't return the real portion at n=%d",178 n );177 psError(PS_ERR_UNKNOWN,true, "psVectorReal didn't return the real portion at n=%d", 178 n ); 179 179 return 5; 180 180 } 181 181 if ( fabsf( vec3->data.F32[ n ] - i ) > FLT_EPSILON ) { 182 psError( __func__, "psVectorImaginary didn't return the real portion at n=%d",183 n );182 psError(PS_ERR_UNKNOWN,true, "psVectorImaginary didn't return the real portion at n=%d", 183 n ); 184 184 return 6; 185 185 } … … 230 230 // 3. verify that the result is a psC32 231 231 if ( vec3->type.type != PS_TYPE_C32 ) { 232 psError( __func__, "Vector Type from psVectorComplex is not complex? (%d)",233 vec3->type.type );232 psError(PS_ERR_UNKNOWN,true, "Vector Type from psVectorComplex is not complex? (%d)", 233 vec3->type.type ); 234 234 return 1; 235 235 } … … 240 240 if ( fabsf( crealf( vec3->data.C32[ n ] ) - n ) > FLT_EPSILON || 241 241 fabsf( cimagf( vec3->data.C32[ n ] ) - ( n * 2 ) ) > FLT_EPSILON ) { 242 psError( __func__, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",243 n, crealf( vec3->data.C32[ n ] ), cimagf( vec3->data.C32[ n ] ) );242 psError(PS_ERR_UNKNOWN,true, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)", 243 n, crealf( vec3->data.C32[ n ] ), cimagf( vec3->data.C32[ n ] ) ); 244 244 return 2; 245 245 }; … … 251 251 252 252 // 7. call psVectorComplex 253 psLogMsg( __func__, PS_LOG_INFO, "Following should be an error (type mismatch)." );253 psLogMsg(__func__, PS_LOG_INFO, "Following should be an error (type mismatch)." ); 254 254 vec3 = psVectorComplex( vec3, vec, vec2 ); 255 255 // 8. verify that an appropriate error occurred. (this partially has to be done via inspection) 256 256 if ( vec3 != NULL ) { 257 psError( __func__, "psVectorComplex returned a vector though input types mismatched." );257 psError(PS_ERR_UNKNOWN,true, "psVectorComplex returned a vector though input types mismatched." ); 258 258 return 3; 259 259 } … … 267 267 // 11. verify thet an appropriate error occurred. (actually, it isn't an error...) 268 268 if ( vec3->n != 100 ) { 269 psError( __func__, "psVectorComplex returned a larger vector than the input supported (%d).", vec3->n );269 psError(PS_ERR_UNKNOWN,true, "psVectorComplex returned a larger vector than the input supported (%d).", vec3->n ); 270 270 return 4; 271 271 } … … 302 302 // 3. verify result is psC32 303 303 if ( vec2->type.type != PS_TYPE_C32 ) { 304 psError( __func__, "the psVectorConjugate didn't return a C32 vector" );304 psError(PS_ERR_UNKNOWN,true, "the psVectorConjugate didn't return a C32 vector" ); 305 305 return 1; 306 306 } … … 310 310 if ( fabsf( crealf( vec->data.C32[ n ] ) - crealf( vec2->data.C32[ n ] ) ) > FLT_EPSILON || 311 311 fabsf( cimagf( vec->data.C32[ n ] ) + cimagf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ) { 312 psError( __func__, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",313 n, crealf( vec2->data.C32[ n ] ), cimagf( vec2->data.C32[ n ] ) );312 psError(PS_ERR_UNKNOWN,true, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)", 313 n, crealf( vec2->data.C32[ n ] ), cimagf( vec2->data.C32[ n ] ) ); 314 314 return 2; 315 315 }; … … 347 347 // 3. verify result is psF32 348 348 if ( vec2->type.type != PS_TYPE_F32 ) { 349 psError( __func__, "the type was not PS_TYPE_F32." );349 psError(PS_ERR_UNKNOWN,true, "the type was not PS_TYPE_F32." ); 350 350 return 1; 351 351 } … … 360 360 val = cabsf( vec->data.C32[ 0 ] ) * cabsf( vec->data.C32[ 0 ] ) / 100 / 100; 361 361 if ( fabsf( vec2->data.F32[ 0 ] - val ) > FLT_EPSILON ) { 362 psError( __func__, "psVectorPowerSpectrum result is invalid (n=0, %.2f %.2f)",363 vec2->data.F32[ 0 ], val );362 psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=0, %.2f %.2f)", 363 vec2->data.F32[ 0 ], val ); 364 364 return 2; 365 365 }; … … 370 370 371 371 if ( fabsf( val - vec2->data.F32[ n ] ) > FLT_EPSILON ) { 372 psError( __func__, "psVectorPowerSpectrum result is invalid (n=%d, %.2f %.2f)",373 n, vec2->data.F32[ n ], val );372 psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=%d, %.2f %.2f)", 373 n, vec2->data.F32[ n ], val ); 374 374 return 2; 375 375 }; … … 378 378 val = cabsf( vec->data.C32[ 50 ] ) * cabsf( vec->data.C32[ 50 ] ) / 100 / 100; 379 379 if ( fabsf( vec2->data.F32[ 50 ] - val ) > FLT_EPSILON ) { 380 psError( __func__, "psVectorPowerSpectrum result is invalid (n=50, %.2f %.2f)",381 vec2->data.F32[ 0 ], val );380 psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=50, %.2f %.2f)", 381 vec2->data.F32[ 0 ], val ); 382 382 return 2; 383 383 }; -
trunk/psLib/test/image/tst_psImage.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 71 71 continue; 72 72 } 73 psError( __func__,"psImageAlloc returned NULL for type %x, size %dx%d.",73 psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned NULL for type %x, size %dx%d.", 74 74 type[t], numCols[i], numRows[i]); 75 75 psFree(image); … … 78 78 79 79 if (image->type.dimen != PS_DIMEN_IMAGE || image->type.type != type[t]) { 80 psError( __func__,"psImageAlloc allocated wrong dimen/type (%d/%d), should be "80 psError(PS_ERR_UNKNOWN, true,"psImageAlloc allocated wrong dimen/type (%d/%d), should be " 81 81 "PS_IMAGE_DIMEN/%d", image->type.dimen, image->type.type, type[t]); 82 82 psFree(image); … … 85 85 86 86 if (image->numCols != numCols[i] || image->numRows != numRows[i]) { 87 psError( __func__,"psImageAlloc allocated wrong size %dx%d, should be %dx%d (type = %d)",87 psError(PS_ERR_UNKNOWN, true,"psImageAlloc allocated wrong size %dx%d, should be %dx%d (type = %d)", 88 88 image->numCols, image->numRows, numCols[i], numRows[i],type[t]); 89 89 psFree(image); … … 92 92 93 93 if (image->col0 != 0 || image->row0 != 0) { 94 psError( __func__,"psImageAlloc returned row0/col0 of %d/%d. Should be 0/0.",94 psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned row0/col0 of %d/%d. Should be 0/0.", 95 95 image->row0, image->row0); 96 96 psFree(image); … … 99 99 100 100 if (image->parent != NULL) { 101 psError( __func__,"psImageAlloc returned non-NULL parent");101 psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned non-NULL parent"); 102 102 psFree(image); 103 103 return 5; … … 105 105 106 106 if (image->children != NULL) { 107 psError( __func__,"psImageAlloc returned non-NULL children array");107 psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned non-NULL children array"); 108 108 psFree(image); 109 109 return 7; … … 123 123 for (psS32 c=0;c<cols;c++) { 124 124 if (image->data.U16[r][c] != 2*c+r) { 125 psError( __func__,"Could not set all pixels in uint16 image at (%d,%d)",c,r);125 psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in uint16 image at (%d,%d)",c,r); 126 126 psFree(image); 127 127 return 8; … … 143 143 for (psS32 c=0;c<cols;c++) { 144 144 if (fabsf(image->data.F32[r][c] - (2.0f*c+r)) > FLT_EPSILON) { 145 psError( __func__,"Could not set all pixels in float image at (%d,%d)",c,r);145 psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in float image at (%d,%d)",c,r); 146 146 psFree(image); 147 147 return 8; … … 163 163 for (psS32 c=0;c<cols;c++) { 164 164 if (fabs(image->data.F64[r][c] - (2.0f*c+r)) > DBL_EPSILON) { 165 psError( __func__,"Could not set all pixels in double image at (%d,%d)",c,r);165 psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in double image at (%d,%d)",c,r); 166 166 psFree(image); 167 167 return 8; … … 184 184 if (fabsf(crealf(image->data.C32[r][c]) - r) > FLT_EPSILON || 185 185 fabsf(cimagf(image->data.C32[r][c]) - c) > FLT_EPSILON ) { 186 psError( __func__,"Could not set all pixels in complex image at (%d,%d)",c,r);186 psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in complex image at (%d,%d)",c,r); 187 187 psFree(image); 188 188 return 8; … … 205 205 for (psS32 c=0;c<cols;c++) { 206 206 if (image->data.PTR[r][c] != temp) { 207 psError( __func__, "Could not set pixel in pointer image at (%d,%d): %x %x",207 psError(PS_ERR_UNKNOWN, true, "Could not set pixel in pointer image at (%d,%d): %x %x", 208 208 c,r,image->data.PTR[r][c],temp); 209 209 psFree(image); … … 229 229 for (psS32 c=0;c<cols;c++) { 230 230 if (image->data.U8[r][c] != (uint8_t)(r + c)) { 231 psError( __func__,"Could not set all pixels in image (type=%d) at (%d,%d)",231 psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in image (type=%d) at (%d,%d)", 232 232 type[t],c,r); 233 233 psFree(image); … … 281 281 // Verify the returned psImage structure pointer is equal to the input parameter output. 282 282 if (img2 != img3) { 283 psError( __func__,"the image given for recycled wasn't");283 psError(PS_ERR_UNKNOWN, true,"the image given for recycled wasn't"); 284 284 return 1; 285 285 } … … 289 289 img4 = psImageCopy(NULL,img,PS_TYPE_F32); 290 290 if (img4 == NULL) { 291 psError( __func__,"output image doesn't exist");291 psError(PS_ERR_UNKNOWN, true,"output image doesn't exist"); 292 292 return 4; 293 293 } 294 294 if (img4->type.type != img->type.type) { 295 psError( __func__,"output image is not the same type as input image");295 psError(PS_ERR_UNKNOWN, true,"output image is not the same type as input image"); 296 296 return 4; 297 297 } … … 301 301 for (unsigned col=0;col<c;col++) { 302 302 if( imgInRow[col] != imgOutRow[col] ) { 303 psError( __func__,"Input image not equal to output image at %d,%d!",303 psError(PS_ERR_UNKNOWN, true,"Input image not equal to output image at %d,%d!", 304 304 col, row); 305 305 return 4; … … 321 321 img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \ 322 322 if (img2 == NULL) { \ 323 psError( __func__,"psImageCopy failed to copy U8."); \323 psError(PS_ERR_UNKNOWN, true,"psImageCopy failed to copy U8."); \ 324 324 return 2; \ 325 325 } \ … … 329 329 for (psU32 col=0;col<c;col++) { \ 330 330 if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \ 331 psError( __func__,"Input image was changed at %d,%d!", \331 psError(PS_ERR_UNKNOWN, true,"Input image was changed at %d,%d!", \ 332 332 col,row); \ 333 333 return 2; \ 334 334 } \ 335 335 if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \ 336 psError( __func__,"returned psImage values after copy don't match at %d,%d " \336 psError(PS_ERR_UNKNOWN, true,"returned psImage values after copy don't match at %d,%d " \ 337 337 "(%d vs %d)",\ 338 338 col,row,img2Row[col], (ps##OUT)(imgRow[col])); \ … … 382 382 img3 = psImageCopy(NULL,NULL,PS_TYPE_F32); 383 383 if (img3 != NULL) { 384 psError( __func__,"psImageCopy didn't return NULL when input image was NULL.");384 psError(PS_ERR_UNKNOWN, true,"psImageCopy didn't return NULL when input image was NULL."); 385 385 return 3; 386 386 } -
trunk/psLib/test/image/tst_psImageConvolve.c
r2204 r2273 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-1 0-27 00:57:33$7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 01:05:00 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 53 53 if (k == NULL) { 54 psError( __func__,"psKernelAlloc returned NULL for [%d:%d,%d:%d].",54 psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for [%d:%d,%d:%d].", 55 55 xMin[i], xMax[i], yMin[i], yMax[i]); 56 56 return i*10+1; … … 59 59 if (k->xMin != xMin[i] || k->xMax != xMax[i] || 60 60 k->yMin != yMin[i] || k->yMax != yMax[i]) { 61 psError( __func__,"Min/max members, [%d:%d,%d:%d], of psKernel wrong. Should be [%d:%d,%d:%d].",61 psError(PS_ERR_UNKNOWN, true,"Min/max members, [%d:%d,%d:%d], of psKernel wrong. Should be [%d:%d,%d:%d].", 62 62 k->xMin,k->xMax, k->yMin, k->yMax, 63 63 xMin[i], xMax[i], yMin[i], yMax[i]); … … 67 67 if (k->image->numCols != xMax[i]-xMin[i]+1 || 68 68 k->image->numRows != yMax[i]-yMin[i]+1) { 69 psError( __func__,"Size of the kernel image is wrong (%dx%d vs %dx%d).",69 psError(PS_ERR_UNKNOWN, true,"Size of the kernel image is wrong (%dx%d vs %dx%d).", 70 70 xMax[i]-xMin[i]+1, yMax[i]-yMin[i]+1, 71 71 k->image->numCols, k->image->numRows); … … 75 75 for (psS32 j=yMin[i]; j<yMax[i]; j++) { 76 76 if (k->kernel[j]+xMin[i] != k->image->data.PS_TYPE_KERNEL_DATA[j-yMin[i]]) { 77 psError( __func__,"The kernel pointer was set wrong for row %d.",77 psError(PS_ERR_UNKNOWN, true,"The kernel pointer was set wrong for row %d.", 78 78 j); 79 79 return i*10+4; … … 87 87 k = psKernelAlloc(5, -5, -2, 2); 88 88 if (k == NULL) { 89 psError( __func__,"psKernelAlloc returned NULL for xMin > xMax.");89 psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for xMin > xMax."); 90 90 return i*10+5; 91 91 } 92 92 93 93 if (k->xMin != -5 || k->xMax != 5) { 94 psError( __func__,"psKernelAlloc didn't swap xMin & xMax.");94 psError(PS_ERR_UNKNOWN, true,"psKernelAlloc didn't swap xMin & xMax."); 95 95 return i*10+6; 96 96 } … … 101 101 k = psKernelAlloc(-2, 2, 5, -5); 102 102 if (k == NULL) { 103 psError( __func__,"psKernelAlloc returned NULL for yMin > yMax.");103 psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for yMin > yMax."); 104 104 return i*10+7; 105 105 } 106 106 107 107 if (k->yMin != -5 || k->yMax != 5) { 108 psError( __func__,"psKernelAlloc didn't swap yMin & yMax.");108 psError(PS_ERR_UNKNOWN, true,"psKernelAlloc didn't swap yMin & yMax."); 109 109 return i*10+8; 110 110 } … … 136 136 137 137 if (result == NULL) { 138 psError( __func__,"psKernelGenerate returned NULL.");138 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL."); 139 139 return 1; 140 140 } … … 142 142 if (result->xMin != -1 || result->xMax != 1 || 143 143 result->yMin != -2 || result->yMax != 2) { 144 psError( __func__,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [0:1,1:2].",144 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [0:1,1:2].", 145 145 result->xMin, result->xMax, result->yMin, result->yMax); 146 146 return 2; … … 154 154 } 155 155 if (fabsf(1.0 - sum) > FLT_EPSILON) { 156 psError( __func__,"psKernelGenerate result is not normalized (sum=%g).",156 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result is not normalized (sum=%g).", 157 157 sum); 158 158 … … 166 166 fabsf(result->kernel[-1][ 0] - 2.0/10.0) > FLT_EPSILON || 167 167 fabsf(result->kernel[-2][-1] - 0.0/10.0) > FLT_EPSILON) { 168 psError( __func__,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",168 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.", 169 169 result->kernel[-1][0], result->kernel[1][1], 170 170 result->kernel[2][0], result->kernel[-2][-1]); … … 191 191 192 192 if (result == NULL) { 193 psError( __func__,"psKernelGenerate returned NULL.");193 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL."); 194 194 return 5; 195 195 } … … 197 197 if (result->xMin != 0 || result->xMax != 1 || 198 198 result->yMin != 0 || result->yMax != 3) { 199 psError( __func__,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [0:1,1:2].",199 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [0:1,1:2].", 200 200 result->xMin, result->xMax, result->yMin, result->yMax); 201 201 return 6; … … 209 209 } 210 210 if (fabsf(1.0 - sum) > FLT_EPSILON) { 211 psError( __func__,"psKernelGenerate result is not normalized (sum=%g).",211 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result is not normalized (sum=%g).", 212 212 sum); 213 213 … … 220 220 fabsf(result->kernel[3][1] - 8.0/21.0) > FLT_EPSILON || 221 221 fabsf(result->kernel[2][1] - 10.0/21.0) > FLT_EPSILON) { 222 psError( __func__,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",222 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.", 223 223 result->kernel[1][0], result->kernel[1][1], 224 224 result->kernel[2][0], result->kernel[2][1]); … … 246 246 result = psKernelGenerate(tVec, xVec, yVec, false); 247 247 if (result == NULL) { 248 psError( __func__,"psKernelGenerate returned NULL.");248 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL."); 249 249 return 9; 250 250 } … … 254 254 fabsf(result->kernel[ 1][ 1] - 6.0/8.0) > FLT_EPSILON || 255 255 fabsf(result->kernel[ 0][ 0] - 1.0/8.0) > FLT_EPSILON) { 256 psError( __func__,"psKernelGenerate result values wrong for truncated time vector.");256 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values wrong for truncated time vector."); 257 257 258 258 return 10; … … 264 264 result = psKernelGenerate(NULL, xVec, yVec, true); 265 265 if (result != NULL) { 266 psError( __func__,"psKernelGenerate returned a kernel with no time vector.");266 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no time vector."); 267 267 return 11; 268 268 } … … 271 271 result = psKernelGenerate(tVec, NULL, yVec, true); 272 272 if (result != NULL) { 273 psError( __func__,"psKernelGenerate returned a kernel with no x vector.");273 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no x vector."); 274 274 return 11; 275 275 } … … 278 278 result = psKernelGenerate(tVec, xVec, NULL, true); 279 279 if (result != NULL) { 280 psError( __func__,"psKernelGenerate returned a kernel with no y vector.");280 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no y vector."); 281 281 return 11; 282 282 } … … 336 336 337 337 if (out == NULL) { 338 psError( __func__, "psImageConvolve returned a NULL for direct gaussian case.");338 psError(PS_ERR_UNKNOWN, true, "psImageConvolve returned a NULL for direct gaussian case."); 339 339 return 1; 340 340 } 341 341 342 342 if (out->numCols != c || out->numRows != r) { 343 psError( __func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",343 psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is %dx%d, but expected %dx%d.", 344 344 out->numCols, out->numRows, 345 345 c,r); … … 350 350 char* typeStr; 351 351 PS_TYPE_NAME(typeStr,out->type.type); 352 psError( __func__, "psImageConvolve result image is of type %s, not psF32.",352 psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is of type %s, not psF32.", 353 353 typeStr); 354 354 return 3; … … 359 359 for (psS32 j=-1;j<1;j++) { 360 360 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 361 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",361 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 362 362 c/2+j,r/2+i, 363 363 out->data.F32[r/2+i][c/2+j], g->kernel[i][j]); … … 365 365 } 366 366 if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) { 367 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",367 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 368 368 j,i, 369 369 out->data.F32[i][j], g->kernel[i][j]); … … 371 371 } 372 372 if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 373 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",373 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 374 374 c/2+j,r-1+i, 375 375 out->data.F32[r-1+i][c/2+j], g->kernel[i][j]); … … 397 397 398 398 if (out == NULL) { 399 psError( __func__, "psImageConvolve returned a NULL for gaussian case.");399 psError(PS_ERR_UNKNOWN, true, "psImageConvolve returned a NULL for gaussian case."); 400 400 return 10; 401 401 } 402 402 403 403 if (out != out2) { 404 psError( __func__, "psImageConvolve didn't recycle the supplied out image struct.");404 psError(PS_ERR_UNKNOWN, true, "psImageConvolve didn't recycle the supplied out image struct."); 405 405 return 11; 406 406 } 407 407 408 408 if (out->numCols != c || out->numRows != r) { 409 psError( __func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",409 psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is %dx%d, but expected %dx%d.", 410 410 out->numCols, out->numRows, 411 411 c,r); … … 416 416 char* typeStr; 417 417 PS_TYPE_NAME(typeStr,out->type.type); 418 psError( __func__, "psImageConvolve result image is of type %s, not psF32.",418 psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is of type %s, not psF32.", 419 419 typeStr); 420 420 return 13; … … 426 426 for (psS32 j=-1;j<1;j++) { 427 427 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 428 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",428 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 429 429 c/2+j,r/2+i, 430 430 out->data.F32[r/2+i][c/2+j], g->kernel[i][j]); … … 433 433 } 434 434 if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) { 435 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",435 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 436 436 j,i, 437 437 out->data.F32[i][j], g->kernel[i][j]); … … 439 439 } 440 440 if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 441 psError( __func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",441 psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 442 442 c/2+j,r-1+i, 443 443 out->data.F32[r-1+i][c/2+j], g->kernel[i][j]); -
trunk/psLib/test/image/tst_psImageExtraction.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 87 87 \ 88 88 if (out->n != TRUTH_SIZE) { \ 89 psError( __func__,"Number of results is wrong (%d, not %d)", \89 psError(PS_ERR_UNKNOWN,true,"Number of results is wrong (%d, not %d)", \ 90 90 out->n,n); \ 91 91 return TESTNUM*4+1; \ … … 93 93 \ 94 94 if (positions->n != TRUTH_SIZE) { \ 95 psError( __func__,"Number of results for positions vector is wrong (%d, not %d)", \95 psError(PS_ERR_UNKNOWN,true,"Number of results for positions vector is wrong (%d, not %d)", \ 96 96 out->n,n); \ 97 97 return TESTNUM*4+2; \ … … 100 100 for (psS32 i=0;i<out->n;i++) { \ 101 101 if (fabs(out->data.F64[i]-image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF64)r) { \ 102 psError( __func__,"Improper result at position %d. Got %g, expected %g",i, \102 psError(PS_ERR_UNKNOWN,true,"Improper result at position %d. Got %g, expected %g",i, \ 103 103 out->data.F64[i],image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]); \ 104 104 return TESTNUM*4+3; \ … … 106 106 if (DIRECTION == PS_CUT_X_POS || DIRECTION == PS_CUT_X_NEG) { \ 107 107 if (positions->data.U32[i] != c/10+TRUTHPIX_X) { \ 108 psError( __func__,"Improper positions (%d vs %d) result @ %d.", \108 psError(PS_ERR_UNKNOWN,true,"Improper positions (%d vs %d) result @ %d.", \ 109 109 positions->data.U32[i],c/10+TRUTHPIX_X,i); \ 110 110 return TESTNUM*4+4; \ … … 112 112 } else { \ 113 113 if (positions->data.U32[i] != r/10+TRUTHPIX_Y) { \ 114 psError( __func__,"Improper positions (%d vs %d) result @ %d.", \114 psError(PS_ERR_UNKNOWN,true,"Improper positions (%d vs %d) result @ %d.", \ 115 115 positions->data.U32[i],r/10+TRUTHPIX_Y,i); \ 116 116 return TESTNUM*4+4; \ … … 165 165 stat ); 166 166 if ( out != NULL ) { 167 psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );167 psError( PS_ERR_UNKNOWN,true, "Giving a NULL image, psImageSlice didn't return NULL as expected" ); 168 168 return 101; 169 169 } … … 184 184 NULL ); 185 185 if ( out != NULL ) { 186 psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );186 psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" ); 187 187 return 102; 188 188 } … … 202 202 stat); 203 203 if ( out != NULL ) { 204 psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );204 psError( PS_ERR_UNKNOWN,true, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" ); 205 205 return 103; 206 206 } … … 220 220 stat ); 221 221 if ( out != NULL ) { 222 psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );222 psError( PS_ERR_UNKNOWN,true, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" ); 223 223 return 104; 224 224 } … … 238 238 stat ); 239 239 if ( out != NULL ) { 240 psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );240 psError( PS_ERR_UNKNOWN,true, "Giving an invalid x position, psImageSlice didn't return NULL as expected" ); 241 241 return 105; 242 242 } … … 251 251 stat ); 252 252 if ( out != NULL ) { 253 psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );253 psError( PS_ERR_UNKNOWN,true, "Giving an invalid y position, psImageSlice didn't return NULL as expected" ); 254 254 return 106; 255 255 } … … 264 264 stat); 265 265 if ( out != NULL ) { 266 psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );266 psError( PS_ERR_UNKNOWN,true, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" ); 267 267 return 107; 268 268 } … … 277 277 stat); 278 278 if ( out != NULL ) { 279 psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );279 psError( PS_ERR_UNKNOWN,true, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" ); 280 280 return 108; 281 281 } … … 296 296 stat); 297 297 if ( out != NULL ) { 298 psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );298 psError( PS_ERR_UNKNOWN,true, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" ); 299 299 return 109; 300 300 } … … 314 314 stat); 315 315 if ( out != NULL ) { 316 psError( __func__, "Mask size different than image size didn't return NULL as expected" );316 psError( PS_ERR_UNKNOWN,true, "Mask size different than image size didn't return NULL as expected" ); 317 317 return 110; 318 318 } … … 330 330 stat); 331 331 if ( out != NULL ) { 332 psError( __func__, "Mask invalid type didn't return NULL as expected.");332 psError( PS_ERR_UNKNOWN,true, "Mask invalid type didn't return NULL as expected."); 333 333 return 111; 334 334 } … … 345 345 stat); 346 346 if ( out != NULL ) { 347 psError( __func__, "Input image with invalid type didn't return NULL as expected.");347 psError( PS_ERR_UNKNOWN,true, "Input image with invalid type didn't return NULL as expected."); 348 348 return 112; 349 349 } … … 390 390 391 391 if (subset2->numCols != c/2 || subset2->numRows != r/2) { 392 psError( __func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",392 psError(PS_ERR_UNKNOWN,true,"psImageSubset output size was not proper(%dx%d, should be %dx%d).", 393 393 subset2->numCols, subset2->numRows, c/2,r/2); 394 394 return 1; … … 396 396 397 397 if (subset3->numCols != c/2 || subset3->numRows != r/2) { 398 psError( __func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",398 psError(PS_ERR_UNKNOWN,true,"psImageSubset output size was not proper(%dx%d, should be %dx%d).", 399 399 subset3->numCols, subset3->numRows, c/2,r/2); 400 400 return 2; … … 407 407 for (psS32 col=0;col<c/2;col++) { 408 408 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) { 409 psError( __func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",409 psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 410 410 row,col,subset2->data.U32[row][col], original->data.U32[row+r/4][col+c/4]); 411 411 return 3; 412 412 } 413 413 if (subset3->data.U32[row][col] != original->data.U32[row][col]) { 414 psError( __func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",414 psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 415 415 row,col,subset2->data.U32[row][col], original->data.U32[row][col]); 416 416 return 4; … … 423 423 424 424 if (subset2->type.type != PS_TYPE_U32) { 425 psError( __func__,"psImageSubset output type was not proper(%d, should be %d).",425 psError(PS_ERR_UNKNOWN,true,"psImageSubset output type was not proper(%d, should be %d).", 426 426 subset2->type.type, PS_TYPE_U32); 427 427 return 6; 428 428 } 429 429 if (subset3->type.type != PS_TYPE_U32) { 430 psError( __func__,"psImageSubset output type was not proper(%d, should be %d).",430 psError(PS_ERR_UNKNOWN,true,"psImageSubset output type was not proper(%d, should be %d).", 431 431 subset3->type.type, PS_TYPE_U32); 432 432 return 7; … … 437 437 438 438 if (subset2->col0 != c/4 || subset2->row0 != r/4) { 439 psError( __func__,"psImageSubset didn't set col0/row0 for subset2 (%d/%d, should be %d/%d).",439 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set col0/row0 for subset2 (%d/%d, should be %d/%d).", 440 440 subset2->col0,subset2->row0,c/4,r/4); 441 441 return 8; 442 442 } 443 443 if (subset3->col0 != 0 || subset3->row0 != 0) { 444 psError( __func__,"psImageSubset didn't set col0/row0 for subset3 (%d/%d, should be %d/%d).",444 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set col0/row0 for subset3 (%d/%d, should be %d/%d).", 445 445 subset3->col0,subset3->row0,0,0); 446 446 return 9; … … 451 451 452 452 if (subset2->parent != original || subset3->parent != original) { 453 psError( __func__,"psImageSubset didn't set parent.");453 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set parent."); 454 454 return 10; 455 455 } … … 458 458 459 459 if (subset2->children != NULL || subset3->children != NULL) { 460 psError( __func__,"psImageSubset didn't set children to NULL.");460 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set children to NULL."); 461 461 return 11; 462 462 } … … 467 467 468 468 if (original->children == NULL || original->children->n != 2) { 469 psError( __func__,"psImageSubset didn't increment number of children by one per subset.");469 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't increment number of children by one per subset."); 470 470 return 12; 471 471 } 472 472 if (original->children->data[0] != subset2 || original->children->data[1] != subset3) { 473 psError( __func__,"psImageSubset didn't properly store the children pointers.");473 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't properly store the children pointers."); 474 474 return 13; 475 475 } … … 482 482 subset1 = psImageSubset(NULL,0,0,c/2,r/2); 483 483 if (subset1 != NULL) { 484 psError( __func__,"psImageSubset didn't return NULL when input image was NULL.");484 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when input image was NULL."); 485 485 return 14; 486 486 } … … 494 494 subset1 = psImageSubset(original,0,r/2,c/2,r/2); 495 495 if (subset1 != NULL) { 496 psError( __func__,"psImageSubset didn't return NULL when numRows=0.");496 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numRows=0."); 497 497 return 15; 498 498 } … … 500 500 subset1 = psImageSubset(original,c/2,0,c/2,r/2); 501 501 if (subset1 != NULL) { 502 psError( __func__,"psImageSubset didn't return NULL when numCols=0.");502 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numCols=0."); 503 503 return 16; 504 504 } 505 505 if (memcmp(original,&preSubsetStruct,sizeof(psImage)) != 0) { 506 psError( __func__,"psImageSubset changed the original struct though it failed to subset.");506 psError(PS_ERR_UNKNOWN,true,"psImageSubset changed the original struct though it failed to subset."); 507 507 return 17; 508 508 } … … 516 516 subset1 = psImageSubset(original,0,0,c/2,r*2); 517 517 if (subset1 != NULL) { 518 psError( __func__,"psImageSubset didn't return NULL when subset origin was outside of "518 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " 519 519 "image (via cols)."); 520 520 return 18; … … 523 523 subset1 = psImageSubset(original,0,0,c*2,r/2); 524 524 if (subset1 != NULL) { 525 psError( __func__,"psImageSubset didn't return NULL when subset origin was outside of "525 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " 526 526 "image (via rows)."); 527 527 return 19; … … 530 530 subset1 = psImageSubset(original,-1,0,c/2,r/2); 531 531 if (subset1 != NULL) { 532 psError( __func__,"psImageSubset didn't return NULL when subset origin was outside of "532 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " 533 533 "image (col0=-1)."); 534 534 return 20; … … 537 537 subset1 = psImageSubset(original,0,-1,c/2,r/2); 538 538 if (subset1 != NULL) { 539 psError( __func__,"psImageSubset didn't return NULL when subset origin was outside of "539 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " 540 540 "image (row0=-1)."); 541 541 return 21; … … 550 550 subset1 = psImageSubset(original,0,0,c/2,r+1); 551 551 if (subset1 != NULL) { 552 psError( __func__,"psImageSubset didn't return NULL when subset was outside of image (via rows).");552 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via rows)."); 553 553 return 22; 554 554 } … … 556 556 subset1 = psImageSubset(original,0,0,c+1,r/2); 557 557 if (subset1 != NULL) { 558 psError( __func__,"psImageSubset didn't return NULL when subset was outside of image (via cols).");558 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via cols)."); 559 559 return 23; 560 560 } … … 562 562 subset1 = psImageSubset(original,0,0,c+1,r+1); 563 563 if (subset1 != NULL) { 564 psError( __func__,"psImageSubset didn't return NULL when subset was outside of image (via row+cols).");564 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via row+cols)."); 565 565 return 24; 566 566 } … … 575 575 // Verify the returned psImage structure member Nchildren is set to zero. 576 576 if (original->children != NULL && original->children->n > 0) { 577 psError( __func__,"psImageFreeChildren didn't set number of children to zero.");577 psError(PS_ERR_UNKNOWN,true,"psImageFreeChildren didn't set number of children to zero."); 578 578 return 25; 579 579 } … … 586 586 preSubsetStruct.col0 != original->col0) { 587 587 588 psError( __func__,"psImageFreeChildren modified parent's non-children elements.");588 psError(PS_ERR_UNKNOWN,true,"psImageFreeChildren modified parent's non-children elements."); 589 589 return 27; 590 590 } … … 626 626 627 627 if (subset == NULL) { 628 psError( __func__,"psImageSubsection returned a NULL with a subset of %s.",628 psError(PS_ERR_UNKNOWN,true,"psImageSubsection returned a NULL with a subset of %s.", 629 629 sectionStr); 630 630 return 10*i+1; … … 632 632 633 633 if (subset->type.type != PS_TYPE_U32) { 634 psError( __func__,"psImageSubsection output type was not proper(%d, should be %d).",634 psError(PS_ERR_UNKNOWN,true,"psImageSubsection output type was not proper(%d, should be %d).", 635 635 subset->type.type, PS_TYPE_U32); 636 636 return 10*i+2; … … 638 638 639 639 if (subset->col0 != x1[i] || subset->row0 != y1[i]) { 640 psError( __func__,"psImageSubsection didn't set properly col0/row0 (%d/%d, should be %d/%d).",640 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set properly col0/row0 (%d/%d, should be %d/%d).", 641 641 subset->col0,subset->row0,x1[i],y1[i]); 642 642 return 10*i+3; … … 644 644 645 645 if (subset->parent != original) { 646 psError( __func__,"psImageSubsection didn't set parent.");646 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set parent."); 647 647 return 10*i+4; 648 648 } 649 649 650 650 if (subset->children != NULL) { 651 psError( __func__,"psImageSubsection didn't set children to NULL.");651 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set children to NULL."); 652 652 return 10*i+5; 653 653 } 654 654 655 655 if (original->children == NULL || original->children->n != i+1) { 656 psError( __func__,"psImageSubsection didn't increment number of children by one per subset.");656 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't increment number of children by one per subset."); 657 657 return 10*i+6; 658 658 } … … 660 660 661 661 if (original->children->data[i] != subset) { 662 psError( __func__,"psImageSubsection didn't properly store the children pointer.");662 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't properly store the children pointer."); 663 663 return 10*i+7; 664 664 } … … 667 667 psS32 numRows = y2[i]-y1[i]+1; 668 668 if (subset->numCols != numCols || subset->numRows != numRows) { 669 psError( __func__,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).",669 psError(PS_ERR_UNKNOWN,true,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).", 670 670 subset->numCols, subset->numRows, numCols, numRows); 671 671 return 10*i+8; … … 675 675 for (psS32 col=0;col<numCols;col++) { 676 676 if (subset->data.U32[row][col] != original->data.U32[row+y1[i]][col+x1[i]]) { 677 psError( __func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",677 psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 678 678 row,col,subset->data.U32[row][col], original->data.U32[row+y1[i]][col+x1[i]]); 679 679 return 10*i+9; … … 686 686 subset = psImageSubsection(original,"[64:32,32:64]"); 687 687 if (subset != NULL) { 688 psError( __func__,"psImageSubsection didn't return NULL when x1 > x2.");688 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when x1 > x2."); 689 689 return 10*i+10; 690 690 } … … 693 693 subset = psImageSubsection(original,"[32:64,64:32]"); 694 694 if (subset != NULL) { 695 psError( __func__,"psImageSubsection didn't return NULL when y1 > y2.");695 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when y1 > y2."); 696 696 return 10*i+11; 697 697 } … … 700 700 subset = psImageSubsection(original,"[64:256,32:64]"); // assumes c<256 701 701 if (subset != NULL) { 702 psError( __func__,"psImageSubsection didn't return NULL when x2 > c.");702 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when x2 > c."); 703 703 return 10*i+12; 704 704 } … … 707 707 subset = psImageSubsection(original,"[32:64,64:256]"); // assumes r==256 708 708 if (subset != NULL) { 709 psError( __func__,"psImageSubsection didn't return NULL when y2 > r.");709 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when y2 > r."); 710 710 return 10*i+13; 711 711 } … … 714 714 subset = psImageSubsection(original,"32:64,32:64"); 715 715 if (subset != NULL) { 716 psError( __func__,"psImageSubsection didn't return NULL when subsection was '32:64,32:64'.");716 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '32:64,32:64'."); 717 717 return 10*i+14; 718 718 } … … 721 721 subset = psImageSubsection(original,"[32-64,32-64]"); 722 722 if (subset != NULL) { 723 psError( __func__,"psImageSubsection didn't return NULL when subsection was '[32-64,32-64]'.");723 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32-64,32-64]'."); 724 724 return 10*i+15; 725 725 } … … 728 728 subset = psImageSubsection(original,"[32:64,32]"); 729 729 if (subset != NULL) { 730 psError( __func__,"psImageSubsection didn't return NULL when subsection was '[32:64,32]'.");730 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32:64,32]'."); 731 731 return 10*i+16; 732 732 } … … 735 735 subset = psImageSubsection(NULL,"[32:64,32:64]"); 736 736 if (subset != NULL) { 737 psError( __func__,"psImageSubsection didn't return NULL when image was NULL.");737 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when image was NULL."); 738 738 return 10*i+17; 739 739 } … … 742 742 subset = psImageSubsection(original,NULL); 743 743 if (subset != NULL) { 744 psError( __func__,"psImageSubsection didn't return NULL when subsection was NULL.");744 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was NULL."); 745 745 return 10*i+18; 746 746 } -
trunk/psLib/test/image/tst_psImageFFT.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 85 85 img2 = psImageFFT(img2,img,PS_FFT_FORWARD); 86 86 if (img2->type.type != PS_TYPE_C32) { 87 psError( __func__,"FFT didn't produce complex values?");87 psError(PS_ERR_UNKNOWN, true,"FFT didn't produce complex values?"); 88 88 return 1; 89 89 } 90 90 if (img2->numCols != m || img2->numRows != n) { 91 psError( __func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",91 psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 92 92 img2->numCols,img2->numRows,m,n); 93 93 return 2; … … 103 103 if (! (col == 0 && (row == 1 || row == n-1)) 104 104 && ! (row == 0 && (col==1 || col == n-1)) ) { 105 psError( __func__,"Result invalid at %d,%d (%.2f)",col,row,mag);105 psError(PS_ERR_UNKNOWN, true,"Result invalid at %d,%d (%.2f)",col,row,mag); 106 106 return 3; 107 107 } … … 109 109 if ( (col == 0 && (row == 1 || row == n-1)) 110 110 || (row == 0 && (col==1 || col == n-1)) ) { 111 psError( __func__,"Result invalid at %d,%d (%.2f)",col,row,mag);111 psError(PS_ERR_UNKNOWN, true,"Result invalid at %d,%d (%.2f)",col,row,mag); 112 112 return 4; 113 113 } … … 120 120 121 121 if (img3->type.type != PS_TYPE_C32) { 122 psError( __func__,"FFT didn't produce complex values?");122 psError(PS_ERR_UNKNOWN, true,"FFT didn't produce complex values?"); 123 123 return 5; 124 124 } 125 125 126 126 if (img3->numCols != m || img3->numRows != n) { 127 psError( __func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",127 psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 128 128 img3->numCols,img3->numRows,m,n); 129 129 return 6; … … 136 136 psF32 pixel = creal(img3Row[col])/m/n; 137 137 if (fabsf(pixel-imgRow[col]) > 0.1) { 138 psError( __func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",138 psError(PS_ERR_UNKNOWN, true,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 139 139 col,row,pixel,imgRow[col]); 140 140 return 7; … … 149 149 char* typeStr; 150 150 PS_TYPE_NAME(typeStr,img3->type.type) 151 psError( __func__,"FFT asked to make real result, but I got a %s type image?",typeStr);151 psError(PS_ERR_UNKNOWN, true,"FFT asked to make real result, but I got a %s type image?",typeStr); 152 152 return 8; 153 153 } 154 154 155 155 if (img3->numCols != m || img3->numRows != n) { 156 psError( __func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",156 psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 157 157 img3->numCols,img3->numRows,m,n); 158 158 return 9; … … 165 165 psF32 pixel = img3Row[col]/m/n; 166 166 if (fabsf(pixel-imgRow[col]) > 0.1) { 167 psError( __func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",167 psError(PS_ERR_UNKNOWN, true,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 168 168 col,row,pixel,imgRow[col]); 169 169 return 10; … … 175 175 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 176 176 if (psImageFFT(NULL,img2,PS_FFT_REVERSE|PS_FFT_FORWARD) != NULL) { 177 psError( __func__,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?");177 psError(PS_ERR_UNKNOWN, true,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?"); 178 178 return 11; 179 179 } … … 181 181 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 182 182 if (psImageFFT(NULL,img2,PS_FFT_FORWARD|PS_FFT_REAL_RESULT) != NULL) { 183 psError( __func__,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?");183 psError(PS_ERR_UNKNOWN, true,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?"); 184 184 return 12; 185 185 } … … 188 188 img4 = psImageFFT(NULL,NULL,PS_FFT_FORWARD); 189 189 if (img4 != NULL ) { 190 psError( __func__,"psImageFFT should return null for a null input image.");190 psError(PS_ERR_UNKNOWN, true,"psImageFFT should return null for a null input image."); 191 191 return 10; 192 192 } … … 197 197 img5 = psImageFFT(NULL,img4,PS_FFT_REAL_RESULT); 198 198 if (img5 != NULL) { 199 psError( __func__,"psImageFFT should return null for an invalid FFT direction.");199 psError(PS_ERR_UNKNOWN, true,"psImageFFT should return null for an invalid FFT direction."); 200 200 return 11; 201 201 } … … 229 229 img2 = psImageReal(img2,img); 230 230 if (img2 == NULL) { 231 psError( __func__,"psImageReal returned a NULL?");231 psError(PS_ERR_UNKNOWN, true,"psImageReal returned a NULL?"); 232 232 return 1; 233 233 } 234 234 if (img2->type.type != PS_TYPE_F32) { 235 psError( __func__,"psImageReal returned a wrong type (%d)?",235 psError(PS_ERR_UNKNOWN, true,"psImageReal returned a wrong type (%d)?", 236 236 img2->type.type); 237 237 return 2; … … 240 240 img3 = psImageImaginary(img3,img); 241 241 if (img3 == NULL) { 242 psError( __func__,"psImageImaginary returned a NULL?");242 psError(PS_ERR_UNKNOWN, true,"psImageImaginary returned a NULL?"); 243 243 return 3; 244 244 } 245 245 if (img3->type.type != PS_TYPE_F32) { 246 psError( __func__,"psImageImaginary returned a wrong type (%d)?",246 psError(PS_ERR_UNKNOWN, true,"psImageImaginary returned a wrong type (%d)?", 247 247 img3->type.type); 248 248 return 4; … … 255 255 for (psU32 col=0;col<m;col++) { 256 256 if (fabsf(img2Row[col] - row) > FLT_EPSILON) { 257 psError( __func__,"psImageReal didn't return the real portion at n=%d",257 psError(PS_ERR_UNKNOWN, true,"psImageReal didn't return the real portion at n=%d", 258 258 n); 259 259 return 5; 260 260 } 261 261 if (fabsf(img3Row[col] - col) > FLT_EPSILON) { 262 psError( __func__,"psImageImaginary didn't return the imag portion at n=%d",262 psError(PS_ERR_UNKNOWN, true,"psImageImaginary didn't return the imag portion at n=%d", 263 263 n); 264 264 return 6; … … 307 307 // 3. verify that the result is a psC32 308 308 if (img3->type.type != PS_TYPE_C32) { 309 psError( __func__,"Image Type from psImageComplex is not complex? (%d)",309 psError(PS_ERR_UNKNOWN, true,"Image Type from psImageComplex is not complex? (%d)", 310 310 img3->type.type); 311 311 return 1; … … 319 319 if (fabsf(crealf(img3Row[col]) - row) > FLT_EPSILON || 320 320 fabsf(cimagf(img3Row[col]) - col) > FLT_EPSILON) { 321 psError( __func__,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",321 psError(PS_ERR_UNKNOWN, true,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)", 322 322 col,row,crealf(img3Row[col]),cimagf(img3Row[col])); 323 323 return 2; … … 334 334 // 8. verify that an appropriate error occurred. (this partially has to be done via inspection) 335 335 if (img3 != NULL) { 336 psError( __func__,"psImageComplex returned a image though input types mismatched.");336 psError(PS_ERR_UNKNOWN, true,"psImageComplex returned a image though input types mismatched."); 337 337 return 3; 338 338 } … … 347 347 // 11. verify thet an appropriate error occurred. 348 348 if (img3 != NULL) { 349 psError( __func__,"psImageComplex returned a image though input sizes mismatched.");349 psError(PS_ERR_UNKNOWN, true,"psImageComplex returned a image though input sizes mismatched."); 350 350 return 4; 351 351 } … … 380 380 // 3. verify result is psC32 381 381 if (img2->type.type != PS_TYPE_C32) { 382 psError( __func__,"the psImageConjugate didn't return a C32 image.");382 psError(PS_ERR_UNKNOWN, true,"the psImageConjugate didn't return a C32 image."); 383 383 return 1; 384 384 } … … 390 390 if (fabsf(crealf(img2Row[col]) - row) > FLT_EPSILON || 391 391 fabsf(cimagf(img2Row[col]) + col) > FLT_EPSILON) { 392 psError( __func__,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",392 psError(PS_ERR_UNKNOWN, true,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)", 393 393 col,row,crealf(img2Row[col]),cimagf(img2Row[col])); 394 394 return 2; … … 425 425 // 3. verify result is psF32 426 426 if (img2->type.type != PS_TYPE_F32) { 427 psError( __func__,"the type was not PS_TYPE_F32.");427 psError(PS_ERR_UNKNOWN, true,"the type was not PS_TYPE_F32."); 428 428 return 1; 429 429 } … … 438 438 439 439 if (fabsf(img2Row[col] - power) > 2.0f*FLT_EPSILON) { 440 psError( __func__,"psImagePowerSpectrum result is invalid (%d,%d, %.2f vs %.2f)",440 psError(PS_ERR_UNKNOWN, true,"psImagePowerSpectrum result is invalid (%d,%d, %.2f vs %.2f)", 441 441 col,row,img2Row[col],power); 442 442 return 2; -
trunk/psLib/test/image/tst_psImageIO.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 97 97 remove(filename); \ 98 98 if (! psImageWriteSection(img3,0,0,1,NULL,0,filename)) { \ 99 psError( __func__,"Failed to write test image %s",filename); \99 psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \ 100 100 return 1; \ 101 101 } \ 102 102 if (! psImageWriteSection(img,0,0,0,NULL,0,filename)) { \ 103 psError( __func__,"Failed to write test image %s",filename); \103 psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \ 104 104 return 2; \ 105 105 } \ 106 106 if (! psImageWriteSection(img,0,0,1,NULL,1,filename)) { \ 107 psError( __func__,"Failed to write test image %s",filename); \107 psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \ 108 108 return 3; \ 109 109 } \ 110 110 if (! psImageWriteSection(img3,0,0,0,NULL,1,filename)) { \ 111 psError( __func__,"Failed to write test image %s",filename); \111 psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \ 112 112 return 4; \ 113 113 } \ … … 119 119 img = psImageReadSection(img,readM0,readN0,readM,readN,0,NULL,0,filename); \ 120 120 /* if (img_ref != img) { */ \ 121 /* psError( __func__,"psImageReadSection didn't recycle the psImage?"); */ \121 /* psError(PS_ERR_UNKNOWN, true,"psImageReadSection didn't recycle the psImage?"); */ \ 122 122 /* return 5; */ \ 123 123 /* } */ \ 124 124 img3 = psImageReadSection(img3,readM0,readN0,readM,readN,1,NULL,0,filename); \ 125 125 if (img3 == NULL) { \ 126 psError( __func__,"Failed to read test image %s",filename); \126 psError(PS_ERR_UNKNOWN, true,"Failed to read test image %s",filename); \ 127 127 return 6; \ 128 128 } \ … … 134 134 for (psU32 col = readM0; col < readM; col++) { \ 135 135 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \ 136 psError( __func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \136 psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \ 137 137 col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \ 138 138 return 7; \ 139 139 } \ 140 140 if (fabsf(img3Row[col-readM0]-img4Row[col]) > FLT_EPSILON) { \ 141 psError( __func__,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \141 psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \ 142 142 col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \ 143 143 return 8; \ … … 152 152 img = psImageReadSection(img,readM0,readN0,readM,readN,1,NULL,1,filename); \ 153 153 if (img == NULL) { \ 154 psError( __func__,"Failed to read test image %s",filename); \154 psError(PS_ERR_UNKNOWN, true,"Failed to read test image %s",filename); \ 155 155 return 9; \ 156 156 } \ … … 162 162 for (psU32 col = readM0; col < readM; col++) { \ 163 163 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \ 164 psError( __func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \164 psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \ 165 165 col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \ 166 166 return 10; \ 167 167 } \ 168 168 if (fabsf(img3Row[col-readM0]-img4Row[col]) > FLT_EPSILON) { \ 169 psError( __func__,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \169 psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \ 170 170 col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \ 171 171 return 11; \ … … 204 204 image = psImageReadSection(image,0,0,M,N,0,NULL,0,"foobar.fits"); 205 205 if (image != NULL) { 206 psError( __func__,"Image returned though filename did not exist.");206 psError(PS_ERR_UNKNOWN, true,"Image returned though filename did not exist."); 207 207 return 12; 208 208 } … … 220 220 image = psImageReadSection(image,0,0,M,N,0,NULL,0,NULL); 221 221 if (image != NULL) { 222 psError( __func__,"Image returned though filename was NULL.");222 psError(PS_ERR_UNKNOWN, true,"Image returned though filename was NULL."); 223 223 return 13; 224 224 } … … 233 233 image = psImageReadSection(image,0,0,M,N,0,NULL,4,"tmpImages/MxN_F32.fits"); 234 234 if (image != NULL) { 235 psError( __func__,"Image returned though extnum was invalid.");235 psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid."); 236 236 return 14; 237 237 } … … 239 239 image = psImageReadSection(image,0,0,M,N,0,"bogus",0,"tmpImages/MxN_F32.fits"); 240 240 if (image != NULL) { 241 psError( __func__,"Image returned though extnum was invalid.");241 psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid."); 242 242 return 15; 243 243 } … … 302 302 ; 303 303 if (! psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) { 304 psError( __func__,"Couldn't write writeTest.fits.");304 psError(PS_ERR_UNKNOWN, true,"Couldn't write writeTest.fits."); 305 305 return 14; 306 306 } 307 307 if (! psImageWriteSection(img2,0,0,0,NULL,0,"tmpImages/writeTest.fits")) { 308 psError( __func__,"Couldn't overwrite writeTest.fits.");308 psError(PS_ERR_UNKNOWN, true,"Couldn't overwrite writeTest.fits."); 309 309 return 15; 310 310 } … … 315 315 img = psImageReadSection(NULL,0,0,m,n,0,NULL,0,"tmpImages/writeTest.fits"); 316 316 if (img == NULL) { 317 psError( __func__,"Could not read in writeTest.fits.");317 psError(PS_ERR_UNKNOWN, true,"Could not read in writeTest.fits."); 318 318 return 16; 319 319 } … … 322 322 for (psU32 col=0;col<m;col++) { 323 323 if (fabsf(imgRow[col] - (row+2*col)) > FLT_EPSILON) { 324 psError( __func__,"The image values were not overwritten at %d,%d (%.2f vs %.2f)",324 psError(PS_ERR_UNKNOWN, true,"The image values were not overwritten at %d,%d (%.2f vs %.2f)", 325 325 col,row,imgRow[col],(row+2*col)); 326 326 return 17; … … 337 337 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message because input image is null."); 338 338 if ( psImageWriteSection(NULL,0,0,0,NULL,0,"tmpImages/writeTest.fits")) { 339 psError( __func__,"psImageWriteSection did not return false when input image is NULL.");339 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false when input image is NULL."); 340 340 return 20; 341 341 } … … 347 347 GENIMAGE(img,32,32,S8,row+2*col); 348 348 if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) { 349 psError( __func__,"psImageWriteSection did not return false when input image type invalid.");349 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false when input image type invalid."); 350 350 return 21; 351 351 } … … 358 358 GENIMAGE(img,32,32,U8,row+2*col); 359 359 if ( psImageWriteSection(img,0,0,0,NULL,0,"panstarrs/writeFits.fits")) { 360 psError( __func__,"psImageWriteSection did not return false for invalid path name.");360 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid path name."); 361 361 return 22; 362 362 } … … 370 370 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid FITS file."); 371 371 if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeInvalidFile.fits")) { 372 psError( __func__,"psImageWriteSection did not return false for invalid FITS file.");372 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid FITS file."); 373 373 return 22; 374 374 } … … 381 381 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension name."); 382 382 if ( psImageWriteSection(img,0,0,0,"ext2",0,"tmpImages/writeTest.fits")) { 383 psError( __func__,"psImageWriteSection did not return false for invalid extension name.");383 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid extension name."); 384 384 return 23; 385 385 } … … 390 390 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension number."); 391 391 if ( psImageWriteSection(img,0,0,0,NULL,99,"tmpImages/writeTest.fits")) { 392 psError( __func__,"psImageWriteSection did not return false for invalid extension number.");392 psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid extension number."); 393 393 return 24; 394 394 } -
trunk/psLib/test/image/tst_psImageManip.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 119 119 } \ 120 120 if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \ 121 psError( __func__,"Pixel value is not as expected (%g vs %g) at %u,%u", \121 psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%g vs %g) at %u,%u", \ 122 122 (psF64)imgRow[col],(psF64)value,col,row); \ 123 123 return 1; \ … … 126 126 } \ 127 127 if (retVal != numClipped) { \ 128 psError( __func__,"Expected %d clips, but got %d", \128 psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \ 129 129 numClipped,retVal); \ 130 130 return 2; \ … … 159 159 if (fabsf(creal(imgRow[col])-creal(value)) > FLT_EPSILON || \ 160 160 fabsf(cimag(imgRow[col])-cimag(value)) > FLT_EPSILON) { \ 161 psError( __func__,"Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \161 psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \ 162 162 creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \ 163 163 return 1; \ … … 166 166 } \ 167 167 if (retVal != numClipped) { \ 168 psError( __func__,"Expected %d clips, but got %d", \168 psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \ 169 169 numClipped,retVal); \ 170 170 return 2; \ … … 198 198 retVal = psImageClip(NULL,min,-1.0f,max,-2.0f); 199 199 if (retVal != 0) { 200 psError( __func__,"Expected zero return for clips of a NULL image.");200 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image."); 201 201 return 3; 202 202 } … … 207 207 retVal = psImageClip(img,max,-1.0f,min,-2.0f); 208 208 if (retVal != 0) { 209 psError( __func__,"Expected zero return for clips when max < min.");209 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips when max < min."); 210 210 return 4; 211 211 } … … 217 217 retVal = psImageClip(img,min,-1.0f,max,-2.0f); 218 218 if (retVal != 0) { 219 psError( __func__,"Expected zero return for clip of invalid image type.");219 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type."); 220 220 return 5; 221 221 } … … 276 276 } \ 277 277 if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \ 278 psError( __func__,"Pixel value is not as expected (%f vs %f) at %d,%d", \278 psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%f vs %f) at %d,%d", \ 279 279 imgRow[col],value,col,row); \ 280 280 return 1; \ … … 283 283 } \ 284 284 if (retVal != numClipped) { \ 285 psError( __func__,"Expected %d clips, but got %d", \285 psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \ 286 286 numClipped,retVal); \ 287 287 return 2; \ … … 299 299 retVal = psImageClipNaN(NULL,-1.0f); 300 300 if (retVal != 0) { 301 psError( __func__,"Expected zero return for clips of a NULL image.");301 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image."); 302 302 return 3; 303 303 } … … 309 309 retVal = psImageClipNaN(img,2.0f); 310 310 if (retVal != 0) { 311 psError( __func__,"Expected zero return for clip of invalid image type.");311 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type."); 312 312 return 4; 313 313 } … … 377 377 } \ 378 378 if (cabs(imgRow[col]-value) > FLT_EPSILON) { \ 379 psError( __func__,"Pixel value is not as expected (%g%+gi vs %g%+gi) at %d,%d", \379 psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%g%+gi vs %g%+gi) at %d,%d", \ 380 380 creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \ 381 381 return 1; \ … … 384 384 } \ 385 385 if (retVal != numClipped) { \ 386 psError( __func__,"Expected %d clips, but got %d", \386 psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \ 387 387 numClipped,retVal); \ 388 388 return 2; \ … … 408 408 retVal = psImageClipComplexRegion(NULL,0,0,0,0); 409 409 if (retVal != 0) { 410 psError( __func__,"Expected zero return for clips of a NULL image.");410 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image."); 411 411 return 3; 412 412 } … … 427 427 retVal = psImageClipComplexRegion(img,10.0+I*1.0,-1.0,5.0+5.0*I,-2.0); 428 428 if (retVal != 0) { 429 psError( __func__,"Expected zero return for creal(min)>creal(max).");429 psError(PS_ERR_UNKNOWN, true,"Expected zero return for creal(min)>creal(max)."); 430 430 return 3; 431 431 } … … 433 433 retVal = psImageClipComplexRegion(img,1.0+I*10.0,-1.0,5.0+5.0*I,-2.0); 434 434 if (retVal != 0) { 435 psError( __func__,"Expected zero return for cimag(min)>cimag(max).");435 psError(PS_ERR_UNKNOWN, true,"Expected zero return for cimag(min)>cimag(max)."); 436 436 return 3; 437 437 } … … 439 439 retVal = psImageClipComplexRegion(img,10.0+I*10.0,-1.0,5.0+5.0*I,-2.0); 440 440 if (retVal != 0) { 441 psError( __func__,"Expected zero return for min>max.");441 psError(PS_ERR_UNKNOWN, true,"Expected zero return for min>max."); 442 442 return 3; 443 443 } … … 457 457 0.0); 458 458 if (retVal != 0) { 459 psError( __func__,"Expected zero return for vmin not in datatype range.");459 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range."); 460 460 return 80; 461 461 } … … 468 468 0.0); 469 469 if (retVal != 0) { 470 psError( __func__,"Expected zero return for vmin not in datatype range.");470 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range."); 471 471 return 81; 472 472 } … … 479 479 0.0); 480 480 if (retVal != 0) { 481 psError( __func__,"Expected zero return for vmin not in datatype range.");481 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range."); 482 482 return 82; 483 483 } … … 490 490 0.0); 491 491 if (retVal != 0) { 492 psError( __func__,"Expected zero return for vmin not in datatype range.");492 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range."); 493 493 return 83; 494 494 } … … 501 501 -2.0*(double)FLT_MAX); 502 502 if (retVal != 0) { 503 psError( __func__,"Expected zero return for vmax not in datatype range.");503 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range."); 504 504 return 84; 505 505 } … … 512 512 2.0*(double)FLT_MAX); 513 513 if (retVal != 0) { 514 psError( __func__,"Expected zero return for vmax not in datatype range.");514 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range."); 515 515 return 85; 516 516 } … … 523 523 -2.0*(double)FLT_MAX*I); 524 524 if (retVal != 0) { 525 psError( __func__,"Expected zero return for vmax not in datatype range.");525 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range."); 526 526 return 87; 527 527 } … … 534 534 2.0*(double)FLT_MAX*I); 535 535 if (retVal != 0) { 536 psError( __func__,"Expected zero return for vmax not in datatype range.");536 psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range."); 537 537 return 88; 538 538 } … … 552 552 0.0); 553 553 if (retVal == 0) { 554 psError( __func__,"Didn't expect zero return for vmin > vmax.");554 psError(PS_ERR_UNKNOWN, true,"Didn't expect zero return for vmin > vmax."); 555 555 return 83; 556 556 } … … 573 573 retVal = psImageClipComplexRegion(img,2.0,10.0,5.0,0.0); 574 574 if (retVal != 0) { 575 psError( __func__,"Expected zero return for clip of invalid image type.");575 psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type."); 576 576 return 84; 577 577 } … … 625 625 retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \ 626 626 if (retVal != 0) { \ 627 psError( __func__,"psImageOverlaySection returned non-zero %s op",OPSTRING); \627 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero %s op",OPSTRING); \ 628 628 return 1; \ 629 629 } \ … … 637 637 } \ 638 638 if (fabsf(imgRow[col] - val) > FLT_EPSILON) { \ 639 psError( __func__,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \639 psError(PS_ERR_UNKNOWN, true,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \ 640 640 col,row,imgRow[col],val,OPSTRING); \ 641 641 return 2; \ 642 642 } \ 643 643 if (row < r/2 && col < c/2 && fabsf(img2Row[col] - 2.0) > FLT_EPSILON) { \ 644 psError( __func__,"Overlay modified at %d,%d (%.2f for %s)", \644 psError(PS_ERR_UNKNOWN, true,"Overlay modified at %d,%d (%.2f for %s)", \ 645 645 col,row,img2Row[col],OPSTRING); \ 646 646 return 2; \ … … 706 706 retVal = psImageOverlaySection(img,img2,c/4,r/4,"+"); 707 707 if (retVal == 0) { 708 psError( __func__,"psImageOverlaySection returned zero even though "708 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though " 709 709 "overlay too big"); 710 710 return 3; … … 714 714 for (unsigned col=0;col<c;col++) { 715 715 if (imgRow[col] != 6.0f) { 716 psError( __func__,"Input image modified when overlay size too big");716 psError(PS_ERR_UNKNOWN, true,"Input image modified when overlay size too big"); 717 717 return 4; 718 718 } … … 729 729 retVal = psImageOverlaySection(img,NULL,c/4,r/4,"+"); 730 730 if (retVal == 0) { 731 psError( __func__,"psImageOverlaySection returned zero even though "731 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though " 732 732 "overlay too big"); 733 733 return 5; … … 737 737 for (unsigned col=0;col<c;col++) { 738 738 if (imgRow[col] != 6.0f) { 739 psError( __func__,"Input image modified when overlay NULL");739 psError(PS_ERR_UNKNOWN, true,"Input image modified when overlay NULL"); 740 740 return 6; 741 741 } … … 751 751 retVal = psImageOverlaySection(NULL,img2,c/4,r/4,"+"); 752 752 if (retVal == 0) { 753 psError( __func__,"psImageOverlaySection returned zero even though "753 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though " 754 754 "overlay too big"); 755 755 return 7; … … 764 764 retVal = psImageOverlaySection(img,img2,0,0,"$"); 765 765 if (retVal == 0) { 766 psError( __func__,"psImageOverlaySection returned zero even though "766 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though " 767 767 "overlay operator is invalid"); 768 768 return 8; … … 777 777 retVal = psImageOverlaySection(img,img2,0,0,NULL); 778 778 if(retVal == 0) { 779 psError( __func__,"psImageOverlaySection returned zero even though "779 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though " 780 780 "overlay operator is NULL"); 781 781 return 9; … … 790 790 retVal = psImageOverlaySection(img,img3,0,0,"+"); 791 791 if(retVal == 0) { 792 psError( __func__,"psImageOverlaySection returned zero eventhough "792 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough " 793 793 " overlay image type is different than input image."); 794 794 return 10; … … 803 803 retVal = psImageOverlaySection(img3,img4,0,0,"+"); 804 804 if(retVal == 0) { 805 psError( __func__,"psImageOverlaySection returned zero eventhough "805 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough " 806 806 "overlay and image type are invalid type."); 807 807 return 11; … … 820 820 retVal = psImageOverlaySection(img,img2,0,0,"/"); 821 821 if (retVal != 0) { 822 psError( __func__,"psImageOverlaySection returned non-zero when "822 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero when " 823 823 "checking divide-by-zero."); 824 824 return 12; … … 906 906 out = psImageRebin(NULL,in,NULL,0,4,&stats); \ 907 907 if (out == NULL) { \ 908 psError( __func__,"psImageRebin returned a NULL pointer!?"); \908 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \ 909 909 return 1; \ 910 910 } \ 911 911 if (out->numRows != 4 || out->numCols != 4) { \ 912 psError( __func__,"psImageRebin didn't produce the proper size image " \912 psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper size image " \ 913 913 "(%d x %d).", \ 914 914 out->numCols, out->numRows); \ … … 920 920 for (psS32 col = 0; col<4; col++) { \ 921 921 if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \ 922 psError( __func__,"psImageRebin didn't produce the proper mean " \922 psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper mean " \ 923 923 "result at (%d,%d) [%f vs %f].", \ 924 924 col,row,outRow[col],truthRow[col]); \ … … 934 934 for ( psS32 col = 0; col<4; col++) { \ 935 935 if(abs((psS32)outRow[col]-(psS32)truthRow[col]) > FLT_EPSILON) { \ 936 psError( __func__,"psImageRebin with mask didn't produce the proper mean " \936 psError(PS_ERR_UNKNOWN, true,"psImageRebin with mask didn't produce the proper mean " \ 937 937 "result at (%d,%d) [%f vs %f].", \ 938 938 col,row,outRow[col],truthRow[col]); \ … … 944 944 out2 = psImageRebin(out,in,NULL,0,3,&stats); \ 945 945 if (out != out2) { \ 946 psError( __func__,"psImageRebin didn't recycle a psImage properly!?"); \946 psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't recycle a psImage properly!?"); \ 947 947 return 7; \ 948 948 } \ 949 949 if (out == NULL) { \ 950 psError( __func__,"psImageRebin returned a NULL pointer!?"); \950 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \ 951 951 return 4; \ 952 952 } \ 953 953 if (out->numRows != 6 || out->numCols != 6) { \ 954 psError( __func__,"psImageRebin didn't produce the proper size image " \954 psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper size image " \ 955 955 "(%d x %d).", \ 956 956 out->numCols, out->numRows); \ … … 962 962 for (psS32 col = 0; col<6; col++) { \ 963 963 if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \ 964 psError( __func__,"psImageRebin didn't produce the proper " \964 psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper " \ 965 965 "max result at (%d,%d) [%f vs %f].", \ 966 966 col,row,outRow[col],truthRow[col]); \ … … 990 990 out = psImageRebin(NULL,in,NULL,0,4,&stats); 991 991 if(out != NULL) { 992 psError( __func__,"psImageRebin return an image eventhough the "992 psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the " 993 993 "type is not handled."); 994 994 return 14; … … 999 999 out = psImageRebin(NULL,in,mask,1,4,&stats); 1000 1000 if(out != NULL) { 1001 psError( __func__,"psImageRebin return an image eventhough the "1001 psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the " 1002 1002 "mask is not the correct type."); 1003 1003 return 17; … … 1012 1012 1013 1013 if (out2 != NULL) { 1014 psError( __func__,"psImageRebin returned an image though the input was "1014 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the input was " 1015 1015 "NULL!?"); 1016 1016 return 8; … … 1024 1024 1025 1025 if (out2 != NULL) { 1026 psError( __func__,"psImageRebin returned an image though the scale was "1026 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the scale was " 1027 1027 "zero!?"); 1028 1028 return 9; … … 1035 1035 1036 1036 if (out2 != NULL) { 1037 psError( __func__,"psImageRebin returned an image though the stats was "1037 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats was " 1038 1038 "NULL!?"); 1039 1039 return 10; … … 1049 1049 1050 1050 if (out2 != NULL) { 1051 psError( __func__,"psImageRebin returned an image though the stats "1051 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats " 1052 1052 "options was zero!?"); 1053 1053 return 11; … … 1059 1059 1060 1060 if (out2 != NULL) { 1061 psError( __func__,"psImageRebin returned an image though the stats "1061 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats " 1062 1062 "options was PS_STAT_USE_RANGE!?"); 1063 1063 return 12; … … 1072 1072 1073 1073 if (out2 != NULL) { 1074 psError( __func__,"psImageRebin returned an image though the stats "1074 psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats " 1075 1075 "options was PS_STAT_SAMPLE_MEAN+PS_STAT_MAX!?"); 1076 1076 return 13; … … 1121 1121 for (psS32 col=0;col<cols;col++) { 1122 1122 if (inRow[col] != outRow[col]) { 1123 psError( __func__,"psImageRoll didn't produce expected result "1123 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1124 1124 "at %d,%d (%f vs %f) for dx=0, dy=0.", 1125 1125 col,row,inRow[col],outRow[col]); … … 1135 1135 for (psS32 col=0;col<cols;col++) { 1136 1136 if (inRow[(col+cols/4) % cols] != outRow[col]) { 1137 psError( __func__,"psImageRoll didn't produce expected result "1137 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1138 1138 "at %d,%d (%f vs %f) for dx=cols/4, dy=0.", 1139 1139 col,row,inRow[(col+cols/4) % cols],outRow[col]); … … 1146 1146 // parameter out if provided. 1147 1147 if (out2 != out) { 1148 psError( __func__,"psImageRoll didn't recycle my out psImage!?");1148 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't recycle my out psImage!?"); 1149 1149 return 1; 1150 1150 } … … 1156 1156 for (psS32 col=0;col<cols;col++) { 1157 1157 if (inRow[col] != outRow[col]) { 1158 psError( __func__,"psImageRoll didn't produce expected result "1158 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1159 1159 "at %d,%d (%f vs %f) for dx=0, dy=rows/4.", 1160 1160 col,row,inRow[col],outRow[col]); … … 1170 1170 for (psS32 col=0;col<cols;col++) { 1171 1171 if (inRow[(col+cols/4) % cols] != outRow[col]) { 1172 psError( __func__,"psImageRoll didn't produce expected result "1172 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1173 1173 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.", 1174 1174 col,row,inRow[(col+cols/4) % cols],outRow[col]); … … 1184 1184 for (psS32 col=0;col<cols;col++) { 1185 1185 if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) { 1186 psError( __func__,"psImageRoll didn't produce expected result "1186 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1187 1187 "at %d,%d (%f vs %f) for dx=-cols/4, dy=0.", 1188 1188 col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]); … … 1198 1198 for (psS32 col=0;col<cols;col++) { 1199 1199 if (inRow[col] != outRow[col]) { 1200 psError( __func__,"psImageRoll didn't produce expected result "1200 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1201 1201 "at %d,%d (%f vs %f) for dx=0, dy=-rows/4.", 1202 1202 col,row,inRow[col],outRow[col]); … … 1212 1212 for (psS32 col=0;col<cols;col++) { 1213 1213 if (inRow[(col+cols-cols/4) % cols] != outRow[col]) { 1214 psError( __func__,"psImageRoll didn't produce expected result "1214 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " 1215 1215 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.", 1216 1216 col,row,inRow[(col+cols-cols/4) % cols],outRow[col]); … … 1226 1226 out2 = psImageRoll(NULL,NULL,0,0); 1227 1227 if (out2 != NULL) { 1228 psError( __func__,"psImageRoll did not return NULL though input image was NULL!?");1228 psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?"); 1229 1229 return 2; 1230 1230 } … … 1249 1249 for (psS32 col=0;col<cols1;col++) { \ 1250 1250 if (inRow[(col+cols1/4)%cols1] != outRow[col]) { \ 1251 psError( __func__,"psImageRoll didn't produce expected result " \1251 psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " \ 1252 1252 "at %d,%d (%f vs %f) for dx=0, dy=0.", \ 1253 1253 col,row,(float)inRow[col],(float)outRow[col]); \ … … 1346 1346 // parameter out if provided. 1347 1347 if (oldOut != NULL && oldOut != fOut) { 1348 psError( __func__,"the output recycle functionality failed");1348 psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed"); 1349 1349 return 2; 1350 1350 } 1351 1351 if (oldBiOut != NULL && oldBiOut != fBiOut) { 1352 psError( __func__,"the output recycle functionality failed");1352 psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed"); 1353 1353 return 4; 1354 1354 } … … 1356 1356 sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR); 1357 1357 if (! psImageWriteSection(fOut,0,0,0,NULL,index,"temp/fOut.fits") ) { 1358 psError( __func__,"Can not write to temp/fOut.fits, so why continue!?");1358 psError(PS_ERR_UNKNOWN, true,"Can not write to temp/fOut.fits, so why continue!?"); 1359 1359 return 20; 1360 1360 } 1361 1361 if (! psImageWriteSection(sOut,0,0,0,NULL,index,"temp/sOut.fits") ) { 1362 psError( __func__,"Can not write to temp/sOut.fits, so why continue!?");1362 psError(PS_ERR_UNKNOWN, true,"Can not write to temp/sOut.fits, so why continue!?"); 1363 1363 return 21; 1364 1364 } 1365 1365 if (! psImageWriteSection(fBiOut,0,0,0,NULL,index,"temp/fBiOut.fits") ) { 1366 psError( __func__,"Can not write to temp/fBiOut.fits, so why continue!?");1366 psError(PS_ERR_UNKNOWN, true,"Can not write to temp/fBiOut.fits, so why continue!?"); 1367 1367 return 40; 1368 1368 } 1369 1369 if (! psImageWriteSection(sBiOut,0,0,0,NULL,index,"temp/sBiOut.fits") ) { 1370 psError( __func__,"Can not write to temp/sBiOut.fits, so why continue!?");1370 psError(PS_ERR_UNKNOWN, true,"Can not write to temp/sBiOut.fits, so why continue!?"); 1371 1371 return 41; 1372 1372 } … … 1378 1378 sBiTruth = psImageReadSection(sBiTruth,0,0,0,0,0,NULL,index,"verified/sBiOut.fits"); 1379 1379 if (fTruth == NULL) { 1380 psError( __func__,"verified psF32 image failed to be read (%d deg. rotation)",1380 psError(PS_ERR_UNKNOWN, true,"verified psF32 image failed to be read (%d deg. rotation)", 1381 1381 rot); 1382 1382 fail = true; 1383 1383 } else { 1384 1384 if (fTruth->numRows != fOut->numRows || fTruth->numCols != fOut->numCols) { 1385 psError( __func__,"Rotated float image size did not match truth "1385 psError(PS_ERR_UNKNOWN, true,"Rotated float image size did not match truth " 1386 1386 "image for %d deg rotation (%dx%d vs %dx%d).", 1387 1387 rot,fOut->numCols,fOut->numRows,fTruth->numCols,fTruth->numRows); … … 1393 1393 for (psS32 col=0;col<fTruth->numCols;col++) { 1394 1394 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1395 psError( __func__,"Float Image mismatch (%f vs %f) at %d,%d.",1395 psError(PS_ERR_UNKNOWN, true,"Float Image mismatch (%f vs %f) at %d,%d.", 1396 1396 outRow[col], truthRow[col],col,row); 1397 1397 fail = true; … … 1403 1403 1404 1404 if (sTruth == NULL) { 1405 psError( __func__,"verified psS16 image failed to be read "1405 psError(PS_ERR_UNKNOWN, true,"verified psS16 image failed to be read " 1406 1406 "(%d deg. rotation)",rot); 1407 1407 fail = true; … … 1409 1409 if (sTruth->numRows != sOut->numRows || 1410 1410 sTruth->numCols != sOut->numCols) { 1411 psError( __func__,"Rotated psS16 image size did not match truth "1411 psError(PS_ERR_UNKNOWN, true,"Rotated psS16 image size did not match truth " 1412 1412 "image for %d deg rotation.",rot); 1413 1413 fail = true; … … 1418 1418 for (psS32 col=0;col<sTruth->numCols;col++) { 1419 1419 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1420 psError( __func__,"Short Image mismatch (%d vs %d) "1420 psError(PS_ERR_UNKNOWN, true,"Short Image mismatch (%d vs %d) " 1421 1421 "at %d,%d.", 1422 1422 outRow[col], truthRow[col],col,row); … … 1430 1430 1431 1431 if (fBiTruth == NULL) { 1432 psError( __func__,"verified psF32 Bi image failed to be read (%d deg. rotation)",1432 psError(PS_ERR_UNKNOWN, true,"verified psF32 Bi image failed to be read (%d deg. rotation)", 1433 1433 rot); 1434 1434 fail = true; 1435 1435 } else { 1436 1436 if (fBiTruth->numRows != fBiOut->numRows || fBiTruth->numCols != fBiOut->numCols) { 1437 psError( __func__,"Rotated float image size did not match truth "1437 psError(PS_ERR_UNKNOWN, true,"Rotated float image size did not match truth " 1438 1438 "image for %d deg rotation (%dx%d vs %dx%d). BILINEAR", 1439 1439 rot,fBiOut->numCols,fBiOut->numRows,fBiTruth->numCols,fBiTruth->numRows); … … 1445 1445 for (psS32 col=0;col<fBiTruth->numCols;col++) { 1446 1446 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1447 psError( __func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR",1447 psError(PS_ERR_UNKNOWN, true,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR", 1448 1448 outRow[col], truthRow[col],col,row); 1449 1449 fail = true; … … 1455 1455 1456 1456 if (sBiTruth == NULL) { 1457 psError( __func__,"verified psS16 image failed to be read "1457 psError(PS_ERR_UNKNOWN, true,"verified psS16 image failed to be read " 1458 1458 "(%d deg. rotation) BILINEAR",rot); 1459 1459 fail = true; … … 1461 1461 if (sBiTruth->numRows != sBiOut->numRows || 1462 1462 sBiTruth->numCols != sBiOut->numCols) { 1463 psError( __func__,"Rotated psS16 image size did not match truth "1463 psError(PS_ERR_UNKNOWN, true,"Rotated psS16 image size did not match truth " 1464 1464 "image for %d deg rotation. BILINEAR",rot); 1465 1465 fail = true; … … 1470 1470 for (psS32 col=0;col<sBiTruth->numCols;col++) { 1471 1471 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1472 psError( __func__,"Short Image mismatch (%d vs %d) "1472 psError(PS_ERR_UNKNOWN, true,"Short Image mismatch (%d vs %d) " 1473 1473 "at %d,%d. BILINEAR", 1474 1474 outRow[col], truthRow[col],col,row); … … 1487 1487 s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT); 1488 1488 if( s32Out != NULL ) { 1489 psError( __func__,"psImage returned is not NULL for invalid image type.");1489 psError(PS_ERR_UNKNOWN, true,"psImage returned is not NULL for invalid image type."); 1490 1490 return 5; 1491 1491 } … … 1496 1496 1497 1497 if (fail) { 1498 psError( __func__,"One or more images didn't match truth or truth did "1498 psError(PS_ERR_UNKNOWN, true,"One or more images didn't match truth or truth did " 1499 1499 "not exist."); 1500 1500 return 10; … … 1507 1507 fOut = psImageRotate(fOut,NULL,0,0,PS_INTERPOLATE_FLAT); 1508 1508 if (fOut != NULL) { 1509 psError( __func__,"NULL wasn't returned though the input image was NULL.");1509 psError(PS_ERR_UNKNOWN, true,"NULL wasn't returned though the input image was NULL."); 1510 1510 return 3; 1511 1511 } … … 1517 1517 fOut = psImageRotate(fOut, fImg, 33, 0, -1); 1518 1518 if (fOut != NULL) { 1519 psError( __func__,"NULL wasn't returned though the interpolation mode "1519 psError(PS_ERR_UNKNOWN, true,"NULL wasn't returned though the interpolation mode " 1520 1520 "is invalid."); 1521 1521 return 4; … … 1598 1598 1599 1599 if (fRecycle != fOut) { 1600 psError( __func__,"psImageShift didn't recycle my image?");1600 psError(PS_ERR_UNKNOWN, true,"psImageShift didn't recycle my image?"); 1601 1601 return 10; 1602 1602 } … … 1609 1609 fOut = psImageShift(fOut,NULL,8,8,NAN,PS_INTERPOLATE_FLAT); 1610 1610 if (fOut != NULL) { 1611 psError( __func__,"psImageShift didn't return NULL given a NULL input image.");1611 psError(PS_ERR_UNKNOWN, true,"psImageShift didn't return NULL given a NULL input image."); 1612 1612 return 11; 1613 1613 } … … 1618 1618 fOut = psImageShift(fOut,fImg,8,8,NAN,-1); 1619 1619 if (fOut != NULL ) { 1620 psError( __func__,"psImageShift didn't return NULL given an invalid interpolation mode.");1620 psError(PS_ERR_UNKNOWN, true,"psImageShift didn't return NULL given an invalid interpolation mode."); 1621 1621 return 12; 1622 1622 } … … 1675 1675 1676 1676 if (fabsf(fRow[col] - fValue) > FLT_EPSILON) { 1677 psError( __func__,"Float image not shifted correctly at %d,%d (%g vs %g)",1677 psError(PS_ERR_UNKNOWN, true,"Float image not shifted correctly at %d,%d (%g vs %g)", 1678 1678 col,row,fRow[col],fValue); 1679 1679 return 1; 1680 1680 } 1681 1681 if (sRow[col] != sValue) { 1682 psError( __func__,"Short image not shifted correctly at %d,%d (%d vs %d)",1682 psError(PS_ERR_UNKNOWN, true,"Short image not shifted correctly at %d,%d (%d vs %d)", 1683 1683 col,row,sRow[col],sValue); 1684 1684 return 2; 1685 1685 } 1686 1686 if (fabsf(fBiRow[col] - fBiValue) > FLT_EPSILON) { 1687 psError( __func__,"Float image not shifted correctly at %d,%d (%g vs %g)",1687 psError(PS_ERR_UNKNOWN, true,"Float image not shifted correctly at %d,%d (%g vs %g)", 1688 1688 col,row,fBiRow[col],fBiValue); 1689 1689 return 1; 1690 1690 } 1691 1691 if (sBiRow[col] != sBiValue) { 1692 psError( __func__,"Short image not shifted correctly at %d,%d (%d vs %d)",1692 psError(PS_ERR_UNKNOWN, true,"Short image not shifted correctly at %d,%d (%d vs %d)", 1693 1693 col,row,sBiRow[col],sBiValue); 1694 1694 return 2; -
trunk/psLib/test/psTest.c
r2204 r2273 85 85 runAll = false; 86 86 if ( sscanf( optarg, "%i", &n ) != 1 ) { 87 psError( __func__, "Failed to parse the testpoint number (%s).",88 optarg );87 psError(PS_ERR_UNKNOWN, true, "Failed to parse the testpoint number (%s).", 88 optarg ); 89 89 break; 90 90 } … … 103 103 } 104 104 if ( ! found ) { 105 psError( __func__, "The specified testpoint number (%d) doesn't exist in this test driver.",106 n );105 psError(PS_ERR_UNKNOWN, true, "The specified testpoint number (%d) doesn't exist in this test driver.", 106 n ); 107 107 break; 108 108 } 109 109 break; 110 110 case '?': 111 psError( __func__, "Option %s is not recognized and is ignored.", optarg );111 psError(PS_ERR_UNKNOWN, true, "Option %s is not recognized and is ignored.", optarg ); 112 112 break; 113 113 } … … 130 130 131 131 if ( ! success ) { 132 psError( testPointFile, "One or more tests failed" ); 132 psError( PS_ERR_UNKNOWN, true, 133 "One or more tests failed" ); 133 134 } 134 135 … … 151 152 if ( retVal == 0 ) { // only bother checking memory if test executed to end. 152 153 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) { 153 psError( __func__, "Memory Leaks Detected" );154 psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" ); 154 155 retVal = 64; 155 156 } … … 175 176 if ( childReturn == 0 ) { // only bother checking memory if test executed to end. 176 177 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) { 177 psError( __func__, "Memory Leaks Detected" );178 psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" ); 178 179 childReturn = 64; 179 180 } -
trunk/psLib/test/sysUtils/tst_psError.c
r2204 r2273 13 13 * @author Eric Van Alst, MHPCC 14 14 * 15 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-1 0-27 00:57:33$15 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-11-04 01:05:00 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 99 99 100 100 // Generate three error messages to have messages on error stack 101 if (psError Msg("test4A",code, true, "Error code = %d", code) != code) {101 if (psError(code, true, "Error code = %d", code) != code) { 102 102 psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify."); 103 103 return 31; 104 104 } 105 if (psError Msg("test4A",(code+1), false, "Error code = %d", (code+1)) != (code+1)) {105 if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) { 106 106 psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify."); 107 107 return 32; 108 108 } 109 if (psError Msg("test4A",(code+2), false, "Error code = %d", (code+2)) != (code+2)) {109 if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) { 110 110 psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify."); 111 111 return 33; … … 165 165 166 166 // Generate three error messages 167 if (psError Msg("test3A",code, true, "Error code = %d", code) != code) {167 if (psError(code, true, "Error code = %d", code) != code) { 168 168 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 169 169 return 23; 170 170 } 171 if (psError Msg("test3A",(code+1), false, "Error code = %d", (code+1)) != (code+1)) {171 if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) { 172 172 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 173 173 return 24; 174 174 } 175 if (psError Msg("test3A",(code+2), false, "Error code = %d", (code+2)) != (code+2)) {175 if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) { 176 176 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 177 177 return 25; … … 219 219 220 220 // Generate error message and verify return value 221 if (psError Msg("test2A",code, true, "Error code = %d", code) != code ) {221 if (psError(code, true, "Error code = %d", code) != code ) { 222 222 psLogMsg("tst_psError02", PS_LOG_ERROR, "Failed return value verify."); 223 223 return 10; … … 233 233 234 234 // Verify the return value of psErrorMsg is the psErrorCode passed 235 if ( psError Msg("test1A",code, true, "Error code = %d", code) != code) {235 if ( psError(code, true, "Error code = %d", code) != code) { 236 236 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return value verify."); 237 237 return 1; … … 240 240 241 241 // test1B empty string in for name argument 242 if ( psError Msg("",code+1, true, "Error code = %d", code+1) != code+1) {242 if ( psError(code+1, true, "Error code = %d", code+1) != code+1) { 243 243 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with empty string."); 244 244 return 2; … … 246 246 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B"); 247 247 248 // test1C null pointer in for name argument249 if ( psErrorMsg(NULL, code+2, true, "Error code = %d", code+2) != code+2) {250 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with null name arg.");251 return 3;252 }253 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1C");254 255 248 // test1D undefined code 256 if ( psError Msg("test1D",-1, true, "Error code = %d", -1) != -1) {249 if ( psError(-1, true, "Error code = %d", -1) != -1) { 257 250 psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with undefined code."); 258 251 return 4; … … 261 254 262 255 // test1E set psErrorMsg argument to false 263 if( psError Msg("test1E",code, false, "Error code = %d", code) != code) {256 if( psError(code, false, "Error code = %d", code) != code) { 264 257 psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with false new arg."); 265 258 return 5; … … 268 261 269 262 // test1F psErrorMsg with a error code less then PS_ERR_BASE(256) 270 if( psError Msg("test1F",9, true, "Errno code = %d", 9) != 9) {263 if( psError(9, true, "Errno code = %d", 9) != 9) { 271 264 psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with errno code."); 272 265 return 6; … … 287 280 288 281 // Test point #1 Multiple type values placed in the error string 289 psError( __func__,282 psError(PS_ERR_UNKNOWN, true, 290 283 "ALL TYPES intval = %d longval = %ld floatval = %f charval = %c strval = %s", 291 284 intval,longval,floatval,charval,stringval); 292 285 293 286 // Test point #2 String values in error message 294 psError(PS_ STRING(__LINE__),"NO VALUES");287 psError(PS_ERR_UNKNOWN, true, "NO VALUES"); 295 288 296 289 // Test point #3 Empty strings in error message 297 psError( "","");290 psError(PS_ERR_UNKNOWN, true, ""); 298 291 299 292 return 0; -
trunk/psLib/test/sysUtils/tst_psMemory.c
r2204 r2273 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-27 00:57:33$8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-04 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 99 99 mem = ( psS32* ) psAlloc( size * sizeof( psS32 ) ); 100 100 if ( mem == NULL ) { 101 psError( __FILE__, "psAlloc returned a NULL value in %s!", __func__ );101 psError(PS_ERR_UNKNOWN, true, "psAlloc returned a NULL value in %s!", __func__ ); 102 102 return 1; 103 103 } … … 130 130 ref = psMemGetRefCounter( mem ); 131 131 if ( ref != 1 ) { 132 psError( __func__, "Expected to buffer reference count to be initially 1, but it was %d.", ref );132 psError(PS_ERR_UNKNOWN, true, "Expected to buffer reference count to be initially 1, but it was %d.", ref ); 133 133 return 1; 134 134 } … … 140 140 ref = psMemGetRefCounter( mem ); 141 141 if ( ref != 4 ) { 142 psError( __func__, "Expected to find buffer reference count to be 4, but it was %d.", ref );142 psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 4, but it was %d.", ref ); 143 143 return 1; 144 144 } … … 149 149 ref = psMemGetRefCounter( mem ); 150 150 if ( ref != 2 ) { 151 psError( __func__, "Expected to find buffer reference count to be 2, but it was %d.", ref );151 psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 2, but it was %d.", ref ); 152 152 return 1; 153 153 } … … 159 159 ref = psMemGetRefCounter( mem ); 160 160 if ( ref != 1 ) { 161 psError( __func__, "Expected to find buffer reference count to be 1, but it was %d.", ref );161 psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 1, but it was %d.", ref ); 162 162 return 1; 163 163 } … … 197 197 198 198 if ( exhaustedCallbackCalled == 0 ) { 199 psError( __FILE__, "Called psRealloc with HUGE memory requirement and survived in %s!", __func__ );199 psError(PS_ERR_UNKNOWN,true, "Called psRealloc with HUGE memory requirement and survived in %s!", __func__ ); 200 200 return 1; 201 201 } … … 232 232 233 233 if ( exhaustedCallbackCalled == 0 ) { 234 psError( __FILE__, "Called psAlloc with HUGE memory requirement and survived in %s!", __func__ );234 psError(PS_ERR_UNKNOWN,true, "Called psAlloc with HUGE memory requirement and survived in %s!", __func__ ); 235 235 return 1; 236 236 } … … 273 273 for ( psS32 i = 0;i < initialSize;i++ ) { 274 274 if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) { 275 psError( __FILE__, "Realloc didn't preserve the contents with expanding buffer in %s.",276 __func__ );275 psError(PS_ERR_UNKNOWN,true, "Realloc didn't preserve the contents with expanding buffer in %s.", 276 __func__ ); 277 277 break; 278 278 } … … 290 290 for ( psS32 i = 0;i < initialSize / 2;i++ ) { 291 291 if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) { 292 psError( __FILE__, "Realloc didn't preserve the contents with shrinking buffer in %s.",293 __func__ );292 psError(PS_ERR_UNKNOWN,true, "Realloc didn't preserve the contents with shrinking buffer in %s.", 293 __func__ ); 294 294 break; 295 295 } … … 333 333 334 334 if ( allocCallbackCalled != 2 || freeCallbackCalled != 2 ) { 335 psError( __FILE__, "alloc/free callbacks were not called the proper number of times in %s",336 __func__ );335 psError(PS_ERR_UNKNOWN,true, "alloc/free callbacks were not called the proper number of times in %s", 336 __func__ ); 337 337 return 1; 338 338 } … … 352 352 353 353 if ( allocCallbackCalled != 2 ) { 354 psError( __FILE__, "realloc callbacks were not called the proper number of times in %s",355 __func__ );354 psError(PS_ERR_UNKNOWN,true, "realloc callbacks were not called the proper number of times in %s", 355 __func__ ); 356 356 return 1; 357 357 } … … 388 388 389 389 if ( nLeaks != 1 ) { 390 psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );390 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ ); 391 391 return 1; 392 392 } 393 393 394 394 if ( blks[ 0 ] ->lineno != lineMark ) { 395 psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one (line %d vs %d) in %s.",396 lineMark, blks[ 0 ] ->lineno, __func__ );395 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one (line %d vs %d) in %s.", 396 lineMark, blks[ 0 ] ->lineno, __func__ ); 397 397 return 1; 398 398 } … … 418 418 419 419 if ( nLeaks != 1 ) { 420 psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );420 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ ); 421 421 return 1; 422 422 } 423 423 424 424 if ( blks[ 0 ] ->lineno != lineMark ) { 425 psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );425 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ ); 426 426 return 1; 427 427 } … … 448 448 449 449 if ( nLeaks != 2 ) { 450 psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );450 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ ); 451 451 return 1; 452 452 } 453 453 454 454 if ( blks[ 0 ] ->lineno != lineMark ) { 455 psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );455 psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ ); 456 456 return 1; 457 457 } … … 499 499 500 500 if ( corruptions != 1 ) { 501 psError( __FILE__, "Expected one memory corruption but found %d in %s.",502 corruptions, __func__ );501 psError(PS_ERR_UNKNOWN,true, "Expected one memory corruption but found %d in %s.", 502 corruptions, __func__ ); 503 503 return 1; 504 504 } 505 505 506 506 if ( problemCallbackCalled != 1 ) { 507 psError( __FILE__, "The memProblemCallback was not invoked but should have been in %s",508 __func__ );507 psError(PS_ERR_UNKNOWN,true, "The memProblemCallback was not invoked but should have been in %s", 508 __func__ ); 509 509 return 1; 510 510 } … … 556 556 557 557 if (err->code != PS_ERR_MEMORY_DEREF_USAGE) { 558 psError Msg("psLibTest.sysUtils.tst_psMemory",PS_ERR_UNKNOWN,true,559 "Multiple psFree calls generated wrong error code (%d)",560 err->code);558 psError(PS_ERR_UNKNOWN,true, 559 "Multiple psFree calls generated wrong error code (%d)", 560 err->code); 561 561 psFree(err); 562 562 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.
