IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.