Go to the documentation of this file.
26 #ifndef O2SCL_SMOOTH_FUNC_H
27 #define O2SCL_SMOOTH_FUNC_H
31 #include <gsl/gsl_qrng.h>
32 #include <o2scl/vector.h>
34 #ifndef DOXYGEN_NO_O2NS
87 O2SCL_ERR2(
"Cannot call set_n() with argument 0 in ",
96 template<
class vec2_t>
void set_step(vec2_t &v) {
101 step.resize(v.size());
121 gsl_qrng *gq=gsl_qrng_alloc(gsl_qrng_sobol,nv);
123 std::vector<double> v(nv);
124 vec_t
x2(nv), y2(nv);
126 for(
size_t j=0;j<nv;j++) {
131 for(
size_t i=0;i<
N;i++) {
134 gsl_qrng_get(gq,&(v[0]));
135 for(
size_t j=0;j<nv;j++) {
136 x2[j]=(1.0+(v[j]*2.0-1.0)*
step[j%
step.size()])*x[j];
140 int fret=(*f)(nv,
x2,y2);
144 for(
size_t j=0;j<nv;j++) {
156 for(
size_t j=0;j<nv;j++) {
157 y[j]/=((double)count);
167 #ifndef DOXYGEN_NO_O2NS
@ exc_efailed
generic failure
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
size_t N
Number of points in the Sobol sequence (default 40)
func_t * f
The pointer to the original function.
void vector_copy(const vec_t &src, vec2_t &dest)
Simple vector copy.
static const double x2[5]
@ exc_einval
invalid argument supplied by user
void set_func(func_t &func)
Set the base function.
void set_n(size_t n_new)
Set the number of points to use in the average.
Smooth a function by averaging in a neighborhood of points defined by a Sobol sequence.
int operator()(size_t nv, const vec_t &x, vec_t &y)
Evaluate the smoothed function.
void set_step(vec2_t &v)
Set the stepsize.
std::vector< double > step
Step size defining the neighborhood (default 0.01)
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).