Blender V4.3
numeric.h
Go to the documentation of this file.
1// Copyright (c) 2007, 2008_WIN32 libmv authors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to
5// deal in the Software without restriction, including without limitation the
6// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7// sell copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19// IN THE SOFTWARE.
20//
21// Matrix and vector classes, based on Eigen2.
22//
23// Avoid using Eigen2 classes directly; instead typedef them here.
24
25#ifndef LIBMV_NUMERIC_NUMERIC_H
26#define LIBMV_NUMERIC_NUMERIC_H
27
28#include <Eigen/Cholesky>
29#include <Eigen/Core>
30#include <Eigen/Eigenvalues>
31#include <Eigen/Geometry>
32#include <Eigen/LU>
33#include <Eigen/QR>
34#include <Eigen/SVD>
35
36#if !defined(__MINGW64__)
37# if defined(_WIN32) || defined(__APPLE__) || defined(__NetBSD__) || \
38 defined(__HAIKU__)
39inline void sincos(double x, double* sinx, double* cosx) {
40 *sinx = sin(x);
41 *cosx = cos(x);
42}
43# endif
44#endif // !__MINGW64__
45
46#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
47inline long lround(double d) {
48 return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
49}
50# if _MSC_VER < 1800
51inline int round(double d) {
52 return (d > 0) ? int(d + 0.5) : int(d - 0.5);
53}
54# endif // _MSC_VER < 1800
55typedef unsigned int uint;
56#endif // _WIN32
57
58namespace libmv {
59
60typedef Eigen::MatrixXd Mat;
61typedef Eigen::VectorXd Vec;
62
63typedef Eigen::MatrixXf Matf;
64typedef Eigen::VectorXf Vecf;
65
66typedef Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic> Matu;
67typedef Eigen::Matrix<unsigned int, Eigen::Dynamic, 1> Vecu;
68typedef Eigen::Matrix<unsigned int, 2, 1> Vec2u;
69
70typedef Eigen::Matrix<double, 2, 2> Mat2;
71typedef Eigen::Matrix<double, 2, 3> Mat23;
72typedef Eigen::Matrix<double, 3, 3> Mat3;
73typedef Eigen::Matrix<double, 3, 4> Mat34;
74typedef Eigen::Matrix<double, 3, 5> Mat35;
75typedef Eigen::Matrix<double, 4, 1> Mat41;
76typedef Eigen::Matrix<double, 4, 3> Mat43;
77typedef Eigen::Matrix<double, 4, 4> Mat4;
78typedef Eigen::Matrix<double, 4, 6> Mat46;
79typedef Eigen::Matrix<float, 2, 2> Mat2f;
80typedef Eigen::Matrix<float, 2, 3> Mat23f;
81typedef Eigen::Matrix<float, 3, 3> Mat3f;
82typedef Eigen::Matrix<float, 3, 4> Mat34f;
83typedef Eigen::Matrix<float, 3, 5> Mat35f;
84typedef Eigen::Matrix<float, 4, 3> Mat43f;
85typedef Eigen::Matrix<float, 4, 4> Mat4f;
86typedef Eigen::Matrix<float, 4, 6> Mat46f;
87
88typedef Eigen::Matrix<double, 3, 3, Eigen::RowMajor> RMat3;
89typedef Eigen::Matrix<double, 4, 4, Eigen::RowMajor> RMat4;
90
91typedef Eigen::Matrix<double, 2, Eigen::Dynamic> Mat2X;
92typedef Eigen::Matrix<double, 3, Eigen::Dynamic> Mat3X;
93typedef Eigen::Matrix<double, 4, Eigen::Dynamic> Mat4X;
94typedef Eigen::Matrix<double, Eigen::Dynamic, 2> MatX2;
95typedef Eigen::Matrix<double, Eigen::Dynamic, 3> MatX3;
96typedef Eigen::Matrix<double, Eigen::Dynamic, 4> MatX4;
97typedef Eigen::Matrix<double, Eigen::Dynamic, 5> MatX5;
98typedef Eigen::Matrix<double, Eigen::Dynamic, 6> MatX6;
99typedef Eigen::Matrix<double, Eigen::Dynamic, 7> MatX7;
100typedef Eigen::Matrix<double, Eigen::Dynamic, 8> MatX8;
101typedef Eigen::Matrix<double, Eigen::Dynamic, 9> MatX9;
102typedef Eigen::Matrix<double, Eigen::Dynamic, 15> MatX15;
103typedef Eigen::Matrix<double, Eigen::Dynamic, 16> MatX16;
104
105typedef Eigen::Vector2d Vec2;
106typedef Eigen::Vector3d Vec3;
107typedef Eigen::Vector4d Vec4;
108typedef Eigen::Matrix<double, 5, 1> Vec5;
109typedef Eigen::Matrix<double, 6, 1> Vec6;
110typedef Eigen::Matrix<double, 7, 1> Vec7;
111typedef Eigen::Matrix<double, 8, 1> Vec8;
112typedef Eigen::Matrix<double, 9, 1> Vec9;
113typedef Eigen::Matrix<double, 10, 1> Vec10;
114typedef Eigen::Matrix<double, 11, 1> Vec11;
115typedef Eigen::Matrix<double, 12, 1> Vec12;
116typedef Eigen::Matrix<double, 13, 1> Vec13;
117typedef Eigen::Matrix<double, 14, 1> Vec14;
118typedef Eigen::Matrix<double, 15, 1> Vec15;
119typedef Eigen::Matrix<double, 16, 1> Vec16;
120typedef Eigen::Matrix<double, 17, 1> Vec17;
121typedef Eigen::Matrix<double, 18, 1> Vec18;
122typedef Eigen::Matrix<double, 19, 1> Vec19;
123typedef Eigen::Matrix<double, 20, 1> Vec20;
124
125typedef Eigen::Vector2f Vec2f;
126typedef Eigen::Vector3f Vec3f;
127typedef Eigen::Vector4f Vec4f;
128
129typedef Eigen::VectorXi VecXi;
130
131typedef Eigen::Vector2i Vec2i;
132typedef Eigen::Vector3i Vec3i;
133typedef Eigen::Vector4i Vec4i;
134
135typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
137
138typedef Eigen::NumTraits<double> EigenDouble;
139
140using Eigen::Dynamic;
141using Eigen::Map;
142using Eigen::Matrix;
143
144// Find U, s, and VT such that
145//
146// A = U * diag(s) * VT
147//
148template <typename TMat, typename TVec>
149inline void SVD(TMat* /*A*/, Vec* /*s*/, Mat* /*U*/, Mat* /*VT*/) {
150 assert(0);
151}
152
153// Solve the linear system Ax = 0 via SVD. Store the solution in x, such that
154// ||x|| = 1.0. Return the singluar value corresponding to the solution.
155// Destroys A and resizes x if necessary.
156// TODO(maclean): Take the SVD of the transpose instead of this zero padding.
157template <typename TMat, typename TVec>
158double Nullspace(TMat* A, TVec* nullspace) {
159 Eigen::JacobiSVD<TMat> svd(*A, Eigen::ComputeFullV);
160 (*nullspace) = svd.matrixV().col(A->cols() - 1);
161 if (A->rows() >= A->cols()) {
162 return svd.singularValues()(A->cols() - 1);
163 } else {
164 return 0.0;
165 }
166}
167
168// Solve the linear system Ax = 0 via SVD. Finds two solutions, x1 and x2, such
169// that x1 is the best solution and x2 is the next best solution (in the L2
170// norm sense). Store the solution in x1 and x2, such that ||x|| = 1.0. Return
171// the singluar value corresponding to the solution x1. Destroys A and resizes
172// x if necessary.
173template <typename TMat, typename TVec1, typename TVec2>
174double Nullspace2(TMat* A, TVec1* x1, TVec2* x2) {
175 Eigen::JacobiSVD<TMat> svd(*A, Eigen::ComputeFullV);
176 *x1 = svd.matrixV().col(A->cols() - 1);
177 *x2 = svd.matrixV().col(A->cols() - 2);
178 if (A->rows() >= A->cols()) {
179 return svd.singularValues()(A->cols() - 1);
180 } else {
181 return 0.0;
182 }
183}
184
185// In place transpose for square matrices.
186template <class TA>
187inline void TransposeInPlace(TA* A) {
188 *A = A->transpose().eval();
189}
190
191template <typename TVec>
192inline double NormL1(const TVec& x) {
193 return x.array().abs().sum();
194}
195
196template <typename TVec>
197inline double NormL2(const TVec& x) {
198 return x.norm();
199}
200
201template <typename TVec>
202inline double NormLInfinity(const TVec& x) {
203 return x.array().abs().maxCoeff();
204}
205
206template <typename TVec>
207inline double DistanceL1(const TVec& x, const TVec& y) {
208 return (x - y).array().abs().sum();
209}
210
211template <typename TVec>
212inline double DistanceL2(const TVec& x, const TVec& y) {
213 return (x - y).norm();
214}
215template <typename TVec>
216inline double DistanceLInfinity(const TVec& x, const TVec& y) {
217 return (x - y).array().abs().maxCoeff();
218}
219
220// Normalize a vector with the L1 norm, and return the norm before it was
221// normalized.
222template <typename TVec>
223inline double NormalizeL1(TVec* x) {
224 double norm = NormL1(*x);
225 *x /= norm;
226 return norm;
227}
228
229// Normalize a vector with the L2 norm, and return the norm before it was
230// normalized.
231template <typename TVec>
232inline double NormalizeL2(TVec* x) {
233 double norm = NormL2(*x);
234 *x /= norm;
235 return norm;
236}
237
238// Normalize a vector with the L^Infinity norm, and return the norm before it
239// was normalized.
240template <typename TVec>
241inline double NormalizeLInfinity(TVec* x) {
242 double norm = NormLInfinity(*x);
243 *x /= norm;
244 return norm;
245}
246
247// Return the square of a number.
248template <typename T>
249inline T Square(T x) {
250 return x * x;
251}
252
253Mat3 RotationAroundX(double angle);
254Mat3 RotationAroundY(double angle);
255Mat3 RotationAroundZ(double angle);
256
257// Returns the rotation matrix of a rotation of angle |axis| around axis.
258// This is computed using the Rodrigues formula, see:
259// http://mathworld.wolfram.com/RodriguesRotationFormula.html
260Mat3 RotationRodrigues(const Vec3& axis);
261
262// Make a rotation matrix such that center becomes the direction of the
263// positive z-axis, and y is oriented close to up.
264Mat3 LookAt(Vec3 center);
265
266// Return a diagonal matrix from a vector containing the diagonal values.
267template <typename TVec>
268inline Mat Diag(const TVec& x) {
269 return x.asDiagonal();
270}
271
272template <typename TMat>
273inline double FrobeniusNorm(const TMat& A) {
274 return sqrt(A.array().abs2().sum());
275}
276
277template <typename TMat>
278inline double FrobeniusDistance(const TMat& A, const TMat& B) {
279 return FrobeniusNorm(A - B);
280}
281
282inline Vec3 CrossProduct(const Vec3& x, const Vec3& y) {
283 return x.cross(y);
284}
285
287
288void MeanAndVarianceAlongRows(const Mat& A,
289 Vec* mean_pointer,
290 Vec* variance_pointer);
291
292#if defined(_WIN32)
293// TODO(bomboze): un-#if this for both platforms once tested under Windows
294/* This solution was extensively discussed here
295 http://forum.kde.org/viewtopic.php?f=74&t=61940 */
296# define SUM_OR_DYNAMIC(x, y) \
297 (x == Eigen::Dynamic || y == Eigen::Dynamic) ? Eigen::Dynamic : (x + y)
298
299template <typename Derived1, typename Derived2>
300struct hstack_return {
301 typedef typename Derived1::Scalar Scalar;
302 enum {
303 RowsAtCompileTime = Derived1::RowsAtCompileTime,
304 ColsAtCompileTime = SUM_OR_DYNAMIC(Derived1::ColsAtCompileTime,
305 Derived2::ColsAtCompileTime),
306 Options = Derived1::Flags & Eigen::RowMajorBit ? Eigen::RowMajor : 0,
307 MaxRowsAtCompileTime = Derived1::MaxRowsAtCompileTime,
308 MaxColsAtCompileTime = SUM_OR_DYNAMIC(Derived1::MaxColsAtCompileTime,
309 Derived2::MaxColsAtCompileTime)
310 };
311 typedef Eigen::Matrix<Scalar,
312 RowsAtCompileTime,
313 ColsAtCompileTime,
314 Options,
315 MaxRowsAtCompileTime,
316 MaxColsAtCompileTime>
317 type;
318};
319
320template <typename Derived1, typename Derived2>
321typename hstack_return<Derived1, Derived2>::type HStack(
322 const Eigen::MatrixBase<Derived1>& lhs,
323 const Eigen::MatrixBase<Derived2>& rhs) {
324 typename hstack_return<Derived1, Derived2>::type res;
325 res.resize(lhs.rows(), lhs.cols() + rhs.cols());
326 res << lhs, rhs;
327 return res;
328};
329
330template <typename Derived1, typename Derived2>
331struct vstack_return {
332 typedef typename Derived1::Scalar Scalar;
333 enum {
334 RowsAtCompileTime = SUM_OR_DYNAMIC(Derived1::RowsAtCompileTime,
335 Derived2::RowsAtCompileTime),
336 ColsAtCompileTime = Derived1::ColsAtCompileTime,
337 Options = Derived1::Flags & Eigen::RowMajorBit ? Eigen::RowMajor : 0,
338 MaxRowsAtCompileTime = SUM_OR_DYNAMIC(Derived1::MaxRowsAtCompileTime,
339 Derived2::MaxRowsAtCompileTime),
340 MaxColsAtCompileTime = Derived1::MaxColsAtCompileTime
341 };
342 typedef Eigen::Matrix<Scalar,
343 RowsAtCompileTime,
344 ColsAtCompileTime,
345 Options,
346 MaxRowsAtCompileTime,
347 MaxColsAtCompileTime>
348 type;
349};
350
351template <typename Derived1, typename Derived2>
352typename vstack_return<Derived1, Derived2>::type VStack(
353 const Eigen::MatrixBase<Derived1>& lhs,
354 const Eigen::MatrixBase<Derived2>& rhs) {
355 typename vstack_return<Derived1, Derived2>::type res;
356 res.resize(lhs.rows() + rhs.rows(), lhs.cols());
357 res << lhs, rhs;
358 return res;
359};
360
361#else // _WIN32
362
363// Since it is not possible to typedef privately here, use a macro.
364// Always take dynamic columns if either side is dynamic.
365# define COLS \
366 ((ColsLeft == Eigen::Dynamic || ColsRight == Eigen::Dynamic) \
367 ? Eigen::Dynamic \
368 : (ColsLeft + ColsRight))
369
370// Same as above, except that prefer fixed size if either is fixed.
371# define ROWS \
372 ((RowsLeft == Eigen::Dynamic && RowsRight == Eigen::Dynamic) \
373 ? Eigen::Dynamic \
374 : ((RowsLeft == Eigen::Dynamic) ? RowsRight : RowsLeft))
375
376// TODO(keir): Add a static assert if both rows are at compiletime.
377template <typename T, int RowsLeft, int RowsRight, int ColsLeft, int ColsRight>
378Eigen::Matrix<T, ROWS, COLS> HStack(
379 const Eigen::Matrix<T, RowsLeft, ColsLeft>& left,
380 const Eigen::Matrix<T, RowsRight, ColsRight>& right) {
381 assert(left.rows() == right.rows());
382 int n = left.rows();
383 int m1 = left.cols();
384 int m2 = right.cols();
385
386 Eigen::Matrix<T, ROWS, COLS> stacked(n, m1 + m2);
387 stacked.block(0, 0, n, m1) = left;
388 stacked.block(0, m1, n, m2) = right;
389 return stacked;
390}
391
392// Reuse the above macros by swapping the order of Rows and Cols. Nasty, but
393// the duplication is worse.
394// TODO(keir): Add a static assert if both rows are at compiletime.
395// TODO(keir): Mail eigen list about making this work for general expressions
396// rather than only matrix types.
397template <typename T, int RowsLeft, int RowsRight, int ColsLeft, int ColsRight>
398Eigen::Matrix<T, COLS, ROWS> VStack(
399 const Eigen::Matrix<T, ColsLeft, RowsLeft>& top,
400 const Eigen::Matrix<T, ColsRight, RowsRight>& bottom) {
401 assert(top.cols() == bottom.cols());
402 int n1 = top.rows();
403 int n2 = bottom.rows();
404 int m = top.cols();
405
406 Eigen::Matrix<T, COLS, ROWS> stacked(n1 + n2, m);
407 stacked.block(0, 0, n1, m) = top;
408 stacked.block(n1, 0, n2, m) = bottom;
409 return stacked;
410}
411# undef COLS
412# undef ROWS
413#endif // _WIN32
414
415void HorizontalStack(const Mat& left, const Mat& right, Mat* stacked);
416
417template <typename TTop, typename TBot, typename TStacked>
418void VerticalStack(const TTop& top, const TBot& bottom, TStacked* stacked) {
419 assert(top.cols() == bottom.cols());
420 int n1 = top.rows();
421 int n2 = bottom.rows();
422 int m = top.cols();
423
424 stacked->resize(n1 + n2, m);
425 stacked->block(0, 0, n1, m) = top;
426 stacked->block(n1, 0, n2, m) = bottom;
427}
428
429void MatrixColumn(const Mat& A, int i, Vec2* v);
430void MatrixColumn(const Mat& A, int i, Vec3* v);
431void MatrixColumn(const Mat& A, int i, Vec4* v);
432
433template <typename TMat, typename TCols>
434TMat ExtractColumns(const TMat& A, const TCols& columns) {
435 TMat compressed(A.rows(), columns.size());
436 for (int i = 0; i < columns.size(); ++i) {
437 compressed.col(i) = A.col(columns[i]);
438 }
439 return compressed;
440}
441
442template <typename TMat, typename TDest>
443void reshape(const TMat& a, int rows, int cols, TDest* b) {
444 assert(a.rows() * a.cols() == rows * cols);
445 b->resize(rows, cols);
446 for (int i = 0; i < rows; i++) {
447 for (int j = 0; j < cols; j++) {
448 (*b)(i, j) = a[cols * i + j];
449 }
450 }
451}
452
453inline bool isnan(double i) {
454#ifdef WIN32
455 return _isnan(i) > 0;
456#else
457 return std::isnan(i);
458#endif
459}
460
463template <typename FloatType>
464FloatType ceil0(const FloatType& value) {
465 FloatType result = std::ceil(std::fabs(value));
466 return (value < 0.0) ? -result : result;
467}
468
470inline Mat3 SkewMat(const Vec3& x) {
471 Mat3 skew;
472 skew << 0, -x(2), x(1), x(2), 0, -x(0), -x(1), x(0), 0;
473 return skew;
474}
477inline Mat23 SkewMatMinimal(const Vec2& x) {
478 Mat23 skew;
479 skew << 0, -1, x(1), 1, 0, -x(0);
480 return skew;
481}
482
484inline Mat3 RotationFromEulerVector(Vec3 euler_vector) {
485 double theta = euler_vector.norm();
486 if (theta == 0.0) {
487 return Mat3::Identity();
488 }
489 Vec3 w = euler_vector / theta;
490 Mat3 w_hat = CrossProductMatrix(w);
491 return Mat3::Identity() + w_hat * sin(theta) +
492 w_hat * w_hat * (1 - cos(theta));
493}
494} // namespace libmv
495
496#endif // LIBMV_NUMERIC_NUMERIC_H
sqrt(x)+1/max(0
unsigned int uint
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition btVector3.h:263
local_group_size(16, 16) .push_constant(Type b
local_group_size(16, 16) .push_constant(Type rhs
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
float Scalar
Definition eigen_utils.h:27
uint top
float[3][3] Mat3
Definition gpu_matrix.cc:28
#define Square(a, x, y)
ccl_device_inline float3 ceil(const float3 a)
ccl_device_inline float3 cos(float3 v)
static int left
#define B
T sin(const AngleRadianBase< T > &a)
T round(const T &a)
double DistanceLInfinity(const TVec &x, const TVec &y)
Definition numeric.h:216
Eigen::Matrix< double, 19, 1 > Vec19
Definition numeric.h:122
Eigen::Matrix< float, 3, 5 > Mat35f
Definition numeric.h:83
Mat Diag(const TVec &x)
Definition numeric.h:268
Eigen::VectorXd Vec
Definition numeric.h:61
bool isnan(double i)
Definition numeric.h:453
Eigen::Matrix< double, 11, 1 > Vec11
Definition numeric.h:114
Eigen::Vector4i Vec4i
Definition numeric.h:133
double Nullspace(TMat *A, TVec *nullspace)
Definition numeric.h:158
Eigen::Vector4d Vec4
Definition numeric.h:107
Eigen::Matrix< double, 6, 1 > Vec6
Definition numeric.h:109
double NormL2(const TVec &x)
Definition numeric.h:197
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > RMat3
Definition numeric.h:88
Eigen::Matrix< double, 13, 1 > Vec13
Definition numeric.h:116
Mat3 CrossProductMatrix(const Vec3 &x)
Definition numeric.cc:80
double DistanceL1(const TVec &x, const TVec &y)
Definition numeric.h:207
Eigen::Matrix< double, 10, 1 > Vec10
Definition numeric.h:113
Mat3 RotationFromEulerVector(Vec3 euler_vector)
Returns the rotaiton matrix built from given vector of euler angles.
Definition numeric.h:484
void TransposeInPlace(TA *A)
Definition numeric.h:187
Eigen::Matrix< double, Eigen::Dynamic, 2 > MatX2
Definition numeric.h:94
Eigen::Vector3i Vec3i
Definition numeric.h:132
Eigen::Matrix< double, 4, 4 > Mat4
Definition numeric.h:77
void VerticalStack(const TTop &top, const TBot &bottom, TStacked *stacked)
Definition numeric.h:418
Eigen::Matrix< double, 4, 1 > Mat41
Definition numeric.h:75
Eigen::Matrix< double, Eigen::Dynamic, 3 > MatX3
Definition numeric.h:95
Eigen::Matrix< double, Eigen::Dynamic, 15 > MatX15
Definition numeric.h:102
double DistanceL2(const TVec &x, const TVec &y)
Definition numeric.h:212
Eigen::Matrix< double, 3, 3 > Mat3
Definition numeric.h:72
void SVD(TMat *, Vec *, Mat *, Mat *)
Definition numeric.h:149
Eigen::Matrix< double, Eigen::Dynamic, 4 > MatX4
Definition numeric.h:96
Eigen::Vector2d Vec2
Definition numeric.h:105
Eigen::Matrix< double, Eigen::Dynamic, 5 > MatX5
Definition numeric.h:97
double NormalizeL1(TVec *x)
Definition numeric.h:223
Mat3 RotationAroundX(double angle)
Definition numeric.cc:25
Eigen::Matrix< float, 2, 2 > Mat2f
Definition numeric.h:79
double NormLInfinity(const TVec &x)
Definition numeric.h:202
Eigen::Matrix< float, 4, 3 > Mat43f
Definition numeric.h:84
double FrobeniusDistance(const TMat &A, const TMat &B)
Definition numeric.h:278
Eigen::Matrix< double, 4, 4, Eigen::RowMajor > RMat4
Definition numeric.h:89
Eigen::VectorXf Vecf
Definition numeric.h:64
Eigen::Matrix< double, 14, 1 > Vec14
Definition numeric.h:117
Eigen::Matrix< double, 4, 6 > Mat46
Definition numeric.h:78
Eigen::MatrixXd Mat
Definition numeric.h:60
void MatrixColumn(const Mat &A, int i, Vec2 *v)
Definition numeric.cc:127
void MeanAndVarianceAlongRows(const Mat &A, Vec *mean_pointer, Vec *variance_pointer)
Definition numeric.cc:90
Mat23 SkewMatMinimal(const Vec2 &x)
Definition numeric.h:477
Eigen::Matrix< T, ROWS, COLS > HStack(const Eigen::Matrix< T, RowsLeft, ColsLeft > &left, const Eigen::Matrix< T, RowsRight, ColsRight > &right)
Definition numeric.h:378
Eigen::Matrix< double, 7, 1 > Vec7
Definition numeric.h:110
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > RMatf
Definition numeric.h:136
Eigen::Vector4f Vec4f
Definition numeric.h:127
Eigen::Matrix< double, Eigen::Dynamic, 9 > MatX9
Definition numeric.h:101
double NormalizeLInfinity(TVec *x)
Definition numeric.h:241
Eigen::Matrix< double, Eigen::Dynamic, 8 > MatX8
Definition numeric.h:100
Eigen::NumTraits< double > EigenDouble
Definition numeric.h:138
Eigen::MatrixXf Matf
Definition numeric.h:63
Eigen::Matrix< float, 3, 3 > Mat3f
Definition numeric.h:81
Mat3 RotationRodrigues(const Vec3 &axis)
Definition numeric.cc:61
Eigen::Matrix< double, 2, 3 > Mat23
Definition numeric.h:71
Eigen::Matrix< double, 3, 4 > Mat34
Definition numeric.h:73
Eigen::Matrix< double, Eigen::Dynamic, 7 > MatX7
Definition numeric.h:99
Eigen::Matrix< double, 8, 1 > Vec8
Definition numeric.h:111
Eigen::Matrix< unsigned int, Eigen::Dynamic, 1 > Vecu
Definition numeric.h:67
Mat3 SkewMat(const Vec3 &x)
Returns the skew anti-symmetric matrix of a vector.
Definition numeric.h:470
Eigen::Vector3f Vec3f
Definition numeric.h:126
Eigen::Matrix< double, 18, 1 > Vec18
Definition numeric.h:121
Eigen::VectorXi VecXi
Definition numeric.h:129
Eigen::Matrix< double, Eigen::Dynamic, 16 > MatX16
Definition numeric.h:103
Eigen::Matrix< double, 5, 1 > Vec5
Definition numeric.h:108
Eigen::Matrix< double, 15, 1 > Vec15
Definition numeric.h:118
FloatType ceil0(const FloatType &value)
Definition numeric.h:464
Eigen::Vector3d Vec3
Definition numeric.h:106
Eigen::Matrix< double, 4, Eigen::Dynamic > Mat4X
Definition numeric.h:93
Eigen::Matrix< double, 3, Eigen::Dynamic > Mat3X
Definition numeric.h:92
Eigen::Matrix< float, 2, 3 > Mat23f
Definition numeric.h:80
Eigen::Matrix< float, 3, 4 > Mat34f
Definition numeric.h:82
Eigen::Matrix< double, 3, 5 > Mat35
Definition numeric.h:74
Eigen::Matrix< unsigned int, Eigen::Dynamic, Eigen::Dynamic > Matu
Definition numeric.h:66
double FrobeniusNorm(const TMat &A)
Definition numeric.h:273
Eigen::Matrix< double, 12, 1 > Vec12
Definition numeric.h:115
Eigen::Matrix< double, 16, 1 > Vec16
Definition numeric.h:119
Eigen::Vector2f Vec2f
Definition numeric.h:125
Eigen::Vector2i Vec2i
Definition numeric.h:131
Eigen::Matrix< T, COLS, ROWS > VStack(const Eigen::Matrix< T, ColsLeft, RowsLeft > &top, const Eigen::Matrix< T, ColsRight, RowsRight > &bottom)
Definition numeric.h:398
Eigen::Matrix< double, 20, 1 > Vec20
Definition numeric.h:123
void HorizontalStack(const Mat &left, const Mat &right, Mat *stacked)
Definition numeric.cc:116
Mat3 RotationAroundZ(double angle)
Definition numeric.cc:49
void reshape(const TMat &a, int rows, int cols, TDest *b)
Definition numeric.h:443
Eigen::Matrix< double, 9, 1 > Vec9
Definition numeric.h:112
Eigen::Matrix< double, 2, Eigen::Dynamic > Mat2X
Definition numeric.h:91
Mat3 RotationAroundY(double angle)
Definition numeric.cc:37
Eigen::Matrix< float, 4, 6 > Mat46f
Definition numeric.h:86
double NormalizeL2(TVec *x)
Definition numeric.h:232
double Nullspace2(TMat *A, TVec1 *x1, TVec2 *x2)
Definition numeric.h:174
Eigen::Matrix< double, 17, 1 > Vec17
Definition numeric.h:120
Eigen::Matrix< double, 2, 2 > Mat2
Definition numeric.h:70
TMat ExtractColumns(const TMat &A, const TCols &columns)
Definition numeric.h:434
Eigen::Matrix< float, 4, 4 > Mat4f
Definition numeric.h:85
Mat3 LookAt(Vec3 center)
Definition numeric.cc:69
Eigen::Matrix< unsigned int, 2, 1 > Vec2u
Definition numeric.h:68
Vec3 CrossProduct(const Vec3 &x, const Vec3 &y)
Definition numeric.h:282
double NormL1(const TVec &x)
Definition numeric.h:192
Eigen::Matrix< double, Eigen::Dynamic, 6 > MatX6
Definition numeric.h:98
Eigen::Matrix< double, 4, 3 > Mat43
Definition numeric.h:76