/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/utils/eh_num.h

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #ifndef __EH_NUM_H__
00022 #define __EH_NUM_H__
00023 
00024 #include <stdio.h>
00025 #include <glib.h>
00026 #include <utils/complex.h>
00027 
00028 typedef double (*Eh_root_fcn)( double x , gpointer user_data );
00029 typedef double (Cost_fcn)( double*, int );
00030 typedef double (*Eh_dbl_func_with_data)(double x , gpointer data );
00031 typedef double (*Eh_dbl_func)( double x );
00032 
00033 typedef double (*Eh_dbl_cpy_func)( gpointer data , double* d );
00034 typedef double (*Eh_dbl_get_func)( gpointer data , gint ind );
00035 typedef double (*Eh_dbl_set_func)( gpointer data , gint ind , double val );
00036 typedef double (*Eh_dbl_add_func)( gpointer data , gint ind , double val );
00037 
00038 typedef void   (*Eh_array_func)  ( gpointer data , gpointer user_data );
00039 
00040 double eh_safe_dbl_division( double a , double b );
00041 gboolean eh_compare_dbl( double , double , double );
00042 
00043 double    eh_gamma_log     ( double xx );
00044 double    eh_gamma_p       ( double a , double x );
00045 double    eh_gamma_q       ( double a , double x );
00046 void      eh_gamma_cf      ( double* gammcf , double a , double x , double* gln );
00047 void      eh_gamma_series  ( double* gamser , double a , double x , double* gln );
00048 double    eh_factorial     ( gssize n );
00049 double    eh_factorial_log ( gssize n );
00050 double    eh_binomial_coef ( gssize n , gssize y );
00051 
00052 void interpolate(double*,double*,gssize,double*,double*,gssize);
00053 void interpolate_bad_val(double*,double*,gssize,double*,double*,gssize,double);
00054 double poly_interpolate( double* xa , double* ya , gssize n , double x , double* dy );
00055 
00056 typedef void(*Eh_poly_basis_func)(double,double*,gssize);
00057 
00058 void       poly_basis_funcs   ( double  x , double* p , gssize n );
00059 double*    eh_poly_fit        ( double* x , double* y , gssize len , gssize n );
00060 double     eh_poly_r_squared  ( double* x , double* y , gssize len , double* p , gssize n );
00061 double     eh_r_squared       ( double* x , double* y , gssize len , Eh_dbl_func_with_data f , gpointer data );
00062 void       eh_svdfit          ( double* x , double* y , double* sig , gssize ndata ,
00063                                 double* a , gssize ma ,
00064                                 double** u , double** v , double* w , double* chisq ,
00065                                 Eh_poly_basis_func funcs );
00066 double     eh_pythag          ( double a , double b );
00067 void       eh_svbksb          ( double** u , double* w , double** v , gssize m , gssize n ,
00068                                 double*  b , double* x );
00069 void       eh_svdcmp          ( double** a , gssize m , gssize n , double* w , double** v );
00070 double     eh_poly_eval       ( double  x , double* p , gssize n );
00071 double*    eh_linear_fit      ( double* x , double* y , gssize len );
00072 void       eh_fit             ( double* x , double* y , gssize len , double* sig , gboolean mwt ,
00073                                 double* a , double* b , double* siga , double* sigb ,
00074                                 double* chi2 , double* q );
00075 
00076 
00077 double trapzd( Eh_dbl_func_with_data func , double a , double b , gssize n , gpointer data );
00078 double qtrap( Eh_dbl_func_with_data func , double a , double b , gpointer data );
00079 double eh_integrate( Eh_dbl_func_with_data func , double a , double b );
00080 double eh_integrate_with_data( Eh_dbl_func_with_data func , double a , double b , gpointer data );
00081 
00082 gboolean eh_is_even( gssize n );
00083 double eh_round( double , double );
00084 double eh_reduce_angle( double angle );
00085 double *tridiag( double *l , double *d , double *u , double *b , double *x , int n );
00086 Complex *c_tridiag( Complex *l , Complex *d , Complex *u , Complex *b , Complex *x , int n );
00087 double rtsafe(void (*funcd)(double, double *, double *, double *), double x1, double x2, double xacc, double *);
00088 double eh_bisection( Eh_root_fcn f , double x_0 , double x_1 , double eps , gpointer user_data );
00089 double *anneal( double *x , int n , Cost_fcn *f , double cost_min );
00090 
00091 double bessel_i_0( double x );
00092 double bessel_k_0( double x );
00093 double eh_kei_0( double x );
00094 
00095 double eh_erf_inv( double y );
00096 
00097 long int i1mach_( long int *i );
00098 double d1mach_( long int *i );
00099 
00100 double*    eh_dbl_array_new         ( gssize n );
00101 double*    eh_dbl_array_new_set     ( gssize n , double val );
00102 double*    eh_dbl_array_dup         ( double* s , gssize n );
00103 double*    eh_dbl_array_copy        ( double* d , double* s , gssize n );
00104 double*    eh_dbl_col_to_array      ( double* d , double* col , gint n , gssize offset );
00105 double*    eh_dbl_array_to_col      ( double* d , double* s   , gint n , gssize offset );
00106 double*    eh_dbl_array_rebin_smaller( double* s , gssize n , double bin_size , gint* d_len );
00107 double*    eh_dbl_array_rebin_larger( double* s , gssize n , double bin_size , gint* d_len );
00108 double*    eh_dbl_array_rebin       ( double* s , gssize n , double bin_size , gint* d_len );
00109 double     eh_dbl_array_min         ( const double* x , gsize n );
00110 gssize     eh_dbl_array_min_ind     ( const double* x , gssize n );
00111 double     eh_dbl_array_max         ( const double* x , gsize n );
00112 gssize     eh_dbl_array_max_ind     ( const double* x , gssize n );
00113 double     eh_dbl_array_abs_max     ( const double* x , gsize n );
00114 gssize     eh_dbl_array_fprint      ( FILE* fp , double* x , gssize n );
00115 gint       eh_dbl_array_write       ( FILE *fp , double *x , gint len );
00116 double     eh_dbl_array_mean        ( const double *x , gsize n );
00117 double*    eh_dbl_array_normalize   ( double* x , gsize n );
00118 double*    eh_dbl_array_foreach     ( double* x , gssize n , Eh_dbl_func f );
00119 double*    eh_dbl_array_mult        ( double* x , gsize n , double a );
00120 double*    eh_dbl_array_mult_each   ( double* d , gssize n , double* s );
00121 double*    eh_dbl_array_add         ( double* dest , double* src , gssize n ) G_GNUC_DEPRECATED;
00122 double*    eh_dbl_array_add_each    ( double* d , gssize n , double* s );
00123 double     eh_dbl_array_var         ( const double* x , gsize n );
00124 double     eh_dbl_array_sum         ( const double* x , gsize n );
00125 double     eh_dbl_array_abs_sum     ( const double* x , gsize n );
00126 void       eh_dbl_array_fabs        ( double* x , gsize n );
00127 double*    eh_dbl_array_diff        ( double* d , const double *x , gsize len , gssize n );
00128 double*    eh_dbl_array_gradient    ( const double* x , gsize n , double dx );
00129 double*    eh_dbl_array_set         ( double *x , gsize n , double set_val );
00130 double*    eh_dbl_array_grid        ( double *x , gsize n , double start , double dx );
00131 double*    eh_dbl_array_running_mean( double* x , gssize len , gssize n_left , gssize n_right );
00132 double*    eh_dbl_array_conv        ( double *x , gsize len_x , double *y , gsize len_y );
00133 double*    eh_low_pass_filter       ( double* x , gssize len );
00134 double*    eh_dbl_array_cum_mean_dir( double *x , gsize n , gboolean forward );
00135 double*    eh_dbl_array_cum_sum_dir ( double *x , gsize n , gboolean forward );
00136 double*    eh_dbl_array_cum_max_dir ( double *x , gsize n , gboolean forward );
00137 double*    eh_dbl_array_cum_min_dir ( double *x , gsize n , gboolean forward );
00138 gboolean   eh_dbl_array_compare     ( double *x , double *y , gssize len , double eps );
00139 gboolean   eh_dbl_array_cmp_ge      ( double* x , double* y , gssize len );
00140 gboolean   eh_dbl_array_each_ge     ( double val , double *x , gssize len );
00141 gboolean   eh_dbl_array_each_le     ( double val , double *x , gssize len );
00142 
00143 gboolean   eh_dbl_array_is_monotonic_up  ( double *x , gsize n );
00144 gboolean   eh_dbl_array_is_monotonic_down( double *x , gsize n );
00145 double*    eh_linspace                   ( double x1 , double x2 , gssize n );
00146 gssize*    eh_id_array                   ( gssize i_0 , gssize i_1 , gssize* n );
00147 double*    eh_uniform_array              ( double x1 , double x2 , double dx , gint* n );
00148 
00149 double*    eh_dbl_array_linspace         ( double* x , gssize n_x ,  double x_0 , double dx );
00150 
00151 
00152 #define eh_dbl_array_cum_mean( x , n )     eh_dbl_array_cum_mean_dir(x,n,TRUE )
00153 #define eh_dbl_array_cum_mean_rev( x , n ) eh_dbl_array_cum_mean_dir(x,n,FALSE)
00154 #define eh_dbl_array_cum_sum( x , n )      eh_dbl_array_cum_sum_dir (x,n,TRUE )
00155 #define eh_dbl_array_cum_sum_rev( x , n )  eh_dbl_array_cum_sum_dir (x,n,FALSE)
00156 #define eh_dbl_array_cum_max( x , n )      eh_dbl_array_cum_max_dir (x,n,TRUE )
00157 #define eh_dbl_array_cum_max_rev( x , n )  eh_dbl_array_cum_max_dir (x,n,FALSE)
00158 #define eh_dbl_array_cum_min( x , n )      eh_dbl_array_cum_min_dir (x,n,TRUE )
00159 #define eh_dbl_array_cum_min_rev( x , n )  eh_dbl_array_cum_min_dir (x,n,FALSE)
00160 
00161 void convlv(double data[], unsigned long n, double respns[], unsigned long m,
00162         int isign, double ans[]);
00163 void four1(double data[], unsigned long nn, int isign);
00164 void realft(double data[], unsigned long n, int isign);
00165 void twofft(double data1[], double data2[], double fft1[], double fft2[],
00166         unsigned long n);
00167 
00168 double eh_dbl_array_mean_weighted( const double x[] , gint len , const double f[] );
00169 
00170 #ifndef HAVE_LOG2
00171 double log2( double x );
00172 #endif
00173 
00174 #undef OLD_EH_NAN
00175 
00176 #if defined( OLD_EH_NAN )
00177 float    eh_nan  ( void     );
00178 int      eh_isnan( float x  );
00179 #else
00180 double   eh_nan  ( void     );
00181 gboolean eh_isnan( double x );
00182 #endif
00183 
00184 void eh_rebin_dbl_array        ( double *x     , double *y     , gssize len ,
00185                                  double *x_bin , double *y_bin , gssize len_bin );
00186 void eh_rebin_dbl_array_bad_val( double *x     , double *y     , gssize len     ,
00187                                  double *x_bin , double *y_bin , gssize len_bin ,
00188                                  double bad_val );
00189 
00190 typedef enum
00191 {
00192    EH_NUM_IMPLICIT ,
00193    EH_NUM_EXPLICIT
00194 }
00195 Eh_num_method;
00196 
00197 double* eh_dbl_array_diffuse_implicit( double* x , gint len , double c );
00198 double* eh_dbl_array_diffuse_explicit( double* x , gint len , double c );
00199 double* eh_dbl_array_diffuse         ( double* x , gint len , double c , Eh_num_method method );
00200 
00201 #endif

Generated on Fri Jan 4 18:04:16 2008 for sedflux by  doxygen 1.5.2