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 |
|
forlano
Messages: 1189 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 ¶ms= *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 ¶ms= *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 *>(¶ms);
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();
}
|
|
|
|
|
Goto Forum:
Current Time: Sat Jun 15 23:25:22 CEST 2024
Total time taken to generate the page: 0.02496 seconds
|