Finite difference method example
We calculate central differences for a given function and compare it to the analytical solution.
#include <Vc/Vc>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "../tsc.h"
#include <common/macros.h>
static constexpr std::size_t N = 10240000, PrintStep = 1000000;
static constexpr float epsilon = 1e-7f;
static constexpr float lower = 0.f;
static constexpr float upper = 40000.f;
static constexpr float h = (upper - lower) / N;
static inline float  fu(
float x) { 
return ( 
std::sin(x) ); }
 
static inline float dfu(
float x) { 
return ( 
std::cos(x) ); }
 
#ifdef USE_SCALAR_SINCOS
  }
  return r;
#else
#endif
}
#ifdef USE_SCALAR_SINCOS
  }
  return r;
#else
#endif
}
 
    Vc::free(dy_points - float_v::Size + 1);
 
    return 0;
}