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 next 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();
}
Re: about some class equivalent to BOOST [message #48848 is a reply to message #48838] Wed, 11 October 2017 23:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Tue, 10 October 2017 19:24
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.


I am confused. 'reinterpret_cast' is C++ core language feature...

Mirek
Re: about some class equivalent to BOOST [message #48852 is a reply to message #48848] Thu, 12 October 2017 19:29 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Wed, 11 October 2017 23:18


I am confused. 'reinterpret_cast' is C++ core language feature...

Mirek


I am confused too ... Embarassed
I saw it for the first time and I believed was part of the boost library.

Thanks,
Luigi

[Updated on: Thu, 12 October 2017 19:30]

Report message to a moderator

Previous Topic: problem when parse html with XMLParser
Next Topic: Request: please make Range classes compatible with Vector!
Goto Forum:
  


Current Time: Wed Apr 24 18:23:05 CEST 2024

Total time taken to generate the page: 0.02436 seconds