IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2004, 1:34:06 PM (22 years ago)
Author:
harman
Message:

Added nan error dividion function

File:
1 edited

Legend:

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

    r1088 r1100  
    2929 *  @author Ross Harman, MHPCC
    3030 *
    31  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    32  *  @date $Date: 2004-06-25 02:00:41 $
     31 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     32 *  @date $Date: 2004-06-25 23:34:06 $
    3333 *
    3434 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141#include <math.h>
    4242#include <stdint.h>
     43#include <tgmath.h>
    4344
    4445#include "psMemory.h"
     
    8788// Conversion for radians to degrees
    8889#define R2D 360.0/M_PI
     90
     91// Division with NAN checking
     92static complex double psNanDiv(complex double a, complex double b)
     93{
     94    complex double out = 0+0i;
     95    out = a/b;
     96    if(isnan(creal(out))) {
     97        psError(__func__, ": NAN encountered in real portion of division");
     98    } else if(isnan(cimag(out))) {
     99        psError(__func__, ": NAN encountered in imaginary portion of division");
     100    }
     101
     102    return out;
     103}
    89104
    90105// Binary SCALAR_XXXX operations
     
    362377    break;                                                                                                   \
    363378default:                                                                                                     \
    364     psError(__func__, ": Line %d - Invalid PS_TYPE: %d", __LINE__, IN1->type);                               \
     379    psError(__func__, ": Invalid PS_TYPE: %d", IN1->type);                                                   \
    365380}
    366381
     
    374389    BINARY_TYPE(DIM1,DIM2,OUT,IN1,*i1 * *i2,IN2);                                                            \
    375390} else if(!strncmp(OP, "/", 1)) {                                                                            \
    376     BINARY_TYPE(DIM1,DIM2,OUT,IN1,*i1 / *i2,IN2);                                                            \
     391    BINARY_TYPE(DIM1,DIM2,OUT,IN1,psNanDiv(*i1,*i2),IN2);                                                    \
    377392} else if(!strncmp(OP, "^", 1)) {                                                                            \
    378393    if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
     
    382397    }                                                                                                        \
    383398} else if(!strncmp(OP, "min", 3)) {                                                                          \
    384     BINARY_TYPE(DIM1,DIM2,OUT,IN1,MIN(*i1,*i2),IN2);                                                         \
     399    if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
     400        psError(__func__, ": Minimum operation not supported for complex numbers");                          \
     401    } else {                                                                                                 \
     402        BINARY_TYPE(DIM1,DIM2,OUT,IN1,fmin(*i1,*i2),IN2);                                                    \
     403    }                                                                                                        \
    385404} else if(!strncmp(OP, "max", 3)) {                                                                          \
    386     BINARY_TYPE(DIM1,DIM2,OUT,IN1,MAX(*i1,*i2),IN2);                                                         \
     405    if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
     406        psError(__func__, ": Maximum operation not supported for complex numbers");                          \
     407    } else {                                                                                                 \
     408        BINARY_TYPE(DIM1,DIM2,OUT,IN1,fmax(*i1,*i2),IN2);                                                    \
     409    }                                                                                                        \
    387410} else {                                                                                                     \
    388     psError(__func__, ": Line %d - Invalid operator: %s", __LINE__, #OP);                                    \
     411    psError(__func__, ": Invalid binary operator: %s", #OP);                                                 \
    389412}
    390413
Note: See TracChangeset for help on using the changeset viewer.