11#include <jem/base/Array.h>
12#include <jem/base/CString.h>
13#include <jem/base/tuple/Tuple.h>
14#include <jem/numeric/Quaternion.h>
15#include <jem/numeric/algebra.h>
16#include <jem/numeric/func/Function.h>
18#include <jive/Array.h>
19#include <jive/util/Constraints.h>
20#include <jive/util/FuncUtils.h>
22#define WARN(key) jem::System::warn() << key << "\n";
23#define ERR(key) jem::System::err() << key << "\n";
28using jem::SliceFromTo;
30using jem::numeric::dotProduct;
31using jem::numeric::Function;
32using jem::numeric::matmul;
33using jem::numeric::MatmulChain;
34using jem::numeric::norm2;
35using jem::numeric::Quaternion;
42using jive::util::FuncUtils;
50const Vector
e1 = {1., 0., 0.};
51const Vector
e2 = {0., 1., 0.};
52const Vector
e3 = {0., 0., 1.};
53const Vector
vec0 = {0., 0., 0.};
54const double TINY = __DBL_EPSILON__ * 1e6;
61Vector
funcGrad(
const Ref<Function> func,
const Vector &args);
68Vector
evalFuncs(
const FuncUtils::FuncArray funcs,
const Vector &args);
75Matrix
funcHessian(
const Ref<Function> func,
const Vector &args);
82Matrix
gradFuncs(
const FuncUtils::FuncArray funcs,
const Vector &args);
88Matrix
eye(
const idx_t dim = 3);
99void logMat(
const Vector &rv,
const Matrix &R);
105void vec2mat(
const Matrix &mat,
const Vector &vec);
111void mat2vec(
const Vector &vec,
const Matrix &mat);
148void mul3(
const Matrix &C,
const Matrix &A,
const Matrix &B);
157void mul3(
const Vector &y,
const Matrix &A,
const Vector &x);
168void expVec(
const Matrix &Exp,
const Vector &v);
178void expVecP(
const Matrix &ExpP,
const Vector &v,
const Vector &vP);
184double trace(
const Matrix &mat);
197idx_t
binom(
const idx_t n,
const idx_t k);
211Matrix
skew(
const Vector &vec);
218void skew(
const Matrix &S,
const Vector &vec);
225Vector
unskew(
const Matrix &mat);
232void setDofValue(jive::util::Constraints &cons,
const idx_t idof,
const double rval);
240void linkDofs(jive::util::Constraints &cons,
const idx_t idof,
const idx_t jdof,
const double coeff);
namespace for all helper functions
Definition helpers.cpp:28
double trace(const Matrix &mat)
calculate the trace of a matrix.
Definition helpers.cpp:269
Vector unskew(const Matrix &mat)
construct a axial vector from a given skew-symmetric matrix
Definition helpers.cpp:332
void expVec(const Matrix &Exp, const Vector &psi)
compute the exponential of a axial vector.
Definition helpers.cpp:185
void setDofValue(jive::util::Constraints &cons, const idx_t idof, const double rval)
prescribe the value of a dof, i.e. constrain idof = rval.
Definition helpers.cpp:358
idx_t factorial(const idx_t n)
calculates the factorial of an integer.
Definition helpers.cpp:281
void vec2mat(const Matrix &mat, const Vector &vec)
rearrange a vector into a matrix.
Definition helpers.cpp:136
Vector funcGrad(const Ref< Function > func, const Vector &args)
gets the gradient of a multivariate function.
Definition helpers.cpp:29
idx_t binom(const idx_t n, const idx_t k)
calculate the binomial coefficient.
Definition helpers.cpp:292
void logMat(const Vector &rv, const Matrix &R)
compute rotational vector from rotation matrix.
Definition helpers.cpp:117
Matrix eye(const idx_t dim)
generates an identity matrix of the given dimension.
Definition helpers.cpp:106
const double TINY
Definition helpers.h:54
Vector evalFuncs(const FuncUtils::FuncArray funcs, const Vector &args)
evaluates an array of multivariate functions.
Definition helpers.cpp:42
const Vector e3
Definition helpers.h:52
const Vector vec0
Definition helpers.h:53
Array< double, 4 > Quadix
Definition helpers.h:47
const Vector e1
Definition helpers.h:50
void linkDofs(jive::util::Constraints &cons, const idx_t idof, const idx_t jdof, const double coeff)
link a slave dof to a master dof, i.e. constrain idof = coeff * jdof.
Definition helpers.cpp:366
Matrix funcHessian(const Ref< Function > func, const Vector &args)
gets the Hessian of a multivariate function.
Definition helpers.cpp:55
Matrix gradFuncs(const FuncUtils::FuncArray funcs, const Vector &args)
gets the gradients of an array of multivariate functions.
Definition helpers.cpp:89
Matrix skew(const Vector &vec)
construct a skew symetric matrix from a given vector.
Definition helpers.cpp:312
double matrixNorm2(const Matrix &mat)
calculates the 2-norm of a matrix.
Definition helpers.cpp:301
void expVecP(const Matrix &ExpP, const Vector &psi, const Vector &psiP)
derivative of jive_helpers::expVec.
Definition helpers.cpp:218
void mul3(const Matrix &C, const Matrix &A, const Matrix &B)
C = A * B for 3 x 3 matrices without heap allocation.
Definition helpers.cpp:162
const Vector e2
Definition helpers.h:51
void mat2vec(const Vector &vec, const Matrix &mat)
rearrange a matrix into a vector.
Definition helpers.cpp:149
Array< IdxVector, 2 > IdxVectorMatrix
Definition helpers.h:48
several compiler macros for faster testing of variables