Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
util
test
_test_eigen_spline.cxx
Go to the documentation of this file.
1
// https://forum.kde.org/viewtopic.php?f=74&t=98871
2
// https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=736985
3
#include <vector>
4
#include <iostream>
5
6
#include <Eigen/Core>
7
#include <unsupported/Eigen/Splines>
8
9
using namespace
Eigen
;
10
11
double
uvalue
(
double
x
,
double
low,
double
high)
12
{
13
return
(x - low)/(high-low);
14
}
15
16
VectorXd
uvalues
(VectorXd xvals)
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
}
26
27
int
main
(
int
argc
,
char
*
argv
[])
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
}
uvalues
VectorXd uvalues(VectorXd xvals)
Definition:
_test_eigen_spline.cxx:16
Eigen
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
main
int main(int argc, char *argv[])
Definition:
_test_eigen_spline.cxx:27
HandyFuncs.Interpolate
def Interpolate(x1, y1, x2, y2, yvalue)
Definition:
HandyFuncs.py:200
MakeVectorFile.step
tuple step
Definition:
MakeVectorFile.py:59
train.x
list x
Definition:
train.py:276
uvalue
double uvalue(double x, double low, double high)
Definition:
_test_eigen_spline.cxx:11
test_gen_rays_pdsp.argc
argc
Definition:
test_gen_rays_pdsp.py:6
generate_CCQE_events.spline
string spline
Definition:
generate_CCQE_events.py:27
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11