Exemple #1
0
void js03_lineshape_func_free(js03_lineshape_func *f)
{
  gsl_interp_accel_free(f->BATH_JS03_gt_r_Spline_Acc);
  gsl_interp_accel_free(f->BATH_JS03_gt_i_Spline_Acc);
  gsl_spline_free(f->BATH_JS03_gt_r_Spline);
  gsl_spline_free(f->BATH_JS03_gt_i_Spline);
}
static float
interp_demData(float *demData, int nl, int ns, double l, double s)
{
  if (l<0 || l>=nl-1 || s<0 || s>=ns-1) {
    return 0;
  }

  int ix = (int)s;
  int iy = (int)l;

  int bilinear = l<3 || l>=nl-3 || s<3 || s>=ns-3;
  //int bilinear = 1;
  if (bilinear) {

    float p00 = demData[ix   + ns*(iy  )];
    float p10 = demData[ix+1 + ns*(iy  )];
    float p01 = demData[ix   + ns*(iy+1)];
    float p11 = demData[ix+1 + ns*(iy+1)];

    return (float)bilinear_interp_fn(s-ix, l-iy, p00, p10, p01, p11);
  }
  else {

    double ret, x[4], y[4], xi[4], yi[4];
    int ii;

    for (ii=0; ii<4; ++ii) {
      y[0] = demData[ix-1 + ns*(iy+ii-1)];
      y[1] = demData[ix   + ns*(iy+ii-1)];
      y[2] = demData[ix+1 + ns*(iy+ii-1)];
      y[3] = demData[ix+2 + ns*(iy+ii-1)];

      x[0] = ix - 1;
      x[1] = ix;
      x[2] = ix + 1;
      x[3] = ix + 2;

      gsl_interp_accel *acc = gsl_interp_accel_alloc ();
      gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, 4);    
      gsl_spline_init (spline, x, y, 4);
      yi[ii] = gsl_spline_eval_check(spline, s, acc);
      gsl_spline_free (spline);
      gsl_interp_accel_free (acc);

      xi[ii] = iy + ii - 1;
    }

    gsl_interp_accel *acc = gsl_interp_accel_alloc ();
    gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, 4);    
    gsl_spline_init (spline, xi, yi, 4);
    ret = gsl_spline_eval_check(spline, l, acc);
    gsl_spline_free (spline);
    gsl_interp_accel_free (acc);
 
    return (float)ret;
  }
  
  asfPrintError("Impossible.");
}
int load_lens(int l_size ,int* l_values){
	
	double* lens_data = malloc( sizeof(double)*MAXLINES*3);
	int* lens_len = malloc( sizeof(int));
	
	load_txt_dbl(lens_data_file, 3, lens_data, lens_len);
	
	int lens_size = *lens_len;
	int lmax = (int)get_lmax();
// 	printf("lmax %d\t%d\n",lmax,lens_size);
	double l_raw[lens_size];
	double cltt_raw[lens_size];
	double cltp_raw[lens_size];
	
	int i,j;
	double pt;
	
	j=0;
	for (i=0; i<lmax+1; i++){
		l_raw[i] = lens_data[j++];
		cltt_raw[i] = lens_data[j++];
		cltp_raw[i] = lens_data[j++];
	}
	
	if (l_values[l_size-1]>l_raw[lmax]){
		printf("lens do not contain enough l's, max data %d max lens: %d\n", l_values[l_size-1], (int)l_raw[lmax]);
		return 1;
		exit;
	}
	
	
	gsl_spline* sptt =  gsl_spline_alloc (gsl_interp_cspline, lmax+1);
	gsl_spline* sptp =  gsl_spline_alloc (gsl_interp_cspline, lmax+1);
	gsl_interp_accel* acctt = gsl_interp_accel_alloc();
	gsl_interp_accel* acctp = gsl_interp_accel_alloc();
	
	gsl_spline_init(sptt,l_raw,cltt_raw,lmax+1);
	gsl_spline_init(sptp,l_raw,cltp_raw,lmax+1);
	
	for (i=0; i<l_size; i++){
		pt = (double)l_values[i];
		lens_tt[i] = 0.0;
		lens_tp[i] = 0.0;
		if(pt!=0){
			lens_tt[i] = gsl_spline_eval(sptt,pt,acctt);
			lens_tp[i] = gsl_spline_eval(sptp,pt,acctp);
		}
	}
	
	gsl_spline_free(sptt);
	gsl_spline_free(sptp);
	gsl_interp_accel_free(acctt);
	gsl_interp_accel_free(acctp);
	
	return 0;
}
void TrajectoryControl::pathSpline_destroy(spline_param* x_path,
		spline_param* y_path, spline_param* ds_path) {
	// Distruggo gli oggetti spline
	gsl_spline_free(x_path->spline_coeff);
	gsl_interp_accel_free(x_path->accumulator);

	gsl_spline_free(y_path->spline_coeff);
	gsl_interp_accel_free(y_path->accumulator);

	gsl_spline_free(ds_path->spline_coeff);
	gsl_interp_accel_free(ds_path->accumulator);
}
Exemple #5
0
void free_lens_corr_func(lensCorrFunc lcf)
{
  if(lcf->splineM != NULL)
    gsl_spline_free(lcf->splineM);
  if(lcf->accelM != NULL)
    gsl_interp_accel_free(lcf->accelM);
    
  if(lcf->splineP != NULL)
    gsl_spline_free(lcf->splineP);
  if(lcf->accelP != NULL)
    gsl_interp_accel_free(lcf->accelP);
  
  free(lcf);
}
Exemple #6
0
void cosmology::cosmo_free(){
    if(verbose){
    std::cout<<"# Cosmo free destructor\n";
    }
    if(bool_zhao){
        gsl_interp_accel_free(zhao_acc);
        gsl_spline_free(zhao_spline);
        bool_zhao=false;
    }
    if(bool_gen){
        gsl_interp_accel_free(gen_acc);
        gsl_spline_free(gen_spline);
        bool_gen=false;
    }
}
Exemple #7
0
int bath_js03_free_params()
{
  int i;
  
  i=0;
  while(BATH_JS03OpBra[i]>0) {
    gsl_interp_accel_free(BATH_JS03BathFunc[i].BATH_JS03_Ct_r_Spline_Acc);
    gsl_interp_accel_free(BATH_JS03BathFunc[i].BATH_JS03_Ct_i_Spline_Acc);
    gsl_spline_free(BATH_JS03BathFunc[i].BATH_JS03_Ct_r_Spline);
    gsl_spline_free(BATH_JS03BathFunc[i].BATH_JS03_Ct_i_Spline);
    i++;
  }

  return 0;
}
Exemple #8
0
static void comp_lens_power_spectrum(lensPowerSpectra lps)
{
#define WORKSPACE_NUM 100000
#define ABSERR 1e-12
#define RELERR 1e-12
#define TABLE_LENGTH 1000
  
  gsl_integration_workspace *workspace;
  gsl_function F;
  double result,abserr;
  double logltab[TABLE_LENGTH];
  double logpkltab[TABLE_LENGTH];
  double chimax;
  int i;
  
  //fill in bin information
  chiLim = lps->chiLim;
  if(lps->chis1 > lps->chis2)
    chimax = lps->chis1;
  else
    chimax = lps->chis2;
  
  fprintf(stderr,"doing lens pk - chiLim = %lf, chiMax = %lf\n",chiLim,chimax);
  
  //init
  workspace = gsl_integration_workspace_alloc((size_t) WORKSPACE_NUM);
  F.function = &lenspk_integrand;
  F.params = lps;
  
  //make table
  double lnlmin = log(wlData.lmin);
  double lnlmax = log(wlData.lmax);
  for(i=0;i<TABLE_LENGTH;++i)
    {
      logltab[i] = i*(lnlmax-lnlmin)/(TABLE_LENGTH-1) + lnlmin;
      
      lps->ell = exp(logltab[i]);
      gsl_integration_qag(&F,0.0,chimax,ABSERR,RELERR,(size_t) WORKSPACE_NUM,GSL_INTEG_GAUSS51,workspace,&result,&abserr);
      
      logpkltab[i] = log(result);
    }
  
  //free
  gsl_integration_workspace_free(workspace);
  
  //init splines and accels
  if(lps->spline != NULL)
    gsl_spline_free(lps->spline);
  lps->spline = gsl_spline_alloc(gsl_interp_akima,(size_t) (TABLE_LENGTH));
  gsl_spline_init(lps->spline,logltab,logpkltab,(size_t) (TABLE_LENGTH));
  if(lps->accel != NULL)
    gsl_interp_accel_reset(lps->accel);
  else
    lps->accel = gsl_interp_accel_alloc();
    
#undef TABLE_LENGTH
#undef ABSERR
#undef RELERR
#undef WORKSPACE_NUM
}
int calc_ave_delta_sigma_in_bin(double*R,int NR,double*delta_sigma,
				double lRlow,double lRhigh,
				double*ave_delta_sigma){
  int status = 0;

  gsl_spline*spline = gsl_spline_alloc(gsl_interp_cspline,NR);
  gsl_spline_init(spline,R,delta_sigma,NR);
  gsl_interp_accel*acc= gsl_interp_accel_alloc();
  gsl_integration_workspace * workspace
    = gsl_integration_workspace_alloc(workspace_size);

  integrand_params*params=malloc(sizeof(integrand_params));
  params->acc=acc;
  params->spline=spline;
  params->workspace=workspace;

  double Rlow=exp(lRlow),Rhigh=exp(lRhigh);

  do_integral(ave_delta_sigma,lRlow,lRhigh,params);
  *ave_delta_sigma *= 2./(Rhigh*Rhigh-Rlow*Rlow);

  gsl_spline_free(spline),gsl_interp_accel_free(acc);
  gsl_integration_workspace_free(workspace);
  free(params);
  return 0;
}
Exemple #10
0
void spline(double *YY, 
		double *X, double *Y, double *XX, int m1, int m2) {

	// m1: length of discrete extremas
	// m2: length of original data points

	gsl_interp_accel *acc = gsl_interp_accel_alloc ();
  	const gsl_interp_type *t = gsl_interp_cspline; 
  	gsl_spline *spline = gsl_spline_alloc (t, m1);

	/* Core function */

  	gsl_spline_init (spline, X, Y, m1);

	double m;
	
	if (m1 > 2 ) {
		for (int j = 0; j < m2; j++) {
			YY[j] = gsl_spline_eval (spline, XX[j], acc);
		} // end of for-j
	} // end of if

	else {
		m = (Y[1] - Y[0]) / (X[1] - X[0]);
		for (int j = 0; j < m2; j++) {
			YY[j] = Y[0] + m * (XX[j] - X[0]);		
		} // end of for-j
	} //end of else

	// delete[] xd;
	gsl_spline_free (spline);
  	gsl_interp_accel_free (acc);

}
void regrid_sed(double z,double *plam,double *pval,long finelength, \
				long sedlength,double *fineplam,double *finepval) {
	
    long ii;
    double x[sedlength],y[sedlength];
	
    for (ii=0;ii<sedlength;ii++) {
        x[ii] = *(plam+ii) * (1.0 + z);
        y[ii] = *(pval+ii);
    }
	
    gsl_interp_accel *acc = gsl_interp_accel_alloc();
    gsl_spline *spline    = gsl_spline_alloc(gsl_interp_cspline, sedlength);
    
    gsl_spline_init(spline, x, y, sedlength);
	
    for (ii=0; ii < finelength; ii++) {
        if (*(fineplam+ii)/(1.0 + z) < *(plam+0)) {
            *(finepval+ii) = 0.0;
        } else {
            *(finepval+ii) = gsl_spline_eval (spline, *(fineplam+ii), acc);
        }
        if (*(finepval+ii) < 0.0)
            *(finepval+ii) = 0.0;
    }
	
    gsl_spline_free(spline);
    gsl_interp_accel_free(acc);
}
Exemple #12
0
int
main (void)
{
  int N = 4;
  double x[4] = {0.00, 0.10,  0.27,  0.30};
  double y[4] = {0.15, 0.70, -0.10,  0.15}; /* Note: first = last 
                                               for periodic data */

  gsl_interp_accel *acc = gsl_interp_accel_alloc ();
  const gsl_interp_type *t = gsl_interp_cspline_periodic; 
  gsl_spline *spline = gsl_spline_alloc (t, N);

  int i; double xi, yi;

  printf ("#m=0,S=5\n");
  for (i = 0; i < N; i++)
    {
      printf ("%g %g\n", x[i], y[i]);
    }

  printf ("#m=1,S=0\n");
  gsl_spline_init (spline, x, y, N);

  for (i = 0; i <= 100; i++)
    {
      xi = (1 - i / 100.0) * x[0] + (i / 100.0) * x[N-1];
      yi = gsl_spline_eval (spline, xi, acc);
      printf ("%g %g\n", xi, yi);
    }
  
  gsl_spline_free (spline);
  gsl_interp_accel_free (acc);
  return 0;
}
void Interpolation::calculateOutputData(double *x, double *y)
{
	gsl_interp_accel *acc = gsl_interp_accel_alloc ();
	const gsl_interp_type *method;
	switch(d_method)
	{
		case 0:
			method = gsl_interp_linear;
			break;
		case 1:
			method = gsl_interp_cspline;
			break;
		case 2:
			method = gsl_interp_akima;
			break;
	}

	gsl_spline *interp = gsl_spline_alloc (method, d_n);
	gsl_spline_init (interp, d_x, d_y, d_n);

    double step = (d_to - d_from)/(double)(d_points - 1);
    for (int j = 0; j < d_points; j++)
	{
	   x[j] = d_from + j*step;
	   y[j] = gsl_spline_eval (interp, x[j], acc);
	}

	gsl_spline_free (interp);
	gsl_interp_accel_free (acc);
}
Exemple #14
0
int
main (void)
{
  int i;
  double xi, yi;
  double x[10], y[10];

  printf ("#m=0,S=2\n");

  for (i = 0; i < 10; i++)
    {
      x[i] = i + 0.5 * sin (i);
      y[i] = i + cos (i * i);
      printf ("%g %g\n", x[i], y[i]);
    }

  printf ("#m=1,S=0\n");

  {
    gsl_interp_accel *acc = gsl_interp_accel_alloc ();
    gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, 10);
    gsl_spline_init (spline, x, y, 10);

    for (xi = x[0]; xi < x[9]; xi += 0.01)
      {
        double yi = gsl_spline_eval (spline, xi, acc);
        printf ("%g %g\n", xi, yi);
      }
    gsl_spline_free (spline);
    gsl_interp_accel_free(acc);
  }
}
Exemple #15
0
cMorph::~cMorph()
{
	gsl_spline_free(splineAkimaPeriodic);
	gsl_interp_accel_free(interpolationAccelerator);
	splineAkimaPeriodic = NULL;
	interpolationAccelerator = NULL;
}
UNUSED static REAL8 XLALSimInspiralNRWaveformGetRefTimeFromRefFreq(
  UNUSED LALH5File* file,
  UNUSED REAL8 fRef
)
{
  #ifndef LAL_HDF5_ENABLED
  XLAL_ERROR(XLAL_EFAILED, "HDF5 support not enabled");
  #else
  /* NOTE: This is an internal function, it is expected that fRef is scaled
   * to correspond to the fRef with a total mass of 1 solar mass */
  LALH5File *curr_group = NULL;
  gsl_vector *omega_t_vec = NULL;
  gsl_vector *omega_w_vec = NULL;
  gsl_interp_accel *acc;
  gsl_spline *spline;
  REAL8 ref_time;
  curr_group = XLALH5GroupOpen(file, "Omega-vs-time");
  ReadHDF5RealVectorDataset(curr_group, "X", &omega_t_vec);
  ReadHDF5RealVectorDataset(curr_group, "Y", &omega_w_vec);
  acc = gsl_interp_accel_alloc();
  spline = gsl_spline_alloc(gsl_interp_cspline, omega_w_vec->size);
  gsl_spline_init(spline, omega_w_vec->data, omega_t_vec->data,
                  omega_t_vec->size);
  ref_time = gsl_spline_eval(spline, fRef * (LAL_MTSUN_SI * LAL_PI), acc);
  gsl_vector_free(omega_t_vec);
  gsl_vector_free(omega_w_vec);
  gsl_spline_free(spline);
  gsl_interp_accel_free(acc);
  return ref_time;
  #endif
}
UNUSED static REAL8 XLALSimInspiralNRWaveformGetInterpValueFromGroupAtPoint(
  UNUSED LALH5File* file,                 /**< Pointer to HDF5 file */
  UNUSED const char *groupName,           /**< Name of group in HDF file */
  UNUSED REAL8 ref_point                  /**< Point at which to evaluate */
  )
{
  #ifndef LAL_HDF5_ENABLED
  XLAL_ERROR(XLAL_EFAILED, "HDF5 support not enabled");
  #else
  LALH5File *curr_group = NULL;
  gsl_vector *curr_t_vec = NULL;
  gsl_vector *curr_y_vec = NULL;
  gsl_interp_accel *acc;
  gsl_spline *spline;
  REAL8 ret_val;
  curr_group = XLALH5GroupOpen(file, groupName);
  ReadHDF5RealVectorDataset(curr_group, "X", &curr_t_vec);
  ReadHDF5RealVectorDataset(curr_group, "Y", &curr_y_vec);
  acc = gsl_interp_accel_alloc();
  spline = gsl_spline_alloc(gsl_interp_cspline, curr_t_vec->size);
  gsl_spline_init(spline, curr_t_vec->data, curr_y_vec->data,
                  curr_t_vec->size);
  ret_val = gsl_spline_eval(spline, ref_point, acc);
  gsl_vector_free(curr_t_vec);
  gsl_vector_free(curr_y_vec);
  gsl_spline_free (spline);
  gsl_interp_accel_free (acc);
  return ret_val;
  #endif
}
Exemple #18
0
double calc_corr_at_R(double R,double*k,double*P,int Nk,int N,double h){
  double zero,psi,x,t,dpsi,f,PIsinht;
  double PI_h = PI/h;
  double PI_2 = PI*0.5;
  gsl_spline*Pspl = gsl_spline_alloc(gsl_interp_cspline,Nk);
  gsl_spline_init(Pspl,k,P,Nk);
  gsl_interp_accel*acc= gsl_interp_accel_alloc();

  double sum = 0;
  int i;
  for(i=0;i<N;i++){
    zero = i+1;
    psi = h*zero*tanh(sinh(h*zero)*PI_2);
    x = psi*PI_h;
    t = h*zero;
    PIsinht = PI*sinh(t);
    dpsi = (PI*t*cosh(t)+sinh(PIsinht))/(1+cosh(PIsinht));
    if (dpsi!=dpsi) dpsi=1.0;
    f = x*get_P(x,R,k,P,Nk,Pspl,acc);
    sum += f*sin(x)*dpsi;
  }

  gsl_spline_free(Pspl),gsl_interp_accel_free(acc);
  return sum/(R*R*R*PI*2);
}
Exemple #19
0
void free_lens_power_spectrum(lensPowerSpectra lps)
{
  if(lps->spline != NULL)
    gsl_spline_free(lps->spline);
  if(lps->accel != NULL)
    gsl_interp_accel_free(lps->accel);
  free(lps);
}
UNUSED static UINT4 XLALSimInspiralNRWaveformGetDataFromHDF5File(
  UNUSED REAL8Vector** output,            /**< Returned vector uncompressed */
  UNUSED LALH5File* pointer,              /**< Pointer to HDF5 file */
  UNUSED REAL8 totalMass,                 /**< Total mass of system for scaling */
  UNUSED REAL8 startTime,                 /**< Start time of veturn vector */
  UNUSED size_t length,                   /**< Length of returned vector */
  UNUSED REAL8 deltaT,                    /**< Sample rate of returned vector */
  UNUSED const char *keyName              /**< Name of vector to uncompress */
  )
{
  #ifndef LAL_HDF5_ENABLED
  XLAL_ERROR(XLAL_EFAILED, "HDF5 support not enabled");
  #else
  UINT4 idx;
  size_t comp_data_length;
  REAL8 massTime;
  gsl_interp_accel *acc;
  gsl_spline *spline;
  gsl_vector *knotsVector, *dataVector;
  LALH5File *group = XLALH5GroupOpen(pointer, keyName);
  knotsVector=dataVector=NULL;

  ReadHDF5RealVectorDataset(group, "X", &knotsVector);
  ReadHDF5RealVectorDataset(group, "Y", &dataVector);

  *output = XLALCreateREAL8Vector(length);

  comp_data_length = dataVector->size;
  /* SPLINE STUFF */
  acc = gsl_interp_accel_alloc();
  spline = gsl_spline_alloc(gsl_interp_cspline, comp_data_length);
  gsl_spline_init(spline, knotsVector->data, dataVector->data,
                  comp_data_length);

  for (idx = 0; idx < length; idx++)
  {
    massTime = (startTime + idx*deltaT) / (totalMass * LAL_MTSUN_SI);
    /* This if statement is used to catch the case where massTime at idx=0
     * ends up at double precision smaller than the first point in the
     * interpolation. In this case set it back to exactly the first point.
     * Sanity checking that we are not trying to use data below the
     * interpolation range is done elsewhere.
     */
    if ((idx == 0) && (massTime < knotsVector->data[0]))
    {
      massTime = knotsVector->data[0];
    }
    (*output)->data[idx] = gsl_spline_eval(spline, massTime, acc);
  }

  gsl_vector_free(knotsVector);
  gsl_vector_free(dataVector);
  gsl_spline_free (spline);
  gsl_interp_accel_free (acc);

  return XLAL_SUCCESS;
  #endif
}
Exemple #21
0
void XYSPline::respline()
{
#ifndef NOGSLLIB
    if (m_spline != 0) {
        gsl_spline_free(m_spline);
        m_spline = 0;
    }
#endif
}
void compute_correlation_func(int ObsNr, double *binsamdata, int snap, float mingalmass, float maxgalmass)
{
	double *r,*proj,*r_tmp,*proj_tmp;
	int ibin, ii, jj;
	char buf[1000];
	FILE *fa;
	gsl_spline *Proj_Spline;
	gsl_interp_accel *Proj_SplineAcc;

	NR=60;

	//printf("\ncalculating correlation function %0.2f < M < %0.2f\n",mingalmass,maxgalmass);

	r=malloc(NR*sizeof(double));
	proj=malloc(NR*sizeof(double));

	halomodel(r,proj,mingalmass,maxgalmass,snap);

	Proj_Spline=gsl_spline_alloc(gsl_interp_cspline,NR);
	Proj_SplineAcc=gsl_interp_accel_alloc();
	gsl_spline_init(Proj_Spline,r,proj,NR);

	//for(ii=0;ii<Nbins[snap][ObsNr]-1;ii++)
	//	printf("Nbins=%d r=%g\n",Nbins[snap][ObsNr], MCMC_Obs[ObsNr].Bin_low[snap][ii]+(MCMC_Obs[ObsNr].Bin_high[snap][ii]-MCMC_Obs[ObsNr].Bin_low[snap][ii])/2.)

	 for(ii=0;ii<Nbins[snap][ObsNr]-1;ii++)
		 binsamdata[ii]=gsl_spline_eval(Proj_Spline,MCMC_Obs[ObsNr].Bin_low[snap][ii]+(MCMC_Obs[ObsNr].Bin_high[snap][ii]-MCMC_Obs[ObsNr].Bin_low[snap][ii])/2.,Proj_SplineAcc);

#ifndef PARALLEL
	 //full3 - full PLANCK
	sprintf(buf, "%s/correlation_guo10_bug_fix_full_z0.02_%0.2f_%0.2f.txt",OutputDir, mingalmass,maxgalmass);
	if(!(fa = fopen(buf, "w")))
	{
		char sbuf[1000];
		sprintf(sbuf, "can't open file `%s'\n", buf);
		terminate(sbuf);
	}
	for(ii=0;ii<Nbins[snap][ObsNr]-1;ii++)
		fprintf(fa, "%g %g %g\n", MCMC_Obs[ObsNr].Bin_low[snap][ii]+(MCMC_Obs[ObsNr].Bin_high[snap][ii]-MCMC_Obs[ObsNr].Bin_low[snap][ii])/2.,binsamdata[ii],binsamdata[ii]*0.1);
	//for(ii=0;ii<NR;ii++)
	//fprintf(fa, "%g %g %g\n", r[ii],proj[ii],proj[ii]*0.1);
	fclose(fa);
#endif

	//original wrp calculation out of halo_model
	//printf("\n\n %g<M<%g",mingalmass,maxgalmass);
	//for(ii=0;ii<NR;ii++)
	//	printf("r=%g proj=%g\n",r[ii],proj[ii]);
  //interpolated into obs bins
	//for(ii=0;ii<Nbins[snap][ObsNr]-1;ii++)
	//	printf("%g %g %g\n", MCMC_Obs[ObsNr].Bin_low[snap][ii]+(MCMC_Obs[ObsNr].Bin_high[snap][ii]-MCMC_Obs[ObsNr].Bin_low[snap][ii])/2.,binsamdata[ii],binsamdata[ii]*0.1);

	 free(r);
	 free(proj);
	 gsl_spline_free(Proj_Spline);
	 gsl_interp_accel_free(Proj_SplineAcc);
}
Exemple #23
0
	Spline::~Spline()
	{
		if (_spline) {
			gsl_spline_free(_spline);
		}

		if (_accelerator) {
			gsl_interp_accel_free(_accelerator);
		}
	}
Exemple #24
0
XYSPline::~XYSPline()
{
#ifndef NOGSLLIB
    if (m_spline != 0)
        gsl_spline_free(m_spline);

    if (m_accel != 0)
        gsl_interp_accel_free(m_accel);
#endif
}
Exemple #25
0
void KKtransform::end() {
	interpolate();
	transform();
	inOut.writeData(txt);
	//if (inOut.check) check();
	gsl_spline_free(spline);
	gsl_interp_accel_free(acc);
	gsl_integration_workspace_free (wspace);
	return;
}
Exemple #26
0
filter::~filter(){
  if(init){
    gsl_spline_free(spline);
    gsl_interp_accel_free(acc);
  }
  if (lambda != NULL){
    delete [] lambda;
    delete [] response;
  }
}
Exemple #27
0
void end_mask(void)
{
  //////
  // Frees all memory related to mask and N(z)
  if(mask_set)
    free(mask);
  if(dndz_set) {
    gsl_interp_accel_free(cute_intacc_dndz);
    gsl_spline_free(cute_spline_dndz);
  }
}
vector<carmen_ackerman_path_point_t>
simulate_car_from_parameters(TrajectoryLookupTable::TrajectoryDimensions &td,
		TrajectoryLookupTable::TrajectoryControlParameters &tcp, double v0, double i_phi,
		TrajectoryLookupTable::CarLatencyBuffer car_latency_buffer,	bool display_phi_profile)
{
	vector<carmen_ackerman_path_point_t> path;
	if (!tcp.valid)
	{
		printf("Warning: invalid TrajectoryControlParameters tcp in simulate_car_from_parameters()\n");
		return (path);
	}

	// Create phi profile

	gsl_interp_accel *acc;
	gsl_spline *phi_spline;
	if (tcp.has_k1)
	{
		double knots_x[4] = {0.0, tcp.tt / 4.0, tcp.tt / 2.0, tcp.tt};
		double knots_y[4] = {i_phi, tcp.k1, tcp.k2, tcp.k3};
		acc = gsl_interp_accel_alloc();
		const gsl_interp_type *type = gsl_interp_cspline;
		phi_spline = gsl_spline_alloc(type, 4);
		gsl_spline_init(phi_spline, knots_x, knots_y, 4);
	}
	else
	{
		double knots_x[3] = {0.0, tcp.tt / 2.0, tcp.tt};
		double knots_y[3] = {i_phi, tcp.k2, tcp.k3};
		acc = gsl_interp_accel_alloc();
		const gsl_interp_type *type = gsl_interp_cspline;
		phi_spline = gsl_spline_alloc(type, 3);
		gsl_spline_init(phi_spline, knots_x, knots_y, 3);
	}
	print_phi_profile_temp(phi_spline, acc, tcp.tt, display_phi_profile);

	Command command;
	Robot_State robot_state;

	double distance_traveled = compute_path_via_simulation(robot_state, command, path, tcp, phi_spline, acc, v0, i_phi, car_latency_buffer);

	gsl_spline_free(phi_spline);
	gsl_interp_accel_free(acc);
	td.dist = sqrt(robot_state.pose.x * robot_state.pose.x + robot_state.pose.y * robot_state.pose.y);
	td.theta = atan2(robot_state.pose.y, robot_state.pose.x);
	td.d_yaw = robot_state.pose.theta;
	td.phi_i = i_phi;
	td.v_i = v0;
	tcp.vf = command.v;
	tcp.sf = distance_traveled;
	td.control_parameters = tcp;

	return (path);
}
Exemple #29
0
void ssm_calc_free(ssm_calc_t *calc, ssm_nav_t *nav)
{
    gsl_rng_free(calc->randgsl);

    if (nav->implementation == SSM_ODE  || nav->implementation == SSM_EKF){

        gsl_odeiv2_step_free(calc->step);
        gsl_odeiv2_evolve_free(calc->evolve);
        gsl_odeiv2_control_free(calc->control);

        if(nav->implementation == SSM_EKF){
            gsl_vector_free(calc->_pred_error);
            gsl_matrix_free(calc->_St);
            gsl_matrix_free(calc->_Stm1);
            gsl_matrix_free(calc->_Rt);
            gsl_matrix_free(calc->_Ht);
            gsl_matrix_free(calc->_Kt);
            gsl_matrix_free(calc->_Tmp_N_SV_N_TS);
            gsl_matrix_free(calc->_Tmp_N_TS_N_SV);
            gsl_matrix_free(calc->_Q);
            gsl_matrix_free(calc->_FtCt);
            gsl_matrix_free(calc->_Ft);
            gsl_vector_free(calc->_eval);
            gsl_matrix_free(calc->_evec);
            gsl_eigen_symmv_free(calc->_w_eigen_vv);
        }

    } else if (nav->implementation == SSM_SDE){
        free(calc->y_pred);
    } else if (nav->implementation == SSM_PSR){
        ssm_psr_free(calc);
    }

    free(calc->to_be_sorted);
    free(calc->index_sorted);

    if(calc->covariates_length){
        int k;
        for(k=0; k< calc->covariates_length; k++) {
            if(calc->spline[k]){
                gsl_spline_free(calc->spline[k]);
            }
            if(calc->acc[k]){
                gsl_interp_accel_free(calc->acc[k]);
            }
        }

        free(calc->spline);
        free(calc->acc);
    }

    free(calc);
}
Exemple #30
0
NeutrinoDISCrossSectionsFromTables::~NeutrinoDISCrossSectionsFromTables(){
  if(is_init){
    // allocate all gsl interpolators
    for ( auto it = xs_inter.begin(); it != xs_inter.end(); it++){
      gsl_spline_free(*it);
    }
    // allocate all gsl interpolators accelerators
    for ( auto it = xs_acc.begin(); it != xs_acc.end(); it++){
      gsl_interp_accel_free(*it);
    }
  }
}