Functions
_test_eigen_spline.cxx File Reference
#include <vector>
#include <iostream>
#include <Eigen/Core>
#include <unsupported/Eigen/Splines>

Go to the source code of this file.

Functions

double uvalue (double x, double low, double high)
 
VectorXd uvalues (VectorXd xvals)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file _test_eigen_spline.cxx.

28 {
29  typedef Spline<double,1> Spline2d;
30 
31  const VectorXd xvals = (VectorXd(5) << 1,2,3,4,6).finished();
32  const VectorXd yvals = xvals.array().square();
33  const Spline2d spline = SplineFitting<Spline2d>::Interpolate(yvals.transpose(), 3, uvalues(xvals).transpose());
34 
35  const double step = 0.1;
36  for (double x = 1; x < 6 + 0.5*step; x += step)
37  {
38  const double uv = uvalue(x, xvals.minCoeff(), xvals.maxCoeff());
39  std::cout << "(" << x << "," << spline(uv).transpose() << "," << spline.derivatives<1>(uv) << ")\n";
40  }
41  std::cout << std::endl;
42 }
VectorXd uvalues(VectorXd xvals)
def Interpolate(x1, y1, x2, y2, yvalue)
Definition: HandyFuncs.py:200
list x
Definition: train.py:276
double uvalue(double x, double low, double high)
QTextStream & endl(QTextStream &s)
double uvalue ( double  x,
double  low,
double  high 
)

Definition at line 11 of file _test_eigen_spline.cxx.

12 {
13  return (x - low)/(high-low);
14 }
list x
Definition: train.py:276
VectorXd uvalues ( VectorXd  xvals)

Definition at line 16 of file _test_eigen_spline.cxx.

17 {
18  const double low = xvals.minCoeff();
19  const double high = xvals.maxCoeff();
20  for (int i=0; i<xvals.size(); ++i)
21  {
22  xvals(i) = uvalue(xvals(i), low, high);
23  }
24  return xvals;
25 }
double uvalue(double x, double low, double high)