equations.h File Reference

Detailed Description

Definition of the Tequations type and the associated functions.

See Also
Tequations, equations.c.

Definition in file equations.h.

Data Structures

struct  TequationInfo
 Information associated with each scalar equation in the equation set. More...
 
struct  Tequations
 Set of equations. More...
 

Macros

#define INIT_NUM_EQUATIONS   10
 Initial room for equations. More...
 

Functions

void InitEquations (Tequations *eqs)
 Constructor. More...
 
void CopyEquations (Tequations *eqs_dst, Tequations *eqs_src)
 Copy constructor. More...
 
void MergeEquations (Tequations *eqs1, Tequations *eqs)
 Copy constructor. More...
 
boolean UsedVarInNonDummyEquations (unsigned int nv, Tequations *eqs)
 Checks if a variable is used in the set of equations. More...
 
boolean UsedVarInEquations (unsigned int nv, Tequations *eqs)
 Checks if a variable is used in the set of equations. More...
 
void RemoveEquationsWithVar (double epsilon, unsigned int nv, Tequations *eqs)
 Removes all equations that include a given variable. More...
 
boolean ReplaceVariableInEquations (double epsilon, unsigned int nv, TLinearConstraint *lc, Tequations *eqs)
 Replaces a variable with a linear expression. More...
 
boolean GaussianElimination (Tequations *eqs)
 Perform Gaussian elimination on the set of equations. More...
 
unsigned int NEquations (Tequations *eqs)
 Number of equations in the set. More...
 
unsigned int NSystemEquations (Tequations *eqs)
 Number of system equations in the set. More...
 
unsigned int NCoordEquations (Tequations *eqs)
 Number of coordenalization equations in the set. More...
 
unsigned int NDummyEquations (Tequations *eqs)
 Number of dummy equations in the set. More...
 
unsigned int NEqualityEquations (Tequations *eqs)
 Number of equalities in the set. More...
 
unsigned int NInequalityEquations (Tequations *eqs)
 Number of inequalities in the set. More...
 
boolean PolynomialEquations (Tequations *eqs)
 Identify polynomial system of equations. More...
 
boolean ScalarEquations (Tequations *eqs)
 Identifies scalar systems. More...
 
boolean IsSystemEquation (unsigned int i, Tequations *eqs)
 Identify system equations. More...
 
boolean IsCoordEquation (unsigned int i, Tequations *eqs)
 Identify coordenalization equations. More...
 
boolean IsDummyEquation (unsigned int i, Tequations *eqs)
 Identify dummy equations. More...
 
unsigned int GetEquationTypeN (unsigned int i, Tequations *eqs)
 Gets the type of a particular equation. More...
 
boolean HasEquation (Tequation *equation, Tequations *eqs)
 Checks if a given equation is already in the set. More...
 
void AddEquation (Tequation *equation, Tequations *eqs)
 Adds an equation to the set. More...
 
void AddEquationNoSimp (Tequation *equation, Tequations *eqs)
 Adds an equation to the set. More...
 
void AddMatrixEquation (TMequation *equation, Tequations *eqs)
 Adds a matrix equation to the set. More...
 
TequationGetEquation (unsigned int n, Tequations *eqs)
 Gets an equation from the set. More...
 
unsigned int CropEquation (unsigned int ne, unsigned int varType, double epsilon, double rho, Tbox *b, Tvariables *vs, Tequations *eqs)
 Equation-wise crop. More...
 
boolean AddEquation2Simplex (unsigned int ne, double lr2tm_q, double lr2tm_s, double epsilon, unsigned int safeSimplex, double rho, Tbox *b, Tvariables *vs, TSimplex *lp, Tequations *eqs)
 Adds an equation to the simplex. More...
 
void UpdateSplitWeight (unsigned int ne, double *splitDim, Tbox *b, Tequations *eqs)
 Computes the linearization error induced by the variables of a given equation. More...
 
void EvaluateEqualityEquations (boolean systemOnly, double *v, double *r, Tequations *eqs)
 Evaluates all equality equations in the set. More...
 
void EvaluateSubSetEqualityEquations (double *v, boolean *se, double *r, Tequations *eqs)
 Evaluates a subset of the equality equations in the set. More...
 
void EvaluateEqualitySparseEquations (double *v, double *r, Tequations *eqs)
 Evaluates the set of equality equations for sparse systems. More...
 
void EvaluateSubSetEqualitySparseEquations (double *v, boolean *se, double *r, Tequations *eqs)
 Evaluates a subset of the set of equality equations for sparse systems. More...
 
void EvaluateEquationsXVectors (double *v, unsigned int ng, unsigned int *g, double *p, double *r, Tequations *eqs)
 Evaluates the matrix equations multiplied by some given vectors. More...
 
void EvaluateInequalityEquations (double *v, double *r, Tequations *eqs)
 Error in inequalities. More...
 
void DeriveEqualityEquations (unsigned int v, Tequations *deqs, Tequations *eqs)
 Derives an equation set. More...
 
void PrintEquations (FILE *f, char **varNames, Tequations *eqs)
 Prints a set of equations. More...
 
void DeleteEquations (Tequations *eqs)
 Destructor. More...
 

Macro Definition Documentation

#define INIT_NUM_EQUATIONS   10

Initial room for equations in an equation set. It will be enlarged if necessary.

See Also
Tequations

Definition at line 30 of file equations.h.

Referenced by InitEquations().

Function Documentation

void CopyEquations ( Tequations eqs_dst,
Tequations eqs_src 
)
void MergeEquations ( Tequations eqs1,
Tequations eqs 
)

Adds a set of equations to another.

Parameters
eqs1The equation set to add.
eqsThe set where to add the equations.

Definition at line 815 of file equations.c.

References AddEquation(), AddMatrixEquation(), Tequations::eqEQU, Tequations::equation, GetOriginalEquation(), Tequations::m, Tequations::mequation, Tequations::mm, and Tequations::nsEQU.

Referenced by CuikSystemMerge().

boolean UsedVarInNonDummyEquations ( unsigned int  nv,
Tequations eqs 
)

Checks if a variable is used in non-dummy equations of the set of equations.

Parameters
nvThe identifier of the variable to look for.
eqsThe equation set from where to get the information.
Returns
TRUE if the variable nv appears in any of the non-dummy equations of the set eqs.

Definition at line 835 of file equations.c.

References DUMMY_EQ, Tequations::equation, FALSE, GetEquationType(), GetEquationVariables(), GetOriginalEquation(), Tequations::mequation, VarIncluded(), and VarIncludedinMEquation().

Referenced by CSRemoveUnusedVars().

boolean UsedVarInEquations ( unsigned int  nv,
Tequations eqs 
)

Checks if a variable is used in the set of equations.

Parameters
nvThe identifier of the variable to look for.
eqsThe equation set from where to get the information.
Returns
TRUE if the variable nv appears in the set eqs.

Definition at line 860 of file equations.c.

References Tequations::equation, FALSE, GetEquationVariables(), GetOriginalEquation(), Tequations::mequation, VarIncluded(), and VarIncludedinMEquation().

Referenced by CSRemoveUnusedVars(), and SampleCuikSystemInBox().

void RemoveEquationsWithVar ( double  epsilon,
unsigned int  nv,
Tequations eqs 
)

Removes all equations that include a given variable. This is one of the steps to remove a variable from a problem. Therefore, equations that do not include the given variable are also affected by this function: we have to shift all the variable indexes higher than the given one.

The use of this function without using function RemoveVariable right immediately after it leaves the cuiksystem in a incoherent state.

Parameters
epsilonMonomials with a constant below epsilon are eliminated.
nvThe identifier of the variable to remove.
eqsThe set of equations to update.

Definition at line 882 of file equations.c.

References AddEquation(), CopyEquations(), DeleteEquations(), Tequations::equation, Error(), FALSE, FixVariableInEquation(), GetEquationVariables(), GetOriginalEquation(), InitEquations(), Tequations::mequation, Tequations::n, Tequations::nm, ShiftVariablesInMEquation(), VarIncluded(), and VarIncludedinMEquation().

Referenced by CSRemoveUnusedVars().

boolean ReplaceVariableInEquations ( double  epsilon,
unsigned int  nv,
TLinearConstraint lc,
Tequations eqs 
)

Replaces a variable by linear combination of variables (including an offset).

The use of this function without using function RemoveVariable right immediately after it leaves the cuiksystem in a incoherent state.

Parameters
epsilonMonomials with a constant below epsilon are eliminated.
nvThe variable to replace.
lcThe linear constraint to use in the replacement.
eqsThe equation set from where to get the information.
Returns
TRUE the equation set still holds after replacing the equation.
See Also
SimplifyCuikSystem

Definition at line 925 of file equations.c.

References AddEquation(), CopyEquations(), DeleteEquations(), Tequations::equation, Error(), FALSE, GetOriginalEquation(), InitEquations(), ReplaceVariableInEquation(), Tequations::scalar, and TRUE.

Referenced by CSRemoveLCVars(), and CSRemoveVarsWithCtRange().

boolean GaussianElimination ( Tequations eqs)

Operates linearly pairs of equations (scale one of the and then sum them) with the objective of getting a simpler equation (i.e., one with less monomials). The rationale is that equations with less monomials produce simpler problems and, in some cases, they can trigger simplifications that are not evident at first sight.

The use of this function without using function RemoveVariable right immediately after it leaves the cuiksystem in a incoherent state.

Parameters
eqsThe equation set to be simplified.
Returns
TRUE the equation set still holds after replacing the equation.
See Also
AccumulateEquations, SimplifyCuikSystem

Definition at line 963 of file equations.c.

References AccumulateEquations(), AddEquation(), CopyEquation(), CopyEquations(), DeleteEquation(), DeleteEquations(), DUMMY_EQ, EQU, Tequations::equation, Error(), FALSE, FindMonomial(), GetEquationCmp(), GetEquationNumVariables(), GetEquationType(), GetMonomial(), GetMonomialCt(), GetNumMonomials(), GetOriginalEquation(), InitEquations(), NEquations(), NO_UINT, PrintEquation(), Tequations::scalar, and TRUE.

Referenced by SimplifyCuikSystem().

unsigned int NEquations ( Tequations eqs)

Number of equations in the set.

Parameters
eqsThe equation set.
Returns
The number of equations in the set.

Definition at line 1075 of file equations.c.

References Tequations::neq.

Referenced by CSRemoveLCVars(), DummifyCuikSystem(), GaussianElimination(), GetCSNumEquations(), and UpdateCuikSystem().

unsigned int NSystemEquations ( Tequations eqs)

Number of system equations in the set.

Parameters
eqsThe equation set.
Returns
The number of system equations in the set.

Definition at line 1080 of file equations.c.

References Tequations::s.

unsigned int NCoordEquations ( Tequations eqs)

Number of coordenalization equations in the set.

Parameters
eqsThe equation set.
Returns
The number of coordenalization equations in the set.

Definition at line 1085 of file equations.c.

References Tequations::c.

unsigned int NDummyEquations ( Tequations eqs)

Number of dummy equations in the set.

Parameters
eqsThe equation set.
Returns
The number of dummy equations in the set.

Definition at line 1090 of file equations.c.

References Tequations::d.

unsigned int NEqualityEquations ( Tequations eqs)

Number of equality equations in the set.

Parameters
eqsThe equation set.
Returns
The number of equality equations in the set.

Definition at line 1095 of file equations.c.

References Tequations::e.

Referenced by ErrorInCSEquations(), ErrorInSimpCSEquations(), ErrorInSolution(), InitJacobian(), and UpdateCuikSystem().

unsigned int NInequalityEquations ( Tequations eqs)

Number of inequality equations in the set.

Parameters
eqsThe equation set.
Returns
The number of inequality equations in the set.

Definition at line 1100 of file equations.c.

References Tequations::e, and Tequations::neq.

Referenced by ErrorInInequalities(), ErrorInSimpInequalitiesOnPoint(), InequalitiesHoldOnPoint(), and SimpInequalitiesHoldOnPoint().

boolean PolynomialEquations ( Tequations eqs)

Identify polynomial system of equations.

Parameters
eqsThe equation set to query.
Returns
TRUE if the set is composed only by polynomial equations.

Definition at line 1105 of file equations.c.

References Tequations::polynomial.

Referenced by IsCSPolynomial(), and SimplifyCuikSystem().

boolean ScalarEquations ( Tequations eqs)

Identifies scalar systems (systems with no matrix equations).

Parameters
eqsThe equation to check.

Definition at line 1110 of file equations.c.

References Tequations::scalar.

Referenced by CuikSystemMerge().

boolean IsSystemEquation ( unsigned int  i,
Tequations eqs 
)

Identify system equations.

Parameters
iThe identifier of the equation to check.
eqsThe equation set.
Returns
TRUE if the selecte equation is a system equation.

Definition at line 1115 of file equations.c.

References Tequations::equation, Error(), GetEquationType(), GetOriginalEquation(), Tequations::neq, SYSTEM_EQ, and TRUE.

Referenced by PrintEquations().

boolean IsCoordEquation ( unsigned int  i,
Tequations eqs 
)

Identify coordenalization equations.

Parameters
iThe identifier of the equation to check.
eqsThe equation set.
Returns
TRUE if the selected equation is a coordenalization equation.

Definition at line 1126 of file equations.c.

References COORD_EQ, Tequations::equation, Error(), GetEquationType(), GetOriginalEquation(), and Tequations::neq.

Referenced by PrintEquations(), and RegenerateSolution().

boolean IsDummyEquation ( unsigned int  i,
Tequations eqs 
)

Identify dummy equations.

Parameters
iThe identifier of the equation to check.
eqsThe equation set.
Returns
TRUE if the selected equation is a dummy equation.

Definition at line 1135 of file equations.c.

References DUMMY_EQ, Tequations::equation, Error(), GetEquationType(), GetOriginalEquation(), and Tequations::neq.

Referenced by PrintEquations(), and RegenerateSolution().

unsigned int GetEquationTypeN ( unsigned int  i,
Tequations eqs 
)

Gets the type of a particular equation.

Parameters
iThe identifier of the equation to check.
eqsThe equation set.
Returns
The type of the selected eqution of NOTYPE_EQ if there is no equation with the given identifier in the set.

Definition at line 1144 of file equations.c.

References Tequations::equation, Error(), GetEquationType(), GetOriginalEquation(), Tequations::neq, NOTYPE_EQ, and SYSTEM_EQ.

boolean HasEquation ( Tequation equation,
Tequations eqs 
)

Checks if a given equation is already in the set.

Parameters
equationThe equation.
eqsThe equation set.
Returns
TRUE if the given equation is already in the set.

Definition at line 1160 of file equations.c.

References CmpEquations(), Tequations::equation, FALSE, and GetOriginalEquation().

Referenced by AddEquation().

void AddEquation ( Tequation equation,
Tequations eqs 
)

Adds an equation to the set and computes its associated information. Empty equations (equations with no monomials) or repeated equations are not added to the set. Moreover, equations are sorted from simplest to more complex.

Parameters
equationThe equation to be added.
eqsThe equation set.
See Also
TequationInfo.

Definition at line 1629 of file equations.c.

References AddEquationInt(), CmpEquations(), Tequations::equation, Error(), GetEquationCmp(), GetEquationType(), GetNumMonomials(), GetOriginalEquation(), HasEquation(), Tequations::n, NOCMP, NormalizeEquation(), and NOTYPE_EQ.

Referenced by AddEquation2CS(), DummifyAndAddEquation(), GaussianElimination(), MergeEquations(), RemoveEquationsWithVar(), and ReplaceVariableInEquations().

void AddEquationNoSimp ( Tequation equation,
Tequations eqs 
)

Adds an equation to the set and computes its associated information. This is like AddEquation but all equations are considered (even the empty or repeated ones) and equations are not sorted. This must be used in equation sets where the order of the equations must be preserved. This happens for some equations sets defined in the Tworld.

Parameters
equationThe equation to be added.
eqsThe equation set.
See Also
TequationInfo.

Definition at line 1656 of file equations.c.

References AddEquationInt(), Error(), GetEquationCmp(), GetEquationType(), NOCMP, and NOTYPE_EQ.

Referenced by GenerateWorldEquations().

void AddMatrixEquation ( TMequation equation,
Tequations eqs 
)

Adds a matrix equation to the set and computes its associated information.

Parameters
equationThe equation to be added.
eqsThe equation set.

Definition at line 1665 of file equations.c.

References CopyMEquation(), Tequations::e, Tequations::eqEQU, FALSE, HasRotations(), MEM_DUP, Tequations::mequation, Tequations::mm, Tequations::neq, NEW, Tequations::nm, Tequations::nsEQU, NumberScalarEquations(), Tequations::polynomial, Tequations::s, and Tequations::scalar.

Referenced by AddMatrixEquation2CS(), DeriveEqualityEquations(), GenerateWorldEquations(), and MergeEquations().

Tequation* GetEquation ( unsigned int  n,
Tequations eqs 
)

Returns a pointer to the n-th equation stored in the set.

Parameters
nThe number of equation to get.
eqsThe equation set.

Definition at line 1697 of file equations.c.

References Tequations::equation, Error(), GetOriginalEquation(), and Tequations::scalar.

Referenced by CSRemoveLCVars(), DummifyCuikSystem(), GenerateWorldSingularityEquations(), GetCSEquation(), and GetJacobianEquation().

unsigned int CropEquation ( unsigned int  ne,
unsigned int  varType,
double  epsilon,
double  rho,
Tbox b,
Tvariables vs,
Tequations eqs 
)

Gets a box (as an array of parameters is of size m) and uses the equation number ne to reduce the ranges of the variables involved in the equation as much as possible.
Only equalities are used for crop (LEQ and GEQ equations are not taken into account).
We use different crop procedures according to the type of equation: LINEAR_EQ, PARABOLA_EQ, SADDLE_EQ, CIRCLE_EQ, SPHERE_EQ or GENERAL_EQ. In the GENERAL_EQ case, equations a the linear approximation is used for the crop. This does not produce the stronger possible crop. For this reason, we implemented non-linear crop for the non-linear equations that appear often in the systems of equations (due to dummification, for instance).

Parameters
neThe equation to use in the crop.
varTypeThe type of variables to which apply the crop. Use ANY_TYPE_VAR for the crop to affect all types of variables.
epsilonOnly ranges with a size larger than epsilon are reduced.
rhoThe crop is repeated as far as the ranges for the variables in the equation reduce a ratio larger than rho.
bThe box with the ranges to crop.
vsThe variable set on which the equations are defined. Used to get the type of variables.
eqsThe equation set.
Returns
NOT_REDUCED_BOX, EMPTY_BOX, REDUCED_BOX
See Also
ReduceBoxEquationWise

Definition at line 1175 of file equations.c.

References BILINEAL_MONOMIAL_EQUATION, BoxSaddleClipping(), BoxSphereClipping(), CIRCLE_EQUATION, CopyBox(), CopyInterval(), CropLinearConstraint(), DeleteBox(), DeleteLinearConstraint(), EMPTY_BOX, TequationInfo::EqType, EQU, Tequations::equation, Error(), EvaluateEquationInt(), FALSE, GENERAL_EQUATION, GetBoxIntervals(), GetBoxNIntervals(), GetEquationBounds(), GetEquationCmp(), GetEquationValue(), GetEquationVariables(), GetFirstOrderApproximationToEquation(), GetLinearConstraintError(), GetMonomial(), GetMonomialCt(), GetMonomialVariables(), GetNumMonomials(), GetOriginalEquation(), GetVariableN(), GetVariableTypeN(), INF, Intersect(), IntervalCenter(), IntervalSize(), TequationInfo::lc, LINEAR_EQUATION, LowerLimit(), TequationInfo::n, Tequations::n, Tequations::neq, NEW, NewInterval(), NOT_REDUCED_BOX, PARABOLA_EQUATION, PolynomialEquation(), PrintEquation(), PrintInterval(), RectangleCircleClipping(), RectangleParabolaClipping(), REDUCED_BOX, SADDLE_EQUATION, SetLinearConstraintError(), SimplexExpandBounds(), SPHERE_EQUATION, TRUE, UpperLimit(), VariableSetSize(), and ZERO.

Referenced by AddEquation2Simplex(), ReduceBoxEquationWise(), and RegenerateSolution().

boolean AddEquation2Simplex ( unsigned int  ne,
double  lr2tm_q,
double  lr2tm_s,
double  epsilon,
unsigned int  safeSimplex,
double  rho,
Tbox b,
Tvariables vs,
TSimplex lp,
Tequations eqs 
)

Adds linear constraints representing the selected equation (i.e., a linear relaxation of the equation) to a simplex tableau. Linear constraints are directly added to the simplex using the information cached in the TequationInfo structure. Non linear equations are linearized using the information stored in the Jacobian and Hessian fields in the corresponding TequationInfo too. Different equations are linearized in a different way

  • For Parabola equations y=x^2: Two planes defined at the center of the x range and, if the variables in the equation are larger than lr2tm_q, we add one plane at each one of the extremes of the x range.
  • For Circle equations x^2+y^2=r^2: Two planes defined at the center of the x-y range and, if the variables in the equation are larger than lr2tm_q, we add one plane tangent to the circle for the corners of the x-y box that are out of the circle.
    • For Sphere equations x^2+y^2+z^2=r^2: Two planes defined at the center of the x-y-z range and, if the variables in the equation are larger than lr2tm_q, we add one plane tangent to the sphere for the corners of the x-y-z box that are out of the sphere.
  • For Saddle equations z=x*y: if the variables in the equation are larger than lr2tm_s, we add one plane for each corner of the x-y square. Otherwise we linearize the equation as a general equation (two planes defined at the center of the x,y,z box).
  • For the rest of equations, a couple of planes defined from the linearization of the equation at the center of the sub-box defined by the variables involved in the equation plus-less an error defined from the remainder of the linearization. For equalities we add the two planes defined in such a way but for inequalities only one plane is necessary.

By using small lr2tm_q and lr2tm_s we generate linear relaxations that tightly bound the functions and this reduces the number of iterations to found the solution. The drawnback is that we we add more constraints to the simplex and this slows downs each iteration.

Equations that define particular variables (cartesian or dummy ones) are only added to the simplex if the variable is used in any of the other constraints already in the simplex. Otherwise we will add useless constraints. This filter is implemented with the array of booleans usedVar. This array is updated as we add equations to the simplex and is checked to see if defined variables are used before adding the corresponding equation to the simplex. For this to be operative, equations are ordered so that system equations are added first to the simplex, then cartesian equations and, finally, dummyfications equations.

There is no need to equations that involves almost constant variables to the simplex. Thus, before adding an EQU equation to the simplex, we evaluate the equations using interval arithmetics and if the result is almost constant(this occurs if the variables involved in the equation are have tiny ranges) we just check if the equation holds or not. If not, the system has no solution.

The same applies to inequalities that already hold. An inequality (LEQ, GEQ equations) that trivially holds do not add any constrain to the simplex and, consequently we do not add it to the Tableau.

Parameters
neThe number of the equation to add.
lr2tm_qSize of the variables in the equation to switch between a specific linearization and a general one for spheres, circles, and parabolas.
lr2tm_sSize of the variables in the equation to switch between a specific linearization and a general one for saddle equations.
epsilonWhen generating a linear constraints, coefficients below epsilon are discarted, since the simplex process has troubles with too small values.
safeSimplexDegree of numerical stability in the simplex as specified by the user in the SAFE SIMPLEX parameter.
rhoBefore adding the equation to the simplex it is croped and the crop process is repeated as far as the variables reduce more than rho. Ranges smaller than epsilon are not reduced any further.
bThe box with the variable ranges. It defines the area where to linearize the equations and where to compute the linearization error, if necessary.
vsThe set of variables. Used to get the type of variables in GetDefinedVar
lpThe simplex structure where to add the constraints.
eqsThe equation set.
See Also
CropEquation, GetDefinedVar
Returns
TRUE if the simplex is still feasible after adding the linear constraints.

Definition at line 2185 of file equations.c.

References ANY_TYPE_VAR, BILINEAL_MONOMIAL_EQUATION, CIRCLE_EQUATION, CleanInfEquation(), CropEquation(), DeleteEquation(), DeleteEquationInfo(), EMPTY_BOX, TequationInfo::EqType, EQU, Tequations::equation, Error(), EvaluateEquationInt(), FALSE, GENERAL_EQUATION, GEQ, GetBoxIntervals(), GetBoxMinSizeVarSet(), GetEquationCmp(), GetEquationValue(), GetEquationVariables(), GetOriginalEquation(), INF, IntervalOffset(), IntervalSize(), IsInside(), TequationInfo::lc, LEQ, LINEAR_EQUATION, LinearizeBilinealMonomialEquation(), LinearizeCircleEquation(), LinearizeGeneralEquation(), LinearizeParabolaEquation(), LinearizeSaddleEquation(), LinearizeSphereEquation(), LowerLimit(), NEW, PARABOLA_EQUATION, PrintEquation(), PrintInterval(), SADDLE_EQUATION, Tequations::scalar, SetEquationInfo(), SimplexAddNewConstraint(), SPHERE_EQUATION, TRUE, and UpperLimit().

Referenced by ReduceBox().

void UpdateSplitWeight ( unsigned int  ne,
double *  splitDim,
Tbox b,
Tequations eqs 
)

When the SPLIT_ERROR parameter is set to TRUE, we select the split variable for a box from the linearization error induced by the variables. This function updates the error induced by the variables in a given equation.

Parameters
neThe equation to use in the update.
splitDimThe array with the linearization errors induced by the variables to be updated.
bThe box with the ranges for the variables.
eqsThe equation set.

Definition at line 2430 of file equations.c.

References TequationInfo::EqType, TequationInfo::equation, Tequations::equation, Error(), ErrorDueToVariable(), GetBoxIntervals(), GetBoxNIntervals(), GetEquationVariables(), GetVariableN(), IntervalCenter(), LINEAR_EQUATION, TequationInfo::n, NEW, and Tequations::scalar.

Referenced by ComputeSplitDimInt().

void EvaluateEqualityEquations ( boolean  systemOnly,
double *  v,
double *  r,
Tequations eqs 
)

Evaluates all equality equations in the set. This includes the equality scalar equations and all matrix equations.

Parameters
systemOnlyTRUE to evaluate only the system equalities. The rest are evalated to 0 (as if they hold).
vThe value for the variables.
rthe array where to store the result.
eqsThe equations to evaluate.

Definition at line 2477 of file equations.c.

References EQU, Tequations::equation, EvaluateMEquation(), EvaluateWholeEquation(), GetEquationCmp(), GetEquationType(), GetOriginalEquation(), Tequations::mequation, Tequations::n, Tequations::nm, and SYSTEM_EQ.

Referenced by CuikNewtonInBox(), CuikNewtonSimp(), ErrorInCSEquations(), ErrorInSimpCSEquations(), ErrorInSolution(), EvaluateCSEquations(), EvaluateHessian(), EvaluateJacobian(), EvaluateSimpCSEquations(), GetLinkTransformsFromSolution(), and PrintWorldAxes().

void EvaluateSubSetEqualityEquations ( double *  v,
boolean se,
double *  r,
Tequations eqs 
)

Evaluates a subset of the equality equations in the set. This includes the equality scalar equations and some of the matrix equations.

Parameters
vThe value for the variables.
seThe selected equations. This is a subset of the equality equations, not of all equations. Thus the size of this boolean array must the one returned by NEqualityEquations.
rthe array where to store the result. The size of this array is the same as the number of TRUE entries in array 'se'. The space must be allocated externally.
eqsThe equations to evaluate.

Definition at line 2505 of file equations.c.

References EQU, Tequations::equation, EvaluateMEquation(), EvaluateWholeEquation(), GetEquationCmp(), GetOriginalEquation(), MAX_EQ_MATRIX, Tequations::mequation, Tequations::n, and Tequations::nm.

Referenced by EvaluateSubSetSimpCSEquations().

void EvaluateEqualitySparseEquations ( double *  v,
double *  r,
Tequations eqs 
)

In sparse systems, many equations are empty. This function is a variant of EvaluateEqualityEquations specialy efficient for this kind of systems.

Parameters
vThe value for the variables.
rthe array where to store the result.
eqsThe equations to evaluate.

Definition at line 2563 of file equations.c.

References CacheScalarEQUInfo(), Tequations::eqEQU, EvaluateMEquation(), EvaluateWholeEquation(), Tequations::mequation, Tequations::n, Tequations::nm, and Tequations::nsEQU.

Referenced by EvaluateJacobianInVector(), and EvaluateTransposedJacobianInVector().

void EvaluateSubSetEqualitySparseEquations ( double *  v,
boolean se,
double *  r,
Tequations eqs 
)

In sparse systems, many equations are empty. This function is a variant of EvaluateSubSetEqualityEquations specialy efficient for this kind of systems.

Parameters
vThe value for the variables.
seThe selected equations. This is a subset of the equality equations, not of all equations. Thus the size of this boolean array must the one returned by NEqualityEquations.
rthe array where to store the result. The size of this array is the same as the number of TRUE entries in array 'se'. The space must be allocated externally.
eqsThe equations to evaluate.

Definition at line 2586 of file equations.c.

References CacheScalarEQUInfo(), Tequations::eqEQU, EvaluateMEquation(), EvaluateWholeEquation(), MAX_EQ_MATRIX, Tequations::mequation, Tequations::n, Tequations::nm, and Tequations::nsEQU.

Referenced by EvaluateJacobianSubSetInVector(), and EvaluateTransposedJacobianSubSetInVector().

void EvaluateEquationsXVectors ( double *  v,
unsigned int  ng,
unsigned int *  g,
double *  p,
double *  r,
Tequations eqs 
)

This is a funcition with a very particular purpose. It evaluates a matrix equation M, and it returns M*v[i] for a set of 3D vectors, v[i].

See EvaluateJacobianXVectors for more details on why this is necessary.

This function triggeres an error if the equation set includes scalar equations.

Parameters
vThe values for the variables.
ngNumber of groups of vectors. We must have one group for each matrix equation.
gNumber of vectors in each group.
pThe 3D vectors (stacked in one array).
rThe output vector.
eqsThe matrix equations to evaluate.

Definition at line 2624 of file equations.c.

References Error(), EvaluateMEquationXVectors(), Tequations::mequation, Tequations::n, and Tequations::nm.

Referenced by EvaluateJacobianXVectors().

void EvaluateInequalityEquations ( double *  v,
double *  r,
Tequations eqs 
)

Evaluates all inequalities and returns and array with the error in each of them. The error is 0 if the inequality hold.

Parameters
vThe value for the variables.
rthe array where to store the result.
eqsThe equations to evaluate.

Definition at line 2643 of file equations.c.

References EQU, Tequations::equation, EvaluateEquation(), GEQ, GetEquationCmp(), GetEquationValue(), GetOriginalEquation(), and Tequations::n.

Referenced by ErrorInInequalities(), ErrorInSimpInequalitiesOnPoint(), InequalitiesHoldOnPoint(), and SimpInequalitiesHoldOnPoint().

void DeriveEqualityEquations ( unsigned int  v,
Tequations deqs,
Tequations eqs 
)

Derives an equation set with respect to a given variable. The derivative is only computed for equality equations.

Parameters
vThe derivation variable.
deqsThe resulting derived equations.
eqsThe equations to derive.

Definition at line 2668 of file equations.c.

References AddEquationInt(), AddMatrixEquation(), DeleteEquation(), DeleteMEquation(), DeriveEquation(), DeriveMEquation(), EQU, Tequations::equation, GetEquationCmp(), GetOriginalEquation(), InitEquations(), Tequations::mequation, Tequations::n, and Tequations::nm.

Referenced by InitHessian(), and InitJacobian().

void PrintEquations ( FILE *  f,
char **  varNames,
Tequations eqs 
)

Writes a set of equations into a stream.

Parameters
fThe stream where to write the equations.
varNamesThe name of the variables. If this parameter is NULL the printed names for the variables are v_X with X the index of the variable.
eqsThe equation set to print.

Definition at line 2694 of file equations.c.

References Tequations::c, Tequations::d, Tequations::equation, GetOriginalEquation(), IsCoordEquation(), IsDummyEquation(), IsSystemEquation(), Tequations::mequation, Tequations::n, Tequations::nm, PrintEquation(), PrintMEquation(), and Tequations::s.

Referenced by CSRemoveLCVars(), CSRemoveVarsWithCtRange(), PrintCuikSystem(), PrintCuikSystemWithSimplification(), PrintJacobian(), and SimplifyCuikSystem().

void DeleteEquations ( Tequations eqs)

Deletes the information stored in the set of equations and frees the allocated memory space.

Parameters
eqsThe set of equations to delete.

Definition at line 2750 of file equations.c.

References DeleteEquationInfo(), DeleteMEquation(), Tequations::eqEQU, Tequations::equation, Tequations::mequation, Tequations::n, Tequations::nm, and Tequations::nsEQU.

Referenced by DeleteCuikSystem(), DeleteHessian(), DeleteJacobian(), DeleteWorldCS(), DummifyCuikSystem(), GaussianElimination(), RemoveEquationsWithVar(), ReplaceVariableInEquations(), and UnUpdateCuikSystem().