jacobian.h File Reference

Introduction

Definition of the TJacobian type and the associated functions.

See also
TJacobian, jacobian.c.

Definition in file jacobian.h.

Data Structures

struct  TJacobian
 The Jacobian of a set of equations. More...
 

Functions

void InitJacobian (Tvariables *vs, Tequations *eqs, TJacobian *j)
 Constructor. More...
 
void InitPositionJacobian (Tvariables *vs, Tequations *eqs, TJacobian *j)
 Constructor. More...
 
void InitScalarPositionJacobian (Tvariables *vs, Tequations *eqs, TJacobian *j)
 Constructor. More...
 
void CopyJacobian (TJacobian *j_dst, TJacobian *j_src)
 Constructor. More...
 
void CopyNonDynamicsJacobian (TJacobian *j_dstP, TJacobian *j_dstO, TJacobian *j_src)
 Copies the non-dynamics Jacobian. More...
 
void CopyPositionJacobian (TJacobian *j_dst, TJacobian *j_src)
 Copies the position Jacobian. More...
 
void GetJacobianSize (unsigned int *nr, unsigned int *nc, TJacobian *j)
 Returns the size of the Jacobian. More...
 
TequationsGetJacobianColumn (unsigned int nv, TJacobian *J)
 Returns one of the Jacobian element. More...
 
TequationGetJacobianEquation (unsigned int r, unsigned int c, TJacobian *j)
 Returns one element of the Jacobian. More...
 
void RewriteJacobian2Orig (Tmapping *map, TJacobian *j)
 Rewrites the equations in a Jacobian to the original system. More...
 
void JacobianLinearCombination (boolean *selectedVars, unsigned int *nv, Tequations *eqs, TJacobian *j)
 Linear combination of the columns of the Jacobian. More...
 
void AllocateJacobianEvaluation (double ***m, TJacobian *j)
 Allocate space for the Jacobian evaluation. More...
 
void EvaluateJacobian (double *v, double **m, TJacobian *j)
 Evaluates the Jacobian. More...
 
void EvaluateJacobianInVector (double *v, unsigned int nr, unsigned int nc, double *m, TJacobian *j)
 Evaluates the Jacobian. More...
 
void EvaluateJacobianSubSetInVector (double *v, boolean *sr, unsigned int nr, unsigned int nc, double *m, TJacobian *j)
 Evaluates some of the Jacobian equations. More...
 
void EvaluateTransposedJacobianInVector (double *v, unsigned int nr, unsigned int nc, double *m, TJacobian *j)
 Evaluates the transposed Jacobian. More...
 
void EvaluateTransposedJacobianSubSetInVector (double *v, boolean *sr, unsigned int nr, unsigned int nc, double *m, TJacobian *j)
 Evaluates a subset of the transposed Jacobian. More...
 
void PrintJacobianEvaluation (FILE *f, double **m, TJacobian *j)
 Prints the result of evaluating the Jacobian. More...
 
void FreeJacobianEvaluation (double **m, TJacobian *j)
 Release space for the Jacobian evaluation. More...
 
void EvaluateJacobianXVectors (double *p, unsigned int n, unsigned int ng, unsigned int *g, double *v, unsigned int *nr, unsigned int *nc, double ***m, TJacobian *j)
 Evaluates the Jacobian multiplied by some given vectors. More...
 
void PrintJacobian (FILE *f, char **varNames, TJacobian *j)
 Prints the symbolic Jacobian. More...
 
void DeleteJacobian (TJacobian *j)
 Destructor. More...
 

Function Documentation

◆ InitJacobian()

void InitJacobian ( Tvariables vs,
Tequations eqs,
TJacobian j 
)

Initializes the Jacobian deriving a set of equations.

Parameters
vsThe variables involved in the equations.
eqsThe equations to derive.
jThe resulting Jacobian.

Definition at line 20 of file jacobian.c.

References CacheScalarEQUInfo(), DeriveEqualityEquations(), TJacobian::eqs, Error(), TJacobian::J, TJacobian::neqs, NEqualityEquations(), NEW, NVariables(), TJacobian::nvars, and TJacobian::vars.

Referenced by AddSimplifiedJacobianEquations(), EvaluateCSJacobian(), GenerateWorldEquations(), GetCSJacobian(), GetSimpCSJacobian(), and UpdateCuikSystem().

◆ InitPositionJacobian()

void InitPositionJacobian ( Tvariables vs,
Tequations eqs,
TJacobian j 
)

Initializes the Jacobian deriving the subset of position of equations.

Parameters
vsThe variables involved in the equations.
eqsThe equations to derive.
jThe resulting Jacobian.

Definition at line 46 of file jacobian.c.

References CacheScalarEQUInfo(), DeriveEqualityPositionEquations(), TJacobian::eqs, Error(), GetNumPositionVariables(), IsPositionVariable(), TJacobian::J, TJacobian::neqs, NEqualityPositionEquations(), NEW, NVariables(), TJacobian::nvars, and TJacobian::vars.

Referenced by AddVelocityEquations().

◆ InitScalarPositionJacobian()

void InitScalarPositionJacobian ( Tvariables vs,
Tequations eqs,
TJacobian j 
)

Initializes the Jacobian deriving the subset of scalar position of equations.

Parameters
vsThe variables involved in the equations.
eqsThe equations to derive.
jThe resulting Jacobian.

Definition at line 82 of file jacobian.c.

References CacheScalarEQUInfo(), DeriveEqualityScalarPositionEquations(), TJacobian::eqs, Error(), GetNumPositionVariables(), IsPositionVariable(), TJacobian::J, TJacobian::neqs, NEqualityScalarPositionEquations(), NEW, NVariables(), TJacobian::nvars, and TJacobian::vars.

Referenced by InitNJacobian().

◆ CopyJacobian()

void CopyJacobian ( TJacobian j_dst,
TJacobian j_src 
)

Initializes a Jacobian from another Jacobian.

Parameters
j_dstThe Jacobian to initialize.
j_srcThe Jacobian from where to get the data.

Definition at line 118 of file jacobian.c.

References CacheScalarEQUInfo(), CopyEquations(), TJacobian::eqs, TJacobian::J, TJacobian::neqs, NEW, TJacobian::nvars, and TJacobian::vars.

Referenced by CopyCuikSystem().

◆ CopyNonDynamicsJacobian()

void CopyNonDynamicsJacobian ( TJacobian j_dstP,
TJacobian j_dstO,
TJacobian j_src 
)

Gets a copy of the part of the Jacobian not directly related with the dynamics: equations not related to position/velocity derived with respect to the position equations. This block is used in a chain rule to obtain the time derivative of the non-dynamics (non position/velocity) equations.

Parameters
j_dstPThe Jacobian with respect to position variables.
j_dstOThe Jacobian with respect to the nont-dynamic variables.
j_srcThe Jacobian from where to get the data.

Definition at line 142 of file jacobian.c.

References CacheScalarEQUInfo(), CopyNonDynamicEquations(), TJacobian::eqs, GetNumNonDynamicVariables(), GetNumPositionVariables(), IsPositionVariable(), IsVelocityVariable(), TJacobian::J, TJacobian::neqs, NEW, NNonDynamicEquations(), TJacobian::nvars, and TJacobian::vars.

Referenced by InitDynamicSpace().

◆ CopyPositionJacobian()

void CopyPositionJacobian ( TJacobian j_dst,
TJacobian j_src 
)

Gets a copy of the position Jacobian (part of the Jacobian corresponding to position variables and equations).

Parameters
j_dstThe Jacobian to initialize.
j_srcThe Jacobian from where to get the data.

Definition at line 192 of file jacobian.c.

References CacheScalarEQUInfo(), CopyPositionEquations(), TJacobian::eqs, GetNumPositionVariables(), IsPositionVariable(), TJacobian::J, TJacobian::neqs, NEW, NPositionEquations(), TJacobian::nvars, and TJacobian::vars.

Referenced by InitDynamicSpace().

◆ GetJacobianSize()

void GetJacobianSize ( unsigned int *  nr,
unsigned int *  nc,
TJacobian j 
)

Gives the Jacobian size.

Parameters
nrNumber of rows of the Jacobian (output).
ncNumber of columns of the Jacobian (output).
jThe Jacobian to query.

Definition at line 221 of file jacobian.c.

References TJacobian::neqs, and TJacobian::nvars.

Referenced by AddJacobianEquationsInt(), ConnectSamplesChart(), GradientSmooth(), InitAtlas(), InitChartInt(), InitDynamicSpace(), InitHessian(), LoadAtlas(), and ManifoldDimension().

◆ GetJacobianColumn()

Tequations* GetJacobianColumn ( unsigned int  nv,
TJacobian J 
)

Returns the derivative of all equations with respect to a given variable, i.e, one of the columns of the Jacobian.

Parameters
nvThe derivation variable.
JThe Jacobian to query.
Returns
A pointer to the equations giving the column of the Jacobian.

Definition at line 227 of file jacobian.c.

References Error(), TJacobian::J, TJacobian::neqs, and TJacobian::nvars.

Referenced by InitHessian().

◆ GetJacobianEquation()

Tequation* GetJacobianEquation ( unsigned int  r,
unsigned int  c,
TJacobian j 
)

Returns a pointer to one element of the Jacobian. This only works for scalar systems.

Parameters
rRow of the element to retrive.
cColumn of the element to retrive.
jThe Jacobian to query.

Definition at line 238 of file jacobian.c.

References Error(), GetEquation(), TJacobian::J, TJacobian::neqs, and TJacobian::nvars.

Referenced by AddJacobianEquationsInt(), AddSimplifiedJacobianEquations(), and GetSCpSystem().

◆ RewriteJacobian2Orig()

void RewriteJacobian2Orig ( Tmapping map,
TJacobian j 
)

For a Jacobian of a simplified system of equations, we change the variable identifiers by those in the orignal system. Note that this is just a variable identifier replacement since all the variables in the simplified system are also in the original.

Parameters
mapThe map from the simplified system to the original.
jThe Jacobian to map.

Definition at line 249 of file jacobian.c.

References TJacobian::J, TJacobian::neqs, TJacobian::nvars, and RewriteEqs2Orig().

Referenced by AddSimplifiedJacobianEquations(), and AddVelocityEquations().

◆ JacobianLinearCombination()

void JacobianLinearCombination ( boolean selectedVars,
unsigned int *  nv,
Tequations eqs,
TJacobian j 
)

Generate linear combinations of the columns of the Jacobian and adds them to a given equation set.

This is used when defining velocity equations.

Parameters
selectedVarsIf not NULL, it allows selecting the columns of the Jacobian to be combined. Also only the selected variables are actually used.
nvThe variable identifier to use as coefficients of the linear combination to generate.
eqsThe equation set where to add the linear combination.
jThe Jacobian with the columns to combine.

Definition at line 260 of file jacobian.c.

References CopyEquations(), DeleteEquations(), Error(), FALSE, TJacobian::J, MergeEquations(), TJacobian::neqs, TJacobian::nvars, TRUE, VarAccumulateEqualityEquations(), and VarScaleEqualityEquations().

Referenced by AddVelocityEquations().

◆ AllocateJacobianEvaluation()

void AllocateJacobianEvaluation ( double ***  m,
TJacobian j 
)

Allocate space for the Jacobian evaluation.

Parameters
mThe allocated space.
jThe Jacobian to evaluate.

Definition at line 295 of file jacobian.c.

References TJacobian::neqs, NEW, and TJacobian::nvars.

Referenced by EvaluateCSJacobian().

◆ EvaluateJacobian()

void EvaluateJacobian ( double *  v,
double **  m,
TJacobian j 
)

Evaluates the Jacobian for a given value of the variables.

Parameters
vThe value for the variables.
mThe matrix where to store the result (see AllocateJacobianEvaluation).
jThe Jacobian to evalute.

Definition at line 309 of file jacobian.c.

References EvaluateEqualityEquations(), FALSE, TJacobian::J, TJacobian::neqs, NEW, and TJacobian::nvars.

Referenced by EvaluateCSJacobian().

◆ EvaluateJacobianInVector()

void EvaluateJacobianInVector ( double *  v,
unsigned int  nr,
unsigned int  nc,
double *  m,
TJacobian j 
)

Evaluates the Jacobian for a given value of the variables and stores the result in a vector instead of in a matrix.

Parameters
vThe value for the variables.
nrNumber of rows of the space to store the Jacobian.
ncNumber of columns of the space to store the Jacobian.
mThe vector where to store the result.
jThe Jacobian to evalute.

Definition at line 327 of file jacobian.c.

References EvaluateEqualitySparseEquations(), TJacobian::J, TJacobian::neqs, NEW, TJacobian::nvars, and SubMatrixFromMatrix().

Referenced by Chart2Manifold(), ComputeAcceleration(), CuikGradientInBox(), CuikNewtonInBox(), CuikNewtonSimp(), Newton2ManifoldPlane(), and RefineSingularPoint().

◆ EvaluateJacobianSubSetInVector()

void EvaluateJacobianSubSetInVector ( double *  v,
boolean sr,
unsigned int  nr,
unsigned int  nc,
double *  m,
TJacobian j 
)

Evaluates some of the Jacobian equations for a given value of the variables and stores the result in a vector instead of in a matrix.

Parameters
vThe value for the variables.
srBoolean array with the selected rows to store in the output.
nrNumber of rows. This typically is the number of equations but can be larger in cases where extra constratins are added to the system.
ncNumber of columns. This typically is the number of variables but can be larger in cases where extra variables are added to the system.
mThe vector where to store the result.
jThe Jacobian to evalute.

Definition at line 344 of file jacobian.c.

References EvaluateSubSetEqualitySparseEquations(), TJacobian::J, TJacobian::neqs, NEW, TJacobian::nvars, and SubMatrixFromMatrix().

Referenced by Chart2Manifold(), and GetChartDegree().

◆ EvaluateTransposedJacobianInVector()

void EvaluateTransposedJacobianInVector ( double *  v,
unsigned int  nr,
unsigned int  nc,
double *  m,
TJacobian j 
)

Evaluates the transposed Jacobian for a given value of the variables and stores the result in a vector instead of in a matrix. The vector is organized column wise (1st column 2nr column, etc).

Parameters
vThe value for the variables.
nrNumber of rows of the space to store the transposed Jacobian
ncNumber of columns of the space to store the transposed Jacobian.
mThe vector where to store the result.
jThe Jacobian to evalute.

Definition at line 384 of file jacobian.c.

References EvaluateEqualitySparseEquations(), TJacobian::J, TJacobian::neqs, NEW, TJacobian::nvars, and SubMatrixFromMatrix().

Referenced by ComputeJacobianKernelBasis(), FindRightNullVector(), GetPositionJacobian(), ManifoldDimension(), and RefineSingularPoint().

◆ EvaluateTransposedJacobianSubSetInVector()

void EvaluateTransposedJacobianSubSetInVector ( double *  v,
boolean sr,
unsigned int  nr,
unsigned int  nc,
double *  m,
TJacobian j 
)

Evaluates a subset of the transposed Jacobian for a given value of the variables and stores the result in a vector instead of in a matrix. The vector is organized column wise (1st column 2nr column, etc).

Parameters
vThe value for the variables.
srSelection of the rows of the Jacobian to store (they becoome columns in the output array).
nrNumber of rows of the the space to store the transposed Jacobian.
ncNumber of columns of the space to store the transposed Jacobian.
mThe vector where to store the result.
jThe Jacobian to evalute.

Definition at line 401 of file jacobian.c.

References EvaluateSubSetEqualitySparseEquations(), TJacobian::J, TJacobian::neqs, NEW, TJacobian::nvars, and SubMatrixFromMatrix().

Referenced by EvaluateTransposedNJacobianSubSetInVector(), and GetPositionJacobian().

◆ PrintJacobianEvaluation()

void PrintJacobianEvaluation ( FILE *  f,
double **  m,
TJacobian j 
)

Prints the result of evaluating the Jacobian. This is basically used for debug.

Parameters
fThe file where to store the jacobian.
mThe matrix with the Jacobian evaluation.
jThe Jacobian.

Definition at line 442 of file jacobian.c.

References TJacobian::neqs, and TJacobian::nvars.

◆ FreeJacobianEvaluation()

void FreeJacobianEvaluation ( double **  m,
TJacobian j 
)

Release space for the Jacobian evaluation typically allocated using AllocateJacobianEvaluation.

Parameters
mThe space to release.
jThe corresponding Jacobian.

Definition at line 462 of file jacobian.c.

References TJacobian::neqs.

◆ EvaluateJacobianXVectors()

void EvaluateJacobianXVectors ( double *  p,
unsigned int  n,
unsigned int  ng,
unsigned int *  g,
double *  v,
unsigned int *  nr,
unsigned int *  nc,
double ***  m,
TJacobian j 
)

This is a funcition with a very particular purpose. It evaluates the matrix equations in the Jacobian on a given point and then, for each matrix equation in the Jacobian, M, it evaluates M*v[i] for a set of 3D vectors, v[i]. This is used when generating the Jacobian of a given set of atom positions with respect ot the internal coordinates. In this case the Jacobian is derived from equations giving the pose P of each link from the internal coordinates. The position of an atom is P*v[i], with v[i] the center of the atom. The derivative of P*v[i] is M*v[i] with M the derivative of P w.r.t. the internal variables.

The output of this function is a matrix with 3*n rows and m columns (n=number of atoms and m= number of internal coordinates).

This is not the default size of the Jacobian and, thus, FreeJacobianEvaluation can not be used to de-allocate the space for the evaluation.

IMPORTANT: This only operates on matrix equations.

Parameters
pThe point where to evaluate the Jacobian.
nThe number of 3D vectors in v (number of atoms).
ngNumber of rigid groups of atoms (groups of vectors in v).
gThe nubmer of atoms to apply to each matrix equation. In principle the Jacobian must include one matrix equation for each link (i.e., rigid group of atoms).
vThe vector with the atom positions.
nrThe number of rows of the output Jacobian.
ncThe number of columsn of the output Jacobian.
mThe output Jacobian.
jThe Jacobian to use in the evaluation.

Definition at line 474 of file jacobian.c.

References EvaluateEquationsXVectors(), TJacobian::J, TJacobian::neqs, NEW, and TJacobian::nvars.

Referenced by WorldAtomJacobian().

◆ PrintJacobian()

void PrintJacobian ( FILE *  f,
char **  varNames,
TJacobian j 
)

Prints the equations in the symbolic Jacobian column-wise.

Parameters
fThe file where to store the equations.
varNamesThe name for each variable. Use NULL to print generic names.
jThe Jacobian structure.

Definition at line 509 of file jacobian.c.

References TJacobian::J, TJacobian::neqs, TJacobian::nvars, and PrintEquations().

◆ DeleteJacobian()