コード例 #1
0
ファイル: GSLIntegrator.cpp プロジェクト: mikaem/PMFpack
 GSLIntegrator::GSLIntegrator(double **_parameters)
 : Integrator(_parameters)
 {
   F.function = &gslfunction;    
   F.params = parameters;
   w = gsl_integration_workspace_alloc (1000);      
   table = gsl_integration_glfixed_table_alloc(192);   
 }
コード例 #2
0
double annihilation_total(double E)
{
	const gsl_integration_glfixed_table *gl_table;
	gl_table = gsl_integration_glfixed_table_alloc(pts);
	gsl_function F;
	F.function = &annihilation;
	F.params = (void*) &E;

	return gsl_integration_glfixed (&F, 0.0, M_PI, gl_table);
}
コード例 #3
0
void fred2_solver(double      a,
                  double      b,
                  gsl_vector* t,
                  gsl_vector* f,
                  gsl_vector* w)
{
  gsl_integration_glfixed_table* glgrid = gsl_integration_glfixed_table_alloc(MAX);
  gsl_permutation*               p      = gsl_permutation_alloc(MAX);
  gsl_matrix*                    lhs    = gsl_matrix_alloc(MAX, MAX);
  gsl_matrix*                    ktilde = gsl_matrix_alloc(MAX, MAX);
  gsl_matrix*                    ak     = gsl_matrix_alloc(MAX, MAX);
  gsl_vector*                    g      = gsl_vector_alloc(MAX);

  int i, j, error, s;
  double ptsi, wghtsi;

  // set Gauss-Legendre integration points and weights
  for (i = 0; i < MAX; i++)
  {
    error = gsl_integration_glfixed_point(a, b, i, &ptsi, &wghtsi, glgrid);
    gsl_vector_set(t, i, ptsi);
    gsl_vector_set(w, i, wghtsi);
  }

  kernel(ak, t, t);
  aux_g(g, t);

  // fill in unit matrix first
  gsl_matrix_set_identity(lhs);

  for (i = 0; i < MAX; i++)
  {
    for (j = 0; j < MAX; j++)
    {
      gsl_matrix_set(ktilde, i, j, gsl_matrix_get(ak, i, j) * gsl_vector_get(w, j));
    }
  }

  // set up LHS matrix
  error = gsl_matrix_sub(lhs, ktilde);

  gsl_linalg_LU_decomp(lhs, p, &s);
  gsl_linalg_LU_solve(lhs, p, g, f);

  gsl_integration_glfixed_table_free(glgrid);
  gsl_permutation_free(p);
  gsl_matrix_free(lhs);
  gsl_matrix_free(ktilde);
  gsl_vector_free(g);
  gsl_matrix_free(ak);
  return;
}
コード例 #4
0
ファイル: integration.c プロジェクト: AbhimanyuAryan/rb-gsl
static VALUE rb_gsl_integration_glfixed_table_alloc(VALUE klass, VALUE n)
{
  gsl_integration_glfixed_table *t;
  t = gsl_integration_glfixed_table_alloc(FIX2INT(n));
  return Data_Wrap_Struct(cgsl_integration_glfixed_table, 0, gsl_integration_glfixed_table_free, t);
}