IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 6, 2004, 2:06:06 PM (22 years ago)
Author:
desonia
Message:

another attempt to get astyle to get it right.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c

    r1406 r1407  
     1
    12/** @file  psMatrixVectorArithmetic.c
    23 *
     
    2930 *  @author Ross Harman, MHPCC
    3031 *
    31  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    32  *  @date $Date: 2004-08-06 22:34:05 $
     32 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     33 *  @date $Date: 2004-08-07 00:06:06 $
    3334 *
    3435 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3637
    3738/******************************************************************************/
     39
    3840/*  INCLUDE FILES                                                             */
     41
    3942/******************************************************************************/
    4043#include <string.h>
     
    4952
    5053/******************************************************************************/
     54
    5155/*  DEFINE STATEMENTS                                                         */
     56
    5257/******************************************************************************/
    5358
     
    5560
    5661/******************************************************************************/
     62
    5763/*  TYPE DEFINITIONS                                                          */
     64
    5865/******************************************************************************/
    5966
     
    6168
    6269/*****************************************************************************/
     70
    6371/*  GLOBAL VARIABLES                                                         */
     72
    6473/*****************************************************************************/
    6574
     
    6776
    6877/*****************************************************************************/
     78
    6979/*  FILE STATIC VARIABLES                                                    */
     80
    7081/*****************************************************************************/
    7182
     
    7384
    7485/*****************************************************************************/
     86
    7587/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
     88
    7689/*****************************************************************************/
    7790
     
    8598static complex double psNanDiv(complex double a, complex double b)
    8699{
    87     complex double out = 0+0i;
    88     out = a/b;
    89     if(isnan(creal(out)) || isnan(cimag(out))) {
     100    complex double out = 0 + 0i;
     101
     102    out = a / b;
     103    if (isnan(creal(out)) || isnan(cimag(out))) {
    90104        psError(__func__, ": Divide by zero");
    91105    }
     
    399413    psType *psTypeOut = NULL;
    400414
    401     psTypeOut = (psType*)out;
    402     if(psTypeOut == NULL) {
     415    psTypeOut = (psType *) out;
     416    if (psTypeOut == NULL) {
    403417        psError(__func__, ": Line %d - Null out argument", __LINE__);
    404418        return out;
    405419    }
    406420
    407     psType1 = (psType*)in1;
    408     if(psType1 == NULL) {
     421    psType1 = (psType *) in1;
     422    if (psType1 == NULL) {
    409423        psError(__func__, ": Line %d - Null in1 argument", __LINE__);
    410424        return out;
    411425    }
    412426
    413     psType2 = (psType*)in2;
    414     if(psType2 == NULL) {
     427    psType2 = (psType *) in2;
     428    if (psType2 == NULL) {
    415429        psError(__func__, ": Line %d - Null in2 argument", __LINE__);
    416430        return out;
    417431    }
    418432
    419     if(op == NULL) {
     433    if (op == NULL) {
    420434        psError(__func__, ": Line %d - Null op argument", __LINE__);
    421435        return out;
     
    429443    elTypeOut = psTypeOut->type;
    430444
    431     if(elType1!=elType2 &&  elType1!=elTypeOut) {
     445    if (elType1 != elType2 && elType1 != elTypeOut) {
    432446        psError(__func__, ": Line %d - Element types for arguments inconsistent: (%d, %d, %d)", __LINE__,
    433447                elType1, elType2, elTypeOut);
     
    435449    }
    436450
    437     if(dim1==PS_DIMEN_OTHER || dim2==PS_DIMEN_OTHER || dimOut==PS_DIMEN_OTHER) {
     451    if (dim1 == PS_DIMEN_OTHER || dim2 == PS_DIMEN_OTHER || dimOut == PS_DIMEN_OTHER) {
    438452        psError(__func__, ": Line %d - PS_DIMEN_OTHER not allowed for arguments: (%d, %d, %d)", __LINE__,
    439453                dim1, dim2, dimOut);
     
    441455    }
    442456
    443     if(dim1 == PS_DIMEN_VECTOR) {
    444         if(((psVector*)in1)->n == 0) {
     457    if (dim1 == PS_DIMEN_VECTOR) {
     458        if (((psVector *) in1)->n == 0) {
    445459            psError(__func__, ": Line %d - Vector contains zero elements");
    446460        }
    447     } else
    448         if(dim1 == PS_DIMEN_IMAGE) {
    449             if(((psImage*)in1)->numCols==0 || ((psImage*)in1)->numRows==0) {
    450                 psError(__func__, ": Line %d - Image contains zero length row or cols");
    451             }
    452         }
    453 
    454     if(dim2 == PS_DIMEN_VECTOR) {
    455         if(((psVector*)in2)->n == 0) {
     461    } else if (dim1 == PS_DIMEN_IMAGE) {
     462        if (((psImage *) in1)->numCols == 0 || ((psImage *) in1)->numRows == 0) {
     463            psError(__func__, ": Line %d - Image contains zero length row or cols");
     464        }
     465    }
     466
     467    if (dim2 == PS_DIMEN_VECTOR) {
     468        if (((psVector *) in2)->n == 0) {
    456469            psError(__func__, ": Line %d - Vector contains zero elements");
    457470        }
    458     } else
    459         if(dim2 == PS_DIMEN_IMAGE) {
    460             if(((psImage*)in2)->numCols==0 || ((psImage*)in2)->numRows==0) {
    461                 psError(__func__, ": Line %d - Image contains zero length row or cols");
    462             }
    463         }
    464 
    465     if(dim1 == PS_DIMEN_SCALAR) {
    466         if(dim2 == PS_DIMEN_SCALAR) {
    467             BINARY_OP(SCALAR,SCALAR,out,psType1,op,psType2);               // scalar op scalar
    468         } else
    469             if(dim2==PS_DIMEN_VECTOR || dim2==PS_DIMEN_TRANSV) {
    470                 BINARY_OP(SCALAR,VECTOR,out,psType1,op,psType2);               // scalar op vector
    471             } else
    472                 if(dim2 == PS_DIMEN_IMAGE) {
    473                     BINARY_OP(SCALAR,IMAGE,out,psType1,op,psType2);                // scalar op image
    474                 } else {
    475                     psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
    476                 }
    477     } else
    478         if(dim1==PS_DIMEN_VECTOR || dim1==PS_DIMEN_TRANSV) {
    479             if(dim2 == PS_DIMEN_SCALAR) {
    480                 BINARY_OP(VECTOR,SCALAR,out,psType1,op,psType2);               // vector op scalar
    481             } else
    482                 if(dim2==PS_DIMEN_VECTOR || dim2==PS_DIMEN_TRANSV) {
    483                     BINARY_OP(VECTOR,VECTOR,out,psType1,op,psType2);               // vector op vector
    484                 } else
    485                     if(dim2 == PS_DIMEN_IMAGE) {
    486                         BINARY_OP(VECTOR,IMAGE,out,psType1,op,psType2);                // vector op image
    487                     } else {
    488                         psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
    489                     }
    490         } else
    491             if(dim1 == PS_DIMEN_IMAGE) {
    492                 if(dim2 == PS_DIMEN_SCALAR) {
    493                     BINARY_OP(IMAGE,SCALAR,out,psType1,op,psType2);                // image op scalar
    494                 } else
    495                     if(dim2==PS_DIMEN_VECTOR || dim2==PS_DIMEN_TRANSV) {
    496                         BINARY_OP(IMAGE,VECTOR,out,psType1,op,psType2);                // image op vector
    497                     } else
    498                         if(dim2 == PS_DIMEN_IMAGE) {
    499                             BINARY_OP(IMAGE,IMAGE,out,psType1,op,psType2);                 // image op image
    500                         } else {
    501                             psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
    502                         }
    503             } else {
    504                 psError(__func__, ": Line %d - Invalid dimensionality for in1 arg: %d", __LINE__, dim1);
    505             }
     471    } else if (dim2 == PS_DIMEN_IMAGE) {
     472        if (((psImage *) in2)->numCols == 0 || ((psImage *) in2)->numRows == 0) {
     473            psError(__func__, ": Line %d - Image contains zero length row or cols");
     474        }
     475    }
     476
     477    if (dim1 == PS_DIMEN_SCALAR) {
     478        if (dim2 == PS_DIMEN_SCALAR) {
     479            BINARY_OP(SCALAR, SCALAR, out, psType1, op, psType2);       // scalar op scalar
     480        } else if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) {
     481            BINARY_OP(SCALAR, VECTOR, out, psType1, op, psType2);       // scalar op vector
     482        } else if (dim2 == PS_DIMEN_IMAGE) {
     483            BINARY_OP(SCALAR, IMAGE, out, psType1, op, psType2);        // scalar op image
     484        } else {
     485            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
     486        }
     487    } else if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) {
     488        if (dim2 == PS_DIMEN_SCALAR) {
     489            BINARY_OP(VECTOR, SCALAR, out, psType1, op, psType2);       // vector op scalar
     490        } else if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) {
     491            BINARY_OP(VECTOR, VECTOR, out, psType1, op, psType2);       // vector op vector
     492        } else if (dim2 == PS_DIMEN_IMAGE) {
     493            BINARY_OP(VECTOR, IMAGE, out, psType1, op, psType2);        // vector op image
     494        } else {
     495            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
     496        }
     497    } else if (dim1 == PS_DIMEN_IMAGE) {
     498        if (dim2 == PS_DIMEN_SCALAR) {
     499            BINARY_OP(IMAGE, SCALAR, out, psType1, op, psType2);        // image op scalar
     500        } else if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) {
     501            BINARY_OP(IMAGE, VECTOR, out, psType1, op, psType2);        // image op vector
     502        } else if (dim2 == PS_DIMEN_IMAGE) {
     503            BINARY_OP(IMAGE, IMAGE, out, psType1, op, psType2); // image op image
     504        } else {
     505            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
     506        }
     507    } else {
     508        psError(__func__, ": Line %d - Invalid dimensionality for in1 arg: %d", __LINE__, dim1);
     509    }
    506510
    507511    return out;
     
    567571    }                                                                                                        \
    568572}
    569 
    570573
    571574// Preprocessor macro function to create arithmetic function based on input type
     
    596599}
    597600
    598 
    599601// Preprocessor macro function to create arithmetic function operation name
    600602#define UNARY_OP(DIM,OUT,IN,OP)                                                                              \
     
    714716    psType *psTypeOut = NULL;
    715717
    716     psTypeOut = (psType*)out;
    717     if(psTypeOut == NULL) {
     718    psTypeOut = (psType *) out;
     719    if (psTypeOut == NULL) {
    718720        psError(__func__, ": Line %d - Null out argument", __LINE__);
    719721        return out;
    720722    }
    721723
    722     psTypeIn = (psType*)in;
    723     if(psTypeIn == NULL) {
     724    psTypeIn = (psType *) in;
     725    if (psTypeIn == NULL) {
    724726        psError(__func__, ": Line %d - Null in argument", __LINE__);
    725727        return out;
    726728    }
    727729
    728     if(op == NULL) {
     730    if (op == NULL) {
    729731        psError(__func__, ": Line %d - Null op argument", __LINE__);
    730732        return out;
     
    736738    elTypeOut = psTypeOut->type;
    737739
    738     if(elTypeIn!=elTypeOut) {
     740    if (elTypeIn != elTypeOut) {
    739741        psError(__func__, ": Line %d - Element types for arguments inconsistent: (%d, %d)", __LINE__,
    740742                elTypeIn, elTypeOut);
     
    742744    }
    743745
    744     if(dimIn!=dimOut) {
     746    if (dimIn != dimOut) {
    745747        psError(__func__, ": Line %d - Dimensionality for arguments inconsistent: (%d, %d)", __LINE__,
    746748                dimIn, dimOut);
     
    748750    }
    749751
    750     if(dimIn==PS_DIMEN_OTHER || dimOut==PS_DIMEN_OTHER) {
     752    if (dimIn == PS_DIMEN_OTHER || dimOut == PS_DIMEN_OTHER) {
    751753        psError(__func__, ": Line %d - PS_DIMEN_OTHER not allowed for arguments: (%d, %d)", __LINE__,
    752754                dimIn, dimOut);
     
    754756    }
    755757
    756     if(dimIn == PS_DIMEN_VECTOR) {
    757         if(((psVector*)in)->n == 0) {
     758    if (dimIn == PS_DIMEN_VECTOR) {
     759        if (((psVector *) in)->n == 0) {
    758760            psError(__func__, ": Line %d - Vector contains zero elements");
    759761        }
    760     } else
    761         if(dimIn == PS_DIMEN_IMAGE) {
    762             if(((psImage*)in)->numCols==0 || ((psImage*)in)->numRows==0) {
    763                 psError(__func__, ": Line %d - Image contains zero length row or cols");
    764             }
    765         }
    766 
    767     if(dimOut == PS_DIMEN_VECTOR) {
    768         if(((psVector*)out)->n == 0) {
     762    } else if (dimIn == PS_DIMEN_IMAGE) {
     763        if (((psImage *) in)->numCols == 0 || ((psImage *) in)->numRows == 0) {
     764            psError(__func__, ": Line %d - Image contains zero length row or cols");
     765        }
     766    }
     767
     768    if (dimOut == PS_DIMEN_VECTOR) {
     769        if (((psVector *) out)->n == 0) {
    769770            psError(__func__, ": Line %d - Vector contains zero elements");
    770771        }
    771     } else
    772         if(dimOut == PS_DIMEN_IMAGE) {
    773             if(((psImage*)out)->numCols==0 || ((psImage*)out)->numRows==0) {
    774                 psError(__func__, ": Line %d - Image contains zero length row or cols");
    775             }
    776         }
    777 
    778     if(dimIn == PS_DIMEN_SCALAR) {
    779         UNARY_OP(SCALAR,out,psTypeIn,op);                                 // scalar
    780     } else
    781         if(dimIn==PS_DIMEN_VECTOR || dimIn==PS_DIMEN_TRANSV) {
    782             UNARY_OP(VECTOR,out,psTypeIn,op);                                 // vector
    783         } else
    784             if(dimIn == PS_DIMEN_IMAGE) {
    785                 UNARY_OP(IMAGE,out,psTypeIn,op);                                  // image
    786             } else {
    787                 psError(__func__, ": Line %d - Invalid dimensionality for in arg: %d", __LINE__, dimIn);
    788             }
     772    } else if (dimOut == PS_DIMEN_IMAGE) {
     773        if (((psImage *) out)->numCols == 0 || ((psImage *) out)->numRows == 0) {
     774            psError(__func__, ": Line %d - Image contains zero length row or cols");
     775        }
     776    }
     777
     778    if (dimIn == PS_DIMEN_SCALAR) {
     779        UNARY_OP(SCALAR, out, psTypeIn, op);    // scalar
     780    } else if (dimIn == PS_DIMEN_VECTOR || dimIn == PS_DIMEN_TRANSV) {
     781        UNARY_OP(VECTOR, out, psTypeIn, op);    // vector
     782    } else if (dimIn == PS_DIMEN_IMAGE) {
     783        UNARY_OP(IMAGE, out, psTypeIn, op);     // image
     784    } else {
     785        psError(__func__, ": Line %d - Invalid dimensionality for in arg: %d", __LINE__, dimIn);
     786    }
    789787
    790788    return out;
Note: See TracChangeset for help on using the changeset viewer.