Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
thd_floatscan.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <math.h>
00008 #include <stdlib.h>
00009
00010 #ifdef isfinite
00011 # define IS_GOOD_FLOAT(x) isfinite(x)
00012 #else
00013 # define IS_GOOD_FLOAT(x) finite(x)
00014 #endif
00015
00016 #if 0
00017 # define IS_GOOD_FLOAT(x) isnan(x)
00018 #endif
00019
00020
00021
00022
00023
00024
00025 int thd_floatscan( int nbuf , float * fbuf )
00026 {
00027 int ii , nerr ;
00028
00029 if( nbuf <= 0 || fbuf == NULL ) return 0 ;
00030
00031 for( nerr=ii=0 ; ii < nbuf ; ii++ ){
00032 if( !IS_GOOD_FLOAT(fbuf[ii]) ){ fbuf[ii] = 0.0 ; nerr++ ; }
00033 }
00034
00035 return nerr ;
00036 }
00037
00038 typedef struct complex { float r , i ; } complex ;
00039
00040 int thd_complexscan( int nbuf , complex * cbuf )
00041 {
00042 int ii , nerr ;
00043
00044 if( nbuf <= 0 || cbuf == NULL ) return 0 ;
00045
00046 for( nerr=ii=0 ; ii < nbuf ; ii++ ){
00047 if( !IS_GOOD_FLOAT(cbuf[ii].r) ){ cbuf[ii].r = 0.0 ; nerr++ ; }
00048 if( !IS_GOOD_FLOAT(cbuf[ii].i) ){ cbuf[ii].i = 0.0 ; nerr++ ; }
00049 }
00050
00051 return nerr ;
00052 }