Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » about some class equivalent to BOOST
about some class equivalent to BOOST [message #48838] Tue, 10 October 2017 19:24 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I am trying to use the Gnu Scientific Library. I have found an example to apply what I need but they use even use the BOOST library.
I wonder if we U++ lovers have something equivalent to perform the same job.
The code that I want to replace is this

f_params &params= *reinterpret_cast<f_params *>(p);

inside the function f.

Many thanks,
Luigi

PS: Here is the full code

#include <cmath>
#include <iostream>
#include <boost/shared_ptr.hpp>


#include <gsl/gsl_integration.h>

struct f_params {
  double a;
  double phi;
};

double f(double x, void *p)
{
  f_params &params= *reinterpret_cast<f_params *>(p);
  return sin(params.a*x+params.phi);
}

void dointeg(void)
{
  f_params params;
  params.a=1.0;
  params.phi=0.0;
  
  gsl_function F;
  F.function = &f;
  F.params = reinterpret_cast<void *>(&params);

  double result, error;
  size_t neval;

  const double xlow=0;
  const double xhigh=10;
  const double epsabs=1e-4;
  const double epsrel=1e-4;
  
  int code=gsl_integration_qng (&F, xlow, xhigh, epsabs, epsrel, &result, &error, &neval);
}

int main(void)
{
  dointeg();
}
 
Read Message
Read Message
Read Message
Previous Topic: problem when parse html with XMLParser
Next Topic: Request: please make Range classes compatible with Vector!
Goto Forum:
  


Current Time: Sat Apr 20 13:22:51 CEST 2024

Total time taken to generate the page: 0.69937 seconds