dynLattice
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
jive_helpers Namespace Reference

namespace for all helper functions

Typedefs

typedef Array< double, 4 > Quadix
 
typedef Array< IdxVector, 2 > IdxVectorMatrix
 

Functions

Vector funcGrad (const Ref< Function > func, const Vector &args)
 gets the gradient of a multivariate function.
 
Vector evalFuncs (const FuncUtils::FuncArray funcs, const Vector &args)
 evaluates an array of multivariate functions.
 
Matrix funcHessian (const Ref< Function > func, const Vector &args)
 gets the Hessian of a multivariate function.
 
Matrix gradFuncs (const FuncUtils::FuncArray funcs, const Vector &args)
 gets the gradients of an array of multivariate functions.
 
Matrix eye (const idx_t dim=3)
 generates an identity matrix of the given dimension.
 
void logMat (const Vector &rv, const Matrix &R)
 compute rotational vector from rotation matrix.
 
void vec2mat (const Matrix &mat, const Vector &vec)
 rearrange a vector into a matrix.
 
void mat2vec (const Vector &vec, const Matrix &mat)
 rearrange a matrix into a vector.
 
void mul3 (const Matrix &C, const Matrix &A, const Matrix &B)
 C = A * B for 3 x 3 matrices without heap allocation.
 
void mul3 (const Vector &y, const Matrix &A, const Vector &x)
 y = A * x for a 3 x 3 matrix without heap allocation.
 
void expVec (const Matrix &Exp, const Vector &v)
 compute the exponential of a axial vector.
 
void expVecP (const Matrix &ExpP, const Vector &v, const Vector &vP)
 derivative of jive_helpers::expVec.
 
double trace (const Matrix &mat)
 calculate the trace of a matrix.
 
idx_t factorial (const idx_t n)
 calculates the factorial of an integer.
 
idx_t binom (const idx_t n, const idx_t k)
 calculate the binomial coefficient.
 
double matrixNorm2 (const Matrix &mat)
 calculates the 2-norm of a matrix.
 
Matrix skew (const Vector &vec)
 construct a skew symetric matrix from a given vector.
 
void skew (const Matrix &S, const Vector &vec)
 fill an existing 3 x 3 matrix with the skew symmetric matrix of a vector
 
Vector unskew (const Matrix &mat)
 construct a axial vector from a given skew-symmetric matrix
 
void setDofValue (jive::util::Constraints &cons, const idx_t idof, const double rval)
 prescribe the value of a dof, i.e. constrain idof = rval.
 
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.
 

Variables

const Vector e1 = {1., 0., 0.}
 
const Vector e2 = {0., 1., 0.}
 
const Vector e3 = {0., 0., 1.}
 
const Vector vec0 = {0., 0., 0.}
 
const double TINY = __DBL_EPSILON__ * 1e6
 

Typedef Documentation

◆ IdxVectorMatrix

typedef Array<IdxVector, 2> jive_helpers::IdxVectorMatrix

◆ Quadix

typedef Array<double, 4> jive_helpers::Quadix

Function Documentation

◆ binom()

idx_t jive_helpers::binom ( const idx_t  n,
const idx_t  k 
)
Parameters
[in]nParameter n
[in]kParameter k
Returns
binomial coefficient nCk

◆ evalFuncs()

Vector jive_helpers::evalFuncs ( const FuncUtils::FuncArray  funcs,
const Vector &  args 
)
Parameters
[in]funcsarray of functions to evaluate
[in]argspoint to evaluate at
Returns
results of the evaluation

◆ expVec()

void jive_helpers::expVec ( const Matrix &  Exp,
const Vector &  v 
)

It computes the matrix exponential of the skew-symmetric matrix of this vector so when \(\Theta=[\theta\times]\) this function will return \(\exp(\Theta)\).

See also
Wikipedia
Parameters
[out]Exp3 x 3 matrix exponential
[in]v3-component axial rotation vector

◆ expVecP()

void jive_helpers::expVecP ( const Matrix &  ExpP,
const Vector &  v,
const Vector &  vP 
)
See also
jive_helpers::expVec
Differentiation rules
Parameters
[out]ExpPDerivative of the 3 x 3 matrix exponential
[in]v3-component axial rotation vector
[in]vPDerivative of the axial rotation vector

◆ eye()

Matrix jive_helpers::eye ( const idx_t  dim = 3)
Parameters
[in]dimdimension of the identity matrix (default 3)
Returns
identity matrix

◆ factorial()

idx_t jive_helpers::factorial ( const idx_t  n)
Parameters
[in]nInteger to calculate the factorial from
Returns
the calculated factorial

◆ funcGrad()

Vector jive_helpers::funcGrad ( const Ref< Function >  func,
const Vector &  args 
)
Parameters
[in]funcfunction of which to evaluate the gradient
[in]argspoint to evaluate the gradient
Returns
gradient

◆ funcHessian()

Matrix jive_helpers::funcHessian ( const Ref< Function >  func,
const Vector &  args 
)
Parameters
[in]funcfunction of which to evaluate the Hessian
[in]argspoint to evaluate the Hessian
Returns
Hessian

◆ gradFuncs()

Matrix jive_helpers::gradFuncs ( const FuncUtils::FuncArray  funcs,
const Vector &  args 
)
Parameters
[in]funcsarray of functions of which to evaluate the gradient
[in]argspoint to evaluate the gradient
Returns
Matrix of the gradients

◆ linkDofs()

void jive_helpers::linkDofs ( jive::util::Constraints &  cons,
const idx_t  idof,
const idx_t  jdof,
const double  coeff 
)
Parameters
[in,out]consconstraints to modify
[in]idofslave dof index
[in]jdofmaster dof index
[in]coeffcoefficient of the master dof

◆ logMat()

void jive_helpers::logMat ( const Vector &  rv,
const Matrix &  R 
)

This function computes the logarithmic map of a rotation matrix as a member of the Lie group SO(3) to the Lie algebra \(\mathfrak{so}(3)\). It returns the axial vector of the rotation matrix.

See also
Wikipedia
Parameters
[out]rv3-component rotational vector
[in]R3 x 3 rotational matrix

◆ mat2vec()

void jive_helpers::mat2vec ( const Vector &  vec,
const Matrix &  mat 
)
Parameters
[out]vecVector populated with the matrix values by row
[in]matMatrix whose entry count matches the vector size

◆ matrixNorm2()

double jive_helpers::matrixNorm2 ( const Matrix &  mat)
Parameters
[in]matMatrix
Returns
resulting 2-norm

◆ mul3() [1/2]

void jive_helpers::mul3 ( const Matrix &  C,
const Matrix &  A,
const Matrix &  B 
)

The product is formed on the stack first, so C may alias A or B (unlike jem::numeric::matmul(C, A, B)); the 3 x 3 sizes are fixed, which makes it faster than the general matmul. Use it for every 3 x 3 product in hot code.

Parameters
[out]C3 x 3 result
[in]A3 x 3 left factor
[in]B3 x 3 right factor

◆ mul3() [2/2]

void jive_helpers::mul3 ( const Vector &  y,
const Matrix &  A,
const Vector &  x 
)

x is copied first, so y may alias x. The sums are formed in the same order as in jem::numeric::matmul (starting from zero), so the results are the same.

Parameters
[out]y3 vector result
[in]A3 x 3 matrix (may be a transposed view)
[in]x3 vector

◆ setDofValue()

void jive_helpers::setDofValue ( jive::util::Constraints &  cons,
const idx_t  idof,
const double  rval 
)
Parameters
[in,out]consconstraints to modify
[in]idofdof index to prescribe
[in]rvalprescribed value

◆ skew() [1/2]

void jive_helpers::skew ( const Matrix &  S,
const Vector &  vec 
)

Does not create a new matrix, so it is the form for hot code.

Parameters
[out]S3 x 3 skew symmetric matrix
[in]vecVector

◆ skew() [2/2]

Matrix jive_helpers::skew ( const Vector &  vec)

Convenient form for set-up code; it creates a new matrix. In hot code use the form below with a work matrix.

Parameters
[in]vecVector to be changed to a skew-symmetric matrix
Returns
skew symmetric matrix

◆ trace()

double jive_helpers::trace ( const Matrix &  mat)
Parameters
[in]matMatrix to get the trace of
Returns
the trace of the given matrix

◆ unskew()

Vector jive_helpers::unskew ( const Matrix &  mat)
Parameters
[in]matSkew-symmetric matrix
Returns
axial vector

◆ vec2mat()

void jive_helpers::vec2mat ( const Matrix &  mat,
const Vector &  vec 
)
Parameters
[out]matMatrix populated from the vector values by row
[in]vecVector whose size matches the number of matrix entries

Variable Documentation

◆ e1

const Vector jive_helpers::e1 = {1., 0., 0.}

◆ e2

const Vector jive_helpers::e2 = {0., 1., 0.}

◆ e3

const Vector jive_helpers::e3 = {0., 0., 1.}

◆ TINY

const double jive_helpers::TINY = __DBL_EPSILON__ * 1e6

◆ vec0

const Vector jive_helpers::vec0 = {0., 0., 0.}