#include "gs2crmod_ext.h" #include #include #include #include VALUE gs2crmod_tensor_complexes_field_gsl_tensor_complex_2(VALUE self, VALUE options) { VALUE field, field_complex, field_narray; VALUE field_complex_narray; VALUE cgsl_tensor_complex; VALUE ccomplex; VALUE shape; int *c_shape; int i, j, k; ccomplex = RGET_CLASS_TOP("Complex"); field = RFCALL_11("field_gsl_tensor", options); cgsl_tensor_complex = RGET_CLASS(cgsl, "TensorComplex"); shape = rb_funcall(field, rb_intern("shape"), 0); /*rb_p(shape);*/ CR_INT_ARY_R2C_STACK(shape, c_shape); field_complex = rb_funcall3(cgsl_tensor_complex, rb_intern("alloc"), 3, RARRAY_PTR(shape)); field_narray = RFCALL_10_ON(field, "narray"); field_complex_narray = RFCALL_10_ON(field_complex, "narray"); /*rb_p(field_complex);*/ for (i=0;int_reg-1) lt[i1] = t_reg[i1-nt_reg] - t_reg[0] + delta_t_reg; } /* Now test which correlation function is to be calculated since full 4D correlation * is usually intractable. The type was read in at begininning and corr_type corresponds to: * * 0 : perpendicular only (lz = 0) * 1 : parallel only (lx = ly = 0) * 2 : time only (lx = lz = 0) * 3 : full correlation (may take very long) (all separations != 0) */ float eps1 = 1e-5, eps2 = 1e5; //define very small and very large numbers to test against float lx_test, ly_test, lz_test; switch (corr_type){ case 0: //perp lx_test = eps2; ly_test = eps2; lz_test = eps1; break; case 1: //par lx_test = eps1; ly_test = eps1; lz_test = eps2; break; case 2: //time lx_test = eps1; ly_test = eps2; lz_test = eps1; break; case 3: //full lx_test = eps2; ly_test = eps2; lz_test = eps2; break; } //Start main loop for correlation function calculation for(i1=0; i10){ coarray[i1] = coarray[i1]/count[i1]; } } //printf("Finish normalization: \n"); //Retun output to CR VALUE cgsl_tensor, output_tensor; cgsl_tensor = RGET_CLASS(cgsl, "Tensor"); //output_tensor = GSL::Tensor.alloc(nbins, ...) output_tensor = rb_funcall(cgsl_tensor, rb_intern("alloc"), 4, INT2FIX(nbins[0]), INT2FIX(nbins[1]), INT2FIX(nbins[2]), INT2FIX(nbins[3])); for(i1=0; i1