jacobian.c File Reference

Detailed Description

Implementation of the TJacobian type and the associated functions.

See Also
TJacobian, jacobian.h.

Definition in file jacobian.c.

Functions

void InitJacobian (Tvariables *vs, Tequations *eqs, TJacobian *j)
 Constructor. More...
 
void CopyJacobian (TJacobian *j_dst, TJacobian *j_src)
 Constructor. 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 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

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 16 of file jacobian.c.

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

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

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 34 of file jacobian.c.

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

Referenced by CopyCuikSystem().

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 evaluate.

Definition at line 49 of file jacobian.c.

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

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

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 55 of file jacobian.c.

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

Referenced by InitHessian().

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 63 of file jacobian.c.

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

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

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

Allocate space for the Jacobian evaluation.

Parameters
mThe allocated space.
jThe Jacobian to evaluate.

Definition at line 71 of file jacobian.c.

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

Referenced by EvaluateCSJacobian().

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 85 of file jacobian.c.

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

Referenced by EvaluateCSJacobian().

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 103 of file jacobian.c.

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

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

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 120 of file jacobian.c.

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

Referenced by Chart2Manifold(), and GetChartDegree().

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 143 of file jacobian.c.

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

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

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 160 of file jacobian.c.

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

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 183 of file jacobian.c.

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

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 200 of file jacobian.c.

References TJacobian::neqs.

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 212 of file jacobian.c.

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

Referenced by WorldAtomJacobian().

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 244 of file jacobian.c.

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

void DeleteJacobian ( TJacobian j)