Example #1
0
int main()
{
#  include "legendre_p.ipp"
#  include "legendre_p_large.ipp"

   add_data(legendre_p);
   add_data(legendre_p_large);

   unsigned data_total = data.size();

   screen_data([](const std::vector<double>& v){  return boost::math::legendre_q(v[0], v[1]);  }, [](const std::vector<double>& v){ return v[3];  });


#if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
   screen_data([](const std::vector<double>& v){  return gsl_sf_legendre_Ql(v[0], v[1]);  }, [](const std::vector<double>& v){ return v[3];  });
#endif

   unsigned data_used = data.size();
   std::string function = "legendre Q[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
   std::string function_short = "legendre Q";

   double time;

   time = exec_timed_test([](const std::vector<double>& v){  return boost::math::legendre_q(v[0], v[1]);  });
   std::cout << time << std::endl;
#if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH))
   report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name());
#endif
   report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name());
   //
   // Boost again, but with promotion to long double turned off:
   //
#if !defined(COMPILER_COMPARISON_TABLES)
   if(sizeof(long double) != sizeof(double))
   {
      time = exec_timed_test([](const std::vector<double>& v){  return boost::math::legendre_q(v[0], v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>()));  });
      std::cout << time << std::endl;
#if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH))
      report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name() + "[br]promote_double<false>");
#endif
      report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name() + "[br]promote_double<false>");
   }
#endif


#if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
   time = exec_timed_test([](const std::vector<double>& v){  return gsl_sf_legendre_Ql(v[0], v[1]);  });
   std::cout << time << std::endl;
   report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION);
#endif

   return 0;
}
Example #2
0
int quad_x2_singularity(double y, int n, double *x_gauss, double *w_gauss, double *x, double *w)
{
  int i, j, k, n1, n2, n3;
  double z, temp, z_temp;
  for(i=1;i<=n;i++)
    {
      x[i] = x_gauss[i];
    }


  for(i=1;i<=n;i++)
    {
      z = 0.0;
      
      z_temp = 0.0;
      
      for(j=0;j<=(n-2);j++)
	{
	  temp = floor((j-1)/2.0);
	  n3 = (int)temp;
	  for(k=0;k<=n3;k++)
	    {
	      z_temp = z_temp + (((2*j) - (4*k) -1)*((2*j) + 1)*gsl_sf_legendre_Ql(j-1-(2*k),y)*legendre_poly(j,x_gauss[i]));
	    }
	}
      z = z - z_temp;
      
      for(j=0;j<=n-1;j++)
	{
	  if((j%2)==0){
	    z = z + (((2.0*j + 1.0)/2.0)*legendre_poly(j,x_gauss[i])*((1.0/(y-1.0))-(1.0/(y+1.0))));
	  } else {
	    z = z + (((2.0*j + 1.0)/2.0)*legendre_poly(j,x_gauss[i])*((1.0/(y-1.0))+(1.0/(y+1.0))));
	  }
	}
      w[i] = w_gauss[i]*z;
    }
  return 0;
}
Example #3
0
int quad_x_singularity(double y, int n, double *x_gauss, double *w_gauss, double *x, double *w)
{
  int i, j;
  double z;
  
  for(i=1;i<=n;i++)
    {
      x[i] = x_gauss[i];
    }

  for(i=1;i<=n;i++)
    {
      z = 0.0;
      for(j=0;j<=n-1;j++)
	{
	  z = z + (((2*j) + 1)*legendre_poly(j,x_gauss[i])*gsl_sf_legendre_Ql(j,y));
	}
      
      w[i] = w_gauss[i]*z;
    }
  return 0;
}
Example #4
0
double r_func(int i, double x)
{
  return (gsl_sf_legendre_Ql(i,x) + ((0.25)*log((x-1.0)*(x-1.0))));
}