52#include <gsl/gsl_statistics.h>
56#define MODULE_ID "XSH_GSL_CORRELATE_GAUSSIANS"
63 {
"debug", required_argument, 0,
DEBUG_OPT},
70 puts (
"Unitary test : Create two Gaussians one shifted to the other of a given quantity, then correlate them to check if correlation returns expected shift");
71 puts(
"Usage : ./tetst_xsh_correl_gaussians [options]");
74 puts(
" --debug=<n> : Level of debug LOW | MEDIUM | HIGH [MEDIUM]" );
75 puts(
" --help : What you see" ) ;
77 puts(
"The input files argument MUST be in this order:" );
78 puts(
" 1. PRE frame");
79 puts(
" 2. SOF a) MODEL : [XSH_MOD_CFG_TAB_UVB]");
80 puts(
" b) POLYNOMIAL: [DISP_TAB, ORDER_TAB_EDGES]");
91 while( (opt = getopt_long( argc, argv,
"debug:help",
95 if ( strcmp( optarg,
"LOW")==0){
98 else if ( strcmp( optarg,
"HIGH")==0){
118 double norm=
sigma*sqrt(2*CPL_MATH_PI);
121 for(i=0;i<
size;i++) {
123 data[i]=a*exp(-(
x-center)*(
x-center)*inv_2_c2);
126 return cpl_error_get_code();
142int main(
int argc,
char** argv)
146 cpl_msg_set_level( CPL_MSG_DEBUG);
152 if ( (argc-optind) >= 2) {
160 double gauss_c=0.5*
size;
162 double* gauss_d1=NULL;
163 double* gauss_d2=NULL;
165 cpl_vector* gauss_v1=cpl_vector_new(
size);
166 cpl_vector* gauss_v2=cpl_vector_new(
size);
168 gauss_d1=cpl_vector_get_data(gauss_v1);
169 gauss_d2=cpl_vector_get_data(gauss_v2);
175 double shift=gsl_stats_correlation(gauss_d1,1., gauss_d2,1.,
size);
183 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
cpl_error_code xsh_gauss_gen(double *data, const double center, const double sigma, const int size)
static struct option LongOptions[]
#define xsh_error_dump(level)
#define xsh_msg(...)
Print a message on info level.
void xsh_free_vector(cpl_vector **v)
Deallocate a vector and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
static void HandleOptions(int argc, char **argv)
#define TESTS_INIT(DRL_ID)