dynLattice
Loading...
Searching...
No Matches
helpers.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "utils/testing.h"
10
11#include <jem/base/Array.h>
12#include <jem/base/CString.h>
13#include <jem/numeric/Quaternion.h>
14#include <jem/numeric/algebra.h>
15#include <jem/numeric/func/Function.h>
16
17#include <jive/Array.h>
18#include <jive/util/FuncUtils.h>
19
20#define WARN(key) jem::System::warn() << key << "\n";
21#define ERR(key) jem::System::err() << key << "\n";
22
23using jem::ALL;
24using jem::Array;
25using jem::idx_t;
26using jem::SliceFromTo;
27using jem::String;
28using jem::numeric::dotProduct;
29using jem::numeric::Function;
30using jem::numeric::matmul;
31using jem::numeric::MatmulChain;
32using jem::numeric::norm2;
33using jem::numeric::Quaternion;
34
35using jive::Cubix;
36using jive::IdxVector;
37using jive::Matrix;
38using jive::Ref;
39using jive::Vector;
40using jive::util::FuncUtils;
41
46namespace jive_helpers
47{
48 typedef Array<double, 4> Quadix;
49 typedef Array<IdxVector, 2> IdxVectorMatrix;
50
51 const Vector e1 = {1., 0., 0.};
52 const Vector e2 = {0., 1., 0.};
53 const Vector e3 = {0., 0., 1.};
54 const Vector vec0 = {0., 0., 0.};
55 const double TINY = __DBL_EPSILON__ * 1e6;
56
64 Vector funcGrad(const Ref<Function> func, const Vector &args);
65
73 Vector evalFuncs(const FuncUtils::FuncArray funcs, const Vector &args);
74
82 Matrix funcHessian(const Ref<Function> func, const Vector &args);
83
91 Matrix gradFuncs(const FuncUtils::FuncArray funcs, const Vector &args);
92
99 Matrix eye(const idx_t dim = 3);
100
112 void logMat(const Vector &rv, const Matrix &R);
113
120 void vec2mat(const Matrix &mat, const Vector &vec);
121
128 void mat2vec(const Vector &vec, const Matrix &mat);
129
141 void expVec(const Matrix &Exp, const Vector &v);
142
153 void expVecP(const Matrix &ExpP, const Vector &v, const Vector &vP);
154
161 double trace(const Matrix &mat);
162
169 idx_t factorial(const idx_t n);
170
178 idx_t binom(const idx_t n, const idx_t k);
179
186 double matrixNorm2(const Matrix &mat);
187
194 Matrix skew(const Vector &vec);
195
203 Vector unskew(const Matrix &mat);
204}; // namespace jive_helpers
void vec2mat(const Matrix &mat, const Vector &vec)
Definition ParaViewModule.cpp:15
namespace for all helper functions
Definition helpers.cpp:10
double trace(const Matrix &mat)
calculate the trace of a matrix.
Definition helpers.cpp:199
Vector unskew(const Matrix &mat)
construct a axial vector from a given skew-symmetric matrix
Definition helpers.cpp:257
void expVec(const Matrix &Exp, const Vector &psi)
compute the exponential of a axial vector.
Definition helpers.cpp:139
idx_t factorial(const idx_t n)
calculates the factorial of an integer.
Definition helpers.cpp:211
Vector funcGrad(const Ref< Function > func, const Vector &args)
gets the gradient of a multivariate function.
Definition helpers.cpp:11
idx_t binom(const idx_t n, const idx_t k)
calculate the binomial coefficient.
Definition helpers.cpp:222
void logMat(const Vector &rv, const Matrix &R)
compute rotational vector from rotation matrix.
Definition helpers.cpp:99
Matrix eye(const idx_t dim)
generates an identity matrix of the given dimension.
Definition helpers.cpp:88
const double TINY
Definition helpers.h:55
Vector evalFuncs(const FuncUtils::FuncArray funcs, const Vector &args)
evaluates an array of multivariate functions.
Definition helpers.cpp:24
const Vector e3
Definition helpers.h:53
const Vector vec0
Definition helpers.h:54
Array< double, 4 > Quadix
Definition helpers.h:48
const Vector e1
Definition helpers.h:51
Matrix funcHessian(const Ref< Function > func, const Vector &args)
gets the Hessian of a multivariate function.
Definition helpers.cpp:37
Matrix gradFuncs(const FuncUtils::FuncArray funcs, const Vector &args)
gets the gradients of an array of multivariate functions.
Definition helpers.cpp:71
Matrix skew(const Vector &vec)
construct a skew symetric matrix from a given vector.
Definition helpers.cpp:242
double matrixNorm2(const Matrix &mat)
calculates the 2-norm of a matrix.
Definition helpers.cpp:231
void expVecP(const Matrix &ExpP, const Vector &psi, const Vector &psiP)
derivative of jive_helpers::expVec.
Definition helpers.cpp:159
const Vector e2
Definition helpers.h:52
void mat2vec(const Vector &vec, const Matrix &mat)
rearrange a matrix into a vector.
Definition helpers.cpp:126
Array< IdxVector, 2 > IdxVectorMatrix
Definition helpers.h:49
several compiler macros for faster testing of variables