Go to the documentation of this file.
21 #include <Eigen/Dense>
28 if (
N == 1)
return 0.0;
29 assert(
j >= 0 &&
size_t(
j) <
N);
30 const double dTheta =
M_PI / (
N - 1);
31 return -
cos(dTheta *
j);
35 if (
N == 1)
return (
a +
b) / 2;
36 return a + (
b -
a) * (
Point(
N,
j) + 1.0) / 2.0;
46 const double dTheta =
M_PI / (
N - 1);
47 for (
size_t j = 0;
j < half; ++
j) {
48 double c =
cos(
j * dTheta);
50 points(
N - 1 -
j) =
c;
60 const double T1 = (
a +
b) / 2,
T2 = (
b -
a) / 2;
68 std::optional<size_t> coincidentPoint(
size_t N,
double x,
double a,
double b,
double tol = 1
e-12) {
69 if (
N == 0)
return std::nullopt;
71 double mid = (
a +
b) / 2;
75 double y = 1.0 - 2.0 * (
x -
a) / (
b -
a);
76 if (y < -1.0 || y > 1.0)
return std::nullopt;
77 double dTheta =
M_PI / (
N - 1);
79 size_t jRounded =
static_cast<size_t>(
std::round(jCandidate));
80 if (
std::abs(jCandidate - jRounded) <
tol)
return jRounded;
86 Vector signedDistances(
size_t N,
double x,
double a,
double b) {
89 for (
size_t j = 0;
j <
N;
j++) {
90 const double dj =
x - points[
j];
97 Vector differentiationMatrixRow(
size_t N,
const Vector& points,
size_t i) {
99 const size_t K =
N - 1;
100 double xi = points(
i);
101 for (
size_t j = 0;
j <
N;
j++) {
104 if (
i == 0 ||
i ==
K)
105 row(
j) = (
i == 0 ? -1 : 1) * (2.0 *
K *
K + 1) / 6.0;
110 double xj = points(
j);
111 double ci = (
i == 0 ||
i ==
K) ? 2. : 1.;
112 double cj = (
j == 0 ||
j ==
K) ? 2. : 1.;
113 double t = ((
i +
j) % 2) == 0 ? 1 : -1;
114 row(
j) = (ci / cj) *
t / (
xi - xj);
123 const Vector distances = signedDistances(
N,
x,
a,
b);
126 if (
auto j = coincidentPoint(
N,
x,
a,
b)) {
134 weights(0) = 0.5 / distances(0);
137 double d = weights(0),
s = -1;
138 for (
size_t j = 1;
j <
N - 1;
j++,
s = -
s) {
139 weights(
j) =
s / distances(
j);
144 weights(
N - 1) = 0.5 *
s / distances(
N - 1);
152 if (
auto j = coincidentPoint(
N,
x,
a,
b)) {
154 return differentiationMatrixRow(
N,
Points(
N), *
j) / ((
b -
a) / 2.0);
166 const Vector distances = signedDistances(
N,
x,
a,
b);
167 for (
size_t j = 0;
j <
N;
j++) {
168 if (
j == 0 ||
j ==
N - 1) {
174 double t = (
j % 2 == 0) ? 1 : -1;
176 double c =
t / distances(
j);
178 k += (
w *
c / distances(
j));
185 for (
size_t j = 0;
j <
N;
j++) {
188 if (
j == 0 ||
j ==
N - 1) {
194 weightDerivatives(
j) = (
w * -
s / (
g * distances(
j) * distances(
j))) -
195 (
w * -
s * k / (
g2 * distances(
j)));
199 return weightDerivatives;
210 for (
size_t i = 0;
i <
N;
i++) {
211 D.row(
i) = differentiationMatrixRow(
N, points,
i);
233 const auto&
S =
svd.singularValues();
235 for (
size_t i = 0;
i <
N - 1; ++
i) invS(
i,
i) = 1.0 /
S(
i);
266 const size_t K =
N - 1,
270 weights(0) = 1.0 / (
K2 +
K % 2 - 1);
271 weights(
N - 1) = weights(0);
274 const size_t mid = (
N - 1) / 2;
275 double dTheta =
M_PI /
K;
276 for (
size_t i = 1;
i <= mid; ++
i) {
277 double w = (
K % 2 == 0) ? 1 -
cos(
i *
M_PI) / (
K2 - 1) : 1;
278 const size_t last_k =
K / 2 +
K % 2 - 1;
279 const double theta =
i * dTheta;
280 for (
size_t k = 1; k <= last_k; ++k)
281 w -= 2.0 *
cos(2 * k * theta) / (4 * k * k - 1);
284 weights(
N - 1 -
i) =
w;
309 for (
size_t j = 0;
j <
N;
j++) fvals(
j) =
f(points(
j));
Pseudo-spectral parameterization for Chebyshev polynomials of the second kind.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double d[K][N]
static DiffMatrix DifferentiationMatrix(size_t N)
static Matrix IntegrationMatrix(size_t N)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
static const Cal3Bundler K2(625, 1e-3, 1e-3)
Jet< T, N > acos(const Jet< T, N > &f)
Jet< T, N > cos(const Jet< T, N > &f)
const MATRIX::ConstRowXpr row(const MATRIX &A, size_t j)
Pose3 g2(g1.expmap(h *V1_g1))
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
void g(const string &key, int i)
void svd(const Matrix &A, Matrix &U, Vector &S, Matrix &V)
static Weights IntegrationWeights(size_t N)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Two-sided Jacobi SVD decomposition of a rectangular matrix.
static Weights CalculateWeights(size_t N, double x, double a=-1, double b=1)
static Vector Points(size_t N)
All Chebyshev points.
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
static Weights DoubleIntegrationWeights(size_t N)
static Vector vector(std::function< double(double)> f, size_t N, double a=-1, double b=1)
Create matrix of values at Chebyshev points given vector-valued function.
static double Point(size_t N, int j)
Specific Chebyshev point, within [-1,1] interval.
static Weights DerivativeWeights(size_t N, double x, double a=-1, double b=1)
gtsam
Author(s):
autogenerated on Fri Mar 28 2025 03:01:13