IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2273


Ignore:
Timestamp:
Nov 3, 2004, 3:05:00 PM (22 years ago)
Author:
desonia
Message:

changed the psError signature to match SDRS. Also made misc. cleanups as
I was combing the files.

Location:
trunk/psLib
Files:
109 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psLib.kdevelop.filelist

    r2110 r2273  
    11# KDevelop Custom Project File List
    2 psLib.kdevelop
    3 psLib.kdevses
    4 testbin/CVS/Entries
    5 testbin/CVS/Repository
    6 testbin/CVS/Root
    7 test/FullUnitTest
    8 test/Makefile
    9 test/psTest.c
    10 test/psTest.h
    11 test/runTest
    12 test/tst_template.c
    13 test/sysUtils/Makefile
    14 test/sysUtils/tst_psAbort.c
    15 test/sysUtils/tst_psError.c
    16 test/sysUtils/tst_psLogMsg.c
    17 test/sysUtils/tst_psMemory.c
    18 test/sysUtils/tst_psStringCopy.c
    19 test/sysUtils/tst_psTrace.c
    20 test/sysUtils/verified/tst_psAbort.stderr
    21 test/sysUtils/verified/tst_psAbort.stdout
    22 test/sysUtils/verified/tst_psError.stderr
    23 test/sysUtils/verified/tst_psError.stdout
    24 test/sysUtils/verified/tst_psHash00.stderr
    25 test/sysUtils/verified/tst_psHash00.stdout
    26 test/sysUtils/verified/tst_psHash01.stderr
    27 test/sysUtils/verified/tst_psHash01.stdout
    28 test/sysUtils/verified/tst_psHash02.stderr
    29 test/sysUtils/verified/tst_psHash03.stderr
    30 test/sysUtils/verified/tst_psHash03.stdout
    31 test/sysUtils/verified/tst_psHash04.stderr
    32 test/sysUtils/verified/tst_psHash04.stdout
    33 test/sysUtils/verified/tst_psLogMsg.stderr
    34 test/sysUtils/verified/tst_psLogMsg.stdout
    35 test/sysUtils/verified/tst_psMemory.stderr
    36 test/sysUtils/verified/tst_psStringCopy.stderr
    37 test/sysUtils/verified/tst_psStringCopy.stdout
    38 test/sysUtils/verified/tst_psTrace.stderr
    39 test/sysUtils/verified/tst_psTrace.stdout
    40 test/sysUtils/verified/CVS/Entries
    41 test/sysUtils/verified/CVS/Repository
    42 test/sysUtils/verified/CVS/Root
    43 test/sysUtils/CVS/Entries
    44 test/sysUtils/CVS/Entries.Log
    45 test/sysUtils/CVS/Repository
    46 test/sysUtils/CVS/Root
    47 test/sysUtils/builddir/CVS/Entries
    48 test/sysUtils/builddir/CVS/Repository
    49 test/sysUtils/builddir/CVS/Root
    50 test/image/Makefile
    51 test/image/tst_psImage.c
    52 test/image/tst_psImageExtraction.c
    53 test/image/tst_psImageFFT.c
    54 test/image/tst_psImageIO.c
    55 test/image/tst_psImageManip.c
    56 test/image/tst_psImageStats00.c
    57 test/image/tst_psImageStats01.c
    58 test/image/tst_psImageStats02.c
    59 test/image/tst_psImageStats03.c
    60 test/image/verified/fOut.fits
    61 test/image/verified/sOut.fits
    62 test/image/verified/tst_psImage.stderr
    63 test/image/verified/tst_psImageExtraction.stderr
    64 test/image/verified/tst_psImageFFT.stderr
    65 test/image/verified/tst_psImageIO.stderr
    66 test/image/verified/tst_psImageManip.stderr
    67 test/image/verified/tst_psImageManip.stdout
    68 test/image/verified/tst_psImageStats00.stderr
    69 test/image/verified/tst_psImageStats00.stdout
    70 test/image/verified/tst_psImageStats01.stderr
    71 test/image/verified/tst_psImageStats01.stdout
    72 test/image/verified/tst_psImageStats02.stdout
    73 test/image/verified/CVS/Entries
    74 test/image/verified/CVS/Repository
    75 test/image/verified/CVS/Root
    76 test/image/CVS/Entries
    77 test/image/CVS/Entries.Log
    78 test/image/CVS/Repository
    79 test/image/CVS/Root
    80 test/dataManip/Makefile
    81 test/dataManip/tst_psFunc00.c
    82 test/dataManip/tst_psFunc01.c
    83 test/dataManip/tst_psFunc02.c
    84 test/dataManip/tst_psFunc03.c
    85 test/dataManip/tst_psFunc04.c
    86 test/dataManip/tst_psFunc05.c
    87 test/dataManip/tst_psFunc07.c
    88 test/dataManip/tst_psHist00.c
    89 test/dataManip/tst_psHist01.c
    90 test/dataManip/tst_psHist02.c
    91 test/dataManip/tst_psHist03.c
    92 test/dataManip/tst_psMatrix01.c
    93 test/dataManip/tst_psMatrix02.c
    94 test/dataManip/tst_psMatrix03.c
    95 test/dataManip/tst_psMatrix04.c
    96 test/dataManip/tst_psMatrix05.c
    97 test/dataManip/tst_psMatrix06.c
    98 test/dataManip/tst_psMatrix07.c
    99 test/dataManip/tst_psMatrixVectorArithmetic01.c
    100 test/dataManip/tst_psMatrixVectorArithmetic02.c
    101 test/dataManip/tst_psMatrixVectorArithmetic03.c
    102 test/dataManip/tst_psMinimize00.c
    103 test/dataManip/tst_psMinimize01.c
    104 test/dataManip/tst_psMinimize02.c
    105 test/dataManip/tst_psMinimize03.c
    106 test/dataManip/tst_psMinimize04.c
    107 test/dataManip/tst_psMinimize05.c
    108 test/dataManip/tst_psMinimize06.c
    109 test/dataManip/tst_psStats00.c
    110 test/dataManip/tst_psStats01.c
    111 test/dataManip/tst_psStats02.c
    112 test/dataManip/tst_psStats03.c
    113 test/dataManip/tst_psStats04.c
    114 test/dataManip/tst_psStats05.c
    115 test/dataManip/tst_psStats06.c
    116 test/dataManip/tst_psStats07.c
    117 test/dataManip/tst_psStats08.c
    118 test/dataManip/tst_psStats09.c
    119 test/dataManip/tst_psVectorFFT.c
    120 test/dataManip/verified/tst_psFunc00.stderr
    121 test/dataManip/verified/tst_psFunc00.stdout
    122 test/dataManip/verified/tst_psFunc01.stdout
    123 test/dataManip/verified/tst_psHist00.stdout
    124 test/dataManip/verified/tst_psHist01.stdout
    125 test/dataManip/verified/tst_psHist02.stdout
    126 test/dataManip/verified/tst_psMatrix01.stdout
    127 test/dataManip/verified/tst_psMatrix02.stderr
    128 test/dataManip/verified/tst_psMatrix02.stdout
    129 test/dataManip/verified/tst_psMatrix03.stderr
    130 test/dataManip/verified/tst_psMatrix03.stdout
    131 test/dataManip/verified/tst_psMatrix04.stderr
    132 test/dataManip/verified/tst_psMatrix04.stdout
    133 test/dataManip/verified/tst_psMatrix05.stdout
    134 test/dataManip/verified/tst_psMatrix06.stdout
    135 test/dataManip/verified/tst_psMatrix07.stderr
    136 test/dataManip/verified/tst_psMatrix07.stdout
    137 test/dataManip/verified/tst_psMatrixVectorArithmetic01.stderr
    138 test/dataManip/verified/tst_psMatrixVectorArithmetic01.stdout
    139 test/dataManip/verified/tst_psMatrixVectorArithmetic02.stdout
    140 test/dataManip/verified/tst_psMatrixVectorArithmetic03.stderr
    141 test/dataManip/verified/tst_psMatrixVectorArithmetic03.stdout
    142 test/dataManip/verified/tst_psStats00.stdout
    143 test/dataManip/verified/tst_psStats01.stdout
    144 test/dataManip/verified/tst_psStats02.stdout
    145 test/dataManip/verified/tst_psStats03.stdout
    146 test/dataManip/verified/tst_psStats05.stdout
    147 test/dataManip/verified/tst_psStats06.stdout
    148 test/dataManip/verified/tst_psStats07.stdout
    149 test/dataManip/verified/tst_psStats08.stdout
    150 test/dataManip/verified/tst_psStats09.stdout
    151 test/dataManip/verified/tst_psVectorFFT.stderr
    152 test/dataManip/verified/CVS/Entries
    153 test/dataManip/verified/CVS/Repository
    154 test/dataManip/verified/CVS/Root
    155 test/dataManip/CVS/Entries
    156 test/dataManip/CVS/Entries.Log
    157 test/dataManip/CVS/Repository
    158 test/dataManip/CVS/Root
    159 test/dataManip/builddir/CVS/Entries
    160 test/dataManip/builddir/CVS/Repository
    161 test/dataManip/builddir/CVS/Root
    162 test/CVS/Entries
    163 test/CVS/Entries.Log
    164 test/CVS/Repository
    165 test/CVS/Root
    166 test/collections/Makefile
    167 test/collections/tst_psArray.c
    168 test/collections/tst_psBitSet.c
    169 test/collections/tst_psHash00.c
    170 test/collections/tst_psHash01.c
    171 test/collections/tst_psHash02.c
    172 test/collections/tst_psHash03.c
    173 test/collections/tst_psHash04.c
    174 test/collections/tst_psList.c
    175 test/collections/tst_psVector.c
    176 test/collections/tst_psVectorSort_01.c
    177 test/collections/tst_psVectorSort_02.c
    178 test/collections/tst_psVectorSort_03.c
    179 test/collections/tst_psVectorSort_04.c
    180 test/collections/verified/tst_psArray.stdout
    181 test/collections/verified/tst_psBitSet.stderr
    182 test/collections/verified/tst_psHash00.stderr
    183 test/collections/verified/tst_psHash00.stdout
    184 test/collections/verified/tst_psHash01.stderr
    185 test/collections/verified/tst_psHash01.stdout
    186 test/collections/verified/tst_psHash02.stderr
    187 test/collections/verified/tst_psHash03.stderr
    188 test/collections/verified/tst_psHash03.stdout
    189 test/collections/verified/tst_psHash04.stderr
    190 test/collections/verified/tst_psHash04.stdout
    191 test/collections/verified/tst_psList.stderr
    192 test/collections/verified/tst_psSort_01.stderr
    193 test/collections/verified/tst_psSort_01.stdout
    194 test/collections/verified/tst_psSort_02.stdout
    195 test/collections/verified/tst_psSort_03.stderr
    196 test/collections/verified/tst_psSort_03.stdout
    197 test/collections/verified/tst_psSort_04.stderr
    198 test/collections/verified/tst_psSort_04.stdout
    199 test/collections/verified/tst_psVector.stderr
    200 test/collections/verified/tst_psVector.stdout
    201 test/collections/verified/tst_psVector_01.stderr
    202 test/collections/verified/tst_psVector_01.stdout
    203 test/collections/verified/tst_psVector_02.stdout
    204 test/collections/verified/tst_psVector_03.stdout
    205 test/collections/verified/tst_psVectorSort_01.stderr
    206 test/collections/verified/tst_psVectorSort_01.stdout
    207 test/collections/verified/tst_psVectorSort_02.stderr
    208 test/collections/verified/tst_psVectorSort_02.stdout
    209 test/collections/verified/tst_psVectorSort_03.stderr
    210 test/collections/verified/tst_psVectorSort_03.stdout
    211 test/collections/verified/tst_psVectorSort_04.stderr
    212 test/collections/verified/tst_psVectorSort_04.stdout
    213 test/collections/verified/CVS/Entries
    214 test/collections/verified/CVS/Repository
    215 test/collections/verified/CVS/Root
    216 test/collections/CVS/Entries
    217 test/collections/CVS/Entries.Log
    218 test/collections/CVS/Repository
    219 test/collections/CVS/Root
    220 test/collections/builddir/CVS/Entries
    221 test/collections/builddir/CVS/Repository
    222 test/collections/builddir/CVS/Root
    223 test/astronomy/header_1.fits
    224 test/astronomy/header_2.fits
    225 test/astronomy/Makefile
    226 test/astronomy/tst_psMetadata_01.c
    227 test/astronomy/tst_psMetadata_02.c
    228 test/astronomy/tst_psMetadata_03.c
    229 test/astronomy/tst_psMetadata_04.c
    230 test/astronomy/tst_psMetadata_05.c
    231 test/astronomy/tst_psMetadata_06.c
    232 test/astronomy/tst_psTime_01.c
    233 test/astronomy/tst_psTime_02.c
    234 test/astronomy/verified/tst_psMetadata_01.stderr
    235 test/astronomy/verified/tst_psMetadata_01.stdout
    236 test/astronomy/verified/tst_psMetadata_02.stderr
    237 test/astronomy/verified/tst_psMetadata_02.stdout
    238 test/astronomy/verified/tst_psMetadata_03.stderr
    239 test/astronomy/verified/tst_psMetadata_03.stdout
    240 test/astronomy/verified/tst_psMetadata_04.stderr
    241 test/astronomy/verified/tst_psMetadata_04.stdout
    242 test/astronomy/verified/tst_psMetadata_05.stderr
    243 test/astronomy/verified/tst_psMetadata_05.stdout
    244 test/astronomy/verified/tst_psMetadata_06.stdout
    245 test/astronomy/verified/tst_psTime_01.stdout
    246 test/astronomy/verified/tst_psTime_02.stderr
    247 test/astronomy/verified/tst_psTime_02.stdout
    248 test/astronomy/verified/CVS/Entries
    249 test/astronomy/verified/CVS/Repository
    250 test/astronomy/verified/CVS/Root
    251 test/astronomy/CVS/Entries
    252 test/astronomy/CVS/Entries.Log
    253 test/astronomy/CVS/Repository
    254 test/astronomy/CVS/Root
    255 test/astronomy/builddir/tst_psMetadata_01.d
    256 test/astronomy/builddir/tst_psMetadata_02.d
    257 test/astronomy/builddir/tst_psMetadata_03.d
    258 test/astronomy/builddir/tst_psMetadata_04.d
    259 test/astronomy/builddir/tst_psMetadata_05.d
    260 test/astronomy/builddir/tst_psMetadata_06.d
    261 test/astronomy/builddir/tst_psTime_01.d
    262 test/astronomy/builddir/tst_psTime_02.d
    263 test/astronomy/builddir/CVS/Entries
    264 test/astronomy/builddir/CVS/Repository
    265 test/astronomy/builddir/CVS/Root
    266 src/Doxyfile
    267 src/mainpage.dox
    268 src/Makefile
    269 src/Makefile.Globals
    270 src/parseErrorCodes.pl
    271 src/psErrorCodes.dat
    272 src/pslib.h
    273 src/sysUtils/Makefile
    274 src/sysUtils/psAbort.c
    275 src/sysUtils/psAbort.h
    276 src/sysUtils/psError.c
    277 src/sysUtils/psError.h
    278 src/sysUtils/psErrorCodes.c
    279 src/sysUtils/psErrorCodes.h
    280 src/sysUtils/psLogMsg.c
    281 src/sysUtils/psLogMsg.h
    282 src/sysUtils/psMemory.c
    283 src/sysUtils/psMemory.h
    284 src/sysUtils/psString.c
    285 src/sysUtils/psString.h
    286 src/sysUtils/psSysUtilsErrors.dat
    287 src/sysUtils/psSysUtilsErrors.h
    288 src/sysUtils/psTrace.c
    289 src/sysUtils/psTrace.h
    290 src/sysUtils/psType.h
    291 src/sysUtils/README
    292 src/sysUtils/makedir/psAbort.d
    293 src/sysUtils/makedir/psError.d
    294 src/sysUtils/makedir/psErrorCodes.d
    295 src/sysUtils/makedir/psHash.d
    296 src/sysUtils/makedir/psLogMsg.d
    297 src/sysUtils/makedir/psMemory.d
    298 src/sysUtils/makedir/psString.d
    299 src/sysUtils/makedir/psTrace.d
    300 src/sysUtils/makedir/CVS/Entries
    301 src/sysUtils/makedir/CVS/Repository
    302 src/sysUtils/makedir/CVS/Root
    303 src/sysUtils/CVS/Entries
    304 src/sysUtils/CVS/Entries.Log
    305 src/sysUtils/CVS/Repository
    306 src/sysUtils/CVS/Root
    307 src/image/Makefile
    308 src/image/psImage.c
    309 src/image/psImage.h
    310 src/image/psImageConvolve.c
    311 src/image/psImageConvolve.h
    312 src/image/psImageErrors.dat
    313 src/image/psImageErrors.h
    314 src/image/psImageExtraction.c
    315 src/image/psImageExtraction.h
    316 src/image/psImageFFT.c
    317 src/image/psImageFFT.h
    318 src/image/psImageIO.c
    319 src/image/psImageIO.h
    320 src/image/psImageManip.c
    321 src/image/psImageManip.h
    322 src/image/psImageStats.c
    323 src/image/psImageStats.h
    324 src/image/makedir/psImage.d
    325 src/image/makedir/psImageConvolve.d
    326 src/image/makedir/psImageExtraction.d
    327 src/image/makedir/psImageFFT.d
    328 src/image/makedir/psImageIO.d
    329 src/image/makedir/psImageManip.d
    330 src/image/makedir/psImageStats.d
    331 src/image/makedir/CVS/Entries
    332 src/image/makedir/CVS/Repository
    333 src/image/makedir/CVS/Root
    334 src/image/CVS/Entries
    335 src/image/CVS/Entries.Log
    336 src/image/CVS/Repository
    337 src/image/CVS/Root
    338 src/dataManip/Makefile
    339 src/dataManip/psDataManipErrors.dat
    340 src/dataManip/psDataManipErrors.h
    341 src/dataManip/psFunctions.c
    342 src/dataManip/psFunctions.h
    343 src/dataManip/psMatrix.c
    344 src/dataManip/psMatrix.h
    345 src/dataManip/psMatrixVectorArithmetic.c
    346 src/dataManip/psMatrixVectorArithmetic.h
    347 src/dataManip/psMinimize.c
    348 src/dataManip/psMinimize.h
    349 src/dataManip/psStats.c
    350 src/dataManip/psStats.h
    351 src/dataManip/psVectorFFT.c
    352 src/dataManip/psVectorFFT.h
    353 src/dataManip/makedir/psFunctions.d
    354 src/dataManip/makedir/psMatrix.d
    355 src/dataManip/makedir/psMatrixVectorArithmetic.d
    356 src/dataManip/makedir/psMinimize.d
    357 src/dataManip/makedir/psStats.d
    358 src/dataManip/makedir/psVectorFFT.d
    359 src/dataManip/makedir/CVS/Entries
    360 src/dataManip/makedir/CVS/Repository
    361 src/dataManip/makedir/CVS/Root
    362 src/dataManip/CVS/Entries
    363 src/dataManip/CVS/Entries.Log
    364 src/dataManip/CVS/Repository
    365 src/dataManip/CVS/Root
    366 src/CVS/Entries
    367 src/CVS/Entries.Log
    368 src/CVS/Repository
    369 src/CVS/Root
    370 src/collections/Makefile
    371 src/collections/psArray.c
    372 src/collections/psArray.h
    373 src/collections/psBitSet.c
    374 src/collections/psBitSet.h
    375 src/collections/psCollectionsErrors.dat
    376 src/collections/psCollectionsErrors.h
    377 src/collections/psCompare.c
    378 src/collections/psCompare.h
    379 src/collections/psHash.c
    380 src/collections/psHash.h
    381 src/collections/psList.c
    382 src/collections/psList.h
    383 src/collections/psScalar.c
    384 src/collections/psScalar.h
    385 src/collections/psVector.c
    386 src/collections/psVector.h
    387 src/collections/makedir/psArray.d
    388 src/collections/makedir/psBitSet.d
    389 src/collections/makedir/psCompare.d
    390 src/collections/makedir/psHash.d
    391 src/collections/makedir/psList.d
    392 src/collections/makedir/psScalar.d
    393 src/collections/makedir/psVector.d
    394 src/collections/makedir/CVS/Entries
    395 src/collections/makedir/CVS/Repository
    396 src/collections/makedir/CVS/Root
    397 src/collections/CVS/Entries
    398 src/collections/CVS/Entries.Log
    399 src/collections/CVS/Repository
    400 src/collections/CVS/Root
    401 src/astronomy/Makefile
    402 src/astronomy/psAstrometry.c
    403 src/astronomy/psAstrometry.h
    404 src/astronomy/psAstronomyErrors.dat
    405 src/astronomy/psAstronomyErrors.h
    406 src/astronomy/psCoord.c
    407 src/astronomy/psCoord.h
    408 src/astronomy/psMetadata.c
    409 src/astronomy/psMetadata.h
    410 src/astronomy/psPhotometry.h
    411 src/astronomy/psTime.c
    412 src/astronomy/psTime.h
    413 src/astronomy/slalib.h
    414 src/astronomy/makedir/psAstrometry.d
    415 src/astronomy/makedir/psCoord.d
    416 src/astronomy/makedir/psMetadata.d
    417 src/astronomy/makedir/psTime.d
    418 src/astronomy/makedir/CVS/Entries
    419 src/astronomy/makedir/CVS/Repository
    420 src/astronomy/makedir/CVS/Root
    421 src/astronomy/depend/CVS/Entries
    422 src/astronomy/depend/CVS/Repository
    423 src/astronomy/depend/CVS/Root
    424 src/astronomy/CVS/Entries
    425 src/astronomy/CVS/Entries.Log
    426 src/astronomy/CVS/Repository
    427 src/astronomy/CVS/Root
    428 lib/CVS/Entries
    429 lib/CVS/Repository
    430 lib/CVS/Root
    431 include/CVS/Entries
    432 include/CVS/Repository
    433 include/CVS/Root
    434 data/eopc01.1900-2004
    435 data/finals.all
    436 data/readme.eopc01
    437 data/readme.finals
    438 data/readme.ser7
    439 data/readme.tai-utc
    440 data/ser7.dat
    441 data/tai-utc.dat
    442 data/CVS/Entries
    443 data/CVS/Repository
    444 data/CVS/Root
    445 CVS/Entries
    446 CVS/Entries.Log
    447 CVS/Repository
    448 CVS/Root
    449 test/image/tst_psImageConvolve.c
    450 test/astronomy/tst_psAstrometry.c
    451 test/astronomy/tst_psMetadataIO.c
  • trunk/psLib/psLib.kdevses

    r2156 r2273  
    22<!DOCTYPE KDevPrjSession>
    33<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" />
    215 <pluginList>
    226  <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/>
    368  </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>
    409  <kdevvalgrind>
    4110   <executable path="" params="" />
  • trunk/psLib/src/Makefile.Globals

    r2246 r2273  
    55##  Assumptions:    Variable "prefix" already defined
    66##
    7 ##  $Revision: 1.21 $  $Name: not supported by cvs2svn $
    8 ##  $Date: 2004-11-01 18:55:38 $
     7##  $Revision: 1.22 $  $Name: not supported by cvs2svn $
     8##  $Date: 2004-11-04 01:04:57 $
    99##
    1010##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5454# Set initial value for CFLAGS which will include all OS common flags for GCC
    5555GCOVFLAGS :=
    56 CFLAGS := -O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS)
     56CFLAGS := -Werror -O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS)
    5757
    5858ifdef NO_TRACE
  • trunk/psLib/src/astro/psCoord.c

    r2221 r2273  
    1010*  @author George Gusciora, MHPCC
    1111*
    12 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-27 23:31:43 $
     12*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-11-04 01:04:57 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psConstants.h"
    2828#include "psError.h"
     29#include "psAstronomyErrors.h"
    2930#include <math.h>
    3031#include <float.h>
     
    278279
    279280    } 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");
    281284
    282285    } 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");
    284289    } 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);
    286293    }
    287294
     
    333340
    334341    } 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");
    336345
    337346    } 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");
    339350    } 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);
    341354    }
    342355
     
    407420        } else if (unit == PS_RADIAN) {}
    408421        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);
    410425        }
    411426
     
    413428    }
    414429
    415     psError(__func__, "Unrecognized offset mode\n");
     430    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     431            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
     432            mode);
    416433    return (NULL);
    417434}
     
    469486            tmpD = offset->d;
    470487        } 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);
    472491        }
    473492
     
    483502    }
    484503
    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
    486508    return (NULL);
    487509}
  • trunk/psLib/src/astro/psTime.c

    r2204 r2273  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:30 $
     13 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:04:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psMetadata.h"
    3232#include "psMetadataIO.h"
    33 
     33#include "psConstants.h"
    3434#include "psAstronomyErrors.h"
    3535
     
    151151    char line[LINESIZE];
    152152    psS32 j = 0;
    153     psS32 maxLines = 100;
     153    psS32 maxLines = 1000;
    154154    psF64 *ptr = NULL;
    155155    psImage *table = NULL;
     
    159159    fd=fopen(fileName, "r");
    160160    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");
    162164        return NULL;
    163165    }
     
    168170    while(fgets(line, LINESIZE, fd) != NULL) {
    169171        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);
    171175            return NULL;
    172176            psFree(table);
     
    201205    fd=fopen(fileName, "r");
    202206    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");
    204210        return NULL ;
    205211    }
     
    218224
    219225            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);
    221229                return NULL;
    222230                psFree(table);
     
    240248}
    241249
    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 entry
    311         if(*(line+7) == ' ') {                   // MJD
    312             *ptr = 0.0;
    313         } else {
    314             *ptr = atof(line+7);
    315         }
    316  
    317         if(*(line+18) == ' ') {                  // Polar motion X
    318             *(ptr+1) = 0.0;
    319         } else {
    320             *(ptr+1) = atof(line+18);
    321         }
    322  
    323         if(*(line+27) == ' ') {                  // Polar motion X error
    324             *(ptr+2) = 0.0;
    325         } else {
    326             *(ptr+2) = atof(line+27);
    327         }
    328  
    329         if(*(line+37) == ' ') {                  // Polar motion Y
    330             *(ptr+3) = 0.0;
    331         } else {
    332             *(ptr+3) = atof(line+37);
    333         }
    334  
    335         if(*(line+46) == ' ') {                  // Polar motion Y error
    336             *(ptr+4) = 0.0;
    337         } else {
    338             *(ptr+4) = atof(line+46);
    339         }
    340  
    341         if(*(line+58) == ' ') {                  // UT1-UTC
    342             *(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 */
    353250
    354251static double lookupTaiUtcTable(const psTime *time)
     
    389286            hiIdx++;
    390287            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");
    392291                return 0.0;
    393292            }
     
    395294        loIdx = hiIdx--;
    396295        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");
    398299            return 0.0;
    399300        }
    400301
     302        // since rows of table can not have same jd, this check is probably not needed.
    401303        denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0];
    402304        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");
    404308            return 0.0;
    405309        } else {
    406 
    407310            // Interpolate three constants required to calculate TAI-UTC
    408311            const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1])
     
    445348    mjdUtc = psTimeToMJD(time);
    446349    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");
    448353
    449354    } 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");
    451358    } else {                                                                // All other times..interpolate
    452359        while(mjdUtc > table->data.F64[hiIdx][3]) {
    453360            hiIdx++;
    454361            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");
    456365                return 0.0;
    457366            }
     
    460369        loIdx = hiIdx--;
    461370        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");
    463374        }
    464375
    465376        denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3];
    466377        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");
    468381        } else {
    469382            out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col])
     
    525438    // Error checks
    526439    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);
    528443        return NULL;
    529444    }
    530445
    531446    outTime = (psTime*)psAlloc(sizeof(psTime));
    532     if(outTime == NULL) {
    533         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    534     }
    535447
    536448    outTime->sec = 0;
     
    551463
    552464    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);
    554467        return NULL;
    555468    }
     
    573486
    574487    // 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;
    584493    }
    585494
    586495    delta = psTimeGetTAIDelta(time);
    587496
    588     if(type == PS_TIME_UTC) {
     497    if (type == PS_TIME_UTC) {
    589498        time->sec = time->sec - delta;    // User wants UTC time. Subtract leapseconds.
    590499    } else if(type == PS_TIME_TAI) {
    591500        time->sec = time->sec + delta;    // User wants TAI time. Add leapseconds.
    592501    } 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);
    594505    }
    595506
     
    623534
    624535    // 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);
    632538
    633539    // Calculate TAI or UTC time based on type of time user passes
     
    698604
    699605    // 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);
    707608
    708609    return lookupSer7Table(time, 6);
     
    717618
    718619    // 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);
    728622
    729623    x = lookupSer7Table((psTime*)time, 4);
     
    741635
    742636    // 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);
    750639
    751640    return lookupTaiUtcTable(time);
     
    758647
    759648    // 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);
    773653
    774654    diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2));
     
    781661    double jd = 0.0;
    782662
    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);
    792666
    793667    // Julian date conversion
     
    807681
    808682    // 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);
    816685
    817686    // Modified Julian date conversion
     
    835704
    836705    // 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);
    844708
    845709    tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     
    854718    // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form
    855719    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);
    857722    }
    858723
    859724    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);
    861727    }
    862728    psFree(tempString);
     
    869735    struct timeval timevalTime;
    870736
    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);
    882743
    883744    timevalTime.tv_sec = time->sec;
     
    901762
    902763    // 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);
    912766
    913767    seconds = time->sec%60;
     
    945799    // Allocate output
    946800    tmTime = (struct tm*)psAlloc(sizeof(struct tm));
    947     if (tmTime == NULL)
    948     {
    949         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    950     }
    951801
    952802    tmTime->tm_year = year - 1900;
     
    982832
    983833    // 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);
    987835
    988836    return outTime;
     
    1010858
    1011859    // 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);
    1015861
    1016862    return outTime;
     
    1020866{
    1021867    char tempString[MAX_TIME_STRING_LENGTH];
    1022     psS32 month;
    1023     psS32 day;
    1024     psS32 year;
    1025     psS32 hour;
    1026     psS32 minute;
    1027     psS32 second;
    1028868    psS32 millisecond;
    1029869    struct tm tmTime;
    1030870    psTime *outTime = NULL;
    1031871
    1032 
    1033     // Preserve input string by creating duplicate
    1034     strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
    1035 
    1036872    // 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--;
    1085892    tmTime.tm_isdst = -1;
    1086893
     
    1089896    outTime->usec = millisecond * 1000;
    1090897
     898    return outTime;
     899}
     900
     901psTime* psTimeFromTimeval(const struct timeval *time)
     902{
     903    psTime *outTime = NULL;
     904
     905
    1091906    // 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);
    1110908
    1111909    // Allocate psTime struct
     
    1117915
    1118916    // 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);
    1123918
    1124919    return outTime;
     
    1138933
    1139934    // 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);
    1145936
    1146937    // Allocate psTime struct
     
    1183974
    1184975    // 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);
    1189977
    1190978    return outTime;
     
    1199987
    1200988    // 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
    1201994    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);
    1215997        return NULL;
    1216998    }
     
    12331015
    12341016    // 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);
    12381018
    12391019    return outTime;
     
    12481028
    12491029    // 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);
    12501034    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);
    12641037        return NULL;
    12651038    }
     
    12941067
    12951068    // 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);
    12961074    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);
    13101077        return NULL;
    13111078    }
  • trunk/psLib/src/astronomy/psAstrometry.c

    r2222 r2273  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-27 23:49:00 $
     10 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-11-04 01:04:57 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626#include "psConstants.h"
     27#include "psAstronomyErrors.h"
     28
    2729#include "slalib.h"
    2830
     
    868870    // generate an error if cell->toTP is not linear.
    869871    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");
    871875    }
    872876
  • trunk/psLib/src/astronomy/psAstronomyErrors.dat

    r2204 r2273  
    77#  N.B. in code, the ERRORNAME appears as PS_ERRORTEXT_ERRORNAME
    88####################################################################
     9psTime_FILE_NOT_FOUND                  Failed to open file %s.  No %s information is available.
     10psTime_FILE_TOO_MANY_ROWS              Too many rows found in file %s. Max number of rows allowed is %d.
     11psTime_TIME_POSTDATES_TABLE            Specified psTime postdates (%g) the table of %s information.
     12psTime_TIME_PREDATES_TABLE             Specified psTime predates (%g) the table of %s information.
     13psTime_TABLE_DUPLICATE_ROWS            The %s table was found to have two rows of the same time value.
     14psTime_TYPE_UNKNOWN                    Specified type, %d, is not supported.
     15psTime_TYPE_MISMATCH                   Specified psTime parameters must have same type.
     16psTime_GET_TOD_FAILED                  Failed to determine the current time from gettimeofday function.
     17psTime_CONVERT_TIME_TO_STRING_FAILED   Failed to convert a time via strftime function.
     18psTime_APPEND_MSEC_FAILED              Failed to append millisecond to time string with snprintf function.
     19psTime_USEC_INVALID                    The psTime usec attribute value, %u, is invalid.  Must be less than 1e6.
     20psTime_ISOTIME_MALFORMED               Specified ISO Time string, '%s', is malformed.  Must be in 'YYYY-MM-DDThh:mm:ss.sss' format.
     21#
     22psCoord_PROJECTION_TYPE_UNDEFINED      The projection type, %s, is undefined.
     23psCoord_PROJECTION_TYPE_UNKNOWN        The projection type, %d, is unknown.
     24psCoord_UNITS_UNKNOWN                  Specified units, 0x%x, is not supported.
     25psCoord_OFFSET_MODE_UNKNOWN            Specified offset mode, 0x%x, is not supported.
     26#
     27psAstrometry_NONLINEAR_TRANSFORM       The %s transfrom is not linear.  Only linear transforms are supported.
     28#
     29psMetadata_METATYPE_INVALID            Specified psMetadataType, %d, is not supported.
     30psMetadata_ADD_LIST_FAILED             Failed to add metadata item, %s, to items list.
     31psMetadata_ADD_TABLE_FAILED            Failed to add metadata item, %s, to items table.
     32psMetadata_REMOVE_LIST_FAILED          Failed to remove metadata item, %s, from metadata list.
     33psMetadata_REMOVE_LIST_INDEX_FAILED    Failed to remove metadata item, at index %d, from metadata list.
     34psMetadata_REMOVE_TABLE_FAILED         Failed to remove metadata item, %s, from metadata table.
     35psMetadata_ADD_COLLECTION_FAILED       Failed to add metadata item, %s, to metadata collection list.
     36psMetadata_ADD_FAILED                  Failed to add metadata item to metadata collection list.
     37psMetadata_FIND_FAILED                 Could not find metadata item, %s.
     38psMetadata_FIND_INDEX_FAILED           Could not find metadata item at index %d.
     39#
     40psMetadataIO_TYPE_INVALID              Specified type, %d, is not supported.
     41psMetadataIO_EXTNUM_NOTPOSITIVE        Specified extension number, %d, is invalid.  Value must be positive if no extension name is given.
     42psMetadataIO_FITS_METATYPE_INVALID     Specified FITS metadata type, %c, is not supported.
     43psMetadataIO_ADD_FAILED                Failed to add metadata item, %s.
     44psMetadataIO_FILE_OPEN_FAILED          Failed to open file '%s'.  Check if it exists and it has the proper permissions.
     45psMetadataIO_FILE_MULTIPLE_CHAR        More than one '%c' character not allowed.  Found on line %d of %s.
     46psMetadataIO_FILE_ELEMENT_NULL         Failed to read a metadata %s on line %d of %s.
     47psMetadataIO_FILE_TYPE_INVALID         Metadata type '%s', found on line %d of %s, is not invalid.
     48psMetadataIO_OVERWRITE_ITEM            Duplicate Metadata item, %s, found on line %d of %s.  Overwrite not allowed.
     49psMetadataIO_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  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 19:35:55 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:04:57 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030
    3131//~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."
    3269//~End
    3370
  • trunk/psLib/src/astronomy/psCoord.c

    r2221 r2273  
    1010*  @author George Gusciora, MHPCC
    1111*
    12 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-27 23:31:43 $
     12*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-11-04 01:04:57 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psConstants.h"
    2828#include "psError.h"
     29#include "psAstronomyErrors.h"
    2930#include <math.h>
    3031#include <float.h>
     
    278279
    279280    } 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");
    281284
    282285    } 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");
    284289    } 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);
    286293    }
    287294
     
    333340
    334341    } 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");
    336345
    337346    } 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");
    339350    } 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);
    341354    }
    342355
     
    407420        } else if (unit == PS_RADIAN) {}
    408421        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);
    410425        }
    411426
     
    413428    }
    414429
    415     psError(__func__, "Unrecognized offset mode\n");
     430    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     431            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
     432            mode);
    416433    return (NULL);
    417434}
     
    469486            tmpD = offset->d;
    470487        } 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);
    472491        }
    473492
     
    483502    }
    484503
    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
    486508    return (NULL);
    487509}
  • trunk/psLib/src/astronomy/psMetadata.c

    r2204 r2273  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-10-27 00:57:30 $
     14*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:57 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psMetadata.h"
    3636#include "psString.h"
     37#include "psAstronomyErrors.h"
     38#include "psConstants.h"
    3739
    3840/******************************************************************************/
     
    123125
    124126
    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
    129129    // Allocate metadata item
    130130    metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
     
    147147    // Set metadata item type
    148148    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);
    149157
    150158    // Set metadata item value
    151159    switch (type) {
    152160    case PS_META_ITEM_SET:
    153         metadataItem->data.V = NULL;
    154161        break;
    155162    case PS_META_BOOL:
     
    180187    case PS_META_UNKNOWN:
    181188    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    }
    191195
    192196    return metadataItem;
     
    224228    psMetadataType newType = PS_META_ITEM_SET;
    225229
    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);
    235235
    236236    newType = metadataItem->type;
    237 
    238237    mdTable = md->table;
    239     if(mdTable == NULL) {
    240         psError( __func__, "Null metadata table not allowed" );
    241         return false;
    242     }
    243 
    244238    mdList = md->list;
    245     if(mdList == NULL) {
    246         psError( __func__, "Null metadata list not allowed");
    247         return false;
    248     }
    249 
    250239    key = metadataItem->name;
    251     if(key == NULL) {
    252         psError(__func__, "Null key item not allowed");
    253         return false;
    254     }
    255240
    256241    // See if key is already in table
     
    262247            // Add leaf node to existing folder node
    263248            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 );
    266252                return false;
    267253            }
     
    272258
    273259            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);
    275263                psFree(newFolderEntry);
    276264                return false;
     
    278266
    279267            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);
    281271                psFree(newFolderEntry);
    282272                return false;
     
    284274
    285275            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);
    287279                psFree(newFolderEntry);
    288280                return false;
     
    290282
    291283            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);
    293287                psFree(newFolderEntry);
    294288                return false;
     
    301295            // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
    302296            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);
    304300                return false;
    305301            }
    306302
    307303            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);
    309307                return false;
    310308            }
    311309
    312310            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);
    314314                return false;
    315315            }
     
    319319        // Node doesn't exist - Add new metadata item to metadata collection's hash
    320320        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);
    322324            return false;
    323325        }
     
    328330    if(metadataItem->type != PS_META_ITEM_SET) {
    329331        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);
    332335            return false;
    333336        }
     
    348351
    349352    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);
    352355        psFree(metadataItem);
    353356        return false;
     
    368371
    369372
    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);
    374376
    375377    mdList = md->list;
    376     if (mdList == NULL) {
    377         psError(__func__, "Null metadata list not allowed");
    378         return false;
    379     }
    380 
    381378    mdTable = md->table;
    382     if (mdTable == NULL) {
    383         psError(__func__, "Null metadata table not allowed");
    384         return false;
    385     }
     379
    386380    // Select removal by key or index
    387381    if (key != NULL) {
     
    390384        entry = (psMetadataItem* ) psHashLookup(mdTable, key);
    391385        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);
    393389            return false;
    394390        }
     
    402398            while (entryChild != NULL) {
    403399                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);
    405403                    return false;
    406404                }
     
    411409            // Table entry has no children. Remove entry from metadata collection's list
    412410            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);
    414414                return false;
    415415            }
     
    417417        // Remove entry from metadata collection's table
    418418        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);
    420422            return false;
    421423        }
     
    425427        entry = psListGet(mdList, where);
    426428        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);
    428432            return false;
    429433        }
     
    431435        key = entry->name;
    432436        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);
    434440            return false;
    435441        }
     
    447453
    448454
    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);
    453458
    454459    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     }
    464460
    465461    entry = (psMetadataItem* ) psHashLookup(mdTable, key);
     
    473469psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
    474470{
     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
     487psBool 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
     497psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
     498{
    475499    psList* mdList = NULL;
    476500    psMetadataItem* entry = NULL;
    477501
    478502
    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);
    483505
    484506    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     }
    535507
    536508    psListSetIterator(mdList, which);
     
    559531
    560532
    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);
    565535
    566536    mdList = md->list;
    567     if (mdList == NULL) {
    568         psError(__func__, "Null metadata list not allowed");
    569         return NULL;
    570     }
    571537
    572538    psListSetIterator(mdList, which);
  • trunk/psLib/src/astronomy/psMetadataIO.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    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); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *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);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    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,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    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);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    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);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        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);
    443438            return output;
    444439        }
     
    471466
    472467    // 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);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                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);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                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);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                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);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                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);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                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);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                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);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    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);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                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);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        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);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    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);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    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);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    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);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    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);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                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);
    654673                continue;
    655674            } // switch
  • trunk/psLib/src/astronomy/psTime.c

    r2204 r2273  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:30 $
     13 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:04:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psMetadata.h"
    3232#include "psMetadataIO.h"
    33 
     33#include "psConstants.h"
    3434#include "psAstronomyErrors.h"
    3535
     
    151151    char line[LINESIZE];
    152152    psS32 j = 0;
    153     psS32 maxLines = 100;
     153    psS32 maxLines = 1000;
    154154    psF64 *ptr = NULL;
    155155    psImage *table = NULL;
     
    159159    fd=fopen(fileName, "r");
    160160    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");
    162164        return NULL;
    163165    }
     
    168170    while(fgets(line, LINESIZE, fd) != NULL) {
    169171        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);
    171175            return NULL;
    172176            psFree(table);
     
    201205    fd=fopen(fileName, "r");
    202206    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");
    204210        return NULL ;
    205211    }
     
    218224
    219225            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);
    221229                return NULL;
    222230                psFree(table);
     
    240248}
    241249
    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 entry
    311         if(*(line+7) == ' ') {                   // MJD
    312             *ptr = 0.0;
    313         } else {
    314             *ptr = atof(line+7);
    315         }
    316  
    317         if(*(line+18) == ' ') {                  // Polar motion X
    318             *(ptr+1) = 0.0;
    319         } else {
    320             *(ptr+1) = atof(line+18);
    321         }
    322  
    323         if(*(line+27) == ' ') {                  // Polar motion X error
    324             *(ptr+2) = 0.0;
    325         } else {
    326             *(ptr+2) = atof(line+27);
    327         }
    328  
    329         if(*(line+37) == ' ') {                  // Polar motion Y
    330             *(ptr+3) = 0.0;
    331         } else {
    332             *(ptr+3) = atof(line+37);
    333         }
    334  
    335         if(*(line+46) == ' ') {                  // Polar motion Y error
    336             *(ptr+4) = 0.0;
    337         } else {
    338             *(ptr+4) = atof(line+46);
    339         }
    340  
    341         if(*(line+58) == ' ') {                  // UT1-UTC
    342             *(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 */
    353250
    354251static double lookupTaiUtcTable(const psTime *time)
     
    389286            hiIdx++;
    390287            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");
    392291                return 0.0;
    393292            }
     
    395294        loIdx = hiIdx--;
    396295        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");
    398299            return 0.0;
    399300        }
    400301
     302        // since rows of table can not have same jd, this check is probably not needed.
    401303        denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0];
    402304        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");
    404308            return 0.0;
    405309        } else {
    406 
    407310            // Interpolate three constants required to calculate TAI-UTC
    408311            const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1])
     
    445348    mjdUtc = psTimeToMJD(time);
    446349    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");
    448353
    449354    } 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");
    451358    } else {                                                                // All other times..interpolate
    452359        while(mjdUtc > table->data.F64[hiIdx][3]) {
    453360            hiIdx++;
    454361            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");
    456365                return 0.0;
    457366            }
     
    460369        loIdx = hiIdx--;
    461370        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");
    463374        }
    464375
    465376        denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3];
    466377        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");
    468381        } else {
    469382            out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col])
     
    525438    // Error checks
    526439    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);
    528443        return NULL;
    529444    }
    530445
    531446    outTime = (psTime*)psAlloc(sizeof(psTime));
    532     if(outTime == NULL) {
    533         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    534     }
    535447
    536448    outTime->sec = 0;
     
    551463
    552464    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);
    554467        return NULL;
    555468    }
     
    573486
    574487    // 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;
    584493    }
    585494
    586495    delta = psTimeGetTAIDelta(time);
    587496
    588     if(type == PS_TIME_UTC) {
     497    if (type == PS_TIME_UTC) {
    589498        time->sec = time->sec - delta;    // User wants UTC time. Subtract leapseconds.
    590499    } else if(type == PS_TIME_TAI) {
    591500        time->sec = time->sec + delta;    // User wants TAI time. Add leapseconds.
    592501    } 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);
    594505    }
    595506
     
    623534
    624535    // 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);
    632538
    633539    // Calculate TAI or UTC time based on type of time user passes
     
    698604
    699605    // 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);
    707608
    708609    return lookupSer7Table(time, 6);
     
    717618
    718619    // 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);
    728622
    729623    x = lookupSer7Table((psTime*)time, 4);
     
    741635
    742636    // 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);
    750639
    751640    return lookupTaiUtcTable(time);
     
    758647
    759648    // 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);
    773653
    774654    diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2));
     
    781661    double jd = 0.0;
    782662
    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);
    792666
    793667    // Julian date conversion
     
    807681
    808682    // 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);
    816685
    817686    // Modified Julian date conversion
     
    835704
    836705    // 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);
    844708
    845709    tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     
    854718    // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form
    855719    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);
    857722    }
    858723
    859724    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);
    861727    }
    862728    psFree(tempString);
     
    869735    struct timeval timevalTime;
    870736
    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);
    882743
    883744    timevalTime.tv_sec = time->sec;
     
    901762
    902763    // 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);
    912766
    913767    seconds = time->sec%60;
     
    945799    // Allocate output
    946800    tmTime = (struct tm*)psAlloc(sizeof(struct tm));
    947     if (tmTime == NULL)
    948     {
    949         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    950     }
    951801
    952802    tmTime->tm_year = year - 1900;
     
    982832
    983833    // 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);
    987835
    988836    return outTime;
     
    1010858
    1011859    // 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);
    1015861
    1016862    return outTime;
     
    1020866{
    1021867    char tempString[MAX_TIME_STRING_LENGTH];
    1022     psS32 month;
    1023     psS32 day;
    1024     psS32 year;
    1025     psS32 hour;
    1026     psS32 minute;
    1027     psS32 second;
    1028868    psS32 millisecond;
    1029869    struct tm tmTime;
    1030870    psTime *outTime = NULL;
    1031871
    1032 
    1033     // Preserve input string by creating duplicate
    1034     strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
    1035 
    1036872    // 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--;
    1085892    tmTime.tm_isdst = -1;
    1086893
     
    1089896    outTime->usec = millisecond * 1000;
    1090897
     898    return outTime;
     899}
     900
     901psTime* psTimeFromTimeval(const struct timeval *time)
     902{
     903    psTime *outTime = NULL;
     904
     905
    1091906    // 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);
    1110908
    1111909    // Allocate psTime struct
     
    1117915
    1118916    // 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);
    1123918
    1124919    return outTime;
     
    1138933
    1139934    // 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);
    1145936
    1146937    // Allocate psTime struct
     
    1183974
    1184975    // 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);
    1189977
    1190978    return outTime;
     
    1199987
    1200988    // 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
    1201994    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);
    1215997        return NULL;
    1216998    }
     
    12331015
    12341016    // 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);
    12381018
    12391019    return outTime;
     
    12481028
    12491029    // 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);
    12501034    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);
    12641037        return NULL;
    12651038    }
     
    12941067
    12951068    // 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);
    12961074    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);
    13101077        return NULL;
    13111078    }
  • trunk/psLib/src/collections/psBitSet.c

    r2204 r2273  
    1111 *  @author Robert DeSonia, MHPCC
    1212 *
    13  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:04:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7272
    7373    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);
    7877        return NULL;
    7978    }
     
    9998
    10099    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);
    104102        return inBitSet;
    105103    } else if ( (bit < 0) ||
    106104                (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);
    111108        return inBitSet;
    112109    }
     
    124121
    125122    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);
    129125        return inBitSet;
    130126    } else if ( (bit < 0) ||
    131127                (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);
    136131        return inBitSet;
    137132    }
     
    149144
    150145    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);
    154148        return false;
    155149    } else if ( (bit < 0) ||
    156150                (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);
    161154        return false;
    162155    }
     
    180173
    181174    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);
    185177        psFree(outBitSet);
    186178        return NULL;
     
    189181
    190182    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);
    194185        psFree(outBitSet);
    195186        return NULL;
     
    217208        psFree(tempStr);
    218209        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);
    223213        return NULL;
    224214    }
     
    227217    if (op != NOT_OP) {
    228218        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);
    232221            psFree(outBitSet);
    233222            return NULL;
     
    235224
    236225        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);
    240228            psFree(outBitSet);
    241229            return NULL;
     
    287275{
    288276    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);
    292279        psFree(outBitSet);
    293280        return NULL;
     
    297284
    298285    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);
    302288    }
    303289
  • trunk/psLib/src/collections/psHash.c

    r2221 r2273  
    1111*  @author George Gusciora, MHPCC
    1212*
    13 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-10-27 23:31:43 $
     13*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-11-04 01:04:57 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    228228    // the way this procedure is called.
    229229    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);
    233232        return NULL;
    234233    }
     
    249248    // anyway.
    250249    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);
    252252    }
    253253    // ptr will have the correct hash bucket.
     
    347347{
    348348    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);
    352351        return false;
    353352    }
    354353    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);
    358356        return false;
    359357    }
    360358    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);
    364361    }
    365362
     
    382379{
    383380    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);
    387383        return NULL;
    388384    }
    389385    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);
    393388        return NULL;
    394389    }
     
    414409
    415410    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);
    419413        return false;
    420414    }
    421415    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);
    425418        return false;
    426419    }
  • trunk/psLib/src/collections/psList.c

    r2204 r2273  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:31 $
     8 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    136136
    137137        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);
    139140            position = list->head;         // since we no list->size != 0, this must be non-NULL
    140141        }
     
    173174
    174175    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.");
    176177        return false;
    177178    }
     
    194195
    195196        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.");
    197198            pthread_mutex_unlock(&list->lock)
    198199            ;
     
    206207
    207208    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);
    209211        pthread_mutex_unlock(&list->lock)
    210212        ;
     
    257259
    258260    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.");
    260263        return;
    261264    }
     
    314317    default:
    315318        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.");
    317321        } else {
    318322            cursor = listGetIterator(list);
  • trunk/psLib/src/collections/psMetadata.c

    r2204 r2273  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-10-27 00:57:30 $
     14*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:57 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psMetadata.h"
    3636#include "psString.h"
     37#include "psAstronomyErrors.h"
     38#include "psConstants.h"
    3739
    3840/******************************************************************************/
     
    123125
    124126
    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
    129129    // Allocate metadata item
    130130    metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
     
    147147    // Set metadata item type
    148148    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);
    149157
    150158    // Set metadata item value
    151159    switch (type) {
    152160    case PS_META_ITEM_SET:
    153         metadataItem->data.V = NULL;
    154161        break;
    155162    case PS_META_BOOL:
     
    180187    case PS_META_UNKNOWN:
    181188    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    }
    191195
    192196    return metadataItem;
     
    224228    psMetadataType newType = PS_META_ITEM_SET;
    225229
    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);
    235235
    236236    newType = metadataItem->type;
    237 
    238237    mdTable = md->table;
    239     if(mdTable == NULL) {
    240         psError( __func__, "Null metadata table not allowed" );
    241         return false;
    242     }
    243 
    244238    mdList = md->list;
    245     if(mdList == NULL) {
    246         psError( __func__, "Null metadata list not allowed");
    247         return false;
    248     }
    249 
    250239    key = metadataItem->name;
    251     if(key == NULL) {
    252         psError(__func__, "Null key item not allowed");
    253         return false;
    254     }
    255240
    256241    // See if key is already in table
     
    262247            // Add leaf node to existing folder node
    263248            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 );
    266252                return false;
    267253            }
     
    272258
    273259            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);
    275263                psFree(newFolderEntry);
    276264                return false;
     
    278266
    279267            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);
    281271                psFree(newFolderEntry);
    282272                return false;
     
    284274
    285275            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);
    287279                psFree(newFolderEntry);
    288280                return false;
     
    290282
    291283            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);
    293287                psFree(newFolderEntry);
    294288                return false;
     
    301295            // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
    302296            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);
    304300                return false;
    305301            }
    306302
    307303            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);
    309307                return false;
    310308            }
    311309
    312310            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);
    314314                return false;
    315315            }
     
    319319        // Node doesn't exist - Add new metadata item to metadata collection's hash
    320320        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);
    322324            return false;
    323325        }
     
    328330    if(metadataItem->type != PS_META_ITEM_SET) {
    329331        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);
    332335            return false;
    333336        }
     
    348351
    349352    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);
    352355        psFree(metadataItem);
    353356        return false;
     
    368371
    369372
    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);
    374376
    375377    mdList = md->list;
    376     if (mdList == NULL) {
    377         psError(__func__, "Null metadata list not allowed");
    378         return false;
    379     }
    380 
    381378    mdTable = md->table;
    382     if (mdTable == NULL) {
    383         psError(__func__, "Null metadata table not allowed");
    384         return false;
    385     }
     379
    386380    // Select removal by key or index
    387381    if (key != NULL) {
     
    390384        entry = (psMetadataItem* ) psHashLookup(mdTable, key);
    391385        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);
    393389            return false;
    394390        }
     
    402398            while (entryChild != NULL) {
    403399                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);
    405403                    return false;
    406404                }
     
    411409            // Table entry has no children. Remove entry from metadata collection's list
    412410            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);
    414414                return false;
    415415            }
     
    417417        // Remove entry from metadata collection's table
    418418        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);
    420422            return false;
    421423        }
     
    425427        entry = psListGet(mdList, where);
    426428        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);
    428432            return false;
    429433        }
     
    431435        key = entry->name;
    432436        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);
    434440            return false;
    435441        }
     
    447453
    448454
    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);
    453458
    454459    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     }
    464460
    465461    entry = (psMetadataItem* ) psHashLookup(mdTable, key);
     
    473469psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
    474470{
     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
     487psBool 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
     497psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
     498{
    475499    psList* mdList = NULL;
    476500    psMetadataItem* entry = NULL;
    477501
    478502
    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);
    483505
    484506    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     }
    535507
    536508    psListSetIterator(mdList, which);
     
    559531
    560532
    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);
    565535
    566536    mdList = md->list;
    567     if (mdList == NULL) {
    568         psError(__func__, "Null metadata list not allowed");
    569         return NULL;
    570     }
    571537
    572538    psListSetIterator(mdList, which);
  • trunk/psLib/src/collections/psMetadataIO.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    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); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *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);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    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,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    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);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    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);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        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);
    443438            return output;
    444439        }
     
    471466
    472467    // 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);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                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);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                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);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                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);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                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);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                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);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                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);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    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);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                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);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        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);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    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);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    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);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    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);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    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);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                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);
    654673                continue;
    655674            } // switch
  • trunk/psLib/src/collections/psScalar.c

    r2055 r2273  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-12 19:32:44 $
     10 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-11-04 01:04:57 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070        break;
    7171    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);
    7675    }
    7776
     
    8584
    8685    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);
    9088        return NULL;
    9189    }
     
    130128        break;
    131129    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);
    136133    }
    137134
  • trunk/psLib/src/collections/psVector.c

    r2204 r2273  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-27 00:57:31 $
     12*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-11-04 01:04:57 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070
    7171    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);
    7574        return NULL;
    7675    } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     
    9998            in->type.dimen !=  PS_DIMEN_TRANSV) {
    10099        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);
    104102        return NULL;
    105103    }
     
    122120{
    123121    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);
    127124        psFree(out);
    128125        return NULL;
     
    183180                char* typeStr; \
    184181                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); \
    189185                psFree(out); \
    190186            } \
     
    209205            char* typeStr;
    210206            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);
    215210            psFree(out);
    216211
     
    232227
    233228    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);
    237231        psFree(outVector);
    238232        return NULL;
     
    300294        break;
    301295    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);
    306299    }
    307300
     
    317310
    318311    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);
    322314        psFree(outVector);
    323315        return NULL;
     
    400392        break;
    401393    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);
    406397    }
    407398
  • trunk/psLib/src/dataManip/psConstants.h

    r2272 r2273  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-03 22:58:53 $
     8 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
    3333if (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); \
    3536    return(RVAL); \
    3637}
     
    3839#define PS_INT_CHECK_POSITIVE(NAME, RVAL) \
    3940if (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) \
     47if ((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)
    4555#define PS_INT_COMPARE(NAME1, NAME2, RVAL) \
    4656if (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); \
    4860    return(RVAL); \
    4961}
     
    5365#define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
    5466if (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); \
    5670    return(RVAL); \
    5771}
     
    5973#define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \
    6074if (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); \
    6278    return(RVAL); \
    6379}
     
    6783the wrong type.
    6884*****************************************************************************/
    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) \
    7087if (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; \
    7392}
    7493
    7594#define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \
    7695if (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) \
     104if (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
    80111
    81112#define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
    82113if (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) \
    88123if (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; \
    91128}
    92129
     
    95132    PS_VECTOR macros:
    96133 *****************************************************************************/
    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) \
    98136if (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; \
    101141} \
    102142
    103143#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
    104144if (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); \
    106148    return(RVAL); \
    107149} \
     
    109151#define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
    110152if ((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); \
    112156    return(RVAL); \
    113157} \
     
    115159#define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
    116160if (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); \
    118164    return(RVAL); \
    119165}
     
    121167#define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
    122168if (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); \
    124172    return(RVAL); \
    125173}
     
    221269#define PS_POLY_CHECK_NULL(NAME, RVAL) \
    222270if (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); \
    224274    return(RVAL); \
    225275} \
     
    227277#define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
    228278if (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); \
    230281    return(RVAL); \
    231282} \
     
    234285    PS_IMAGE macros:
    235286*****************************************************************************/
    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) \
    237289if (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) \
    243298if (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; \
    247303}
    248304
    249305#define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \
    250306if (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); \
    252310    return(RVAL); \
    253311}
     
    260318#define PS_READOUT_CHECK_NULL(NAME, RVAL) \
    261319if (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); \
    263323    return(RVAL); \
    264324}
  • trunk/psLib/src/dataManip/psDataManipErrors.dat

    r2080 r2273  
    88####################################################################
    99#
    10 psVectorFFT_IMAGE_TYPE_UNSUPPORTED     Input psVector type, %s, is not supported. Valid data types are psF32 and psC32.
     10psVectorFFT_TYPE_NOT_F32_C32           Input psVector type, %s, is not supported. Valid data types are psF32 and psC32.
    1111psVectorFFT_REVERSE_NOT_COMPLEX        Input psVector (%s) is not complex.  Reverse FFT operation requires a complex input.
    1212psVectorFFT_FORWARD_NOT_REAL           Input psVector (%s) is not real.  Forward FFT operation requires a real input.
     
    1818psVectorFFT_NONCOMPLEX_NOTSUPPORTED    Input psVector type, %s, is required to be either psC32 or psC64.
    1919psVectorFFT_DIRECTION_NOTSET           Must specify the direction as either PS_FFT_FORWARD or PS_FFT_REVERSE.
     20#
     21psStats_NOT_F32_F64                    Invalid data type, %s.  Only psF32 and psF64 data types are supported.
     22psStats_VECTOR_TYPE_UNSUPPORTED        Input psVector type, %s, is not supported.
     23psStats_YVAL_OUT_OF_RANGE              Specified yVal, %g, is not within y-range, %g to %g.
     24psStats_ROBUST_QUARTILE_BINS_FAILED    Could not determine the robust lower/upper quartile bin numbers.
     25psStats_STATS_FAILED                   Failed to calculate the specified statistic.
     26#
     27psFunctions_INVALID_POLYNOMIAL_TYPE    Unknown polynomial type 0x%x found.  Evaluation failed.
     28psFunctions_TYPE_NOT_SUPPORTED         Input psVector type, %s, is not supported.
     29psFunctions_NOT_ENOUGH_DATAPOINTS      Given vector does not have enough data points for %d-order interpolation.
     30#
     31psMatrix_COUNT_DIFFERS                 Number of elements inconsistent, %d vs %d.  Number of elements must match.
     32psMatrix_IMAGE_SIZE_DIFFERS            Specified psImage dimensions differed, %dx%d vs %dx%d.
     33psMatrix_TYPE_MISMATCH                 Specified data type, %s, is not supported.
     34psMatrix_MIN_COMPLEX_SUPPORT           The minimum operation is not supported with complex data.
     35psMatrix_MAX_COMPLEX_SUPPORT           The maximum operation is not supported with complex data.
     36psMatrix_OPERATION_UNSUPPORTED         Specified operation, %s, is not supported.
     37psMatrix_DIMEN_OTHER_FOUND             %s's dimensionality is PS_DIMEN_OTHER, which is  not allowed.
     38psMatrix_OUTPUT_VECTOR_NOT_CREATED     Couldn't create a proper output psVector.
     39psMatrix_OUTPUT_IMAGE_NOT_CREATED      Couldn't create a proper output psImage.
     40psMatrix_DIMEN_INVALID                 Specified parameter, %s, has invalid dimensionality, %d.
     41psMatrix_VECTOR_EMPTY                  Input psVector contains no elements.  No data to perform operation with.
     42psMatrix_IMAGE_EMPTY                   Input psImage contains no pixels.  No data to perform operation with.
  • trunk/psLib/src/dataManip/psDataManipErrors.h

    r2080 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-13 20:46:57 $
     9 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:04:59 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030
    3131//~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."
    3333#define PS_ERRORTEXT_psVectorFFT_REVERSE_NOT_COMPLEX "Input psVector (%s) is not complex.  Reverse FFT operation requires a complex input."
    3434#define PS_ERRORTEXT_psVectorFFT_FORWARD_NOT_REAL "Input psVector (%s) is not real.  Forward FFT operation requires a real input."
     
    4040#define PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED "Input psVector type, %s, is required to be either psC32 or psC64."
    4141#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."
    4262//~End
    4363
  • trunk/psLib/src/dataManip/psFunctions.c

    r2224 r2273  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-28 00:22:53 $
     9 *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:04:59 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psFunctions.h"
    3636#include "psConstants.h"
     37
     38#include "psDataManipErrors.h"
     39
    3740/*****************************************************************************/
    3841/* DEFINE STATEMENTS                                                         */
     
    5053static void dPolynomial3DFree(psDPolynomial3D* myPoly);
    5154static void dPolynomial4DFree(psDPolynomial4D* myPoly);
     55static void spline1DFree(psSpline1D *tmpSpline);
     56static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
     57static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
    5258
    5359/*****************************************************************************/
     
    6773/*****************************************************************************/
    6874
     75static 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
     98static void polynomial1DFree(psPolynomial1D* myPoly)
     99{
     100    psFree(myPoly->coeff);
     101    psFree(myPoly->coeffErr);
     102    psFree(myPoly->mask);
     103}
     104
     105static 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
     119static 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
     140static 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
     167static void dPolynomial1DFree(psDPolynomial1D* myPoly)
     168{
     169    psFree(myPoly->coeff);
     170    psFree(myPoly->coeffErr);
     171    psFree(myPoly->mask);
     172}
     173
     174static 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
     188static 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
     209static 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
    69236/*****************************************************************************
    70 CreateChebyshevPolys(n): this routine takes as input the required order n,
     237createChebyshevPolys(n): this routine takes as input the required order n,
    71238and returns as output as a pointer to an array of n psPolynomial1D
    72239structures, corresponding to the first n Chebyshev polynomials.
     
    76243outer coefficients of the Chebyshev polynomials.
    77244 *****************************************************************************/
    78 static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
     245static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
    79246{
    80247    PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
     
    103270
    104271    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 *****************************************************************************/
     279static 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?
     308static 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
     353static 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
     377static 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
     412static 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
     440static 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
     481static 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
     515static 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 *****************************************************************************/
     566static 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?
     584static 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
     609static 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
     631static 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
     665static 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
     693static 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
     734static 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
     768static 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/*****************************************************************************
     818p_psInterpolate1D(): This routine will take as input n-element floating
     819point arrays domain and range, and the x value, assumed to lie with the
     820domain vector.  It produces as output the (n-1)-order LaGrange interpolated
     821value of x.
     822 
     823XXX: do we error check for non-distinct domain values?
     824 *****************************************************************************/
     825static 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/*****************************************************************************
     886interpolate1DF32(): this is the base 1-D flat memory routine to perform
     887LaGrange interpolation.
     888 *****************************************************************************/
     889static 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));
    105923}
    106924
     
    3361154}
    3371155
    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 
    4861156float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
    4871157{
     
    4891159
    4901160    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    491         return(p_psOrdPolynomial1DEval(x, myPoly));
     1161        return(ordPolynomial1DEval(x, myPoly));
    4921162    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    493         return(p_psChebPolynomial1DEval(x, myPoly));
     1163        return(chebPolynomial1DEval(x, myPoly));
    4941164    } 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);
    4961168    }
    4971169    return(0.0);
     
    5201192}
    5211193
    522 
    523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
     1194float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
    5241195{
    5251196    PS_POLY_CHECK_NULL(myPoly, NAN);
    5261197
    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 polynomials
    559     // 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 
    5861198    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    587         return(p_psOrdPolynomial2DEval(x, y, myPoly));
     1199        return(ordPolynomial2DEval(x, y, myPoly));
    5881200    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    589         return(p_psChebPolynomial2DEval(x, y, myPoly));
     1201        return(chebPolynomial2DEval(x, y, myPoly));
    5901202    } 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);
    5921206    }
    5931207    return(0.0);
    5941208}
    595 
    5961209
    5971210psVector *psPolynomial2DEvalVector(const psVector *x,
     
    6321245}
    6331246
    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 polynomials
    675     // 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 
    7051247float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
    7061248{
     
    7081250
    7091251    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    710         return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
     1252        return(ordPolynomial3DEval(x, y, z, myPoly));
    7111253    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    712         return(p_psChebPolynomial3DEval(x, y, z, myPoly));
     1254        return(chebPolynomial3DEval(x, y, z, myPoly));
    7131255    } 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);
    7151259    }
    7161260    return(0.0);
     
    7651309}
    7661310
    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 polynomials
    818     // 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 
    8541311float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
    8551312{
     
    8571314
    8581315    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    859         return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
     1316        return(ordPolynomial4DEval(w,x,y,z, myPoly));
    8601317    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    861         return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
     1318        return(chebPolynomial4DEval(w,x,y,z, myPoly));
    8621319    } 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);
    8641323    }
    8651324    return(0.0);
     
    9241383    return(tmp);
    9251384}
    926 
    927 
    928 
    9291385
    9301386
     
    10921548}
    10931549
    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 }
    12081550
    12091551double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
     
    12121554
    12131555    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1214         return(p_psDOrdPolynomial1DEval(x, myPoly));
     1556        return(dOrdPolynomial1DEval(x, myPoly));
    12151557    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1216         return(p_psDChebPolynomial1DEval(x, myPoly));
     1558        return(dChebPolynomial1DEval(x, myPoly));
    12171559    } 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);
    12191563    }
    12201564    return(0.0);
     
    12441588
    12451589
    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 polynomials
    1279     // 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 
    13031590double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
    13041591{
     
    13061593
    13071594    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1308         return(p_psDOrdPolynomial2DEval(x, y, myPoly));
     1595        return(dOrdPolynomial2DEval(x, y, myPoly));
    13091596    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1310         return(p_psDChebPolynomial2DEval(x, y, myPoly));
     1597        return(dChebPolynomial2DEval(x, y, myPoly));
    13111598    } 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);
    13131602    }
    13141603    return(0.0);
     
    13531642
    13541643
    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 polynomials
    1395     // 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 
    14251644double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
    14261645{
     
    14281647
    14291648    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1430         return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
     1649        return(dOrdPolynomial3DEval(x, y, z, myPoly));
    14311650    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1432         return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
     1651        return(dChebPolynomial3DEval(x, y, z, myPoly));
    14331652    } 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);
    14351656    }
    14361657    return(0.0);
     
    14851706}
    14861707
    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 polynomials
    1540     // 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 
    15761708double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
    15771709{
     
    15791711
    15801712    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1581         return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
     1713        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
    15821714    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1583         return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
     1715        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
    15841716    } 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);
    15861720    }
    15871721    return(0.0);
     
    16991833    (tmp->domains)[numSplines] = max;
    17001834
     1835    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
    17011836    return(tmp);
    17021837}
    17031838
    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 }
    17281839
    17291840/*****************************************************************************
     
    17651876
    17661877/*****************************************************************************
    1767 p_psVectorBinDisectF32(): This is a private function which takes as input a
     1878vectorBinDisectF32(): This is a private function which takes as input a
    17681879vector of floating point data as well as a single floating point values.
    17691880The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
     
    17761887XXX: name since we don't take psVectors as input.
    17771888 *****************************************************************************/
    1778 psS32 p_psVectorBinDisectF32(float *bins,
    1779                              psS32 numBins,
    1780                              float x)
     1889static psS32 vectorBinDisectF32(float *bins,
     1890                                psS32 numBins,
     1891                                float x)
    17811892{
    17821893    psS32 min;
     
    17841895    psS32 mid;
    17851896
    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);
    17881899
    17891900    if (x < bins[0]) {
    17901901        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).",
    17921903                 x, bins[0], bins[numBins-1]);
    17931904        return(-2);
     
    17961907    if (x > bins[numBins-1]) {
    17971908        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).",
    17991910                 x, bins[0], bins[numBins-1]);
    18001911        return(-1);
     
    18061917
    18071918    while (min != max) {
    1808         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
     1919        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    18091920                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18101921                min, mid, max, x, bins[mid]);
    18111922
    18121923        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);
    18151926            return(mid);
    18161927        } else if (x < bins[mid]) {
     
    18221933    }
    18231934
    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);
    18261937    return(min);
    18271938}
    18281939
    18291940/*****************************************************************************
    1830 p_psVectorBinDisectS32(): integer version of above.
     1941vectorBinDisectS32(): integer version of above.
    18311942 *****************************************************************************/
    1832 psS32 p_psVectorBinDisectS32(psS32 *bins,
    1833                              psS32 numBins,
    1834                              psS32 x)
     1943static psS32 vectorBinDisectS32(psS32 *bins,
     1944                                psS32 numBins,
     1945                                psS32 x)
    18351946{
    18361947    psS32 min;
     
    18381949    psS32 mid;
    18391950
    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);
    18421953
    18431954    if ((x < bins[0]) ||
    18441955            (x > bins[numBins-1])) {
    18451956        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).",
    18471958                 x, bins[0], bins[numBins-1]);
    18481959        return(-1);
     
    18541965
    18551966    while (min != max) {
    1856         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
     1967        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    18571968                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18581969                min, mid, max, x, bins[mid]);
    18591970
    18601971        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);
    18631974            return(min);
    18641975        } else if (x < bins[mid]) {
     
    18701981    }
    18711982
    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);
    18741985    return(min);
    18751986}
     
    18841995
    18851996    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));
    18871998    } 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));
    18892000    } 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);
    18912006        return(-2);
    18922007    }
    18932008    return(-1);
    1894 }
    1895 
    1896 /*****************************************************************************
    1897 p_psInterpolate1D(): This routine will take as input n-element floating
    1898 point arrays domain and range, and the x value, assumed to lie with the
    1899 domain vector.  It produces as output the (n-1)-order LaGrange interpolated
    1900 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 the
    1940     // 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 perform
    1966 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));
    20022009}
    20032010
     
    20352042
    20362043    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);
    20382047        return(NULL);
    20392048    }
     
    20422051        psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
    20432052                "---- 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));
    20492058    } else if (x->type.type == PS_TYPE_F64) {
    20502059        // XXX: use recycled vectors here.
     
    20532062
    20542063        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);
    20602069        psFree(range32);
    20612070        psFree(domain32);
     
    20672076
    20682077    } 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);
    20712083    }
    20722084
     
    20842096and an independent x value.  Each determines which spline that x corresponds
    20852097to by doing a bracket disection on the domains of the spline data structure
    2086 (p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
     2098(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    20872099by a call to the 1D polynomial functions.
    20882100 
     
    21002112
    21012113    n = spline->n;
    2102     binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2114    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
    21032115    if (binNum < 0) {
    21042116        psLogMsg(__func__, PS_LOG_WARN,
     
    21392151        }
    21402152    } 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);
    21422158        return(NULL);
    21432159    }
  • trunk/psLib/src/dataManip/psFunctions.h

    r2269 r2273  
    1212*  @author George Gusciora, MHPCC
    1313*
    14 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-11-03 03:30:30 $
     14*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:59 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    398398                            float max);
    399399
    400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
    401 
    402400psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
    403401                                   psS32 order);
  • trunk/psLib/src/dataManip/psMatrix.c

    r2214 r2273  
    2020 *  @author Ross Harman, MHPCC
    2121 *   
    22  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    23  *  @date $Date: 2004-10-27 20:20:11 $
     22 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     23 *  @date $Date: 2004-11-04 01:04:59 $
    2424 *
    2525 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040#include "psVector.h"
    4141#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
    8345
    8446/** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
    8547#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
    8648if (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);             \
    8851    return RETURN;                                                                                  \
    8952} 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);                                       \
    9155    return RETURN;                                                                                  \
    9256}
     
    9559#define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
    9660if (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);                     \
    9863    return RETURN;                                                                                  \
    9964}
     
    10267#define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
    10368if (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);                             \
    10571    return RETURN;                                                                                  \
    10672}
     
    12692    gsl_permutation perm;
    12793
     94    #define psMatrixLUD_EXIT { \
     95                               psFree(outImage); \
     96                               return NULL; \
     97                             }
     98
    12899    // Error checks
    129100    PS_CHECK_POINTERS(inImage, outImage, outImage);
    130     PS_IMAGE_CHECK_NULL(inImage, outImage);
    131101    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
    138106    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);
    139110
    140111    // Initialize data
     
    179150    PS_IMAGE_CHECK_NULL(inImage, outVector);
    180151    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);
    183153    PS_VECTOR_CHECK_NULL(outVector, outVector);
    184154    PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
     
    188158    PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector);
    189159
     160    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     161
     162
    190163    // Initialize data
    191164    numRows = inImage->numRows;
     
    226199
    227200    // 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);
    232202    PS_CHECK_POINTERS(inImage, outImage, outImage);
    233203    PS_IMAGE_CHECK_NULL(inImage, outImage);
    234204    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);
    239208
    240209    // Initialize data
     
    282251    PS_IMAGE_CHECK_NULL(inImage, NULL);
    283252    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
    284     PS_CHECK_SIZE_IMAGE(inImage, NULL);
     253    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
    285254
    286255    // Initialize data
     
    325294    PS_IMAGE_CHECK_NULL(inImage1, outImage);
    326295    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
    327     PS_CHECK_SIZE_IMAGE(inImage1, outImage);
     296    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
    328297    PS_IMAGE_CHECK_NULL(inImage2, outImage);
    329298    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);
    332300    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);
    334303
    335304    // Initialize data
     
    364333    PS_IMAGE_CHECK_NULL(inImage, outImage);
    365334    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);
    370338
    371339    // Initialize data
     
    403371    PS_IMAGE_CHECK_NULL(inImage, outImage);
    404372    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);
    409376
    410377    // Initialize data
     
    438405    psS32 size = 0;
    439406
    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);
    442414    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);
    444416
    445417    if (inImage->numRows == 1) {
    446418        // Create transposed row vector
    447         PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);
     419        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
    448420        outVector->type.dimen = PS_DIMEN_TRANSV;
    449421    } else if (inImage->numCols == 1) {
    450422        // Create non-transposed column vector
    451         PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
     423        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
    452424    } 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);
    455428        return outVector;
    456429    }
     
    467440
    468441        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);
    470445            return outVector;
    471446        }
     
    481456
    482457        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);
    484461            return outVector;
    485462        }
     
    502479    if (inVector->type.dimen == PS_DIMEN_VECTOR) {
    503480        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);
    506483        // More checks for PS_DIMEN_VECTOR
    507484        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);
    509488            return outImage;
    510489        } 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);
    512493            return outImage;
    513494        }
     
    517498    } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
    518499        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);
    521502        // More checks for PS_DIMEN_TRANSV
    522503        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);
    524507            return outImage;
    525508        } 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);
    527512            return outImage;
    528513        }
  • trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c

    r2204 r2273  
    2929 *  @author Ross Harman, MHPCC
    3030 *
    31  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    32  *  @date $Date: 2004-10-27 00:57:31 $
     31 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     32 *  @date $Date: 2004-11-04 01:04:59 $
    3333 *
    3434 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848#include "psScalar.h"
    4949#include "psLogMsg.h"
     50#include "psConstants.h"
     51#include "psDataManipErrors.h"
    5052
    5153/*****************************************************************************
     
    5860// Conversion for radians to degrees
    5961#define R2D 57.29577950924861   /* 180.0/PI */
    60 
    61 /* IEEE Standards on floating-point makes this function pointless, really.
    62 // Division with NAN checking
    63 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 */
    7562
    7663// Binary SCALAR_XXXX operations
     
    142129#define VECTOR_VECTOR(OUT,IN1,OP,IN2,TYPE)                                                                   \
    143130{                                                                                                            \
    144     psS32 i = 0;                                                                                               \
    145     psS32 n1 = 0;                                                                                              \
    146     psS32 n2 = 0;                                                                                              \
     131    psS32 i = 0;                                                                                             \
     132    psS32 n1 = 0;                                                                                            \
     133    psS32 n2 = 0;                                                                                            \
    147134    ps##TYPE *o = NULL;                                                                                      \
    148135    ps##TYPE *i1 = NULL;                                                                                     \
     
    151138    n2  = ((psVector* )IN2)->n;                                                                              \
    152139    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);                                                                                     \
    154143        if (OUT != IN1 && OUT != IN2) {                                                                      \
    155144            psFree(OUT);                                                                                     \
     
    167156#define VECTOR_IMAGE(OUT,IN1,OP,IN2,TYPE)                                                                    \
    168157{                                                                                                            \
    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;                                                                                      \
    174163    psDimen dim1 = 0;                                                                                        \
    175164    ps##TYPE *o = NULL;                                                                                      \
     
    181170    numCols2 = ((psImage* )IN2)->numCols;                                                                    \
    182171    \
    183     if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */                                                      \
     172    if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */                                             \
    184173        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);                                                                           \
    186177            if (OUT != IN1 && OUT != IN2) {                                                                  \
    187178                psFree(OUT);                                                                                 \
     
    200191    } else {  /* Transposed vectors */                                                                       \
    201192        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);                       \
    203196            if (OUT != IN1 && OUT != IN2) {                                                                  \
    204197                psFree(OUT);                                                                                 \
     
    256249    numCols1 = ((psImage* )IN1)->numCols;                                                                    \
    257250    \
    258     if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */                                                      \
     251    if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */                                             \
    259252        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);                                                                           \
    261256            if (OUT != IN1 && OUT != IN2) {                                                                  \
    262257                psFree(OUT);                                                                                 \
     
    275270    } else {  /* Transposed vectors */                                                                       \
    276271        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);                                                                           \
    278275            if (OUT != IN1) {                                                                                \
    279276                psFree(OUT);                                                                                 \
     
    309306    numCols2 = ((psImage* )IN2)->numCols;                                                                    \
    310307    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);                                                     \
    313311        if (OUT != IN1 && OUT != IN2) {                                                                      \
    314312            psFree(OUT);                                                                                     \
     
    366364    break;                                                                                                   \
    367365default:                                                                                                     \
    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);  */                                                                                      \
    369371    if (OUT != IN1 && OUT != IN2) {                                                                          \
    370372        psFree(OUT);                                                                                         \
     
    391393} else if(!strncmp(OP, "min", 3)) {                                                                          \
    392394    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);                                                  \
    394397        if (OUT != IN1 && OUT != IN2) {                                                                      \
    395398            psFree(OUT);                                                                                     \
     
    401404} else if(!strncmp(OP, "max", 3)) {                                                                          \
    402405    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);                                                  \
    404408        if (OUT != IN1 && OUT != IN2) {                                                                      \
    405409            psFree(OUT);                                                                                     \
     
    410414    }                                                                                                        \
    411415} else {                                                                                                     \
    412     psError(__func__, ": Invalid operation: %s", OP);                                                        \
     416    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                                \
     417            PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED,                                                     \
     418            OP);                                                                                             \
    413419    if (OUT != IN1 && OUT != IN2) {                                                                          \
    414420        psFree(OUT);                                                                                         \
     
    419425psPtr psBinaryOp(psPtr out, psPtr in1, char *op, psPtr in2)
    420426{
    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;
    476453
    477454    if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) {
    478455        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");
    480457        }
    481458    } else if (dim1 == PS_DIMEN_IMAGE) {
    482459        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");
    484461        }
    485462    }
     
    487464    if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) {
    488465        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");
    490467        }
    491468    } else if (dim2 == PS_DIMEN_IMAGE) {
    492469        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");
    494471        }
    495472    }
     
    513490            out = psVectorRecycle(out,((psVector*)in2)->n,elType1);
    514491            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);
    516494                return NULL;
    517495            }
     
    520498            out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows,elType1);
    521499            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);
    523502                return NULL;
    524503            }
    525504            BINARY_OP(SCALAR, IMAGE, out, psType1, op, psType2);        // scalar op image
    526505        } 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;
    528510        }
    529511    } else if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) {
     
    531513            out = psVectorRecycle(out,((psVector*)in1)->n,elType1);
    532514            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);
    534517                return NULL;
    535518            }
     
    538521            out = psVectorRecycle(out,((psVector*)in2)->n,elType2);
    539522            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);
    541525                return NULL;
    542526            }
     
    545529            out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows, elType2);
    546530            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);
    548533                return NULL;
    549534            }
    550535            BINARY_OP(VECTOR, IMAGE, out, psType1, op, psType2);        // vector op image
    551536        } 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;
    553541        }
    554542    } else if (dim1 == PS_DIMEN_IMAGE) {
    555543        out = psImageRecycle(out, ((psImage*)in1)->numCols, ((psImage*)in1)->numRows, elType1);
    556544        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);
    558547            return NULL;
    559548        }
     
    565554            BINARY_OP(IMAGE, IMAGE, out, psType1, op, psType2); // image op image
    566555        } 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;
    572560        }
    573561    } 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;
    579566    }
    580567
     
    605592#define VECTOR(OUT,IN,OP,TYPE)                                                                               \
    606593{                                                                                                            \
    607     psS32 i = 0;                                                                                               \
    608     psS32 nIn = 0;                                                                                             \
    609     psS32 nOut = 0;                                                                                            \
     594    psS32 i = 0;                                                                                             \
     595    psS32 nIn = 0;                                                                                           \
     596    psS32 nOut = 0;                                                                                          \
    610597    ps##TYPE *o = NULL;                                                                                      \
    611598    ps##TYPE *i1 = NULL;                                                                                     \
     
    613600    nOut = ((psVector* )OUT)->n;                                                                             \
    614601    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);                                                                                  \
    616605        if (OUT != IN) {                                                                                     \
    617606            psFree(OUT);                                                                                     \
     
    629618#define IMAGE(OUT,IN,OP,TYPE)                                                                                \
    630619{                                                                                                            \
    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;                                                                                    \
    637626    ps##TYPE *o = NULL;                                                                                      \
    638627    ps##TYPE *i1 = NULL;                                                                                     \
     
    642631    numColsOut = ((psImage* )OUT)->numCols;                                                                  \
    643632    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);                                               \
    646636        if (OUT != IN) {                                                                                     \
    647637            psFree(OUT);                                                                                     \
     
    697687    DIM(OUT,IN,OP,C32);                                                                                      \
    698688    break;                                                                                                   \
    699 default:                                                                                                     \
    700     psError(__func__, ": Invalid PS_TYPE: %d", IN->type);                                                    \
    701     if (OUT != IN) {                                                                                         \
    702         psFree(OUT);                                                                                         \
    703     }                                                                                                        \
    704     return NULL;                                                                                             \
     689default: {                                                                                                     \
     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    } \
    705700}
    706701
     
    815810    }                                                                                                        \
    816811} else {                                                                                                     \
    817     psError(__func__, ": Invalid operation: %s", OP);                                                        \
     812    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                                \
     813            PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED,                                                     \
     814            OP);                                                                                             \
    818815}
    819816
    820817psPtr psUnaryOp(psPtr out, psPtr in, char *op)
    821818{
    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;
    845836
    846837    switch (dimIn) {
     
    857848    case PS_DIMEN_TRANSV:
    858849        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;
    864853        }
    865854
     
    868857                              elTypeIn);
    869858        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;
    872862        }
    873863
     
    876866    case PS_DIMEN_IMAGE:
    877867        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;
    883871        }
    884872
     
    888876                             elTypeIn);
    889877        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;
    892881        }
    893882
     
    898887            psFree(out);
    899888        }
    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;
    902893    }
    903894
  • trunk/psLib/src/dataManip/psMinimize.c

    r2269 r2273  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-03 03:30:30 $
     11 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:04:59 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    291291
    292292    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",
    294295                y32->n, mySpline->n);
    295296        return(NULL);
     
    318319    // Check if these are cubic splines (n==4).  If not, psError.
    319320    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.",
    321323                (mySpline->spline[0])->n-1);
    322324        return(NULL);
     
    952954        PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n);
    953955        if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    954             p_psNormalizeVectorRange(x64Static, -1.0, 1.0);
     956            psNormalizeVectorRange(x64Static, -1.0, 1.0);
    955957        }
    956958        x64 = x64Static;
     
    968970        tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);
    969971    } else {
    970         psError(__func__, "unknown polynomial type.\n");
     972        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     973                "unknown polynomial type.\n");
    971974        return(NULL);
    972975    }
     
    13651368    bracket = p_psDetermineBracket2(params, line, paramMask, coords, func);
    13661369    if (bracket == NULL) {
    1367         psError(__func__, "(1) Could not bracket minimum.");
     1370        psError(PS_ERR_UNKNOWN, false,
     1371                "Could not bracket minimum.");
    13681372        return(NAN);
    13691373    }
     
    15521556                                  func);
    15531557                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");
    15551560                    psFree(v);
    15561561                    return(false);
     
    15921597        mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func);
    15931598        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.");
    15951601            psFree(v);
    15961602            return(false);
  • trunk/psLib/src/dataManip/psStats.c

    r2269 r2273  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-03 03:30:30 $
     11 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:04:59 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434#include "psFunctions.h"
    3535#include "psConstants.h"
     36
     37#include "psDataManipErrors.h"
    3638
    3739/*****************************************************************************/
     
    735737
    736738    // 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
    741741    // 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
    746744    // We allocate a temporary mask vector since during the iterative
    747745    // steps that follow, we will be masking off additional data points.
     
    869867        p_psNormalizeVectorRangeF64(myData, low, high);
    870868    } 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);
    872874    }
    873875}
     
    954956        // Ensure that yVal is within the range of the bins we are using.
    955957        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]);
    958961        }
    959962        yErr->data.F64[0] = 1.0;
     
    11131116
    11141117    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);
    11161120        return(1);
    11171121    }
    11181122    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);
    11201125        return(1);
    11211126    }
     
    11741179    psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
    11751180
    1176     p_psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
     1181    psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
    11771182    for (i=0;i<robustHistogramVector->n;i++) {
    11781183        myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
     
    15361541        // do nothing
    15371542    } 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);
    15391548    }
    15401549    return (tmp);
     
    16031612            (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
    16041613        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);
    16061616        }
    16071617    }
     
    16091619    if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
    16101620        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.");
    16121623        }
    16131624    }
  • trunk/psLib/src/dataManip/psVectorFFT.c

    r2204 r2273  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:04:59 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6363                                 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
    6464    } 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);
    6867        psFree(out);
    6968        return NULL;
     
    7271    /* check if a plan exists now */
    7372    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);
    7775        psFree(out);
    7876        return NULL;
     
    144142        char* typeStr;
    145143        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);
    150147        psFree(out);
    151148        return NULL;
     
    204201        char* typeStr;
    205202        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);
    210206        psFree(out);
    211207        return NULL;
     
    237233        PS_TYPE_NAME(typeStrReal,type);
    238234        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);
    243238        psFree(out);
    244239        return NULL;
     
    272267        char* typeStr;
    273268        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);
    278272        psFree(out);
    279273        return NULL;
     
    333327        char* typeStr;
    334328        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);
    339332        psFree(out);
    340333        return NULL;
     
    414407        char* typeStr;
    415408        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  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:05:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    if ( ((direction & PS_FFT_FORWARD) != 0) ) {
    4444        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);
    4847            psFree(out);
    4948            return NULL;
    5049        }
    5150        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);
    5553            psFree(out);
    5654            return NULL;
    5755        }
    5856    } 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);
    6259        psFree(out);
    6360        return NULL;
     
    8683    /* check if a plan exists now -- if not, it is a real problem at this point */
    8784    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);
    9187        psFree(out);
    9288        return NULL;
     
    163159        char* typeStr;
    164160        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);
    169164
    170165        psFree(out);
     
    226221        char* typeStr;
    227222        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);
    232226        psFree(out);
    233227        return NULL;
     
    257251        PS_TYPE_NAME(typeStrReal,type);
    258252        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);
    263256        psFree(out);
    264257        return NULL;
     
    266259
    267260    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);
    272264        psFree(out);
    273265        return NULL;
     
    308300        char* typeStr;
    309301        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);
    314305        psFree(out);
    315306        return NULL;
     
    369360        char* typeStr;
    370361        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);
    375365        psFree(out);
    376366        return NULL;
     
    434424        char* typeStr;
    435425        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  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:04:59 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6363                                 (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
    6464    } 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);
    6867        psFree(out);
    6968        return NULL;
     
    7271    /* check if a plan exists now */
    7372    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);
    7775        psFree(out);
    7876        return NULL;
     
    144142        char* typeStr;
    145143        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);
    150147        psFree(out);
    151148        return NULL;
     
    204201        char* typeStr;
    205202        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);
    210206        psFree(out);
    211207        return NULL;
     
    237233        PS_TYPE_NAME(typeStrReal,type);
    238234        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);
    243238        psFree(out);
    244239        return NULL;
     
    272267        char* typeStr;
    273268        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);
    278272        psFree(out);
    279273        return NULL;
     
    333327        char* typeStr;
    334328        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);
    339332        psFree(out);
    340333        return NULL;
     
    414407        char* typeStr;
    415408        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  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040
    4141    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);
    4645        return NULL;
    4746    }
     
    119118    if (old->type.dimen != PS_DIMEN_IMAGE) {
    120119        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);
    124122        return NULL;
    125123    }
     
    175173
    176174    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);
    180177        psFree(output);
    181178        return NULL;
     
    183180
    184181    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);
    188184        psFree(output);
    189185        return NULL;
     
    191187
    192188    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);
    196191        psFree(output);
    197192        return NULL;
     
    205200
    206201    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);
    211205        psFree(output);
    212206        return NULL;
     
    319313            char* typeStr;
    320314            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);
    325318            psFree(output);
    326319
     
    372365
    373366    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);
    377369        return unexposedValue;
    378370    }
     
    400392        break;                                                       \
    401393    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);                                               \
    406397    }                                                                \
    407398    break
     
    423414            char* typeStr;
    424415            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);
    429419        }
    430420    }
  • trunk/psLib/src/image/psImageConvolve.c

    r2204 r2273  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:05:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110    // got non-NULL vectors?
    111111    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);
    115114        return NULL;
    116115    }
     
    125124        PS_TYPE_NAME(typeYStr,yShifts->type.type);
    126125        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);
    131129        return NULL;
    132130    }
     
    218216            char* typeStr;
    219217            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);
    224221        }
    225222    }
     
    236233
    237234    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);
    241237        psFree(out);
    242238        return NULL;
     
    297293                char* typeStr;
    298294                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);
    303298                psFree(out);
    304299                return NULL;
     
    317312        psS32 kCols = kernel->image->numCols;
    318313        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);
    324318            psFree(out);
    325319            return NULL;
     
    376370        psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD);
    377371        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);
    381374            psFree(out);
    382375            return NULL;
     
    385378        psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
    386379        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);
    390382            psFree(out);
    391383            return NULL;
     
    398390                                         PS_FFT_REVERSE);
    399391        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);
    403394            psFree(out);
    404395            return NULL;
  • trunk/psLib/src/image/psImageExtraction.c

    r2204 r2273  
    99 *  @author Robert DeSonia, MHPCC
    1010 *
    11  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 00:57:31 $
     11 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535
    3636    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);
    4039        return NULL;
    4140    }
    4241
    4342    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);
    4745        return NULL;
    4846    }
     
    6159            col1 > image->numCols ||
    6260            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);
    6865        return NULL;
    6966    }
     
    152149    // section should be of the form '[col0:col1,row0:row1]'
    153150    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);
    157153        return NULL;
    158154    }
    159155
    160156    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);
    165160        return NULL;
    166161    }
    167162
    168163    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);
    173167        return NULL;
    174168    }
     
    180174{
    181175    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);
    185178        return NULL;
    186179    }
     
    209202            col0 >= col1 ||
    210203            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);
    216208        psFree(image);
    217209        return NULL;
     
    267259
    268260    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);
    272263        psFree(out);
    273264        return NULL;
     
    288279            col0 >= col1 ||
    289280            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);
    295285        psFree(out);
    296286        return NULL;
     
    307297    if (mask != NULL) {
    308298        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);
    314303            psFree(out);
    315304            return NULL;
     
    318307            char* typeStr;
    319308            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);
    324312            psFree(out);
    325313            return NULL;
     
    328316
    329317    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);
    333320        psFree(out);
    334321        return NULL;
     
    338325    // single stats operation
    339326    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);
    343329        psFree(out);
    344330        return NULL;
     
    423409                char* typeStr;
    424410                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);
    429414                psFree(out);
    430415                out = NULL;
     
    485470        psFree(maskVec);
    486471    } 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);
    491475        psFree(out);
    492476        out = NULL;
     
    512496{
    513497    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);
    517500        psFree(out);
    518501        return NULL;
     
    522505
    523506    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);
    528510        psFree(out);
    529511        return NULL;
     
    534516            endCol < 0 || endCol >= numCols ||
    535517            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);
    541522        psFree(out);
    542523        return NULL;
     
    544525
    545526    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);
    550530        psFree(out);
    551531        return NULL;
     
    554534    if (mask != NULL) {
    555535        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);
    561540            psFree(out);
    562541            return NULL;
     
    565544            char* typeStr;
    566545            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);
    571549            psFree(out);
    572550            return NULL;
     
    627605            char* typeStr;
    628606            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);
    633610            psFree(out);
    634611            out = NULL;
     
    653630
    654631    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);
    658634        psFree(out);
    659635        return NULL;
     
    664640    if (mask != NULL) {
    665641        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);
    671646            psFree(out);
    672647            return NULL;
     
    675650            char* typeStr;
    676651            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);
    681655            psFree(out);
    682656            return NULL;
     
    686660    if (centerCol < 0 || centerCol >= numCols ||
    687661            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);
    693666        psFree(out);
    694667        return NULL;
     
    696669
    697670    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);
    701673        psFree(out);
    702674        return NULL;
     
    704676
    705677    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);
    710681        psFree(out);
    711682        return NULL;
     
    713684
    714685    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);
    718688        psFree(out);
    719689        return NULL;
     
    723693    // single stats operation
    724694    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);
    729698        psFree(out);
    730699        return NULL;
  • trunk/psLib/src/image/psImageFFT.c

    r2204 r2273  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:05:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    if ( ((direction & PS_FFT_FORWARD) != 0) ) {
    4444        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);
    4847            psFree(out);
    4948            return NULL;
    5049        }
    5150        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);
    5553            psFree(out);
    5654            return NULL;
    5755        }
    5856    } 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);
    6259        psFree(out);
    6360        return NULL;
     
    8683    /* check if a plan exists now -- if not, it is a real problem at this point */
    8784    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);
    9187        psFree(out);
    9288        return NULL;
     
    163159        char* typeStr;
    164160        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);
    169164
    170165        psFree(out);
     
    226221        char* typeStr;
    227222        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);
    232226        psFree(out);
    233227        return NULL;
     
    257251        PS_TYPE_NAME(typeStrReal,type);
    258252        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);
    263256        psFree(out);
    264257        return NULL;
     
    266259
    267260    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);
    272264        psFree(out);
    273265        return NULL;
     
    308300        char* typeStr;
    309301        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);
    314305        psFree(out);
    315306        return NULL;
     
    369360        char* typeStr;
    370361        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);
    375365        psFree(out);
    376366        return NULL;
     
    434424        char* typeStr;
    435425        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  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 19:35:58 $
     9 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747
    4848    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);
    5251        psFree(output);
    5352        return NULL;
     
    5857    if (fptr == NULL || status != 0) {
    5958        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);
    6462        psFree(output);
    6563        return NULL;
     
    7270            status = 0;
    7371            (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);
    7875            psFree(output);
    7976            return NULL;
     
    8481            status = 0;
    8582            (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);
    9086            psFree(output);
    9187            return NULL;
     
    9894        status = 0;
    9995        (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);
    10499        psFree(output);
    105100        return NULL;
     
    111106        status = 0;
    112107        (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);
    117111        psFree(output);
    118112        return NULL;
     
    123117        status = 0;
    124118        (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);
    129122        psFree(output);
    130123        return NULL;
     
    136129        status = 0;
    137130        (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);
    142134        psFree(output);
    143135        return NULL;
     
    201193        break;
    202194    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);
    207198        psFree(output);
    208199        return NULL;
     
    215206        status = 0;
    216207        (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);
    221211        return NULL;
    222212    }
     
    253243    /* need a valid image to write */
    254244    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);
    258247        return false;
    259248    }
     
    301290            char* typeStr;
    302291            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);
    307295            return false;
    308296        }
     
    315303        if (fptr == NULL || status != 0) {
    316304            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);
    321308            return false;
    322309        }
     
    328315                status = 0;
    329316                (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);
    334320                return false;
    335321            }
     
    341327                status = 0;
    342328                (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);
    347332                return false;
    348333            } else if (numHDUs == extnum) {
     
    352337                status = 0;
    353338                (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);
    358342                return false;
    359343            }
     
    368352        if (fptr == NULL || status != 0) {
    369353            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);
    374357            return false;
    375358        }
     
    386369            status = 0;
    387370            (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);
    392374            return false;
    393375        }
     
    403385                status = 0;
    404386                (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);
    409390                return false;
    410391            }
     
    424405        status = 0;
    425406        (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);
    430410        return false;
    431411    }
  • trunk/psLib/src/image/psImageManip.c

    r2204 r2273  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343
    4444    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);
    4948        return 0;
    5049    }
     
    5857    case PS_TYPE_##type: { \
    5958            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); \
    6563            } \
    6664            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); \
    7269            } \
    7370            for (psU32 row = 0;row<numRows;row++) { \
     
    8986    case PS_TYPE_##type: { \
    9087            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); \
    9692            } \
    9793            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); \
    10398            } \
    10499            for (psU32 row = 0;row<numRows;row++) { \
     
    133128            char* typeStr;
    134129            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);
    139133        }
    140134    }
     
    179173            char* typeStr;
    180174            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);
    185178        }
    186179    }
     
    204197
    205198    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);
    209201        return 1;
    210202    }
    211203
    212204    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);
    216207        return 1;
    217208    }
     
    224215        PS_TYPE_NAME(typeStr,type);
    225216        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);
    230220        return 2;
    231221    }
     
    244234            imageColLimit > imageNumCols) {
    245235
    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);
    251240        return 3;
    252241    }
     
    277266                    break; \
    278267                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); \
    283271                    return 5; \
    284272                } \
     
    303291            char* typeStr;
    304292            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);
    309296            return 6;
    310297        }
     
    329316
    330317    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);
    334320        return 0;
    335321    }
    336322
    337323    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);
    342327        return 0;
    343328    }
    344329    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);
    349333        return 0;
    350334    }
     
    357341        if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \
    358342                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); \
    364347            break; \
    365348        } \
    366349        if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \
    367350                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); \
    373355            break; \
    374356        } \
     
    396378            char* typeStr;
    397379            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);
    402383        }
    403384    }
     
    424405
    425406    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);
    429409        psFree(out);
    430410        return NULL;
     
    432412
    433413    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);
    438417        psFree(out);
    439418        return NULL;
     
    441420
    442421    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);
    446424        psFree(out);
    447425        return NULL;
     
    449427
    450428    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);
    455432        psFree(out);
    456433        return NULL;
     
    463440            char* typeStr;
    464441            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);
    469445            psFree(out);
    470446            psFree(vec);
     
    536512            char* typeStr;
    537513            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);
    542517            psFree(out);
    543518            out = NULL;
     
    562537
    563538    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);
    567541        psFree(out);
    568542        return NULL;
     
    570544
    571545    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);
    576549        psFree(out);
    577550        return NULL;
     
    579552
    580553    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);
    585557        psFree(out);
    586558        return NULL;
     
    622594            char* typeStr;
    623595            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);
    628599            psFree(out);
    629600            out = NULL;
     
    644615
    645616    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);
    649619        psFree(out);
    650620        return NULL;
     
    694664{
    695665    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);
    699668        psFree(out);
    700669        return NULL;
     
    741710                char* typeStr;
    742711                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);
    747715                psFree(out);
    748716                return NULL;
     
    788756                char* typeStr;
    789757                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);
    794761                psFree(out);
    795762                return NULL;
     
    834801                char* typeStr;
    835802                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);
    840806                psFree(out);
    841807                return NULL;
     
    891857                    cimag(unexposedValue) < PS_MIN_##TYPE || \
    892858                    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); \
    900865                psFree(out); \
    901866                out = NULL; \
     
    959924                char* typeStr; \
    960925                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); \
    965929                psFree(out); \
    966930                out = NULL; \
     
    973937            PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR);
    974938        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);
    979942            psFree(out);
    980943            out = NULL;
     
    998961
    999962    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);
    1003965        psFree(out);
    1004966        return NULL;
     
    1018980            cimag(unexposedValue) < PS_MIN_##TYPE || \
    1019981            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); \
    1027988        psFree(out); \
    1028989        out = NULL; \
     
    10581019            char* typeStr; \
    10591020            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); \
    10641024            psFree(out); \
    10651025            out = NULL; \
     
    10731033        PSIMAGE_SHIFT_ARBITRARY_CASE(BILINEAR);
    10741034    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);
    10791038        psFree(out);
    10801039        out = NULL;
  • trunk/psLib/src/image/psImageStats.c

    r2265 r2273  
    11/** @file psImageStats.c
    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.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 Hawaii
    15 */
     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 */
    1616
    1717#include <stdlib.h>
     
    4646
    4747    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);
    5150        return NULL;
    5251    }
    5352
    5453    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);
    5856        return NULL;
    5957    }
    6058
    6159    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);
    6562        return stats;
    6663    }
     
    7673            char* typeStr;
    7774            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);
    8278            psFree(junkData);
    8379            return NULL;
     
    125121            char* typeStr;
    126122            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);
    131126            psFree(out);
    132127            psFree(junkData);
     
    150145
    151146/*****************************************************************************
    152 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
     147calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
    153148interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
    154149order to use Chebyshev polynomials, we must scale the coordinates from
     
    156151output a vector of evenly spaced floating point values between -1.0:1.0.
    157152 *****************************************************************************/
    158 double *CalcScaleFactors(psS32 n)
    159 {
    160     PS_INT_CHEC_NON_NEGATIVE(n, NULL);
     153double* calcScaleFactors(psS32 n)
     154{
     155    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
    161156    psS32 i = 0;
    162157    double tmp = 0.0;
     
    172167}
    173168
    174 psVector *VecCalcScaleFactors(psVector *scalingFactors, psS32 n)
     169psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
    175170{
    176171    PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
    177172    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);
    179174    psS32 i = 0;
    180175    double tmp = 0.0;
     
    243238            (input->type.type != PS_TYPE_F32) &&
    244239            (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");
    246242    }
    247243    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    259255    // Check for null inputs
    260256    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);
    264259        return NULL;
    265260    }
    266261
    267262    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);
    271265        return NULL;
    272266    }
     
    283277    // We scale the pixel positions to values
    284278    // 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);
    287281
    288282    // Determine how many Chebyshev polynomials
     
    363357            (input->type.type != PS_TYPE_F32) &&
    364358            (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");
    366361    }
    367362    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    376371    double *cScalingFactors = NULL;
    377372    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    }
    380387
    381388    // We scale the pixel positions to values between -1.0 and 1.0
    382389    // 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);
    385392
    386393    // Determine how many Chebyshev polynomials
  • trunk/psLib/src/imageops/psImageConvolve.c

    r2204 r2273  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:31 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:05:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110    // got non-NULL vectors?
    111111    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);
    115114        return NULL;
    116115    }
     
    125124        PS_TYPE_NAME(typeYStr,yShifts->type.type);
    126125        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);
    131129        return NULL;
    132130    }
     
    218216            char* typeStr;
    219217            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);
    224221        }
    225222    }
     
    236233
    237234    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);
    241237        psFree(out);
    242238        return NULL;
     
    297293                char* typeStr;
    298294                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);
    303298                psFree(out);
    304299                return NULL;
     
    317312        psS32 kCols = kernel->image->numCols;
    318313        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);
    324318            psFree(out);
    325319            return NULL;
     
    376370        psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD);
    377371        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);
    381374            psFree(out);
    382375            return NULL;
     
    385378        psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
    386379        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);
    390382            psFree(out);
    391383            return NULL;
     
    398390                                         PS_FFT_REVERSE);
    399391        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);
    403394            psFree(out);
    404395            return NULL;
  • trunk/psLib/src/imageops/psImageStats.c

    r2265 r2273  
    11/** @file psImageStats.c
    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.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 Hawaii
    15 */
     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 */
    1616
    1717#include <stdlib.h>
     
    4646
    4747    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);
    5150        return NULL;
    5251    }
    5352
    5453    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);
    5856        return NULL;
    5957    }
    6058
    6159    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);
    6562        return stats;
    6663    }
     
    7673            char* typeStr;
    7774            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);
    8278            psFree(junkData);
    8379            return NULL;
     
    125121            char* typeStr;
    126122            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);
    131126            psFree(out);
    132127            psFree(junkData);
     
    150145
    151146/*****************************************************************************
    152 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
     147calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
    153148interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
    154149order to use Chebyshev polynomials, we must scale the coordinates from
     
    156151output a vector of evenly spaced floating point values between -1.0:1.0.
    157152 *****************************************************************************/
    158 double *CalcScaleFactors(psS32 n)
    159 {
    160     PS_INT_CHEC_NON_NEGATIVE(n, NULL);
     153double* calcScaleFactors(psS32 n)
     154{
     155    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
    161156    psS32 i = 0;
    162157    double tmp = 0.0;
     
    172167}
    173168
    174 psVector *VecCalcScaleFactors(psVector *scalingFactors, psS32 n)
     169psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
    175170{
    176171    PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
    177172    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);
    179174    psS32 i = 0;
    180175    double tmp = 0.0;
     
    243238            (input->type.type != PS_TYPE_F32) &&
    244239            (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");
    246242    }
    247243    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    259255    // Check for null inputs
    260256    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);
    264259        return NULL;
    265260    }
    266261
    267262    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);
    271265        return NULL;
    272266    }
     
    283277    // We scale the pixel positions to values
    284278    // 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);
    287281
    288282    // Determine how many Chebyshev polynomials
     
    363357            (input->type.type != PS_TYPE_F32) &&
    364358            (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");
    366361    }
    367362    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    376371    double *cScalingFactors = NULL;
    377372    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    }
    380387
    381388    // We scale the pixel positions to values between -1.0 and 1.0
    382389    // 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);
    385392
    386393    // Determine how many Chebyshev polynomials
  • trunk/psLib/src/math/psConstants.h

    r2272 r2273  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-03 22:58:53 $
     8 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
    3333if (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); \
    3536    return(RVAL); \
    3637}
     
    3839#define PS_INT_CHECK_POSITIVE(NAME, RVAL) \
    3940if (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) \
     47if ((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)
    4555#define PS_INT_COMPARE(NAME1, NAME2, RVAL) \
    4656if (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); \
    4860    return(RVAL); \
    4961}
     
    5365#define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
    5466if (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); \
    5670    return(RVAL); \
    5771}
     
    5973#define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \
    6074if (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); \
    6278    return(RVAL); \
    6379}
     
    6783the wrong type.
    6884*****************************************************************************/
    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) \
    7087if (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; \
    7392}
    7493
    7594#define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \
    7695if (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) \
     104if (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
    80111
    81112#define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
    82113if (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) \
    88123if (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; \
    91128}
    92129
     
    95132    PS_VECTOR macros:
    96133 *****************************************************************************/
    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) \
    98136if (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; \
    101141} \
    102142
    103143#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
    104144if (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); \
    106148    return(RVAL); \
    107149} \
     
    109151#define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
    110152if ((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); \
    112156    return(RVAL); \
    113157} \
     
    115159#define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
    116160if (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); \
    118164    return(RVAL); \
    119165}
     
    121167#define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
    122168if (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); \
    124172    return(RVAL); \
    125173}
     
    221269#define PS_POLY_CHECK_NULL(NAME, RVAL) \
    222270if (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); \
    224274    return(RVAL); \
    225275} \
     
    227277#define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
    228278if (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); \
    230281    return(RVAL); \
    231282} \
     
    234285    PS_IMAGE macros:
    235286*****************************************************************************/
    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) \
    237289if (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) \
    243298if (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; \
    247303}
    248304
    249305#define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \
    250306if (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); \
    252310    return(RVAL); \
    253311}
     
    260318#define PS_READOUT_CHECK_NULL(NAME, RVAL) \
    261319if (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); \
    263323    return(RVAL); \
    264324}
  • trunk/psLib/src/math/psMatrix.c

    r2214 r2273  
    2020 *  @author Ross Harman, MHPCC
    2121 *   
    22  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    23  *  @date $Date: 2004-10-27 20:20:11 $
     22 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     23 *  @date $Date: 2004-11-04 01:04:59 $
    2424 *
    2525 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040#include "psVector.h"
    4141#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
    8345
    8446/** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
    8547#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
    8648if (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);             \
    8851    return RETURN;                                                                                  \
    8952} 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);                                       \
    9155    return RETURN;                                                                                  \
    9256}
     
    9559#define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
    9660if (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);                     \
    9863    return RETURN;                                                                                  \
    9964}
     
    10267#define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
    10368if (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);                             \
    10571    return RETURN;                                                                                  \
    10672}
     
    12692    gsl_permutation perm;
    12793
     94    #define psMatrixLUD_EXIT { \
     95                               psFree(outImage); \
     96                               return NULL; \
     97                             }
     98
    12899    // Error checks
    129100    PS_CHECK_POINTERS(inImage, outImage, outImage);
    130     PS_IMAGE_CHECK_NULL(inImage, outImage);
    131101    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
    138106    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);
    139110
    140111    // Initialize data
     
    179150    PS_IMAGE_CHECK_NULL(inImage, outVector);
    180151    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);
    183153    PS_VECTOR_CHECK_NULL(outVector, outVector);
    184154    PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
     
    188158    PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector);
    189159
     160    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     161
     162
    190163    // Initialize data
    191164    numRows = inImage->numRows;
     
    226199
    227200    // 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);
    232202    PS_CHECK_POINTERS(inImage, outImage, outImage);
    233203    PS_IMAGE_CHECK_NULL(inImage, outImage);
    234204    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);
    239208
    240209    // Initialize data
     
    282251    PS_IMAGE_CHECK_NULL(inImage, NULL);
    283252    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
    284     PS_CHECK_SIZE_IMAGE(inImage, NULL);
     253    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
    285254
    286255    // Initialize data
     
    325294    PS_IMAGE_CHECK_NULL(inImage1, outImage);
    326295    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
    327     PS_CHECK_SIZE_IMAGE(inImage1, outImage);
     296    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
    328297    PS_IMAGE_CHECK_NULL(inImage2, outImage);
    329298    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);
    332300    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);
    334303
    335304    // Initialize data
     
    364333    PS_IMAGE_CHECK_NULL(inImage, outImage);
    365334    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);
    370338
    371339    // Initialize data
     
    403371    PS_IMAGE_CHECK_NULL(inImage, outImage);
    404372    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);
    409376
    410377    // Initialize data
     
    438405    psS32 size = 0;
    439406
    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);
    442414    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);
    444416
    445417    if (inImage->numRows == 1) {
    446418        // Create transposed row vector
    447         PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);
     419        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
    448420        outVector->type.dimen = PS_DIMEN_TRANSV;
    449421    } else if (inImage->numCols == 1) {
    450422        // Create non-transposed column vector
    451         PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
     423        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
    452424    } 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);
    455428        return outVector;
    456429    }
     
    467440
    468441        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);
    470445            return outVector;
    471446        }
     
    481456
    482457        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);
    484461            return outVector;
    485462        }
     
    502479    if (inVector->type.dimen == PS_DIMEN_VECTOR) {
    503480        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);
    506483        // More checks for PS_DIMEN_VECTOR
    507484        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);
    509488            return outImage;
    510489        } 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);
    512493            return outImage;
    513494        }
     
    517498    } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
    518499        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);
    521502        // More checks for PS_DIMEN_TRANSV
    522503        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);
    524507            return outImage;
    525508        } 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);
    527512            return outImage;
    528513        }
  • trunk/psLib/src/math/psMinimize.c

    r2269 r2273  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-03 03:30:30 $
     11 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:04:59 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    291291
    292292    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",
    294295                y32->n, mySpline->n);
    295296        return(NULL);
     
    318319    // Check if these are cubic splines (n==4).  If not, psError.
    319320    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.",
    321323                (mySpline->spline[0])->n-1);
    322324        return(NULL);
     
    952954        PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n);
    953955        if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    954             p_psNormalizeVectorRange(x64Static, -1.0, 1.0);
     956            psNormalizeVectorRange(x64Static, -1.0, 1.0);
    955957        }
    956958        x64 = x64Static;
     
    968970        tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);
    969971    } else {
    970         psError(__func__, "unknown polynomial type.\n");
     972        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     973                "unknown polynomial type.\n");
    971974        return(NULL);
    972975    }
     
    13651368    bracket = p_psDetermineBracket2(params, line, paramMask, coords, func);
    13661369    if (bracket == NULL) {
    1367         psError(__func__, "(1) Could not bracket minimum.");
     1370        psError(PS_ERR_UNKNOWN, false,
     1371                "Could not bracket minimum.");
    13681372        return(NAN);
    13691373    }
     
    15521556                                  func);
    15531557                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");
    15551560                    psFree(v);
    15561561                    return(false);
     
    15921597        mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func);
    15931598        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.");
    15951601            psFree(v);
    15961602            return(false);
  • trunk/psLib/src/math/psPolynomial.c

    r2224 r2273  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-28 00:22:53 $
     9 *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:04:59 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psFunctions.h"
    3636#include "psConstants.h"
     37
     38#include "psDataManipErrors.h"
     39
    3740/*****************************************************************************/
    3841/* DEFINE STATEMENTS                                                         */
     
    5053static void dPolynomial3DFree(psDPolynomial3D* myPoly);
    5154static void dPolynomial4DFree(psDPolynomial4D* myPoly);
     55static void spline1DFree(psSpline1D *tmpSpline);
     56static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
     57static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
    5258
    5359/*****************************************************************************/
     
    6773/*****************************************************************************/
    6874
     75static 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
     98static void polynomial1DFree(psPolynomial1D* myPoly)
     99{
     100    psFree(myPoly->coeff);
     101    psFree(myPoly->coeffErr);
     102    psFree(myPoly->mask);
     103}
     104
     105static 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
     119static 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
     140static 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
     167static void dPolynomial1DFree(psDPolynomial1D* myPoly)
     168{
     169    psFree(myPoly->coeff);
     170    psFree(myPoly->coeffErr);
     171    psFree(myPoly->mask);
     172}
     173
     174static 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
     188static 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
     209static 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
    69236/*****************************************************************************
    70 CreateChebyshevPolys(n): this routine takes as input the required order n,
     237createChebyshevPolys(n): this routine takes as input the required order n,
    71238and returns as output as a pointer to an array of n psPolynomial1D
    72239structures, corresponding to the first n Chebyshev polynomials.
     
    76243outer coefficients of the Chebyshev polynomials.
    77244 *****************************************************************************/
    78 static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
     245static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
    79246{
    80247    PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
     
    103270
    104271    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 *****************************************************************************/
     279static 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?
     308static 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
     353static 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
     377static 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
     412static 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
     440static 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
     481static 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
     515static 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 *****************************************************************************/
     566static 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?
     584static 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
     609static 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
     631static 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
     665static 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
     693static 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
     734static 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
     768static 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/*****************************************************************************
     818p_psInterpolate1D(): This routine will take as input n-element floating
     819point arrays domain and range, and the x value, assumed to lie with the
     820domain vector.  It produces as output the (n-1)-order LaGrange interpolated
     821value of x.
     822 
     823XXX: do we error check for non-distinct domain values?
     824 *****************************************************************************/
     825static 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/*****************************************************************************
     886interpolate1DF32(): this is the base 1-D flat memory routine to perform
     887LaGrange interpolation.
     888 *****************************************************************************/
     889static 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));
    105923}
    106924
     
    3361154}
    3371155
    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 
    4861156float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
    4871157{
     
    4891159
    4901160    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    491         return(p_psOrdPolynomial1DEval(x, myPoly));
     1161        return(ordPolynomial1DEval(x, myPoly));
    4921162    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    493         return(p_psChebPolynomial1DEval(x, myPoly));
     1163        return(chebPolynomial1DEval(x, myPoly));
    4941164    } 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);
    4961168    }
    4971169    return(0.0);
     
    5201192}
    5211193
    522 
    523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
     1194float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
    5241195{
    5251196    PS_POLY_CHECK_NULL(myPoly, NAN);
    5261197
    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 polynomials
    559     // 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 
    5861198    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    587         return(p_psOrdPolynomial2DEval(x, y, myPoly));
     1199        return(ordPolynomial2DEval(x, y, myPoly));
    5881200    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    589         return(p_psChebPolynomial2DEval(x, y, myPoly));
     1201        return(chebPolynomial2DEval(x, y, myPoly));
    5901202    } 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);
    5921206    }
    5931207    return(0.0);
    5941208}
    595 
    5961209
    5971210psVector *psPolynomial2DEvalVector(const psVector *x,
     
    6321245}
    6331246
    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 polynomials
    675     // 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 
    7051247float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
    7061248{
     
    7081250
    7091251    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    710         return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
     1252        return(ordPolynomial3DEval(x, y, z, myPoly));
    7111253    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    712         return(p_psChebPolynomial3DEval(x, y, z, myPoly));
     1254        return(chebPolynomial3DEval(x, y, z, myPoly));
    7131255    } 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);
    7151259    }
    7161260    return(0.0);
     
    7651309}
    7661310
    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 polynomials
    818     // 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 
    8541311float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
    8551312{
     
    8571314
    8581315    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    859         return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
     1316        return(ordPolynomial4DEval(w,x,y,z, myPoly));
    8601317    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    861         return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
     1318        return(chebPolynomial4DEval(w,x,y,z, myPoly));
    8621319    } 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);
    8641323    }
    8651324    return(0.0);
     
    9241383    return(tmp);
    9251384}
    926 
    927 
    928 
    9291385
    9301386
     
    10921548}
    10931549
    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 }
    12081550
    12091551double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
     
    12121554
    12131555    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1214         return(p_psDOrdPolynomial1DEval(x, myPoly));
     1556        return(dOrdPolynomial1DEval(x, myPoly));
    12151557    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1216         return(p_psDChebPolynomial1DEval(x, myPoly));
     1558        return(dChebPolynomial1DEval(x, myPoly));
    12171559    } 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);
    12191563    }
    12201564    return(0.0);
     
    12441588
    12451589
    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 polynomials
    1279     // 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 
    13031590double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
    13041591{
     
    13061593
    13071594    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1308         return(p_psDOrdPolynomial2DEval(x, y, myPoly));
     1595        return(dOrdPolynomial2DEval(x, y, myPoly));
    13091596    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1310         return(p_psDChebPolynomial2DEval(x, y, myPoly));
     1597        return(dChebPolynomial2DEval(x, y, myPoly));
    13111598    } 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);
    13131602    }
    13141603    return(0.0);
     
    13531642
    13541643
    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 polynomials
    1395     // 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 
    14251644double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
    14261645{
     
    14281647
    14291648    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1430         return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
     1649        return(dOrdPolynomial3DEval(x, y, z, myPoly));
    14311650    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1432         return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
     1651        return(dChebPolynomial3DEval(x, y, z, myPoly));
    14331652    } 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);
    14351656    }
    14361657    return(0.0);
     
    14851706}
    14861707
    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 polynomials
    1540     // 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 
    15761708double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
    15771709{
     
    15791711
    15801712    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1581         return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
     1713        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
    15821714    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1583         return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
     1715        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
    15841716    } 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);
    15861720    }
    15871721    return(0.0);
     
    16991833    (tmp->domains)[numSplines] = max;
    17001834
     1835    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
    17011836    return(tmp);
    17021837}
    17031838
    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 }
    17281839
    17291840/*****************************************************************************
     
    17651876
    17661877/*****************************************************************************
    1767 p_psVectorBinDisectF32(): This is a private function which takes as input a
     1878vectorBinDisectF32(): This is a private function which takes as input a
    17681879vector of floating point data as well as a single floating point values.
    17691880The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
     
    17761887XXX: name since we don't take psVectors as input.
    17771888 *****************************************************************************/
    1778 psS32 p_psVectorBinDisectF32(float *bins,
    1779                              psS32 numBins,
    1780                              float x)
     1889static psS32 vectorBinDisectF32(float *bins,
     1890                                psS32 numBins,
     1891                                float x)
    17811892{
    17821893    psS32 min;
     
    17841895    psS32 mid;
    17851896
    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);
    17881899
    17891900    if (x < bins[0]) {
    17901901        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).",
    17921903                 x, bins[0], bins[numBins-1]);
    17931904        return(-2);
     
    17961907    if (x > bins[numBins-1]) {
    17971908        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).",
    17991910                 x, bins[0], bins[numBins-1]);
    18001911        return(-1);
     
    18061917
    18071918    while (min != max) {
    1808         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
     1919        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    18091920                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18101921                min, mid, max, x, bins[mid]);
    18111922
    18121923        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);
    18151926            return(mid);
    18161927        } else if (x < bins[mid]) {
     
    18221933    }
    18231934
    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);
    18261937    return(min);
    18271938}
    18281939
    18291940/*****************************************************************************
    1830 p_psVectorBinDisectS32(): integer version of above.
     1941vectorBinDisectS32(): integer version of above.
    18311942 *****************************************************************************/
    1832 psS32 p_psVectorBinDisectS32(psS32 *bins,
    1833                              psS32 numBins,
    1834                              psS32 x)
     1943static psS32 vectorBinDisectS32(psS32 *bins,
     1944                                psS32 numBins,
     1945                                psS32 x)
    18351946{
    18361947    psS32 min;
     
    18381949    psS32 mid;
    18391950
    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);
    18421953
    18431954    if ((x < bins[0]) ||
    18441955            (x > bins[numBins-1])) {
    18451956        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).",
    18471958                 x, bins[0], bins[numBins-1]);
    18481959        return(-1);
     
    18541965
    18551966    while (min != max) {
    1856         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
     1967        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    18571968                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18581969                min, mid, max, x, bins[mid]);
    18591970
    18601971        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);
    18631974            return(min);
    18641975        } else if (x < bins[mid]) {
     
    18701981    }
    18711982
    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);
    18741985    return(min);
    18751986}
     
    18841995
    18851996    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));
    18871998    } 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));
    18892000    } 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);
    18912006        return(-2);
    18922007    }
    18932008    return(-1);
    1894 }
    1895 
    1896 /*****************************************************************************
    1897 p_psInterpolate1D(): This routine will take as input n-element floating
    1898 point arrays domain and range, and the x value, assumed to lie with the
    1899 domain vector.  It produces as output the (n-1)-order LaGrange interpolated
    1900 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 the
    1940     // 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 perform
    1966 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));
    20022009}
    20032010
     
    20352042
    20362043    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);
    20382047        return(NULL);
    20392048    }
     
    20422051        psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
    20432052                "---- 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));
    20492058    } else if (x->type.type == PS_TYPE_F64) {
    20502059        // XXX: use recycled vectors here.
     
    20532062
    20542063        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);
    20602069        psFree(range32);
    20612070        psFree(domain32);
     
    20672076
    20682077    } 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);
    20712083    }
    20722084
     
    20842096and an independent x value.  Each determines which spline that x corresponds
    20852097to by doing a bracket disection on the domains of the spline data structure
    2086 (p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
     2098(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    20872099by a call to the 1D polynomial functions.
    20882100 
     
    21002112
    21012113    n = spline->n;
    2102     binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2114    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
    21032115    if (binNum < 0) {
    21042116        psLogMsg(__func__, PS_LOG_WARN,
     
    21392151        }
    21402152    } 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);
    21422158        return(NULL);
    21432159    }
  • trunk/psLib/src/math/psPolynomial.h

    r2269 r2273  
    1212*  @author George Gusciora, MHPCC
    1313*
    14 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-11-03 03:30:30 $
     14*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:59 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    398398                            float max);
    399399
    400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
    401 
    402400psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
    403401                                   psS32 order);
  • trunk/psLib/src/math/psSpline.c

    r2224 r2273  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-28 00:22:53 $
     9 *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:04:59 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psFunctions.h"
    3636#include "psConstants.h"
     37
     38#include "psDataManipErrors.h"
     39
    3740/*****************************************************************************/
    3841/* DEFINE STATEMENTS                                                         */
     
    5053static void dPolynomial3DFree(psDPolynomial3D* myPoly);
    5154static void dPolynomial4DFree(psDPolynomial4D* myPoly);
     55static void spline1DFree(psSpline1D *tmpSpline);
     56static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
     57static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
    5258
    5359/*****************************************************************************/
     
    6773/*****************************************************************************/
    6874
     75static 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
     98static void polynomial1DFree(psPolynomial1D* myPoly)
     99{
     100    psFree(myPoly->coeff);
     101    psFree(myPoly->coeffErr);
     102    psFree(myPoly->mask);
     103}
     104
     105static 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
     119static 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
     140static 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
     167static void dPolynomial1DFree(psDPolynomial1D* myPoly)
     168{
     169    psFree(myPoly->coeff);
     170    psFree(myPoly->coeffErr);
     171    psFree(myPoly->mask);
     172}
     173
     174static 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
     188static 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
     209static 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
    69236/*****************************************************************************
    70 CreateChebyshevPolys(n): this routine takes as input the required order n,
     237createChebyshevPolys(n): this routine takes as input the required order n,
    71238and returns as output as a pointer to an array of n psPolynomial1D
    72239structures, corresponding to the first n Chebyshev polynomials.
     
    76243outer coefficients of the Chebyshev polynomials.
    77244 *****************************************************************************/
    78 static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
     245static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
    79246{
    80247    PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
     
    103270
    104271    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 *****************************************************************************/
     279static 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?
     308static 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
     353static 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
     377static 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
     412static 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
     440static 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
     481static 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
     515static 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 *****************************************************************************/
     566static 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?
     584static 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
     609static 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
     631static 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
     665static 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
     693static 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
     734static 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
     768static 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/*****************************************************************************
     818p_psInterpolate1D(): This routine will take as input n-element floating
     819point arrays domain and range, and the x value, assumed to lie with the
     820domain vector.  It produces as output the (n-1)-order LaGrange interpolated
     821value of x.
     822 
     823XXX: do we error check for non-distinct domain values?
     824 *****************************************************************************/
     825static 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/*****************************************************************************
     886interpolate1DF32(): this is the base 1-D flat memory routine to perform
     887LaGrange interpolation.
     888 *****************************************************************************/
     889static 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));
    105923}
    106924
     
    3361154}
    3371155
    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 
    4861156float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
    4871157{
     
    4891159
    4901160    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    491         return(p_psOrdPolynomial1DEval(x, myPoly));
     1161        return(ordPolynomial1DEval(x, myPoly));
    4921162    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    493         return(p_psChebPolynomial1DEval(x, myPoly));
     1163        return(chebPolynomial1DEval(x, myPoly));
    4941164    } 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);
    4961168    }
    4971169    return(0.0);
     
    5201192}
    5211193
    522 
    523 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
     1194float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
    5241195{
    5251196    PS_POLY_CHECK_NULL(myPoly, NAN);
    5261197
    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 polynomials
    559     // 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 
    5861198    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    587         return(p_psOrdPolynomial2DEval(x, y, myPoly));
     1199        return(ordPolynomial2DEval(x, y, myPoly));
    5881200    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    589         return(p_psChebPolynomial2DEval(x, y, myPoly));
     1201        return(chebPolynomial2DEval(x, y, myPoly));
    5901202    } 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);
    5921206    }
    5931207    return(0.0);
    5941208}
    595 
    5961209
    5971210psVector *psPolynomial2DEvalVector(const psVector *x,
     
    6321245}
    6331246
    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 polynomials
    675     // 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 
    7051247float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
    7061248{
     
    7081250
    7091251    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    710         return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
     1252        return(ordPolynomial3DEval(x, y, z, myPoly));
    7111253    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    712         return(p_psChebPolynomial3DEval(x, y, z, myPoly));
     1254        return(chebPolynomial3DEval(x, y, z, myPoly));
    7131255    } 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);
    7151259    }
    7161260    return(0.0);
     
    7651309}
    7661310
    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 polynomials
    818     // 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 
    8541311float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
    8551312{
     
    8571314
    8581315    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    859         return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
     1316        return(ordPolynomial4DEval(w,x,y,z, myPoly));
    8601317    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    861         return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
     1318        return(chebPolynomial4DEval(w,x,y,z, myPoly));
    8621319    } 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);
    8641323    }
    8651324    return(0.0);
     
    9241383    return(tmp);
    9251384}
    926 
    927 
    928 
    9291385
    9301386
     
    10921548}
    10931549
    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 }
    12081550
    12091551double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
     
    12121554
    12131555    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1214         return(p_psDOrdPolynomial1DEval(x, myPoly));
     1556        return(dOrdPolynomial1DEval(x, myPoly));
    12151557    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1216         return(p_psDChebPolynomial1DEval(x, myPoly));
     1558        return(dChebPolynomial1DEval(x, myPoly));
    12171559    } 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);
    12191563    }
    12201564    return(0.0);
     
    12441588
    12451589
    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 polynomials
    1279     // 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 
    13031590double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
    13041591{
     
    13061593
    13071594    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1308         return(p_psDOrdPolynomial2DEval(x, y, myPoly));
     1595        return(dOrdPolynomial2DEval(x, y, myPoly));
    13091596    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1310         return(p_psDChebPolynomial2DEval(x, y, myPoly));
     1597        return(dChebPolynomial2DEval(x, y, myPoly));
    13111598    } 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);
    13131602    }
    13141603    return(0.0);
     
    13531642
    13541643
    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 polynomials
    1395     // 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 
    14251644double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
    14261645{
     
    14281647
    14291648    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1430         return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
     1649        return(dOrdPolynomial3DEval(x, y, z, myPoly));
    14311650    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1432         return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
     1651        return(dChebPolynomial3DEval(x, y, z, myPoly));
    14331652    } 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);
    14351656    }
    14361657    return(0.0);
     
    14851706}
    14861707
    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 polynomials
    1540     // 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 
    15761708double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
    15771709{
     
    15791711
    15801712    if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1581         return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
     1713        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
    15821714    } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1583         return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
     1715        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
    15841716    } 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);
    15861720    }
    15871721    return(0.0);
     
    16991833    (tmp->domains)[numSplines] = max;
    17001834
     1835    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
    17011836    return(tmp);
    17021837}
    17031838
    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 }
    17281839
    17291840/*****************************************************************************
     
    17651876
    17661877/*****************************************************************************
    1767 p_psVectorBinDisectF32(): This is a private function which takes as input a
     1878vectorBinDisectF32(): This is a private function which takes as input a
    17681879vector of floating point data as well as a single floating point values.
    17691880The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
     
    17761887XXX: name since we don't take psVectors as input.
    17771888 *****************************************************************************/
    1778 psS32 p_psVectorBinDisectF32(float *bins,
    1779                              psS32 numBins,
    1780                              float x)
     1889static psS32 vectorBinDisectF32(float *bins,
     1890                                psS32 numBins,
     1891                                float x)
    17811892{
    17821893    psS32 min;
     
    17841895    psS32 mid;
    17851896
    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);
    17881899
    17891900    if (x < bins[0]) {
    17901901        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).",
    17921903                 x, bins[0], bins[numBins-1]);
    17931904        return(-2);
     
    17961907    if (x > bins[numBins-1]) {
    17971908        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).",
    17991910                 x, bins[0], bins[numBins-1]);
    18001911        return(-1);
     
    18061917
    18071918    while (min != max) {
    1808         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
     1919        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    18091920                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18101921                min, mid, max, x, bins[mid]);
    18111922
    18121923        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);
    18151926            return(mid);
    18161927        } else if (x < bins[mid]) {
     
    18221933    }
    18231934
    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);
    18261937    return(min);
    18271938}
    18281939
    18291940/*****************************************************************************
    1830 p_psVectorBinDisectS32(): integer version of above.
     1941vectorBinDisectS32(): integer version of above.
    18311942 *****************************************************************************/
    1832 psS32 p_psVectorBinDisectS32(psS32 *bins,
    1833                              psS32 numBins,
    1834                              psS32 x)
     1943static psS32 vectorBinDisectS32(psS32 *bins,
     1944                                psS32 numBins,
     1945                                psS32 x)
    18351946{
    18361947    psS32 min;
     
    18381949    psS32 mid;
    18391950
    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);
    18421953
    18431954    if ((x < bins[0]) ||
    18441955            (x > bins[numBins-1])) {
    18451956        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).",
    18471958                 x, bins[0], bins[numBins-1]);
    18481959        return(-1);
     
    18541965
    18551966    while (min != max) {
    1856         psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
     1967        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    18571968                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    18581969                min, mid, max, x, bins[mid]);
    18591970
    18601971        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);
    18631974            return(min);
    18641975        } else if (x < bins[mid]) {
     
    18701981    }
    18711982
    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);
    18741985    return(min);
    18751986}
     
    18841995
    18851996    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));
    18871998    } 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));
    18892000    } 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);
    18912006        return(-2);
    18922007    }
    18932008    return(-1);
    1894 }
    1895 
    1896 /*****************************************************************************
    1897 p_psInterpolate1D(): This routine will take as input n-element floating
    1898 point arrays domain and range, and the x value, assumed to lie with the
    1899 domain vector.  It produces as output the (n-1)-order LaGrange interpolated
    1900 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 the
    1940     // 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 perform
    1966 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));
    20022009}
    20032010
     
    20352042
    20362043    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);
    20382047        return(NULL);
    20392048    }
     
    20422051        psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
    20432052                "---- 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));
    20492058    } else if (x->type.type == PS_TYPE_F64) {
    20502059        // XXX: use recycled vectors here.
     
    20532062
    20542063        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);
    20602069        psFree(range32);
    20612070        psFree(domain32);
     
    20672076
    20682077    } 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);
    20712083    }
    20722084
     
    20842096and an independent x value.  Each determines which spline that x corresponds
    20852097to by doing a bracket disection on the domains of the spline data structure
    2086 (p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
     2098(vectorBinDisectF32()).  Then it evaluates the spline at that x location
    20872099by a call to the 1D polynomial functions.
    20882100 
     
    21002112
    21012113    n = spline->n;
    2102     binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
     2114    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
    21032115    if (binNum < 0) {
    21042116        psLogMsg(__func__, PS_LOG_WARN,
     
    21392151        }
    21402152    } 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);
    21422158        return(NULL);
    21432159    }
  • trunk/psLib/src/math/psSpline.h

    r2269 r2273  
    1212*  @author George Gusciora, MHPCC
    1313*
    14 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-11-03 03:30:30 $
     14*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:59 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    398398                            float max);
    399399
    400 psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
    401 
    402400psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
    403401                                   psS32 order);
  • trunk/psLib/src/math/psStats.c

    r2269 r2273  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-03 03:30:30 $
     11 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:04:59 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434#include "psFunctions.h"
    3535#include "psConstants.h"
     36
     37#include "psDataManipErrors.h"
    3638
    3739/*****************************************************************************/
     
    735737
    736738    // 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
    741741    // 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
    746744    // We allocate a temporary mask vector since during the iterative
    747745    // steps that follow, we will be masking off additional data points.
     
    869867        p_psNormalizeVectorRangeF64(myData, low, high);
    870868    } 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);
    872874    }
    873875}
     
    954956        // Ensure that yVal is within the range of the bins we are using.
    955957        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]);
    958961        }
    959962        yErr->data.F64[0] = 1.0;
     
    11131116
    11141117    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);
    11161120        return(1);
    11171121    }
    11181122    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);
    11201125        return(1);
    11211126    }
     
    11741179    psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
    11751180
    1176     p_psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
     1181    psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
    11771182    for (i=0;i<robustHistogramVector->n;i++) {
    11781183        myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
     
    15361541        // do nothing
    15371542    } 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);
    15391548    }
    15401549    return (tmp);
     
    16031612            (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
    16041613        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);
    16061616        }
    16071617    }
     
    16091619    if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
    16101620        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.");
    16121623        }
    16131624    }
  • trunk/psLib/src/mathtypes/psImage.c

    r2204 r2273  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040
    4141    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);
    4645        return NULL;
    4746    }
     
    119118    if (old->type.dimen != PS_DIMEN_IMAGE) {
    120119        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);
    124122        return NULL;
    125123    }
     
    175173
    176174    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);
    180177        psFree(output);
    181178        return NULL;
     
    183180
    184181    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);
    188184        psFree(output);
    189185        return NULL;
     
    191187
    192188    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);
    196191        psFree(output);
    197192        return NULL;
     
    205200
    206201    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);
    211205        psFree(output);
    212206        return NULL;
     
    319313            char* typeStr;
    320314            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);
    325318            psFree(output);
    326319
     
    372365
    373366    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);
    377369        return unexposedValue;
    378370    }
     
    400392        break;                                                       \
    401393    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);                                               \
    406397    }                                                                \
    407398    break
     
    423414            char* typeStr;
    424415            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);
    429419        }
    430420    }
  • trunk/psLib/src/mathtypes/psScalar.c

    r2055 r2273  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-12 19:32:44 $
     10 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-11-04 01:04:57 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070        break;
    7171    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);
    7675    }
    7776
     
    8584
    8685    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);
    9088        return NULL;
    9189    }
     
    130128        break;
    131129    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);
    136133    }
    137134
  • trunk/psLib/src/mathtypes/psVector.c

    r2204 r2273  
    1010*  @author Robert DeSonia, MHPCC
    1111*
    12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-27 00:57:31 $
     12*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-11-04 01:04:57 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7070
    7171    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);
    7574        return NULL;
    7675    } else if (in->nalloc != nalloc) {     // No need to realloc to same size
     
    9998            in->type.dimen !=  PS_DIMEN_TRANSV) {
    10099        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);
    104102        return NULL;
    105103    }
     
    122120{
    123121    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);
    127124        psFree(out);
    128125        return NULL;
     
    183180                char* typeStr; \
    184181                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); \
    189185                psFree(out); \
    190186            } \
     
    209205            char* typeStr;
    210206            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);
    215210            psFree(out);
    216211
     
    232227
    233228    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);
    237231        psFree(outVector);
    238232        return NULL;
     
    300294        break;
    301295    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);
    306299    }
    307300
     
    317310
    318311    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);
    322314        psFree(outVector);
    323315        return NULL;
     
    400392        break;
    401393    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);
    406397    }
    407398
  • trunk/psLib/src/psErrorCodes.dat

    r1818 r2273  
    1717BAD_PARAMETER_SIZE             size of parameter's data is outside of acceptable range.
    1818UNEXPECTED_NULL                unexpected NULL found
     19OS_CALL_FAILED                 unexpected result from an OS standard library call.
  • trunk/psLib/src/sys/psError.c

    r2204 r2273  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6767}
    6868
    69 void psError(const char *name, const char *fmt, ...)
     69psErrorCode p_psError(const char* file,
     70                      int lineno,
     71                      const char* func,
     72                      psErrorCode code,
     73                      psBool new,
     74                      const char* fmt,
     75                      ...)
    7076{
    71     va_list argPtr;             // variable list arguement pointer
     77    char errMsg[2048];
     78    psErr* err;
     79    char msgName[256];
    7280
    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);
    10882
    10983    va_list argPtr;             // variable list arguement pointer
     
    11690    va_start(argPtr, fmt);
    11791
    118     vsnprintf(errMsg,1024,fmt,argPtr);
     92    vsnprintf(errMsg,2048,fmt,argPtr);
    11993    err = psErrAlloc(msgName,code,errMsg);
    12094    pushErrorStack(err);
     
    160134}
    161135
     136void 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}
    162151void psErrorStackPrint(FILE *fd, const char *fmt, ...)
    163152{
  • trunk/psLib/src/sys/psError.h

    r2204 r2273  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-10-27 00:57:31 $
     14 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-11-04 01:05:00 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    104104 *  log message.
    105105 *
     106 *  This function modifies the error stack.
     107 *
     108 *  @return psErrorCode    the given error code
    106109 */
    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
     110psErrorCode 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,
    110117    ...
    111118);
    112119
    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__)
    127121
    128122/** Create a new psErr struct
  • trunk/psLib/src/sys/psErrorCodes.c

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646            {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
    4747            {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"},
    4950            //~End
    5051            {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
     
    132133
    133134    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);
    137137        return;
    138138    }
     
    152152                        err) ) {
    153153
    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);
    158157        }
    159158        p_psMemSetPersistent(dynamicErrorCodes->head,true);
  • trunk/psLib/src/sys/psErrorCodes.h

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252    PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
    5353    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
    5556    //~End
    5657    PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
  • trunk/psLib/src/sys/psLogMsg.c

    r2204 r2273  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:05:00 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110
    111111    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
    112         psErrorMsg(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);
    115115        return false;
    116116    }
     
    131131            return true;
    132132        }
    133         psErrorMsg(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);
    136136        return 1;
    137137    } else if (strcmp(protocol, "file") == 0) {
     
    139139
    140140        if (file == NULL) {
    141             psErrorMsg(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);
    144144            return false;
    145145        }
     
    151151    }
    152152
    153     psErrorMsg(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);
    156156    return false;
    157157}
     
    215215            break;
    216216        default:
    217             psErrorMsg(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);
    219219            break;
    220220        }
  • trunk/psLib/src/sys/psMemory.c

    r2210 r2273  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-10-27 19:35:59 $
     10*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-11-04 01:05:00 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100{
    101101    if (ptr->refCounter < 1) {
    102         psErrorMsg(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);
    105105    }
    106106
     
    228228
    229229    if (m == NULL) {
    230         psErrorMsg(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);
    232232        return 1;
    233233    }
     
    235235    if (m->refCounter == 0) {
    236236        // using an unreferenced block of memory, are you?
    237         psErrorMsg(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);
    240240        return 1;
    241241    }
    242242
    243243    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    244         psErrorMsg(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);
    247247        return 1;
    248248    }
    249249    if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
    250         psErrorMsg(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);
    253253        return 1;
    254254    }
     
    431431        psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    432432
    433         psErrorMsg(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);
    436436
    437437        return;
  • trunk/psLib/src/sys/psString.c

    r2204 r2273  
    99 *  @author Eric Van Alst, MHPCC
    1010 *
    11  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 00:57:31 $
     11 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838    if (nChar < 0) {
    3939        // Log error message and return NULL
    40         psErrorMsg(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);
    4343        return NULL;
    4444    }
  • trunk/psLib/src/sys/psTrace.c

    r2221 r2273  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 23:31:44 $
     11 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    161161    // XXX: Verify that this is the correct behavior.
    162162    if (strcmp("", addNodeName) == 0) {
    163         psErrorMsg(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);
    165165        return false;
    166166    }
     
    173173
    174174    if (addNodeName[0] != '.') {
    175         psErrorMsg(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);
    178178        return false;
    179179    }
     
    262262    // Add the new component to the component tree.
    263263    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);
    270268
    271269        if (comp[0] != '.') {
     
    482480
    483481    if (NULL == comp) {
    484         psErrorMsg(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__);
    487485        return;
    488486    }
  • trunk/psLib/src/sysUtils/psError.c

    r2204 r2273  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6767}
    6868
    69 void psError(const char *name, const char *fmt, ...)
     69psErrorCode p_psError(const char* file,
     70                      int lineno,
     71                      const char* func,
     72                      psErrorCode code,
     73                      psBool new,
     74                      const char* fmt,
     75                      ...)
    7076{
    71     va_list argPtr;             // variable list arguement pointer
     77    char errMsg[2048];
     78    psErr* err;
     79    char msgName[256];
    7280
    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);
    10882
    10983    va_list argPtr;             // variable list arguement pointer
     
    11690    va_start(argPtr, fmt);
    11791
    118     vsnprintf(errMsg,1024,fmt,argPtr);
     92    vsnprintf(errMsg,2048,fmt,argPtr);
    11993    err = psErrAlloc(msgName,code,errMsg);
    12094    pushErrorStack(err);
     
    160134}
    161135
     136void 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}
    162151void psErrorStackPrint(FILE *fd, const char *fmt, ...)
    163152{
  • trunk/psLib/src/sysUtils/psError.h

    r2204 r2273  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-10-27 00:57:31 $
     14 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-11-04 01:05:00 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    104104 *  log message.
    105105 *
     106 *  This function modifies the error stack.
     107 *
     108 *  @return psErrorCode    the given error code
    106109 */
    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
     110psErrorCode 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,
    110117    ...
    111118);
    112119
    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__)
    127121
    128122/** Create a new psErr struct
  • trunk/psLib/src/sysUtils/psErrorCodes.c

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646            {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
    4747            {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"},
    4950            //~End
    5051            {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
     
    132133
    133134    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);
    137137        return;
    138138    }
     
    152152                        err) ) {
    153153
    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);
    158157        }
    159158        p_psMemSetPersistent(dynamicErrorCodes->head,true);
  • trunk/psLib/src/sysUtils/psErrorCodes.h

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252    PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
    5353    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
    5556    //~End
    5657    PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
  • trunk/psLib/src/sysUtils/psLogMsg.c

    r2204 r2273  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:05:00 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110
    111111    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
    112         psErrorMsg(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);
    115115        return false;
    116116    }
     
    131131            return true;
    132132        }
    133         psErrorMsg(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);
    136136        return 1;
    137137    } else if (strcmp(protocol, "file") == 0) {
     
    139139
    140140        if (file == NULL) {
    141             psErrorMsg(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);
    144144            return false;
    145145        }
     
    151151    }
    152152
    153     psErrorMsg(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);
    156156    return false;
    157157}
     
    215215            break;
    216216        default:
    217             psErrorMsg(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);
    219219            break;
    220220        }
  • trunk/psLib/src/sysUtils/psMemory.c

    r2210 r2273  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-10-27 19:35:59 $
     10*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-11-04 01:05:00 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100{
    101101    if (ptr->refCounter < 1) {
    102         psErrorMsg(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);
    105105    }
    106106
     
    228228
    229229    if (m == NULL) {
    230         psErrorMsg(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);
    232232        return 1;
    233233    }
     
    235235    if (m->refCounter == 0) {
    236236        // using an unreferenced block of memory, are you?
    237         psErrorMsg(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);
    240240        return 1;
    241241    }
    242242
    243243    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    244         psErrorMsg(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);
    247247        return 1;
    248248    }
    249249    if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
    250         psErrorMsg(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);
    253253        return 1;
    254254    }
     
    431431        psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    432432
    433         psErrorMsg(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);
    436436
    437437        return;
  • trunk/psLib/src/sysUtils/psString.c

    r2204 r2273  
    99 *  @author Eric Van Alst, MHPCC
    1010 *
    11  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 00:57:31 $
     11 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838    if (nChar < 0) {
    3939        // Log error message and return NULL
    40         psErrorMsg(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);
    4343        return NULL;
    4444    }
  • trunk/psLib/src/sysUtils/psTrace.c

    r2221 r2273  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 23:31:44 $
     11 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    161161    // XXX: Verify that this is the correct behavior.
    162162    if (strcmp("", addNodeName) == 0) {
    163         psErrorMsg(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);
    165165        return false;
    166166    }
     
    173173
    174174    if (addNodeName[0] != '.') {
    175         psErrorMsg(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);
    178178        return false;
    179179    }
     
    262262    // Add the new component to the component tree.
    263263    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);
    270268
    271269        if (comp[0] != '.') {
     
    482480
    483481    if (NULL == comp) {
    484         psErrorMsg(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__);
    487485        return;
    488486    }
  • trunk/psLib/src/types/psBitSet.c

    r2204 r2273  
    1111 *  @author Robert DeSonia, MHPCC
    1212 *
    13  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:04:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7272
    7373    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);
    7877        return NULL;
    7978    }
     
    9998
    10099    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);
    104102        return inBitSet;
    105103    } else if ( (bit < 0) ||
    106104                (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);
    111108        return inBitSet;
    112109    }
     
    124121
    125122    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);
    129125        return inBitSet;
    130126    } else if ( (bit < 0) ||
    131127                (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);
    136131        return inBitSet;
    137132    }
     
    149144
    150145    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);
    154148        return false;
    155149    } else if ( (bit < 0) ||
    156150                (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);
    161154        return false;
    162155    }
     
    180173
    181174    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);
    185177        psFree(outBitSet);
    186178        return NULL;
     
    189181
    190182    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);
    194185        psFree(outBitSet);
    195186        return NULL;
     
    217208        psFree(tempStr);
    218209        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);
    223213        return NULL;
    224214    }
     
    227217    if (op != NOT_OP) {
    228218        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);
    232221            psFree(outBitSet);
    233222            return NULL;
     
    235224
    236225        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);
    240228            psFree(outBitSet);
    241229            return NULL;
     
    287275{
    288276    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);
    292279        psFree(outBitSet);
    293280        return NULL;
     
    297284
    298285    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);
    302288    }
    303289
  • trunk/psLib/src/types/psHash.c

    r2221 r2273  
    1111*  @author George Gusciora, MHPCC
    1212*
    13 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-10-27 23:31:43 $
     13*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-11-04 01:04:57 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    228228    // the way this procedure is called.
    229229    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);
    233232        return NULL;
    234233    }
     
    249248    // anyway.
    250249    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);
    252252    }
    253253    // ptr will have the correct hash bucket.
     
    347347{
    348348    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);
    352351        return false;
    353352    }
    354353    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);
    358356        return false;
    359357    }
    360358    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);
    364361    }
    365362
     
    382379{
    383380    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);
    387383        return NULL;
    388384    }
    389385    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);
    393388        return NULL;
    394389    }
     
    414409
    415410    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);
    419413        return false;
    420414    }
    421415    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);
    425418        return false;
    426419    }
  • trunk/psLib/src/types/psList.c

    r2204 r2273  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:31 $
     8 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    136136
    137137        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);
    139140            position = list->head;         // since we no list->size != 0, this must be non-NULL
    140141        }
     
    173174
    174175    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.");
    176177        return false;
    177178    }
     
    194195
    195196        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.");
    197198            pthread_mutex_unlock(&list->lock)
    198199            ;
     
    206207
    207208    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);
    209211        pthread_mutex_unlock(&list->lock)
    210212        ;
     
    257259
    258260    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.");
    260263        return;
    261264    }
     
    314317    default:
    315318        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.");
    317321        } else {
    318322            cursor = listGetIterator(list);
  • trunk/psLib/src/types/psMetadata.c

    r2204 r2273  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-10-27 00:57:30 $
     14*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-11-04 01:04:57 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "psMetadata.h"
    3636#include "psString.h"
     37#include "psAstronomyErrors.h"
     38#include "psConstants.h"
    3739
    3840/******************************************************************************/
     
    123125
    124126
    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
    129129    // Allocate metadata item
    130130    metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
     
    147147    // Set metadata item type
    148148    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);
    149157
    150158    // Set metadata item value
    151159    switch (type) {
    152160    case PS_META_ITEM_SET:
    153         metadataItem->data.V = NULL;
    154161        break;
    155162    case PS_META_BOOL:
     
    180187    case PS_META_UNKNOWN:
    181188    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    }
    191195
    192196    return metadataItem;
     
    224228    psMetadataType newType = PS_META_ITEM_SET;
    225229
    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);
    235235
    236236    newType = metadataItem->type;
    237 
    238237    mdTable = md->table;
    239     if(mdTable == NULL) {
    240         psError( __func__, "Null metadata table not allowed" );
    241         return false;
    242     }
    243 
    244238    mdList = md->list;
    245     if(mdList == NULL) {
    246         psError( __func__, "Null metadata list not allowed");
    247         return false;
    248     }
    249 
    250239    key = metadataItem->name;
    251     if(key == NULL) {
    252         psError(__func__, "Null key item not allowed");
    253         return false;
    254     }
    255240
    256241    // See if key is already in table
     
    262247            // Add leaf node to existing folder node
    263248            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 );
    266252                return false;
    267253            }
     
    272258
    273259            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);
    275263                psFree(newFolderEntry);
    276264                return false;
     
    278266
    279267            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);
    281271                psFree(newFolderEntry);
    282272                return false;
     
    284274
    285275            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);
    287279                psFree(newFolderEntry);
    288280                return false;
     
    290282
    291283            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);
    293287                psFree(newFolderEntry);
    294288                return false;
     
    301295            // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
    302296            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);
    304300                return false;
    305301            }
    306302
    307303            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);
    309307                return false;
    310308            }
    311309
    312310            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);
    314314                return false;
    315315            }
     
    319319        // Node doesn't exist - Add new metadata item to metadata collection's hash
    320320        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);
    322324            return false;
    323325        }
     
    328330    if(metadataItem->type != PS_META_ITEM_SET) {
    329331        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);
    332335            return false;
    333336        }
     
    348351
    349352    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);
    352355        psFree(metadataItem);
    353356        return false;
     
    368371
    369372
    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);
    374376
    375377    mdList = md->list;
    376     if (mdList == NULL) {
    377         psError(__func__, "Null metadata list not allowed");
    378         return false;
    379     }
    380 
    381378    mdTable = md->table;
    382     if (mdTable == NULL) {
    383         psError(__func__, "Null metadata table not allowed");
    384         return false;
    385     }
     379
    386380    // Select removal by key or index
    387381    if (key != NULL) {
     
    390384        entry = (psMetadataItem* ) psHashLookup(mdTable, key);
    391385        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);
    393389            return false;
    394390        }
     
    402398            while (entryChild != NULL) {
    403399                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);
    405403                    return false;
    406404                }
     
    411409            // Table entry has no children. Remove entry from metadata collection's list
    412410            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);
    414414                return false;
    415415            }
     
    417417        // Remove entry from metadata collection's table
    418418        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);
    420422            return false;
    421423        }
     
    425427        entry = psListGet(mdList, where);
    426428        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);
    428432            return false;
    429433        }
     
    431435        key = entry->name;
    432436        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);
    434440            return false;
    435441        }
     
    447453
    448454
    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);
    453458
    454459    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     }
    464460
    465461    entry = (psMetadataItem* ) psHashLookup(mdTable, key);
     
    473469psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
    474470{
     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
     487psBool 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
     497psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
     498{
    475499    psList* mdList = NULL;
    476500    psMetadataItem* entry = NULL;
    477501
    478502
    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);
    483505
    484506    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     }
    535507
    536508    psListSetIterator(mdList, which);
     
    559531
    560532
    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);
    565535
    566536    mdList = md->list;
    567     if (mdList == NULL) {
    568         psError(__func__, "Null metadata list not allowed");
    569         return NULL;
    570     }
    571537
    572538    psListSetIterator(mdList, which);
  • trunk/psLib/src/types/psMetadataConfig.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    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); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *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);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    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,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    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);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    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);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        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);
    443438            return output;
    444439        }
     
    471466
    472467    // 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);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                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);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                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);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                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);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                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);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                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);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                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);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    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);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                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);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        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);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    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);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    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);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    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);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    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);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                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);
    654673                continue;
    655674            } // switch
  • trunk/psLib/src/xml/psXML.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    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); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *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);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    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,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    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);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    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);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        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);
    443438            return output;
    444439        }
     
    471466
    472467    // 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);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                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);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                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);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                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);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                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);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                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);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                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);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    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);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                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);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        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);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    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);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    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);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    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);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    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);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                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);
    654673                continue;
    655674            } // switch
  • trunk/psLib/test/astronomy/tst_psMetadata_01.c

    r2204 r2273  
    1717*  @author  Ross Harman, MHPCC
    1818*
    19 *  @version $Revision: 1.13 $  $Name: not supported by cvs2svn $
    20 *  @date  $Date: 2004-10-27 00:57:33 $
     19*  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
     20*  @date  $Date: 2004-11-04 01:05:00 $
    2121*
    2222*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    227227    metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits");
    228228    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.");
    230230        return 10;
    231231    }
     
    238238    metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits");
    239239    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.");
    241241        return 11;
    242242    }
     
    249249    metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits");
    250250    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");
    252252        return 12;
    253253    }
  • trunk/psLib/test/astronomy/tst_psMetadata_02.c

    r2204 r2273  
    1414*  @author  Ross Harman, MHPCC
    1515*
    16 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    17 *  @date  $Date: 2004-10-27 00:57:33 $
     16*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     17*  @date  $Date: 2004-11-04 01:05:00 $
    1818*
    1919*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9292    badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD");
    9393    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.");
    9595        return 10;
    9696    }
  • trunk/psLib/test/astronomy/tst_psMetadata_03.c

    r2204 r2273  
    1414*  @author  Ross Harman, MHPCC
    1515*
    16 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
    17 *  @date  $Date: 2004-10-27 00:57:33 $
     16*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
     17*  @date  $Date: 2004-11-04 01:05:00 $
    1818*
    1919*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9191    printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name");
    9292    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.");
    9494        return 10;
    9595    }
    9696    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.");
    9898        return 11;
    9999    }
    100100    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.");
    102102        return 12;
    103103    }
    104104    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.");
    106106        return 13;
    107107    }
     
    112112    printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index");
    113113    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.");
    115115        return 14;
    116116    }
    117117    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.");
    119119        return 15;
    120120    }
    121121    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.");
    123123        return 16;
    124124    }
    125125    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.");
    127127        return 17;
    128128    }
     
    134134                            "Null metadata collection not allowed", 0);
    135135    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.");
    137137        return 18;
    138138    }
     
    144144                            "Couldn't find metadata item. Name: AARGH", 0);
    145145    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.");
    147147        return 19;
    148148    }
     
    154154                            "Couldn't find metadata item in list. Index: 22", 0);
    155155    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.");
    157157        return 20;
    158158    }
     
    167167    errMetadata->table = NULL;
    168168    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.");
    170170        return 21;
    171171    }
    172172    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.");
    174174        return 31;
    175175    }
     
    183183    errMetadata->list = NULL;
    184184    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.");
    186186        return 22;
    187187    }
    188188    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.");
    190190        return 32;
    191191    }
     
    199199    errItem->name = NULL;
    200200    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.");
    202202        return 23;
    203203    }
     
    211211    errMetadata->table = NULL;
    212212    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.");
    214214        return 24;
    215215    }
     
    227227    psFree(errMetadata);
    228228    if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    229         psError(__func__,"Memory leaks detected.");
     229        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    230230        return 25;
    231231    }
  • trunk/psLib/test/astronomy/tst_psMetadata_04.c

    r2204 r2273  
    1818*  @author  Ross Harman, MHPCC
    1919*
    20 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    21 *  @date  $Date: 2004-10-27 00:57:33 $
     20*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     21*  @date  $Date: 2004-11-04 01:05:00 $
    2222*
    2323*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    108108                            "Null metadata collection not allowed", 0);
    109109    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.");
    111111        return 11;
    112112    }
     
    118118                            "Null key name not allowed", 0);
    119119    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.");
    121121        return 12;
    122122    }
     
    128128                            "Couldn't find metadata item. Name: AARGH", 0);
    129129    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.");
    131131        return 13;
    132132    }
     
    150150    item = psMetadataGet(NULL, 0);
    151151    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.");
    153153        return 15;
    154154    }
     
    160160                            "Couldn't find metadata item with given index. Index: 22", 0);
    161161    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.");
    163163        return 16;
    164164    }
     
    171171    metadata->table = NULL;
    172172    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.");
    174174        return 20;
    175175    }
     
    183183    metadata->list = NULL;
    184184    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.");
    186186        return 20;
    187187    }
     
    197197    psFree(item4);
    198198    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    199         psError(__func__,"memory leaks detected.");
     199        psError(PS_ERR_UNKNOWN, true,"memory leaks detected.");
    200200        return 20;
    201201    }
  • trunk/psLib/test/astronomy/tst_psMetadata_05.c

    r2204 r2273  
    2222*  @author  Ross Harman, MHPCC
    2323*
    24 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
    25 *  @date  $Date: 2004-10-27 00:57:33 $
     24*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
     25*  @date  $Date: 2004-11-04 01:05:00 $
    2626*
    2727*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    145145    }
    146146    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.");
    148148        return 45;
    149149    }
     
    151151    metadata->list = NULL;
    152152    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.");
    154154        return 50;
    155155    }
     
    213213                            "Null metadata collection not allowed", 0);
    214214    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.");
    216216        return 40;
    217217    }
     
    219219    metadata->list = NULL;
    220220    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.");
    222222        return 41;
    223223    }
     
    267267    psFree(item8);
    268268    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    269         psError(__func__,"Memory leaks detected.");
     269        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    270270        return 50;
    271271    }
  • trunk/psLib/test/astronomy/tst_psMetadata_06.c

    r2204 r2273  
    1313*  @author  Ross Harman, MHPCC
    1414*
    15 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    16 *  @date  $Date: 2004-10-27 00:57:33 $
     15*  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     16*  @date  $Date: 2004-11-04 01:05:00 $
    1717*
    1818*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888    printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node");
    8989    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.");
    9191        return 20;
    9292    }
    9393    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.");
    9595        return 21;
    9696    }
     
    102102    printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node");
    103103    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.");
    105105        return 22;
    106106    }
     
    111111    printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node");
    112112    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.");
    114114        return 23;
    115115    }
    116116    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.");
    118118        return 24;
    119119    }
     
    130130    psFree(metadata);
    131131    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    132         psError(__func__,"Memory leaks detected.");
     132        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    133133        return 25;
    134134    }
  • trunk/psLib/test/collections/tst_psArray.c

    r2204 r2273  
    1212 *  @author  Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2004-10-27 00:57:33 $
     14 *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     15 *  @date  $Date: 2004-11-04 01:05:00 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    psArray *psArr = psArrayAlloc(5);
    4444    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.");
    4646        return 1;
    4747    }
     
    6464        printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
    6565        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.");
    6767            return 2;
    6868        }
     
    7070    printf("array size = %d\n", psArr->nalloc);
    7171    if (psArr->nalloc != 5) {
    72         psError(__func__,"Array Size wrong");
     72        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
    7373        return 3;
    7474    }
    7575    printf("array population = %d\n", psArr->n);
    7676    if (psArr->n != 5) {
    77         psError(__func__,"Array population wrong");
     77        psError(PS_ERR_UNKNOWN, true,"Array population wrong");
    7878        return 4;
    7979    }
     
    9898        printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
    9999        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.");
    101101            return 5;
    102102        }
     
    104104    printf("array size = %d\n", psArr->nalloc);
    105105    if (psArr->nalloc != 10) {
    106         psError(__func__,"Array Size wrong");
     106        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
    107107        return 6;
    108108    }
    109109    printf("array population = %d\n", psArr->n);
    110110    if (psArr->n != 10) {
    111         psError(__func__,"Array Population wrong");
     111        psError(PS_ERR_UNKNOWN, true,"Array Population wrong");
    112112        return 7;
    113113    }
     
    122122        printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
    123123        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.");
    125125            return 8;
    126126        }
     
    128128    printf("array size = %d\n", psArr->nalloc);
    129129    if (psArr->nalloc != 3) {
    130         psError(__func__,"Array Size wrong");
     130        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
    131131        return 9;
    132132    }
    133133    printf("array population = %d\n", psArr->n);
    134134    if (psArr->n != 3) {
    135         psError(__func__,"Array Population wrong");
     135        psError(PS_ERR_UNKNOWN, true,"Array Population wrong");
    136136        return 10;
    137137    }
  • trunk/psLib/test/collections/tst_psList.c

    r2204 r2273  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:33 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:05:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444
    4545    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");
    4747        return 1;
    4848    }
     
    6666    list = psListAlloc(NULL);
    6767    if (list == NULL) {
    68         psError(__func__,"psListAlloc failed to return a list.");
     68        psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list.");
    6969        return 1;
    7070    }
    7171
    7272    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.");
    7474        return 2;
    7575    }
    7676
    7777    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.");
    7979        return 3;
    8080    }
     
    8484    list = psListAlloc(data);
    8585    if (list == NULL) {
    86         psError(__func__,"psListAlloc failed to return a list.");
     86        psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list.");
    8787        return 4;
    8888    }
    8989
    9090    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.");
    9292        return 5;
    9393    }
    9494
    9595    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.");
    9797        return 6;
    9898    }
    9999
    100100    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.");
    102102        return 7;
    103103    }
     
    105105    ref = psMemGetRefCounter(data);
    106106    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);
    108108        return 8;
    109109    }
     
    139139    //  1. list is NULL (error)
    140140    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.");
    142142        return 1;
    143143    }
     
    146146    psFree(data);
    147147    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.");
    149149        return 2;
    150150    }
     
    152152    //  2. data is NULL (error, list should not grow)
    153153    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?");
    155155        return 40;
    156156    }
    157157    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.");
    159159        return 3;
    160160    }
     
    164164    *data = 2;
    165165    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.");
    167167        return 21;
    168168    }
    169169
    170170    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.");
    172172        return 20;
    173173    }
     
    176176    // verify that the size incremented
    177177    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");
    179179        return 4;
    180180    }
     
    182182    // verify that the head is the inserted data item
    183183    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.");
    185185        return 5;
    186186    }
     
    189189    *data = 3;
    190190    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.");
    192192        return 21;
    193193    }
    194194
    195195    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.");
    197197        return 22;
    198198    }
     
    200200    // verify that the size incremented
    201201    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");
    203203        return 6;
    204204    }
     
    206206    // verify that the head is still the same
    207207    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.");
    209209        return 7;
    210210    }
     
    212212    // verify that the tail is the data item inserted
    213213    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.");
    215215        return 8;
    216216    }
     
    223223
    224224    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?");
    226226        return 30;
    227227    }
    228228    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.");
    230230        return 24;
    231231    }
     
    234234    if (list->size != 3) {
    235235        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.");
    237237        return 9;
    238238    }
     
    243243
    244244    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.");
    246246        return 30;
    247247    }
    248248
    249249    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.");
    251251        return 25;
    252252    }
     
    255255    if (list->size != 4 || *(psS32*)list->head->next->data != 5) {
    256256        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.");
    258258        return 10;
    259259    }
     
    262262    *data = 6;
    263263    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.");
    265265        return 31;
    266266    }
    267267    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.");
    269269        return 26;
    270270    }
     
    273273    if (list->size != 5  || *(psS32 *)list->head->next->next->next->data != 6) {
    274274        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.");
    276276        return 50;
    277277    }
     
    280280    *data = 7;
    281281    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.");
    283283        return 32;
    284284    }
    285285    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.");
    287287        return 28;
    288288    }
     
    291291    if (list->size != 6  || *(psS32 *)list->head->next->next->data != 7) {
    292292        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.");
    294294        return 11;
    295295    }
     
    300300
    301301    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?");
    303303        return 30;
    304304    }
    305305
    306306    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.");
    308308        return 29;
    309309    }
     
    314314    if (list->size != 7) {
    315315        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.");
    317317        return 12;
    318318    }
     
    366366    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
    367367    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.");
    369369        return 1;
    370370    };
     
    394394    data = (psS32*)psListGet(list,3);
    395395    if (data == NULL || *data != 3) {
    396         psError(__func__,"psListGet failed with which=3");
     396        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=3");
    397397        return 2;
    398398    }
    399399    data = (psS32*)psListGet(list,1);
    400400    if (data == NULL || *data != 1) {
    401         psError(__func__,"psListGet failed with which=1");
     401        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=1");
    402402        return 3;
    403403    }
     
    406406    data = (psS32*)psListGet(list,5);
    407407    if (data != NULL) {
    408         psError(__func__,"psListGet failed with which=5");
     408        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=5");
    409409        return 4;
    410410    }
    411411    data = (psS32*)psListGet(list,4);
    412412    if (data != NULL) {
    413         psError(__func__,"psListGet failed with which=4");
     413        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=4");
    414414        return 5;
    415415    }
     
    418418    data = (psS32*)psListGet(list,PS_LIST_HEAD);
    419419    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");
    421421        return 6;
    422422    }
     
    425425    data = (psS32*)psListGet(list,PS_LIST_NEXT);
    426426    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");
    428428        return 7;
    429429    }
     
    432432    data = (psS32*)psListGet(list,PS_LIST_TAIL);
    433433    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");
    435435        return 8;
    436436    }
     
    439439    data = (psS32*)psListGet(list,PS_LIST_PREVIOUS);
    440440    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");
    442442        return 9;
    443443    }
     
    473473    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
    474474    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.");
    476476        return 1;
    477477    };
     
    493493            (psListGet(list,PS_LIST_HEAD) == data) ) {
    494494        printListInt(list);
    495         psError(__func__,"Failed to remove PS_LIST_HEAD");
     495        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_HEAD");
    496496        return 1;
    497497    }
     
    499499    if (list->size != 14) {
    500500        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.");
    502502        return 1;
    503503    }
     
    508508            (psListGet(list,PS_LIST_TAIL) == data) ) {
    509509        printListInt(list);
    510         psError(__func__,"Failed to remove PS_LIST_TAIL");
     510        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_TAIL");
    511511        return 1;
    512512    }
     
    514514    if (list->size != 13) {
    515515        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.");
    517517        return 1;
    518518    }
     
    522522    if (! psListRemove(list,PS_LIST_NEXT,NULL)) {
    523523        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");
    525525        return 1;
    526526    }
     
    528528    if (list->size != 12) {
    529529        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.");
    531531        return 1;
    532532    }
     
    536536    if (psListRemove(list,PS_LIST_NEXT,NULL)) {
    537537        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");
    539539        return 1;
    540540    }
     
    545545            ( psListGet(list,3) == data) ) {
    546546        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");
    548548        return 1;
    549549    }
     
    551551    if (list->size != 11) {
    552552        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.");
    554554        return 1;
    555555    }
     
    560560    if (psListRemove(list,PS_LIST_PREVIOUS,NULL)) {
    561561        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");
    563563        return 1;
    564564    }
     
    569569            (psListGet(list,9) == data) ) {
    570570        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");
    572572        return 1;
    573573    }
     
    575575    if (list->size != 10) {
    576576        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.");
    578578        return 1;
    579579    }
     
    584584            ( psListGet(list,1) == data) ) {
    585585        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");
    587587        return 1;
    588588    }
     
    590590    if (list->size != 9) {
    591591        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.");
    593593        return 1;
    594594    }
     
    598598    if (psListRemove(list,PS_LIST_UNKNOWN,NULL)) {
    599599        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");
    601601        return 1;
    602602    }
     
    607607            (psListGet(list,PS_LIST_HEAD) == data) ) {
    608608        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");
    610610        return 1;
    611611    }
     
    613613    if (list->size != 8) {
    614614        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.");
    616616        return 1;
    617617    }
     
    621621            (psListGet(list,PS_LIST_TAIL) == data) ) {
    622622        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");
    624624        return 1;
    625625    }
     
    627627    if (list->size != 7) {
    628628        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.");
    630630        return 1;
    631631    }
     
    637637            (psListGet(list,1) == data) ) {
    638638        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");
    640640        return 1;
    641641    }
     
    643643    if (list->size != 6) {
    644644        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.");
    646646        return 1;
    647647    }
     
    651651    if ( psListRemove(list,PS_LIST_UNKNOWN,data) ) {
    652652        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");
    654654        return 1;
    655655    }
     
    666666            (psListGet(list,PS_LIST_HEAD) == data) ) {
    667667        printListInt(list);
    668         psError(__func__,"Failed to remove last element");
     668        psError(PS_ERR_UNKNOWN, true,"Failed to remove last element");
    669669        return 1;
    670670    }
     
    672672    if (list->size != 0) {
    673673        printListInt(list);
    674         psError(__func__,"Didn't remove all the elements.");
     674        psError(PS_ERR_UNKNOWN, true,"Didn't remove all the elements.");
    675675        return 1;
    676676    }
     
    709709
    710710    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");
    712712        return 1;
    713713    }
    714714    for (psS32 i=0;i<arr->n;i++) {
    715715        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).",
    717717                    i,*(psS32*)arr->data[i]);
    718718            return 1;
    719719        }
    720720        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).",
    722722                    i,*(psS32*)arr->data[i]);
    723723            return 1;
    724724        }
    725725        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).",
    727727                    i,psMemGetRefCounter(arr->data[i]));
    728728            return 1;
     
    747747
    748748    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");
    750750        return 1;
    751751    }
    752752    for (psS32 i=0;i<arr->n;i++) {
    753753        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).",
    755755                    i,*(psS32*)arr->data[i]);
    756756            return 1;
    757757        }
    758758        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).",
    760760                    i,*(psS32*)arr->data[i]);
    761761            return 1;
    762762        }
    763763        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).",
    765765                    i,psMemGetRefCounter(arr->data[i]));
    766766            return 1;
     
    775775    arr = psListToArray(NULL);
    776776    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");
    778778        return 1;
    779779    }
     
    781781    list = psArrayToList(NULL);
    782782    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");
    784784        return 1;
    785785    }
     
    790790    list = psArrayToList(arr);
    791791    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 "
    793793                "empty array.");
    794794        return 1;
     
    800800    arr = psListToArray(list);
    801801    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 "
    803803                "empty list.");
    804804        return 1;
     
    853853    psListSetIterator(list,PS_LIST_TAIL);
    854854    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.");
    856856        return 1;
    857857    }
     
    860860    psListSetIterator(list,PS_LIST_HEAD);
    861861    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.");
    863863        return 2;
    864864    }
     
    867867    psListSetIterator(list,PS_LIST_NEXT);
    868868    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.");
    870870        return 3;
    871871    }
    872872    psListSetIterator(list,PS_LIST_NEXT);
    873873    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.");
    875875        return 4;
    876876    }
     
    879879    psListSetIterator(list,PS_LIST_PREVIOUS);
    880880    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.");
    882882        return 5;
    883883    }
    884884    psListSetIterator(list,PS_LIST_PREVIOUS);
    885885    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.");
    887887        return 6;
    888888    }
     
    893893    psListSetIterator(list,PS_LIST_UNKNOWN);
    894894    if (*(psS32*)psListGetCurrent(list) != 1) {
    895         psError(__func__,"PS_LIST_UNKNOWN moved cursor.");
     895        psError(PS_ERR_UNKNOWN, true,"PS_LIST_UNKNOWN moved cursor.");
    896896        return 7;
    897897    }
    898898    psListSetIterator(list,PS_LIST_CURRENT);
    899899    if (*(psS32*)psListGetCurrent(list) != 1) {
    900         psError(__func__,"PS_LIST_CURRENT moved cursor.");
     900        psError(PS_ERR_UNKNOWN, true,"PS_LIST_CURRENT moved cursor.");
    901901        return 8;
    902902    }
     
    904904    // test psListGetPrevious/Next
    905905    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.");
    907907        return 9;
    908908    }
    909909    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.");
    911911        return 10;
    912912    }
    913913    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.");
    915915        return 11;
    916916    }
    917917    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.");
    919919        return 12;
    920920    }
    921921    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..");
    923923        return 13;
    924924    }
    925925    if (psListGetPrevious(list) != NULL) {
    926         psError(__func__,"psListGetPrevious moved cursor beyond head.");
     926        psError(PS_ERR_UNKNOWN, true,"psListGetPrevious moved cursor beyond head.");
    927927        return 14;
    928928    }
     
    930930    psListSetIterator(list,PS_LIST_TAIL); // works according to an above test
    931931    if (psListGetNext(list) != NULL) {
    932         psError(__func__,"psListGetNext moved cursor beyond tail.");
     932        psError(PS_ERR_UNKNOWN, true,"psListGetNext moved cursor beyond tail.");
    933933        return 15;
    934934    }
     
    959959        psListAdd(list,PS_LIST_TAIL,data[lcv]);
    960960        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");
    962962            return 1;
    963963        }
     
    969969    */
    970970    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?");
    972972        return 2;
    973973    }
     
    989989    for (psS32 i=0;i<15;i++) {
    990990        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");
    992992            return 3;
    993993        }
     
    10391039            iter = psListGet(list,PS_LIST_NEXT)) {
    10401040        if (*prevValue > *iter) {
    1041             psError(__func__,"Hey, the list wasn't sorted!?");
     1041            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
    10421042            return 1;
    10431043        }
     
    10591059            iter = psListGet(list,PS_LIST_NEXT)) {
    10601060        if (*prevValue < *iter) {
    1061             psError(__func__,"Hey, the list wasn't sorted!?");
     1061            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
    10621062            return 1;
    10631063        }
     
    11051105            iter = psListGet(list,PS_LIST_NEXT)) {
    11061106        if (*prev > *iter) {
    1107             psError(__func__,"Hey, the list wasn't sorted!?");
     1107            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
    11081108            return 1;
    11091109        }
     
    11251125            iter = psListGet(list,PS_LIST_NEXT)) {
    11261126        if (*prev < *iter) {
    1127             psError(__func__,"Hey, the list wasn't sorted!?");
     1127            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
    11281128            return 1;
    11291129        }
  • trunk/psLib/test/collections/tst_psMetadata_01.c

    r2204 r2273  
    1717*  @author  Ross Harman, MHPCC
    1818*
    19 *  @version $Revision: 1.13 $  $Name: not supported by cvs2svn $
    20 *  @date  $Date: 2004-10-27 00:57:33 $
     19*  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
     20*  @date  $Date: 2004-11-04 01:05:00 $
    2121*
    2222*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    227227    metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits");
    228228    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.");
    230230        return 10;
    231231    }
     
    238238    metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits");
    239239    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.");
    241241        return 11;
    242242    }
     
    249249    metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits");
    250250    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");
    252252        return 12;
    253253    }
  • trunk/psLib/test/collections/tst_psMetadata_02.c

    r2204 r2273  
    1414*  @author  Ross Harman, MHPCC
    1515*
    16 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    17 *  @date  $Date: 2004-10-27 00:57:33 $
     16*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     17*  @date  $Date: 2004-11-04 01:05:00 $
    1818*
    1919*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9292    badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD");
    9393    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.");
    9595        return 10;
    9696    }
  • trunk/psLib/test/collections/tst_psMetadata_03.c

    r2204 r2273  
    1414*  @author  Ross Harman, MHPCC
    1515*
    16 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
    17 *  @date  $Date: 2004-10-27 00:57:33 $
     16*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
     17*  @date  $Date: 2004-11-04 01:05:00 $
    1818*
    1919*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9191    printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name");
    9292    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.");
    9494        return 10;
    9595    }
    9696    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.");
    9898        return 11;
    9999    }
    100100    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.");
    102102        return 12;
    103103    }
    104104    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.");
    106106        return 13;
    107107    }
     
    112112    printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index");
    113113    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.");
    115115        return 14;
    116116    }
    117117    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.");
    119119        return 15;
    120120    }
    121121    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.");
    123123        return 16;
    124124    }
    125125    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.");
    127127        return 17;
    128128    }
     
    134134                            "Null metadata collection not allowed", 0);
    135135    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.");
    137137        return 18;
    138138    }
     
    144144                            "Couldn't find metadata item. Name: AARGH", 0);
    145145    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.");
    147147        return 19;
    148148    }
     
    154154                            "Couldn't find metadata item in list. Index: 22", 0);
    155155    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.");
    157157        return 20;
    158158    }
     
    167167    errMetadata->table = NULL;
    168168    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.");
    170170        return 21;
    171171    }
    172172    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.");
    174174        return 31;
    175175    }
     
    183183    errMetadata->list = NULL;
    184184    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.");
    186186        return 22;
    187187    }
    188188    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.");
    190190        return 32;
    191191    }
     
    199199    errItem->name = NULL;
    200200    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.");
    202202        return 23;
    203203    }
     
    211211    errMetadata->table = NULL;
    212212    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.");
    214214        return 24;
    215215    }
     
    227227    psFree(errMetadata);
    228228    if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    229         psError(__func__,"Memory leaks detected.");
     229        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    230230        return 25;
    231231    }
  • trunk/psLib/test/collections/tst_psMetadata_04.c

    r2204 r2273  
    1818*  @author  Ross Harman, MHPCC
    1919*
    20 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    21 *  @date  $Date: 2004-10-27 00:57:33 $
     20*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     21*  @date  $Date: 2004-11-04 01:05:00 $
    2222*
    2323*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    108108                            "Null metadata collection not allowed", 0);
    109109    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.");
    111111        return 11;
    112112    }
     
    118118                            "Null key name not allowed", 0);
    119119    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.");
    121121        return 12;
    122122    }
     
    128128                            "Couldn't find metadata item. Name: AARGH", 0);
    129129    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.");
    131131        return 13;
    132132    }
     
    150150    item = psMetadataGet(NULL, 0);
    151151    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.");
    153153        return 15;
    154154    }
     
    160160                            "Couldn't find metadata item with given index. Index: 22", 0);
    161161    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.");
    163163        return 16;
    164164    }
     
    171171    metadata->table = NULL;
    172172    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.");
    174174        return 20;
    175175    }
     
    183183    metadata->list = NULL;
    184184    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.");
    186186        return 20;
    187187    }
     
    197197    psFree(item4);
    198198    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    199         psError(__func__,"memory leaks detected.");
     199        psError(PS_ERR_UNKNOWN, true,"memory leaks detected.");
    200200        return 20;
    201201    }
  • trunk/psLib/test/collections/tst_psMetadata_05.c

    r2204 r2273  
    2222*  @author  Ross Harman, MHPCC
    2323*
    24 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
    25 *  @date  $Date: 2004-10-27 00:57:33 $
     24*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
     25*  @date  $Date: 2004-11-04 01:05:00 $
    2626*
    2727*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    145145    }
    146146    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.");
    148148        return 45;
    149149    }
     
    151151    metadata->list = NULL;
    152152    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.");
    154154        return 50;
    155155    }
     
    213213                            "Null metadata collection not allowed", 0);
    214214    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.");
    216216        return 40;
    217217    }
     
    219219    metadata->list = NULL;
    220220    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.");
    222222        return 41;
    223223    }
     
    267267    psFree(item8);
    268268    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    269         psError(__func__,"Memory leaks detected.");
     269        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    270270        return 50;
    271271    }
  • trunk/psLib/test/collections/tst_psMetadata_06.c

    r2204 r2273  
    1313*  @author  Ross Harman, MHPCC
    1414*
    15 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    16 *  @date  $Date: 2004-10-27 00:57:33 $
     15*  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     16*  @date  $Date: 2004-11-04 01:05:00 $
    1717*
    1818*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888    printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node");
    8989    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.");
    9191        return 20;
    9292    }
    9393    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.");
    9595        return 21;
    9696    }
     
    102102    printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node");
    103103    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.");
    105105        return 22;
    106106    }
     
    111111    printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node");
    112112    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.");
    114114        return 23;
    115115    }
    116116    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.");
    118118        return 24;
    119119    }
     
    130130    psFree(metadata);
    131131    if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
    132         psError(__func__,"Memory leaks detected.");
     132        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
    133133        return 25;
    134134    }
  • trunk/psLib/test/dataManip/tst_psFunc02.c

    r2204 r2273  
    6464    }
    6565
    66     p_psSpline1DFree(tmpSpline);
     66    psFree(tmpSpline);
    6767    psMemCheckCorruption(1);
    6868    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     
    9090    }
    9191
    92     p_psSpline1DFree(tmpSpline);
     92    psFree(tmpSpline);
    9393    psMemCheckCorruption(1);
    9494    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     
    144144    }
    145145
    146     p_psSpline1DFree(tmpSpline);
     146    psFree(tmpSpline);
    147147    psMemCheckCorruption(1);
    148148    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     
    198198    }
    199199
    200     p_psSpline1DFree(tmpSpline);
     200    psFree(tmpSpline);
    201201    psMemCheckCorruption(1);
    202202    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     
    224224    }
    225225
    226     p_psSpline1DFree(tmpSpline);
     226    psFree(tmpSpline);
    227227    psMemCheckCorruption(1);
    228228    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     
    278278    }
    279279
    280     p_psSpline1DFree(tmpSpline);
     280    psFree(tmpSpline);
    281281    psMemCheckCorruption(1);
    282282    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
  • trunk/psLib/test/dataManip/tst_psFunc03.c

    r2204 r2273  
    7272    }
    7373
    74     p_psSpline1DFree(tmpSpline);
     74    psFree(tmpSpline);
    7575    psFree(bounds);
    7676    psMemCheckCorruption(1);
     
    132132    }
    133133
    134     p_psSpline1DFree(tmpSpline);
     134    psFree(tmpSpline);
    135135    psFree(bounds);
    136136    psMemCheckCorruption(1);
  • trunk/psLib/test/dataManip/tst_psFunc04.c

    r2204 r2273  
    5353    }
    5454
    55     p_psSpline1DFree(tmpSpline);
     55    psFree(tmpSpline);
    5656    psMemCheckCorruption(1);
    5757    psFree(data);
     
    105105    }
    106106
    107     p_psSpline1DFree(tmpSpline);
     107    psFree(tmpSpline);
    108108    psMemCheckCorruption(1);
    109109    psFree(data);
  • trunk/psLib/test/dataManip/tst_psFunc05.c

    r2204 r2273  
    5959    }
    6060
    61     p_psSpline1DFree(tmpSpline);
     61    psFree(tmpSpline);
    6262
    6363    psFree(x);
  • trunk/psLib/test/dataManip/tst_psFunc07.c

    r2223 r2273  
    8383    psFree(newX);
    8484    psFree(y);
    85     p_psSpline1DFree(tmpSpline);
     85    psFree(tmpSpline);
    8686    psFree(newY);
    8787
     
    152152    psFree(newX);
    153153    psFree(y);
    154     p_psSpline1DFree(tmpSpline);
     154    psFree(tmpSpline);
    155155    psFree(newY);
    156156
  • trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c

    r2204 r2273  
    1010 *  @author  Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2004-10-27 00:57:33 $
     12 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
     13 *  @date  $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383#define CHECK_MEMORY \
    8484if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {  \
    85     psError(__func__,"Memory leaks detected."); \
     85    psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); \
    8686    return 50; \
    8787} \
    8888psS32 nBad = psMemCheckCorruption(0); \
    8989if(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); \
    9191    return 51; \
    9292}
  • trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c

    r2204 r2273  
    1515 *  @author  Ross Harman, MHPCC
    1616 *
    17  *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    18  *  @date  $Date: 2004-10-27 00:57:33 $
     17 *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     18 *  @date  $Date: 2004-11-04 01:05:00 $
    1919 *
    2020 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    221221    CREATE_AND_SET_VECTOR(vector6,F64,0,3);
    222222    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.");
    224224        return 10;
    225225    }
     
    228228    vector4->type.dimen = PS_DIMEN_OTHER;
    229229    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.");
    231231        return 11;
    232232    }
     
    236236    CREATE_AND_SET_IMAGE(image10,F64,0,3,3);
    237237    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.");
    239239        return 12;
    240240    }
  • trunk/psLib/test/dataManip/tst_psMinimize04.c

    r2204 r2273  
    237237    myPoly = psVectorFitPolynomial1D(NULL, NULL, NULL, NULL);
    238238    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.");
    240240        testStatus = false;
    241241    }
  • trunk/psLib/test/dataManip/tst_psMinimize04b.c

    r2204 r2273  
    4747        yErr->data.F64[i] = 1.0;
    4848    }
    49     p_psNormalizeVectorF64(x);
     49    psNormalizeVectorRange(x,0.0,1.0);
    5050
    5151    printPositiveTestHeader(stdout,
     
    113113        y->data.F64[i] = setData(x->data.F64[i]);
    114114    }
    115     p_psNormalizeVectorF64(x);
     115    psNormalizeVectorRange(x,0.0,1.0);
    116116
    117117    printPositiveTestHeader(stdout,
     
    173173        y->data.F64[i] = setData(x->data.F64[i]);
    174174    }
    175     p_psNormalizeVectorF64(x);
     175    psNormalizeVectorRange(x,0.0,1.0);
    176176
    177177    printPositiveTestHeader(stdout,
  • trunk/psLib/test/dataManip/tst_psMinimize04b_F32.c

    r2204 r2273  
    4747        yErr->data.F32[i] = 1.0;
    4848    }
    49     p_psNormalizeVector(x);
     49    psNormalizeVectorRange(x,0.0f,1.0f);
    5050
    5151    printPositiveTestHeader(stdout,
     
    113113        y->data.F32[i] = setData(x->data.F32[i]);
    114114    }
    115     p_psNormalizeVector(x);
     115    psNormalizeVectorRange(x,0.0f,1.0f);
    116116
    117117    printPositiveTestHeader(stdout,
     
    173173        y->data.F32[i] = setData(x->data.F32[i]);
    174174    }
    175     p_psNormalizeVector(x);
     175    psNormalizeVectorRange(x,0.0,1.0);
    176176
    177177    printPositiveTestHeader(stdout,
  • trunk/psLib/test/dataManip/tst_psMinimize06.c

    r2204 r2273  
    3535    if (myDeriv == NULL) {
    3636        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");
    3838    }
    3939
  • trunk/psLib/test/dataManip/tst_psVectorFFT.c

    r2204 r2273  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-10-27 00:57:33 $
     8*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-11-04 01:05:00 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8585    vec2 = psVectorFFT( NULL, vec, PS_FFT_FORWARD );
    8686    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?" );
    8888        return 1;
    8989    }
     
    9494        if ( n == 1 || n == 99 ) {
    9595            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 );
    9797                return 2;
    9898            }
    9999        } else {
    100100            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 );
    102102                return 3;
    103103            }
     
    108108    vec3 = psVectorFFT( NULL, vec2, PS_FFT_REVERSE );
    109109    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?" );
    111111        return 4;
    112112    }
     
    115115        psF32 vecVal = crealf( vec3->data.C32[ n ] ) / 100;
    116116        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 );
    119119            return 5;
    120120        }
     
    150150    vec2 = psVectorReal( vec2, vec );
    151151    if ( vec2 == NULL ) {
    152         psError( __func__, "psVectorReal returned a NULL?" );
     152        psError(PS_ERR_UNKNOWN,true, "psVectorReal returned a NULL?" );
    153153        return 1;
    154154    }
    155155    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 );
    158158        return 2;
    159159    }
     
    161161    vec3 = psVectorImaginary( vec3, vec );
    162162    if ( vec3 == NULL ) {
    163         psError( __func__, "psVectorImaginary returned a NULL?" );
     163        psError(PS_ERR_UNKNOWN,true, "psVectorImaginary returned a NULL?" );
    164164        return 3;
    165165    }
    166166    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 );
    169169        return 4;
    170170    }
     
    175175        psF32 i = ( n * 2 );
    176176        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 );
    179179            return 5;
    180180        }
    181181        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 );
    184184            return 6;
    185185        }
     
    230230    // 3. verify that the result is a psC32
    231231    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 );
    234234        return 1;
    235235    }
     
    240240        if ( fabsf( crealf( vec3->data.C32[ n ] ) - n ) > FLT_EPSILON ||
    241241                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 ] ) );
    244244            return 2;
    245245        };
     
    251251
    252252    // 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)." );
    254254    vec3 = psVectorComplex( vec3, vec, vec2 );
    255255    // 8. verify that an appropriate error occurred. (this partially has to be done via inspection)
    256256    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." );
    258258        return 3;
    259259    }
     
    267267    // 11. verify thet an appropriate error occurred. (actually, it isn't an error...)
    268268    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 );
    270270        return 4;
    271271    }
     
    302302    // 3. verify result is psC32
    303303    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" );
    305305        return 1;
    306306    }
     
    310310        if ( fabsf( crealf( vec->data.C32[ n ] ) - crealf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ||
    311311                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 ] ) );
    314314            return 2;
    315315        };
     
    347347    // 3. verify result is psF32
    348348    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." );
    350350        return 1;
    351351    }
     
    360360    val = cabsf( vec->data.C32[ 0 ] ) * cabsf( vec->data.C32[ 0 ] ) / 100 / 100;
    361361    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 );
    364364        return 2;
    365365    };
     
    370370
    371371        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 );
    374374            return 2;
    375375        };
     
    378378    val = cabsf( vec->data.C32[ 50 ] ) * cabsf( vec->data.C32[ 50 ] ) / 100 / 100;
    379379    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 );
    382382        return 2;
    383383    };
  • trunk/psLib/test/image/tst_psImage.c

    r2204 r2273  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:33 $
     8 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:05:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7171                    continue;
    7272                }
    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.",
    7474                        type[t], numCols[i], numRows[i]);
    7575                psFree(image);
     
    7878
    7979            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 "
    8181                        "PS_IMAGE_DIMEN/%d", image->type.dimen, image->type.type, type[t]);
    8282                psFree(image);
     
    8585
    8686            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)",
    8888                        image->numCols, image->numRows, numCols[i], numRows[i],type[t]);
    8989                psFree(image);
     
    9292
    9393            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.",
    9595                        image->row0, image->row0);
    9696                psFree(image);
     
    9999
    100100            if (image->parent != NULL) {
    101                 psError(__func__,"psImageAlloc returned non-NULL parent");
     101                psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned non-NULL parent");
    102102                psFree(image);
    103103                return 5;
     
    105105
    106106            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");
    108108                psFree(image);
    109109                return 7;
     
    123123                        for (psS32 c=0;c<cols;c++) {
    124124                            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);
    126126                                psFree(image);
    127127                                return 8;
     
    143143                        for (psS32 c=0;c<cols;c++) {
    144144                            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);
    146146                                psFree(image);
    147147                                return 8;
     
    163163                        for (psS32 c=0;c<cols;c++) {
    164164                            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);
    166166                                psFree(image);
    167167                                return 8;
     
    184184                            if (fabsf(crealf(image->data.C32[r][c]) - r) > FLT_EPSILON ||
    185185                                    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);
    187187                                psFree(image);
    188188                                return 8;
     
    205205                        for (psS32 c=0;c<cols;c++) {
    206206                            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",
    208208                                        c,r,image->data.PTR[r][c],temp);
    209209                                psFree(image);
     
    229229                        for (psS32 c=0;c<cols;c++) {
    230230                            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)",
    232232                                        type[t],c,r);
    233233                                psFree(image);
     
    281281    // Verify the returned psImage structure pointer is equal to the input parameter output.
    282282    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");
    284284        return 1;
    285285    }
     
    289289    img4 = psImageCopy(NULL,img,PS_TYPE_F32);
    290290    if (img4 == NULL) {
    291         psError(__func__,"output image doesn't exist");
     291        psError(PS_ERR_UNKNOWN, true,"output image doesn't exist");
    292292        return 4;
    293293    }
    294294    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");
    296296        return 4;
    297297    }
     
    301301        for (unsigned col=0;col<c;col++) {
    302302            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!",
    304304                        col, row);
    305305                return 4;
     
    321321    img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \
    322322    if (img2 == NULL) { \
    323         psError(__func__,"psImageCopy failed to copy U8."); \
     323        psError(PS_ERR_UNKNOWN, true,"psImageCopy failed to copy U8."); \
    324324        return 2; \
    325325    } \
     
    329329        for (psU32 col=0;col<c;col++) { \
    330330            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!", \
    332332                        col,row); \
    333333                return 2; \
    334334            } \
    335335            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 " \
    337337                        "(%d vs %d)",\
    338338                        col,row,img2Row[col], (ps##OUT)(imgRow[col])); \
     
    382382    img3 = psImageCopy(NULL,NULL,PS_TYPE_F32);
    383383    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.");
    385385        return 3;
    386386    }
  • trunk/psLib/test/image/tst_psImageConvolve.c

    r2204 r2273  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-27 00:57:33 $
     7 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 01:05:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252
    5353        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].",
    5555                    xMin[i], xMax[i], yMin[i], yMax[i]);
    5656            return i*10+1;
     
    5959        if (k->xMin != xMin[i] || k->xMax != xMax[i] ||
    6060                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].",
    6262                    k->xMin,k->xMax, k->yMin, k->yMax,
    6363                    xMin[i], xMax[i], yMin[i], yMax[i]);
     
    6767        if (k->image->numCols != xMax[i]-xMin[i]+1 ||
    6868                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).",
    7070                    xMax[i]-xMin[i]+1, yMax[i]-yMin[i]+1,
    7171                    k->image->numCols, k->image->numRows);
     
    7575        for (psS32 j=yMin[i]; j<yMax[i]; j++) {
    7676            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.",
    7878                        j);
    7979                return i*10+4;
     
    8787    k = psKernelAlloc(5, -5, -2, 2);
    8888    if (k == NULL) {
    89         psError(__func__,"psKernelAlloc returned NULL for xMin > xMax.");
     89        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for xMin > xMax.");
    9090        return i*10+5;
    9191    }
    9292
    9393    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.");
    9595        return i*10+6;
    9696    }
     
    101101    k = psKernelAlloc(-2, 2, 5, -5);
    102102    if (k == NULL) {
    103         psError(__func__,"psKernelAlloc returned NULL for yMin > yMax.");
     103        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for yMin > yMax.");
    104104        return i*10+7;
    105105    }
    106106
    107107    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.");
    109109        return i*10+8;
    110110    }
     
    136136
    137137    if (result == NULL) {
    138         psError(__func__,"psKernelGenerate returned NULL.");
     138        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
    139139        return 1;
    140140    }
     
    142142    if (result->xMin != -1 || result->xMax != 1 ||
    143143            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].",
    145145                result->xMin, result->xMax, result->yMin, result->yMax);
    146146        return 2;
     
    154154    }
    155155    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).",
    157157                sum);
    158158
     
    166166            fabsf(result->kernel[-1][ 0] - 2.0/10.0) > FLT_EPSILON ||
    167167            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.",
    169169                result->kernel[-1][0], result->kernel[1][1],
    170170                result->kernel[2][0], result->kernel[-2][-1]);
     
    191191
    192192    if (result == NULL) {
    193         psError(__func__,"psKernelGenerate returned NULL.");
     193        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
    194194        return 5;
    195195    }
     
    197197    if (result->xMin != 0 || result->xMax != 1 ||
    198198            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].",
    200200                result->xMin, result->xMax, result->yMin, result->yMax);
    201201        return 6;
     
    209209    }
    210210    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).",
    212212                sum);
    213213
     
    220220            fabsf(result->kernel[3][1] - 8.0/21.0) > FLT_EPSILON ||
    221221            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.",
    223223                result->kernel[1][0], result->kernel[1][1],
    224224                result->kernel[2][0], result->kernel[2][1]);
     
    246246    result = psKernelGenerate(tVec, xVec, yVec, false);
    247247    if (result == NULL) {
    248         psError(__func__,"psKernelGenerate returned NULL.");
     248        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
    249249        return 9;
    250250    }
     
    254254            fabsf(result->kernel[ 1][ 1] - 6.0/8.0) > FLT_EPSILON ||
    255255            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.");
    257257
    258258        return 10;
     
    264264    result = psKernelGenerate(NULL, xVec, yVec, true);
    265265    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.");
    267267        return 11;
    268268    }
     
    271271    result = psKernelGenerate(tVec, NULL, yVec, true);
    272272    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.");
    274274        return 11;
    275275    }
     
    278278    result = psKernelGenerate(tVec, xVec, NULL, true);
    279279    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.");
    281281        return 11;
    282282    }
     
    336336 
    337337    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.");
    339339        return 1;
    340340    }
    341341 
    342342    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.",
    344344                out->numCols, out->numRows,
    345345                c,r);
     
    350350        char* typeStr;
    351351        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.",
    353353                typeStr);
    354354        return 3;
     
    359359        for (psS32 j=-1;j<1;j++) {
    360360            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.",
    362362                        c/2+j,r/2+i,
    363363                        out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
     
    365365            }
    366366            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.",
    368368                        j,i,
    369369                        out->data.F32[i][j], g->kernel[i][j]);
     
    371371            }
    372372            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.",
    374374                        c/2+j,r-1+i,
    375375                        out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
     
    397397 
    398398    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.");
    400400        return 10;
    401401    }
    402402 
    403403    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.");
    405405        return 11;
    406406    }
    407407 
    408408    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.",
    410410                out->numCols, out->numRows,
    411411                c,r);
     
    416416        char* typeStr;
    417417        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.",
    419419                typeStr);
    420420        return 13;
     
    426426        for (psS32 j=-1;j<1;j++) {
    427427            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.",
    429429                        c/2+j,r/2+i,
    430430                        out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
     
    433433            }
    434434            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.",
    436436                        j,i,
    437437                        out->data.F32[i][j], g->kernel[i][j]);
     
    439439            }
    440440            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.",
    442442                        c/2+j,r-1+i,
    443443                        out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
  • trunk/psLib/test/image/tst_psImageExtraction.c

    r2204 r2273  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-10-27 00:57:33 $
     8*  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-11-04 01:05:00 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8787    \
    8888    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)", \
    9090                out->n,n); \
    9191        return TESTNUM*4+1; \
     
    9393    \
    9494    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)", \
    9696                out->n,n); \
    9797        return TESTNUM*4+2; \
     
    100100    for (psS32 i=0;i<out->n;i++) { \
    101101        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, \
    103103                    out->data.F64[i],image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]); \
    104104            return TESTNUM*4+3; \
     
    106106        if (DIRECTION == PS_CUT_X_POS || DIRECTION == PS_CUT_X_NEG) { \
    107107            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.", \
    109109                        positions->data.U32[i],c/10+TRUTHPIX_X,i); \
    110110                return TESTNUM*4+4; \
     
    112112        } else { \
    113113            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.", \
    115115                        positions->data.U32[i],r/10+TRUTHPIX_Y,i); \
    116116                return TESTNUM*4+4; \
     
    165165                        stat );
    166166    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" );
    168168        return 101;
    169169    }
     
    184184                        NULL );
    185185    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" );
    187187        return 102;
    188188    }
     
    202202                        stat);
    203203    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" );
    205205        return 103;
    206206    }
     
    220220                        stat );
    221221    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" );
    223223        return 104;
    224224    }
     
    238238                        stat );
    239239    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" );
    241241        return 105;
    242242    }
     
    251251                        stat );
    252252    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" );
    254254        return 106;
    255255    }
     
    264264                        stat);
    265265    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" );
    267267        return 107;
    268268    }
     
    277277                        stat);
    278278    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" );
    280280        return 108;
    281281    }
     
    296296                        stat);
    297297    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" );
    299299        return 109;
    300300    }
     
    314314                        stat);
    315315    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" );
    317317        return 110;
    318318    }
     
    330330                         stat);
    331331    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.");
    333333        return 111;
    334334    }
     
    345345                        stat);
    346346    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.");
    348348        return 112;
    349349    }
     
    390390
    391391    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).",
    393393                subset2->numCols, subset2->numRows, c/2,r/2);
    394394        return 1;
     
    396396
    397397    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).",
    399399                subset3->numCols, subset3->numRows, c/2,r/2);
    400400        return 2;
     
    407407        for (psS32 col=0;col<c/2;col++) {
    408408            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).",
    410410                        row,col,subset2->data.U32[row][col], original->data.U32[row+r/4][col+c/4]);
    411411                return 3;
    412412            }
    413413            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).",
    415415                        row,col,subset2->data.U32[row][col], original->data.U32[row][col]);
    416416                return 4;
     
    423423
    424424    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).",
    426426                subset2->type.type, PS_TYPE_U32);
    427427        return 6;
    428428    }
    429429    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).",
    431431                subset3->type.type, PS_TYPE_U32);
    432432        return 7;
     
    437437
    438438    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).",
    440440                subset2->col0,subset2->row0,c/4,r/4);
    441441        return 8;
    442442    }
    443443    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).",
    445445                subset3->col0,subset3->row0,0,0);
    446446        return 9;
     
    451451
    452452    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.");
    454454        return 10;
    455455    }
     
    458458
    459459    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.");
    461461        return 11;
    462462    }
     
    467467
    468468    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.");
    470470        return 12;
    471471    }
    472472    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.");
    474474        return 13;
    475475    }
     
    482482    subset1 = psImageSubset(NULL,0,0,c/2,r/2);
    483483    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.");
    485485        return 14;
    486486    }
     
    494494    subset1 = psImageSubset(original,0,r/2,c/2,r/2);
    495495    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.");
    497497        return 15;
    498498    }
     
    500500    subset1 = psImageSubset(original,c/2,0,c/2,r/2);
    501501    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.");
    503503        return 16;
    504504    }
    505505    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.");
    507507        return 17;
    508508    }
     
    516516    subset1 = psImageSubset(original,0,0,c/2,r*2);
    517517    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 "
    519519                "image (via cols).");
    520520        return 18;
     
    523523    subset1 = psImageSubset(original,0,0,c*2,r/2);
    524524    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 "
    526526                "image (via rows).");
    527527        return 19;
     
    530530    subset1 = psImageSubset(original,-1,0,c/2,r/2);
    531531    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 "
    533533                "image (col0=-1).");
    534534        return 20;
     
    537537    subset1 = psImageSubset(original,0,-1,c/2,r/2);
    538538    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 "
    540540                "image (row0=-1).");
    541541        return 21;
     
    550550    subset1 = psImageSubset(original,0,0,c/2,r+1);
    551551    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).");
    553553        return 22;
    554554    }
     
    556556    subset1 = psImageSubset(original,0,0,c+1,r/2);
    557557    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).");
    559559        return 23;
    560560    }
     
    562562    subset1 = psImageSubset(original,0,0,c+1,r+1);
    563563    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).");
    565565        return 24;
    566566    }
     
    575575    // Verify the returned psImage structure member Nchildren is set to zero.
    576576    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.");
    578578        return 25;
    579579    }
     
    586586            preSubsetStruct.col0 != original->col0) {
    587587
    588         psError(__func__,"psImageFreeChildren modified parent's non-children elements.");
     588        psError(PS_ERR_UNKNOWN,true,"psImageFreeChildren modified parent's non-children elements.");
    589589        return 27;
    590590    }
     
    626626
    627627        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.",
    629629                    sectionStr);
    630630            return 10*i+1;
     
    632632
    633633        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).",
    635635                    subset->type.type, PS_TYPE_U32);
    636636            return 10*i+2;
     
    638638
    639639        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).",
    641641                    subset->col0,subset->row0,x1[i],y1[i]);
    642642            return 10*i+3;
     
    644644
    645645        if (subset->parent != original) {
    646             psError(__func__,"psImageSubsection didn't set parent.");
     646            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set parent.");
    647647            return 10*i+4;
    648648        }
    649649
    650650        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.");
    652652            return 10*i+5;
    653653        }
    654654
    655655        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.");
    657657            return 10*i+6;
    658658        }
     
    660660
    661661        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.");
    663663            return 10*i+7;
    664664        }
     
    667667        psS32 numRows = y2[i]-y1[i]+1;
    668668        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).",
    670670                    subset->numCols, subset->numRows, numCols, numRows);
    671671            return 10*i+8;
     
    675675            for (psS32 col=0;col<numCols;col++) {
    676676                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).",
    678678                            row,col,subset->data.U32[row][col], original->data.U32[row+y1[i]][col+x1[i]]);
    679679                    return 10*i+9;
     
    686686    subset = psImageSubsection(original,"[64:32,32:64]");
    687687    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.");
    689689        return 10*i+10;
    690690    }
     
    693693    subset = psImageSubsection(original,"[32:64,64:32]");
    694694    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.");
    696696        return 10*i+11;
    697697    }
     
    700700    subset = psImageSubsection(original,"[64:256,32:64]"); // assumes c<256
    701701    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.");
    703703        return 10*i+12;
    704704    }
     
    707707    subset = psImageSubsection(original,"[32:64,64:256]"); // assumes r==256
    708708    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.");
    710710        return 10*i+13;
    711711    }
     
    714714    subset = psImageSubsection(original,"32:64,32:64");
    715715    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'.");
    717717        return 10*i+14;
    718718    }
     
    721721    subset = psImageSubsection(original,"[32-64,32-64]");
    722722    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]'.");
    724724        return 10*i+15;
    725725    }
     
    728728    subset = psImageSubsection(original,"[32:64,32]");
    729729    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]'.");
    731731        return 10*i+16;
    732732    }
     
    735735    subset = psImageSubsection(NULL,"[32:64,32:64]");
    736736    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.");
    738738        return 10*i+17;
    739739    }
     
    742742    subset = psImageSubsection(original,NULL);
    743743    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.");
    745745        return 10*i+18;
    746746    }
  • trunk/psLib/test/image/tst_psImageFFT.c

    r2204 r2273  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:33 $
     8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:05:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8585    img2 = psImageFFT(img2,img,PS_FFT_FORWARD);
    8686    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?");
    8888        return 1;
    8989    }
    9090    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).",
    9292                img2->numCols,img2->numRows,m,n);
    9393        return 2;
     
    103103                if (! (col == 0 && (row == 1 || row == n-1))
    104104                        && ! (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);
    106106                    return 3;
    107107                }
     
    109109                if ( (col == 0 && (row == 1 || row == n-1))
    110110                        || (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);
    112112                    return 4;
    113113                }
     
    120120
    121121    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?");
    123123        return 5;
    124124    }
    125125
    126126    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).",
    128128                img3->numCols,img3->numRows,m,n);
    129129        return 6;
     
    136136            psF32 pixel = creal(img3Row[col])/m/n;
    137137            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)",
    139139                        col,row,pixel,imgRow[col]);
    140140                return 7;
     
    149149        char* typeStr;
    150150        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);
    152152        return 8;
    153153    }
    154154
    155155    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).",
    157157                img3->numCols,img3->numRows,m,n);
    158158        return 9;
     
    165165            psF32 pixel = img3Row[col]/m/n;
    166166            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)",
    168168                        col,row,pixel,imgRow[col]);
    169169                return 10;
     
    175175    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
    176176    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?");
    178178        return 11;
    179179    }
     
    181181    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
    182182    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?");
    184184        return 12;
    185185    }
     
    188188    img4 = psImageFFT(NULL,NULL,PS_FFT_FORWARD);
    189189    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.");
    191191        return 10;
    192192    }
     
    197197    img5 = psImageFFT(NULL,img4,PS_FFT_REAL_RESULT);
    198198    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.");
    200200        return 11;
    201201    }
     
    229229    img2 = psImageReal(img2,img);
    230230    if (img2 == NULL) {
    231         psError(__func__,"psImageReal returned a NULL?");
     231        psError(PS_ERR_UNKNOWN, true,"psImageReal returned a NULL?");
    232232        return 1;
    233233    }
    234234    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)?",
    236236                img2->type.type);
    237237        return 2;
     
    240240    img3 = psImageImaginary(img3,img);
    241241    if (img3 == NULL) {
    242         psError(__func__,"psImageImaginary returned a NULL?");
     242        psError(PS_ERR_UNKNOWN, true,"psImageImaginary returned a NULL?");
    243243        return 3;
    244244    }
    245245    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)?",
    247247                img3->type.type);
    248248        return 4;
     
    255255        for (psU32 col=0;col<m;col++) {
    256256            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",
    258258                        n);
    259259                return 5;
    260260            }
    261261            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",
    263263                        n);
    264264                return 6;
     
    307307    // 3. verify that the result is a psC32
    308308    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)",
    310310                img3->type.type);
    311311        return 1;
     
    319319            if (fabsf(crealf(img3Row[col]) - row) > FLT_EPSILON ||
    320320                    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)",
    322322                        col,row,crealf(img3Row[col]),cimagf(img3Row[col]));
    323323                return 2;
     
    334334    // 8. verify that an appropriate error occurred. (this partially has to be done via inspection)
    335335    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.");
    337337        return 3;
    338338    }
     
    347347    // 11. verify thet an appropriate error occurred.
    348348    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.");
    350350        return 4;
    351351    }
     
    380380    // 3. verify result is psC32
    381381    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.");
    383383        return 1;
    384384    }
     
    390390            if (fabsf(crealf(img2Row[col]) - row) > FLT_EPSILON ||
    391391                    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)",
    393393                        col,row,crealf(img2Row[col]),cimagf(img2Row[col]));
    394394                return 2;
     
    425425    // 3. verify result is psF32
    426426    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.");
    428428        return 1;
    429429    }
     
    438438
    439439            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)",
    441441                        col,row,img2Row[col],power);
    442442                return 2;
  • trunk/psLib/test/image/tst_psImageIO.c

    r2204 r2273  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:33 $
     8 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:05:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9797        remove(filename); \
    9898        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); \
    100100            return 1; \
    101101        } \
    102102        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); \
    104104            return 2; \
    105105        } \
    106106        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); \
    108108            return 3; \
    109109        } \
    110110        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); \
    112112            return 4; \
    113113        } \
     
    119119        img = psImageReadSection(img,readM0,readN0,readM,readN,0,NULL,0,filename); \
    120120        /*        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?"); */ \
    122122        /*            return 5; */ \
    123123        /*        } */ \
    124124        img3 = psImageReadSection(img3,readM0,readN0,readM,readN,1,NULL,0,filename); \
    125125        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); \
    127127            return 6; \
    128128        } \
     
    134134            for (psU32 col = readM0; col < readM; col++) { \
    135135                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", \
    137137                            col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \
    138138                    return 7; \
    139139                } \
    140140                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", \
    142142                            col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \
    143143                    return 8; \
     
    152152        img = psImageReadSection(img,readM0,readN0,readM,readN,1,NULL,1,filename); \
    153153        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); \
    155155            return 9; \
    156156        } \
     
    162162            for (psU32 col = readM0; col < readM; col++) { \
    163163                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", \
    165165                            col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \
    166166                    return 10; \
    167167                } \
    168168                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", \
    170170                            col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \
    171171                    return 11; \
     
    204204    image = psImageReadSection(image,0,0,M,N,0,NULL,0,"foobar.fits");
    205205    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.");
    207207        return 12;
    208208    }
     
    220220    image = psImageReadSection(image,0,0,M,N,0,NULL,0,NULL);
    221221    if (image != NULL) {
    222         psError(__func__,"Image returned though filename was NULL.");
     222        psError(PS_ERR_UNKNOWN, true,"Image returned though filename was NULL.");
    223223        return 13;
    224224    }
     
    233233    image = psImageReadSection(image,0,0,M,N,0,NULL,4,"tmpImages/MxN_F32.fits");
    234234    if (image != NULL) {
    235         psError(__func__,"Image returned though extnum was invalid.");
     235        psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid.");
    236236        return 14;
    237237    }
     
    239239    image = psImageReadSection(image,0,0,M,N,0,"bogus",0,"tmpImages/MxN_F32.fits");
    240240    if (image != NULL) {
    241         psError(__func__,"Image returned though extnum was invalid.");
     241        psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid.");
    242242        return 15;
    243243    }
     
    302302        ;
    303303    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.");
    305305        return 14;
    306306    }
    307307    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.");
    309309        return 15;
    310310    }
     
    315315    img = psImageReadSection(NULL,0,0,m,n,0,NULL,0,"tmpImages/writeTest.fits");
    316316    if (img == NULL) {
    317         psError(__func__,"Could not read in writeTest.fits.");
     317        psError(PS_ERR_UNKNOWN, true,"Could not read in writeTest.fits.");
    318318        return 16;
    319319    }
     
    322322        for (psU32 col=0;col<m;col++) {
    323323            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)",
    325325                        col,row,imgRow[col],(row+2*col));
    326326                return 17;
     
    337337    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message because input image is null.");
    338338    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.");
    340340        return 20;
    341341    }
     
    347347    GENIMAGE(img,32,32,S8,row+2*col);
    348348    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.");
    350350        return 21;
    351351    }
     
    358358    GENIMAGE(img,32,32,U8,row+2*col);
    359359    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.");
    361361        return 22;
    362362    }
     
    370370    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid FITS file.");
    371371    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.");
    373373        return 22;
    374374    }
     
    381381    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension name.");
    382382    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.");
    384384        return 23;
    385385    }
     
    390390    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension number.");
    391391    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.");
    393393        return 24;
    394394    }
  • trunk/psLib/test/image/tst_psImageManip.c

    r2204 r2273  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 00:57:33 $
     8 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:05:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    119119            } \
    120120            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", \
    122122                        (psF64)imgRow[col],(psF64)value,col,row); \
    123123                return 1; \
     
    126126    } \
    127127    if (retVal != numClipped) { \
    128         psError(__func__,"Expected %d clips, but got %d", \
     128        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
    129129                numClipped,retVal); \
    130130        return 2; \
     
    159159            if (fabsf(creal(imgRow[col])-creal(value)) > FLT_EPSILON || \
    160160                    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", \
    162162                        creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
    163163                return 1; \
     
    166166    } \
    167167    if (retVal != numClipped) { \
    168         psError(__func__,"Expected %d clips, but got %d", \
     168        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
    169169                numClipped,retVal); \
    170170        return 2; \
     
    198198    retVal = psImageClip(NULL,min,-1.0f,max,-2.0f);
    199199    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.");
    201201        return 3;
    202202    }
     
    207207    retVal = psImageClip(img,max,-1.0f,min,-2.0f);
    208208    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.");
    210210        return 4;
    211211    }
     
    217217    retVal = psImageClip(img,min,-1.0f,max,-2.0f);
    218218    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.");
    220220        return 5;
    221221    }
     
    276276            } \
    277277            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", \
    279279                        imgRow[col],value,col,row); \
    280280                return 1; \
     
    283283    } \
    284284    if (retVal != numClipped) { \
    285         psError(__func__,"Expected %d clips, but got %d", \
     285        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
    286286                numClipped,retVal); \
    287287        return 2; \
     
    299299    retVal = psImageClipNaN(NULL,-1.0f);
    300300    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.");
    302302        return 3;
    303303    }
     
    309309    retVal = psImageClipNaN(img,2.0f);
    310310    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.");
    312312        return 4;
    313313    }
     
    377377            } \
    378378            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", \
    380380                        creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
    381381                return 1; \
     
    384384    } \
    385385    if (retVal != numClipped) { \
    386         psError(__func__,"Expected %d clips, but got %d", \
     386        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
    387387                numClipped,retVal); \
    388388        return 2; \
     
    408408    retVal = psImageClipComplexRegion(NULL,0,0,0,0);
    409409    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.");
    411411        return 3;
    412412    }
     
    427427    retVal = psImageClipComplexRegion(img,10.0+I*1.0,-1.0,5.0+5.0*I,-2.0);
    428428    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).");
    430430        return 3;
    431431    }
     
    433433    retVal = psImageClipComplexRegion(img,1.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
    434434    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).");
    436436        return 3;
    437437    }
     
    439439    retVal = psImageClipComplexRegion(img,10.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
    440440    if (retVal != 0) {
    441         psError(__func__,"Expected zero return for min>max.");
     441        psError(PS_ERR_UNKNOWN, true,"Expected zero return for min>max.");
    442442        return 3;
    443443    }
     
    457457                                      0.0);
    458458    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.");
    460460        return 80;
    461461    }
     
    468468                                      0.0);
    469469    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.");
    471471        return 81;
    472472    }
     
    479479                                      0.0);
    480480    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.");
    482482        return 82;
    483483    }
     
    490490                                      0.0);
    491491    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.");
    493493        return 83;
    494494    }
     
    501501                                      -2.0*(double)FLT_MAX);
    502502    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.");
    504504        return 84;
    505505    }
     
    512512                                      2.0*(double)FLT_MAX);
    513513    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.");
    515515        return 85;
    516516    }
     
    523523                                      -2.0*(double)FLT_MAX*I);
    524524    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.");
    526526        return 87;
    527527    }
     
    534534                                      2.0*(double)FLT_MAX*I);
    535535    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.");
    537537        return 88;
    538538    }
     
    552552                                      0.0);
    553553    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.");
    555555        return 83;
    556556    }
     
    573573    retVal = psImageClipComplexRegion(img,2.0,10.0,5.0,0.0);
    574574    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.");
    576576        return 84;
    577577    }
     
    625625    retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \
    626626    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); \
    628628        return 1; \
    629629    } \
     
    637637            } \
    638638            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)", \
    640640                        col,row,imgRow[col],val,OPSTRING); \
    641641                return 2; \
    642642            } \
    643643            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)", \
    645645                        col,row,img2Row[col],OPSTRING); \
    646646                return 2; \
     
    706706    retVal = psImageOverlaySection(img,img2,c/4,r/4,"+");
    707707    if (retVal == 0) {
    708         psError(__func__,"psImageOverlaySection returned zero even though "
     708        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
    709709                "overlay too big");
    710710        return 3;
     
    714714        for (unsigned col=0;col<c;col++) {
    715715            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");
    717717                return 4;
    718718            }
     
    729729    retVal = psImageOverlaySection(img,NULL,c/4,r/4,"+");
    730730    if (retVal == 0) {
    731         psError(__func__,"psImageOverlaySection returned zero even though "
     731        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
    732732                "overlay too big");
    733733        return 5;
     
    737737        for (unsigned col=0;col<c;col++) {
    738738            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");
    740740                return 6;
    741741            }
     
    751751    retVal = psImageOverlaySection(NULL,img2,c/4,r/4,"+");
    752752    if (retVal == 0) {
    753         psError(__func__,"psImageOverlaySection returned zero even though "
     753        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
    754754                "overlay too big");
    755755        return 7;
     
    764764    retVal = psImageOverlaySection(img,img2,0,0,"$");
    765765    if (retVal == 0) {
    766         psError(__func__,"psImageOverlaySection returned zero even though "
     766        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
    767767                "overlay operator is invalid");
    768768        return 8;
     
    777777    retVal = psImageOverlaySection(img,img2,0,0,NULL);
    778778    if(retVal == 0) {
    779         psError(__func__,"psImageOverlaySection returned zero even though "
     779        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
    780780                "overlay operator is NULL");
    781781        return 9;
     
    790790    retVal = psImageOverlaySection(img,img3,0,0,"+");
    791791    if(retVal == 0) {
    792         psError(__func__,"psImageOverlaySection returned zero eventhough "
     792        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "
    793793                " overlay image type is different than input image.");
    794794        return 10;
     
    803803    retVal = psImageOverlaySection(img3,img4,0,0,"+");
    804804    if(retVal == 0) {
    805         psError(__func__,"psImageOverlaySection returned zero eventhough "
     805        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "
    806806                "overlay and image type are invalid type.");
    807807        return 11;
     
    820820    retVal = psImageOverlaySection(img,img2,0,0,"/");
    821821    if (retVal != 0) {
    822         psError(__func__,"psImageOverlaySection returned non-zero when "
     822        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero when "
    823823                "checking divide-by-zero.");
    824824        return 12;
     
    906906    out = psImageRebin(NULL,in,NULL,0,4,&stats); \
    907907    if (out == NULL) { \
    908         psError(__func__,"psImageRebin returned a NULL pointer!?"); \
     908        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \
    909909        return 1; \
    910910    } \
    911911    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 " \
    913913                "(%d x %d).", \
    914914                out->numCols, out->numRows); \
     
    920920        for (psS32 col = 0; col<4; col++) { \
    921921            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 " \
    923923                        "result at (%d,%d) [%f vs %f].", \
    924924                        col,row,outRow[col],truthRow[col]); \
     
    934934        for ( psS32 col = 0; col<4; col++) { \
    935935            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 " \
    937937                        "result at (%d,%d) [%f vs %f].", \
    938938                        col,row,outRow[col],truthRow[col]); \
     
    944944    out2 = psImageRebin(out,in,NULL,0,3,&stats); \
    945945    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!?"); \
    947947        return 7; \
    948948    } \
    949949    if (out == NULL) { \
    950         psError(__func__,"psImageRebin returned a NULL pointer!?"); \
     950        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \
    951951        return 4; \
    952952    } \
    953953    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 " \
    955955                "(%d x %d).", \
    956956                out->numCols, out->numRows); \
     
    962962        for (psS32 col = 0; col<6; col++) { \
    963963            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 " \
    965965                        "max result at (%d,%d) [%f vs %f].", \
    966966                        col,row,outRow[col],truthRow[col]); \
     
    990990    out = psImageRebin(NULL,in,NULL,0,4,&stats);
    991991    if(out != NULL) {
    992         psError(__func__,"psImageRebin return an image eventhough the "
     992        psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the "
    993993                "type is not handled.");
    994994        return 14;
     
    999999    out = psImageRebin(NULL,in,mask,1,4,&stats);
    10001000    if(out != NULL) {
    1001         psError(__func__,"psImageRebin return an image eventhough the "
     1001        psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the "
    10021002                "mask is not the correct type.");
    10031003        return 17;
     
    10121012
    10131013    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 "
    10151015                "NULL!?");
    10161016        return 8;
     
    10241024
    10251025    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 "
    10271027                "zero!?");
    10281028        return 9;
     
    10351035
    10361036    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 "
    10381038                "NULL!?");
    10391039        return 10;
     
    10491049
    10501050    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 "
    10521052                "options was zero!?");
    10531053        return 11;
     
    10591059
    10601060    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 "
    10621062                "options was PS_STAT_USE_RANGE!?");
    10631063        return 12;
     
    10721072
    10731073    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 "
    10751075                "options was PS_STAT_SAMPLE_MEAN+PS_STAT_MAX!?");
    10761076        return 13;
     
    11211121        for (psS32 col=0;col<cols;col++) {
    11221122            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 "
    11241124                        "at %d,%d (%f vs %f) for dx=0, dy=0.",
    11251125                        col,row,inRow[col],outRow[col]);
     
    11351135        for (psS32 col=0;col<cols;col++) {
    11361136            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 "
    11381138                        "at %d,%d (%f vs %f) for dx=cols/4, dy=0.",
    11391139                        col,row,inRow[(col+cols/4) % cols],outRow[col]);
     
    11461146    // parameter out if provided.
    11471147    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!?");
    11491149        return 1;
    11501150    }
     
    11561156        for (psS32 col=0;col<cols;col++) {
    11571157            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 "
    11591159                        "at %d,%d (%f vs %f) for dx=0, dy=rows/4.",
    11601160                        col,row,inRow[col],outRow[col]);
     
    11701170        for (psS32 col=0;col<cols;col++) {
    11711171            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 "
    11731173                        "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.",
    11741174                        col,row,inRow[(col+cols/4) % cols],outRow[col]);
     
    11841184        for (psS32 col=0;col<cols;col++) {
    11851185            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 "
    11871187                        "at %d,%d (%f vs %f) for dx=-cols/4, dy=0.",
    11881188                        col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]);
     
    11981198        for (psS32 col=0;col<cols;col++) {
    11991199            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 "
    12011201                        "at %d,%d (%f vs %f) for dx=0, dy=-rows/4.",
    12021202                        col,row,inRow[col],outRow[col]);
     
    12121212        for (psS32 col=0;col<cols;col++) {
    12131213            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 "
    12151215                        "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.",
    12161216                        col,row,inRow[(col+cols-cols/4) % cols],outRow[col]);
     
    12261226    out2 = psImageRoll(NULL,NULL,0,0);
    12271227    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!?");
    12291229        return 2;
    12301230    }
     
    12491249        for (psS32 col=0;col<cols1;col++) { \
    12501250            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 " \
    12521252                        "at %d,%d (%f vs %f) for dx=0, dy=0.", \
    12531253                        col,row,(float)inRow[col],(float)outRow[col]); \
     
    13461346        // parameter out if provided.
    13471347        if (oldOut != NULL && oldOut != fOut) {
    1348             psError(__func__,"the output recycle functionality failed");
     1348            psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed");
    13491349            return 2;
    13501350        }
    13511351        if (oldBiOut != NULL && oldBiOut != fBiOut) {
    1352             psError(__func__,"the output recycle functionality failed");
     1352            psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed");
    13531353            return 4;
    13541354        }
     
    13561356        sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
    13571357        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!?");
    13591359            return 20;
    13601360        }
    13611361        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!?");
    13631363            return 21;
    13641364        }
    13651365        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!?");
    13671367            return 40;
    13681368        }
    13691369        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!?");
    13711371            return 41;
    13721372        }
     
    13781378        sBiTruth = psImageReadSection(sBiTruth,0,0,0,0,0,NULL,index,"verified/sBiOut.fits");
    13791379        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)",
    13811381                    rot);
    13821382            fail = true;
    13831383        } else {
    13841384            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 "
    13861386                        "image for %d deg rotation (%dx%d vs %dx%d).",
    13871387                        rot,fOut->numCols,fOut->numRows,fTruth->numCols,fTruth->numRows);
     
    13931393                    for (psS32 col=0;col<fTruth->numCols;col++) {
    13941394                        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.",
    13961396                                    outRow[col], truthRow[col],col,row);
    13971397                            fail = true;
     
    14031403
    14041404        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 "
    14061406                    "(%d deg. rotation)",rot);
    14071407            fail = true;
     
    14091409            if (sTruth->numRows != sOut->numRows ||
    14101410                    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 "
    14121412                        "image for %d deg rotation.",rot);
    14131413                fail = true;
     
    14181418                    for (psS32 col=0;col<sTruth->numCols;col++) {
    14191419                        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) "
    14211421                                    "at %d,%d.",
    14221422                                    outRow[col], truthRow[col],col,row);
     
    14301430
    14311431        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)",
    14331433                    rot);
    14341434            fail = true;
    14351435        } else {
    14361436            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 "
    14381438                        "image for %d deg rotation (%dx%d vs %dx%d). BILINEAR",
    14391439                        rot,fBiOut->numCols,fBiOut->numRows,fBiTruth->numCols,fBiTruth->numRows);
     
    14451445                    for (psS32 col=0;col<fBiTruth->numCols;col++) {
    14461446                        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",
    14481448                                    outRow[col], truthRow[col],col,row);
    14491449                            fail = true;
     
    14551455
    14561456        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 "
    14581458                    "(%d deg. rotation) BILINEAR",rot);
    14591459            fail = true;
     
    14611461            if (sBiTruth->numRows != sBiOut->numRows ||
    14621462                    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 "
    14641464                        "image for %d deg rotation. BILINEAR",rot);
    14651465                fail = true;
     
    14701470                    for (psS32 col=0;col<sBiTruth->numCols;col++) {
    14711471                        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) "
    14731473                                    "at %d,%d. BILINEAR",
    14741474                                    outRow[col], truthRow[col],col,row);
     
    14871487            s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT);
    14881488            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.");
    14901490                return 5;
    14911491            }
     
    14961496
    14971497    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 "
    14991499                "not exist.");
    15001500        return 10;
     
    15071507    fOut = psImageRotate(fOut,NULL,0,0,PS_INTERPOLATE_FLAT);
    15081508    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.");
    15101510        return 3;
    15111511    }
     
    15171517    fOut = psImageRotate(fOut, fImg, 33, 0, -1);
    15181518    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 "
    15201520                "is invalid.");
    15211521        return 4;
     
    15981598
    15991599    if (fRecycle != fOut) {
    1600         psError(__func__,"psImageShift didn't recycle my image?");
     1600        psError(PS_ERR_UNKNOWN, true,"psImageShift didn't recycle my image?");
    16011601        return 10;
    16021602    }
     
    16091609    fOut = psImageShift(fOut,NULL,8,8,NAN,PS_INTERPOLATE_FLAT);
    16101610    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.");
    16121612        return 11;
    16131613    }
     
    16181618    fOut = psImageShift(fOut,fImg,8,8,NAN,-1);
    16191619    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.");
    16211621        return 12;
    16221622    }
     
    16751675
    16761676            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)",
    16781678                        col,row,fRow[col],fValue);
    16791679                return 1;
    16801680            }
    16811681            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)",
    16831683                        col,row,sRow[col],sValue);
    16841684                return 2;
    16851685            }
    16861686            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)",
    16881688                        col,row,fBiRow[col],fBiValue);
    16891689                return 1;
    16901690            }
    16911691            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)",
    16931693                        col,row,sBiRow[col],sBiValue);
    16941694                return 2;
  • trunk/psLib/test/psTest.c

    r2204 r2273  
    8585                runAll = false;
    8686                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 );
    8989                    break;
    9090                }
     
    103103                }
    104104                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 );
    107107                    break;
    108108                }
    109109                break;
    110110            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 );
    112112                break;
    113113            }
     
    130130
    131131    if ( ! success ) {
    132         psError( testPointFile, "One or more tests failed" );
     132        psError( PS_ERR_UNKNOWN, true,
     133                 "One or more tests failed" );
    133134    }
    134135
     
    151152            if ( retVal == 0 ) { // only bother checking memory if test executed to end.
    152153                if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
    153                     psError( __func__, "Memory Leaks Detected" );
     154                    psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" );
    154155                    retVal = 64;
    155156                }
     
    175176        if ( childReturn == 0 ) { // only bother checking memory if test executed to end.
    176177            if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
    177                 psError( __func__, "Memory Leaks Detected" );
     178                psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" );
    178179                childReturn = 64;
    179180            }
  • trunk/psLib/test/sysUtils/tst_psError.c

    r2204 r2273  
    1313 *  @author  Eric Van Alst, MHPCC
    1414 *
    15  *  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
    16  *  @date  $Date: 2004-10-27 00:57:33 $
     15 *  @version $Revision: 1.15 $  $Name: not supported by cvs2svn $
     16 *  @date  $Date: 2004-11-04 01:05:00 $
    1717 *
    1818 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9999
    100100    // Generate three error messages to have messages on error stack
    101     if (psErrorMsg("test4A", code, true, "Error code = %d", code) !=  code) {
     101    if (psError(code, true, "Error code = %d", code) !=  code) {
    102102        psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
    103103        return 31;
    104104    }
    105     if (psErrorMsg("test4A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
     105    if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) {
    106106        psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
    107107        return 32;
    108108    }
    109     if (psErrorMsg("test4A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
     109    if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) {
    110110        psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
    111111        return 33;
     
    165165
    166166    // Generate three error messages
    167     if (psErrorMsg("test3A", code, true, "Error code = %d", code) !=  code) {
     167    if (psError(code, true, "Error code = %d", code) !=  code) {
    168168        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
    169169        return 23;
    170170    }
    171     if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
     171    if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) {
    172172        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
    173173        return 24;
    174174    }
    175     if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
     175    if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) {
    176176        psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
    177177        return 25;
     
    219219
    220220    // Generate error message and verify return value
    221     if (psErrorMsg("test2A", code, true, "Error code = %d", code) != code ) {
     221    if (psError(code, true, "Error code = %d", code) != code ) {
    222222        psLogMsg("tst_psError02", PS_LOG_ERROR, "Failed return value verify.");
    223223        return 10;
     
    233233
    234234    // Verify the return value of psErrorMsg is the psErrorCode passed
    235     if ( psErrorMsg("test1A", code, true, "Error code = %d", code) != code) {
     235    if ( psError(code, true, "Error code = %d", code) != code) {
    236236        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return value verify.");
    237237        return 1;
     
    240240
    241241    // test1B empty string in for name argument
    242     if ( psErrorMsg("", code+1, true, "Error code = %d", code+1) != code+1) {
     242    if ( psError(code+1, true, "Error code = %d", code+1) != code+1) {
    243243        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with empty string.");
    244244        return 2;
     
    246246    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
    247247
    248     // test1C null pointer in  for name argument
    249     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 
    255248    // test1D undefined code
    256     if ( psErrorMsg("test1D", -1, true, "Error code = %d", -1) != -1) {
     249    if ( psError(-1, true, "Error code = %d", -1) != -1) {
    257250        psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with undefined code.");
    258251        return 4;
     
    261254
    262255    // test1E set psErrorMsg argument to false
    263     if( psErrorMsg("test1E", code, false, "Error code = %d", code) != code) {
     256    if( psError(code, false, "Error code = %d", code) != code) {
    264257        psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with false new arg.");
    265258        return 5;
     
    268261
    269262    // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)
    270     if( psErrorMsg("test1F", 9, true, "Errno code = %d", 9) != 9) {
     263    if( psError(9, true, "Errno code = %d", 9) != 9) {
    271264        psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with errno code.");
    272265        return 6;
     
    287280
    288281    // Test point #1 Multiple type values placed in the error string
    289     psError(__func__,
     282    psError(PS_ERR_UNKNOWN, true,
    290283            "ALL TYPES intval = %d longval = %ld floatval = %f charval = %c strval = %s",
    291284            intval,longval,floatval,charval,stringval);
    292285
    293286    // Test point #2 String values in error message
    294     psError(PS_STRING(__LINE__),"NO VALUES");
     287    psError(PS_ERR_UNKNOWN, true, "NO VALUES");
    295288
    296289    // Test point #3 Empty strings in error message
    297     psError("","");
     290    psError(PS_ERR_UNKNOWN, true, "");
    298291
    299292    return 0;
  • trunk/psLib/test/sysUtils/tst_psMemory.c

    r2204 r2273  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-10-27 00:57:33 $
     8*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-11-04 01:05:00 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9999    mem = ( psS32* ) psAlloc( size * sizeof( psS32 ) );
    100100    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__ );
    102102        return 1;
    103103    }
     
    130130    ref = psMemGetRefCounter( mem );
    131131    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 );
    133133        return 1;
    134134    }
     
    140140    ref = psMemGetRefCounter( mem );
    141141    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 );
    143143        return 1;
    144144    }
     
    149149    ref = psMemGetRefCounter( mem );
    150150    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 );
    152152        return 1;
    153153    }
     
    159159    ref = psMemGetRefCounter( mem );
    160160    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 );
    162162        return 1;
    163163    }
     
    197197
    198198    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__ );
    200200        return 1;
    201201    }
     
    232232
    233233    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__ );
    235235        return 1;
    236236    }
     
    273273    for ( psS32 i = 0;i < initialSize;i++ ) {
    274274        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__ );
    277277            break;
    278278        }
     
    290290    for ( psS32 i = 0;i < initialSize / 2;i++ ) {
    291291        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__ );
    294294            break;
    295295        }
     
    333333
    334334    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__ );
    337337        return 1;
    338338    }
     
    352352
    353353    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__ );
    356356        return 1;
    357357    }
     
    388388
    389389    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__ );
    391391        return 1;
    392392    }
    393393
    394394    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__ );
    397397        return 1;
    398398    }
     
    418418
    419419    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__ );
    421421        return 1;
    422422    }
    423423
    424424    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__ );
    426426        return 1;
    427427    }
     
    448448
    449449    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__ );
    451451        return 1;
    452452    }
    453453
    454454    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__ );
    456456        return 1;
    457457    }
     
    499499
    500500    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__ );
    503503        return 1;
    504504    }
    505505
    506506    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__ );
    509509        return 1;
    510510    }
     
    556556
    557557    if (err->code != PS_ERR_MEMORY_DEREF_USAGE) {
    558         psErrorMsg("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);
    561561        psFree(err);
    562562        return 1;
Note: See TracChangeset for help on using the changeset viewer.