mequation.c File Reference

Detailed Description

Implementation of the matrix equation operations.

See Also
TMequation, mequation.h.

Definition in file mequation.c.

Functions

void RecomputeScalarEquations (TMequation *me)
 Recomputes the scalar equations derived from a metrix one. More...
 
void InitMEquation (TMequation *me)
 Construtor. More...
 
void CopyMEquation (TMequation *me_dst, TMequation *me_src)
 Copy constructor. More...
 
void ResetMEquation (TMequation *me)
 Resets the information stored in the matrix equation. More...
 
boolean IsEmptyMEquation (TMequation *me)
 Identify empty matrix equations. More...
 
unsigned int MEquationSize (TMequation *me)
 Size of the matrix equation. More...
 
boolean HasRotations (TMequation *me)
 Cheks if a matrix equation includes rotations. More...
 
void SetTranslationMEquation (TMequation *me)
 Sets a matrix equation as a translation equation. More...
 
boolean VarIncludedinMEquation (unsigned int v, TMequation *me)
 Checks if the matrix equation includes a given variable. More...
 
void AddDispTrans2MEquation (int s, unsigned int v, double *vect, TMequation *me)
 Adds a displacement along a vector. More...
 
void AddVarTrans2MEquation (unsigned int t, int s, unsigned int v, TMequation *me)
 Adds a variable transform to the matrix equation. More...
 
void AddPatchTrans2MEquation (unsigned int t, int s, unsigned int u, unsigned int v, double **p, TMequation *me)
 Adds a Parametrized-Patch transform to a matrix equation. More...
 
void AddCtTrans2MEquation (THTransform *t, TMequation *me)
 Adds a constant transform to a matrix equation. More...
 
void AddTransSeq2MEquation (int s, TTransSeq *ts, TMequation *me)
 Concatenates a transform sequence to the matrix equation. More...
 
unsigned int NumberScalarEquations (TMequation *me)
 Number of scaler equations defined by a matrix equation. More...
 
void ShiftVariablesInMEquation (unsigned int nv, TMequation *me)
 Adjust variable indices after removina a variable. More...
 
boolean SimplifiedMEquation (TMequation *me)
 Identifies simplified equations. More...
 
void SimplifyMEquation (TMequation *me)
 Tries to reduce the complexity of the matrix equation. More...
 
void DeriveMEquation (unsigned int v, TMequation *dme, TMequation *me)
 Derives a matrix equation. More...
 
unsigned int EvaluateMEquation (double *v, double *r, TMequation *me)
 Evaluates a matrix equation. More...
 
void EvaluateMEquationXVectors (double *v, unsigned int n, double *p, double *r, TMequation *me)
 Equation x vector evaluation. More...
 
void PrintMEquation (FILE *f, char **varNames, TMequation *me)
 Prints a Transform sequence to a file. More...
 
void DeleteMEquation (TMequation *me)
 Destructor. More...
 

Function Documentation

void RecomputeScalarEquations ( TMequation me)

Recomputes the scalar equations derived from a metrix one taking into account the used dof.

Parameters
meThe matrix equation to update.

Definition at line 30 of file mequation.c.

References AXIS_H, AXIS_X, AXIS_Y, AXIS_Z, TMequation::c, HasCtRotTransSeq(), TMequation::n, TMequation::neq, TMequation::r, RX, RY, RZ, TRUE, TMequation::ts, TX, TY, TZ, and UpdateUsedDOF().

Referenced by AddCtTrans2MEquation(), AddPatchTrans2MEquation(), AddTransSeq2MEquation(), AddVarTrans2MEquation(), InitMEquation(), and SimplifyMEquation().

void InitMEquation ( TMequation me)

Initializes a matrix equation Id=Id

Parameters
meThe matrix equation.

Definition at line 99 of file mequation.c.

References AddCtTrans2TransSeq(), FALSE, HTransformIdentity(), InitTransSeq(), TMequation::n, TMequation::neq, NEW, RecomputeScalarEquations(), TMequation::rhs, TMequation::simp, and TMequation::ts.

Referenced by GenerateMEquationFromBranch().

void CopyMEquation ( TMequation me_dst,
TMequation me_src 
)

Copies one matix equation into another.

Parameters
me_dstThe matrix equation to generate.
me_srcThe matrix equation from which to get the data.

Definition at line 113 of file mequation.c.

References TMequation::c, CopyTransSeq(), HTransformCopy(), TMequation::n, TMequation::neq, NEW, TMequation::r, TMequation::rhs, TMequation::simp, and TMequation::ts.

Referenced by AddMatrixEquation(), and CopyEquations().

void ResetMEquation ( TMequation me)

Resets the information stored in the matrix equation so that it can be re-used without delete/init.

Parameters
meThe matrix equation to reset.

Definition at line 134 of file mequation.c.

References Error(), FALSE, HTransformIdentity(), TMequation::n, TMequation::neq, ResetTransSeq(), TMequation::rhs, TMequation::simp, and TMequation::ts.

boolean IsEmptyMEquation ( TMequation me)

Identifies empty matrix equations.

Parameters
meThe matrix equation to check.

Definition at line 145 of file mequation.c.

References TMequation::neq.

unsigned int MEquationSize ( TMequation me)

Size of the matrix equation where the size is considered as the lenght of the largest tranform sequence included in the matrix equation.

Parameters
meThe matrix equation to query.
Returns
The size of the matrix equation.

Definition at line 150 of file mequation.c.

References TMequation::n, TransSeqSize(), and TMequation::ts.

boolean HasRotations ( TMequation me)

Cheks if a matrix equation includes rotations.

Parameters
meThe matrix equation to check.
Returns
TRUE if the matrix equation includes rotations.

Definition at line 163 of file mequation.c.

References TMequation::n, RX, RY, RZ, TMequation::ts, and UpdateUsedDOF().

Referenced by AddMatrixEquation().

void SetTranslationMEquation ( TMequation me)

Modifies a matrix equation so that only their translation part is taken into consideration when evaluating them.

Parameters
meThe matrix to modify.

Definition at line 174 of file mequation.c.

References AXIS_H, TMequation::c, Error(), TMequation::neq, TMequation::r, TMequation::simp, and TRUE.

boolean VarIncludedinMEquation ( unsigned int  v,
TMequation me 
)

Checks if the matrix equation includes a given variable.

Parameters
vThe variable identifier.
meThe matrix equation to check.
Returns
TRUE if the matrix equations includes variable 'v'.

Definition at line 191 of file mequation.c.

References FALSE, TMequation::ts, and VarIncludedinTransSeq().

Referenced by RemoveEquationsWithVar(), UsedVarInEquations(), and UsedVarInNonDummyEquations().

void AddDispTrans2MEquation ( int  s,
unsigned int  v,
double *  vect,
TMequation me 
)

Adds a variable transform that represents a scaled displacement along a vector.

Parameters
sThe sign for 'v'.
vVariable involved in the transform.
vectVector defining the displacement.
meThe matrix equation to enlarge.

Definition at line 206 of file mequation.c.

References AddDispTrans2TransSeq(), and TMequation::ts.

void AddVarTrans2MEquation ( unsigned int  t,
int  s,
unsigned int  v,
TMequation me 
)

Adds a variable transform at the end of a matrix equation.

Parameters
tType of transform.
sThe sign for 'v'.
vVariable involved in the transform.
meThe matrix equation to enlarge.

Definition at line 212 of file mequation.c.

References AddVarTrans2TransSeq(), Error(), TMequation::n, RecomputeScalarEquations(), TMequation::simp, and TMequation::ts.

void AddPatchTrans2MEquation ( unsigned int  t,
int  s,
unsigned int  u,
unsigned int  v,
double **  p,
TMequation me 
)

Adds a Parametrized-Patch transform to a matrix equation.

Parameters
tSubtype of PA transform (PA,dPA_U,dPA_V,ddPA_UU,d2PA_UV,ddPA_VV).
sThe sign of the transform (-1 means to invert the transform).
uFirst variable (parameter) involved in the transform.
vSecond variable (parameter) involved in the transform.
pThe four points defining the patch.
meThe matrix equation to enlarge.

Definition at line 224 of file mequation.c.

References AddPatchTrans2TransSeq(), Error(), TMequation::n, RecomputeScalarEquations(), TMequation::simp, and TMequation::ts.

void AddCtTrans2MEquation ( THTransform t,
TMequation me 
)

Adds a constant transform at the end of a matrix equation.

Note that identity transforms or matrices that result in identity transforms when added at the end of the sequence are skipped.

Parameters
tThe transform to add.
meThe matrix equation to enlarge..

Definition at line 238 of file mequation.c.

References AddCtTrans2TransSeq(), Error(), TMequation::n, RecomputeScalarEquations(), TMequation::simp, and TMequation::ts.

void AddTransSeq2MEquation ( int  s,
TTransSeq ts,
TMequation me 
)

Concatenates a transform sequence to the matrix equation.

Parameters
sThe sign of the transform. If below 0, the tranform sequence has to be inverted before adding it.
tsThe transform to add.
meThe matrix equation to update.

Definition at line 250 of file mequation.c.

References AddTrans2TransSeq(), DeleteTrans(), Error(), GetElementFromTransSeq(), TMequation::n, RecomputeScalarEquations(), TMequation::simp, TransInvert(), TransSeqSize(), and TMequation::ts.

Referenced by GenerateMEquationFromBranch().

unsigned int NumberScalarEquations ( TMequation me)

Number of scaler equations defined by a matrix equation.

Parameters
meThe matrix equation to check.
Returns
Number of scaler equations defined by a matrix equation.

Definition at line 281 of file mequation.c.

References TMequation::neq.

Referenced by AddMatrixEquation().

void ShiftVariablesInMEquation ( unsigned int  nv,
TMequation me 
)

After removing a variable not used in the system we have to shift down the indices of the variables with larger index than the removed one.

Parameters
nvThe removed variable.
meThe matrix equation.

Definition at line 286 of file mequation.c.

References TMequation::n, ShiftVariablesInTransSeq(), and TMequation::ts.

Referenced by RemoveEquationsWithVar().

boolean SimplifiedMEquation ( TMequation me)

Identifies simplified equations. The simplification is the last step in the definition of a matrix equation. Only simplified equations can be added to cuiksystem.

Parameters
meThe equation to query.
Returns
TRUE if the equation is already simplified.

Definition at line 294 of file mequation.c.

References TMequation::simp.

Referenced by AddMatrixEquation2CS().

void SimplifyMEquation ( TMequation me)

Performs operations in order to simplify the computations with the matrix equation. This should only be used when the matrix equation is fully defined. If new terms are added to the matrix equatoin after the simplification, the equation might become inconsistent.

Right now we only simplify single transforms sequence equated to the identity. Other simplifications might be possible (i,e, move to the right hand side constant terms in the sum of matrix expressions). Howerver these cases are less frequent and, thus we do not consider them.

Parameters
meThe equaton to simplify.

Definition at line 299 of file mequation.c.

References Error(), TMequation::n, TMequation::neq, RecomputeScalarEquations(), TMequation::simp, SimplifyTransSeq(), TRUE, and TMequation::ts.

Referenced by GenerateMEquationFromBranch().

void DeriveMEquation ( unsigned int  v,
TMequation dme,
TMequation me 
)

Derives a matrix equation. This results in one or more matrix product sequences equated to zero.

Parameters
vThe derivation variable.
dmeThe output derived matrix equation.
meThe matrix equation to derive.

Definition at line 312 of file mequation.c.

References TMequation::c, DeriveTransSeq(), Error(), HTransformZero(), MEM_EXPAND, TMequation::n, TMequation::neq, NEW, TMequation::r, TMequation::rhs, TMequation::simp, TRUE, and TMequation::ts.

Referenced by DeriveEqualityEquations().

unsigned int EvaluateMEquation ( double *  v,
double *  r,
TMequation me 
)

Evaluates a matrix equation and stores the result on a given array. Note that the result only includes values for the scalar equations derived from the matrix equation.

Parameters
vValue for the variables.
rThe array where to store the results.
meThe matrix equation to evaluate.
Returns
The number of output values stores in r (
See Also
NumberScalarEquations).

Definition at line 356 of file mequation.c.

References TMequation::c, EvaluateTransSeq(), HTransformDelete(), HTransformGetElement(), TMequation::n, TMequation::neq, TMequation::r, TMequation::rhs, and TMequation::ts.

Referenced by EvaluateEqualityEquations(), EvaluateEqualitySparseEquations(), EvaluateSubSetEqualityEquations(), and EvaluateSubSetEqualitySparseEquations().

void EvaluateMEquationXVectors ( double *  v,
unsigned int  n,
double *  p,
double *  r,
TMequation me 
)

Evalutes a matrix equation and returns the result of muliplying the resulting matrix with a set of 3D vectors.

See EvaluateJacobianXVectors why this is useful at all.

Parameters
vThe value for the variables.
nThe number of vectors.
pThe 3D vectors (stacked in one array).
rThe output vector with the evaluation.
meThe matrix equation to use in the evaluation.

Definition at line 378 of file mequation.c.

References AccumulateVector(), EvaluateTransSeq(), HTransformApply(), HTransformDelete(), TMequation::n, TMequation::neq, and TMequation::ts.

Referenced by EvaluateEquationsXVectors().

void PrintMEquation ( FILE *  f,
char **  varNames,
TMequation me 
)

Prints a Transform sequence to a file.

Parameters
fThe file.
varNamesThe variable names, if available (otherwise set thie to NULL).
meThe matrix equation to print.

Definition at line 414 of file mequation.c.

References HTransformIsIdentity(), TMequation::n, PrintTransSeq(), TMequation::rhs, and TMequation::ts.

Referenced by PrintEquations().

void DeleteMEquation ( TMequation me)

Releases the memeory stored by a matrix equation.

Parameters
meThe matrix equation to delete.

Definition at line 432 of file mequation.c.

References DeleteTransSeq(), HTransformDelete(), TMequation::n, TMequation::rhs, and TMequation::ts.

Referenced by DeleteEquations(), DeriveEqualityEquations(), GenerateEquationsFromBranch(), and GenerateWorldEquations().