Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

equation.h File Reference

Definition of the Tequation type and the associated functions. More...

#include "boolean.h"
#include "interval.h"
#include "variables.h"
#include "variable_set.h"
#include "monomial.h"
#include "linear_constraint.h"
#include "csmapping.h"
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  Tequation
 An equation. More...

Defines

#define MAX_TERMS_SIMP   1
 Maximum number of terms to be used in the simplifications.
#define INIT_NUM_MONOMIALS   100
 Initial room for monomials.
#define LINEAR_EQUATION   0
 One of the possible type of equations.
#define CIRCLE_EQUATION   1
 One of the possible type of equations.
#define SADDLE_EQUATION   2
 One of the possible type of equations.
#define PARABOLA_EQUATION   3
 One of the possible type of equations.
#define SPHERE_EQUATION   4
 One of the possible type of equations.
#define BILINEAR_EQUATION   5
 One of the possible type of equations.
#define GENERAL_EQUATION   6
 One of the possible type of equations.
#define UNKNOWN_EQ_TYPE   7
 Used for equations with non-assigned type.
#define SYSTEM_EQ   0
 One of the possible type of equations.
#define COORD_EQ   1
 One of the possible type of equations.
#define DUMMY_EQ   2
 One of the possible type of equations.
#define DERIVED_EQ   3
 One of the possible type of equations.
#define NOTYPE_EQ   4
 One of the possible type of equations.
#define GEQ   0
#define LEQ   1
#define EQU   2
#define NOCMP   3
 In a Tequation, the equation relational operator is not defined yet.

Functions

void InitEquation (Tequation *eq)
 Constructor.
void ResetEquation (Tequation *eq)
 Reset equation information.
void EquationFromLinearConstraint (TLinearConstraint *lc, Tequation *eq)
 Defines a new equation from a linear constraint.
void EquationFromLinearConstraintProduct (TLinearConstraint *lc1, TLinearConstraint *lc2, Tequation *eq)
 Defines a new equation from the product of two linear constraints.
void CopyEquation (Tequation *eq_dst, Tequation *eq_orig)
 Copy constructor.
void RewriteEquation (double epsilon, Tmapping *map, Tequation *eqOut, Tequation *eq)
 Applies the mapping to an equation.
void AccumulateEquations (Tequation *eqn, double ct, Tequation *eq)
 Adds a scaled equation to another equation.
unsigned int FixVariableInEquation (double epsilon, unsigned int nv, double b, Tequation *eq)
 Turns a variable into a constant.
unsigned int ReplaceVariableInEquation (double epsilon, unsigned int nv, TLinearConstraint *lc, Tequation *eq)
 Replaces a variable.
void CtScaleEquation (double ct, Tequation *eq)
 Scales an equation by a constant factor.
void VarScaleEquation (unsigned int v, Tequation *eq)
 Scales an equation with a variable factor.
void NormalizeEquation (Tequation *eq)
 Normalizes an equation.
boolean IsSimplificable (unsigned int simpLevel, unsigned int nTerms, boolean *systemVars, unsigned int *v, TLinearConstraint *lc, Tequation *eq)
 Identify equations than can trigger variable simplifications.
void SetEquationCmp (unsigned int cmp, Tequation *eq)
 Changes the relational operator (LEQ, GEQ, EQU) of the equation.
void SetEquationType (unsigned int type, Tequation *eq)
 Changes the type of the equation (SYSTEM_EQ, CARTESIAN_EQ, DUMMY_EQ, DERIVED_EQ).
void SetEquationValue (double v, Tequation *eq)
 Changes the right-hand value of the equation.
boolean LinearEquation (Tequation *eq)
 Identify linear equations.
boolean BilinearEquation (Tequation *eq)
 Identify bilinear equations.
boolean CircleEquation (Tequation *eq)
 Identify circle equations.
boolean SphereEquation (Tequation *eq)
 Identify sphere equations.
boolean SaddleEquation (Tequation *eq)
 Identify scaled saddle equations.
boolean ParabolaEquation (Tequation *eq)
 Identify scaled parabola equations.
unsigned int GetEquationCmp (Tequation *eq)
 Gets the type of relational operator of the equation.
unsigned int GetEquationType (Tequation *eq)
 Gets the equation type.
double GetEquationValue (Tequation *eq)
 Gets the right-hand value of the equation.
unsigned int GetEquationOrder (Tequation *eq)
 Gets the equation order.
Tvariable_setGetEquationVariables (Tequation *eq)
 Gets the set of variables equation used in the equation.
unsigned int GetEquationNumVariables (Tequation *eq)
 Gets the number of variables equation used in the equation.
unsigned int CmpEquations (Tequation *eq1, Tequation *eq2)
 Equation comparison.
void AddMonomial (Tmonomial *f, Tequation *eq)
 Adds a new monomial to the equation.
void GenerateParabolaEquation (unsigned int vx, unsigned int vy, Tequation *eq)
 Construtor. Generates a parabola equation.
void GenerateScaledParabolaEquation (double s, unsigned int vx, unsigned int vy, Tequation *eq)
 Construtor. Generates a scaled parabola equation.
void GenerateSaddleEquation (unsigned int vx, unsigned int vy, unsigned int vz, Tequation *eq)
 Construtor. Generates a saddle equation.
void GenerateScaledSaddleEquation (double s, unsigned int vx, unsigned int vy, unsigned int vz, Tequation *eq)
 Construtor. Generates a scaled saddle equation.
void GenerateGeneralNormEquation (unsigned int nv, unsigned int *v, double n, Tequation *eq)
 Construtor. Generates an equation that is the norm of a vector.
void GenerateNormEquation (unsigned int vx, unsigned int vy, unsigned int vz, double n, Tequation *eq)
 Construtor. Generates an equation that is the norm of a 3d vector.
void GenerateCrossProductEquations (unsigned int v1x, unsigned int v1y, unsigned int v1z, unsigned int v2x, unsigned int v2y, unsigned int v2z, unsigned int v3x, unsigned int v3y, unsigned int v3z, unsigned int vs, double s, Tequation *eq)
 Construtor. Generates the three equations of the cross product of two unitary vectors.
void GenerateDotProductEquation (unsigned int v1x, unsigned int v1y, unsigned int v1z, unsigned int v2x, unsigned int v2y, unsigned int v2z, unsigned int vc, double c, Tequation *eq)
 Construtor. Generates the equation of the dot product of two unitary vectors.
unsigned int FindMonomial (Tmonomial *f, Tequation *eq)
 Searches for a given monomial in the equation.
TmonomialGetMonomial (unsigned int i, Tequation *eq)
 Gets a monomial from an equation.
unsigned int GetNumMonomials (Tequation *eq)
 Number of monomials in an equation.
void LinearEquation2LinearConstraint (TLinearConstraint *lc, Tequation *eq)
 Converts a linear equation into a linear constraint.
double EvaluateEquation (double *varValues, Tequation *eq)
 Evaluates an equation in a given point.
void EvaluateEquationInt (Tinterval *varValues, Tinterval *i_out, Tequation *eq)
 Interval evaluation of an equation.
void DeriveEquation (unsigned int nv, Tequation *d, Tequation *eq)
 Derives an equation.
void PrintMonomials (FILE *f, char **varNames, Tequation *eq)
 Prints an equation as a set if monomials.
void PrintEquation (FILE *f, char **varNames, Tequation *eq)
 Prints an equation.
void DeleteEquation (Tequation *eq)
 Destructor.

Detailed Description

Definition of the Tequation type and the associated functions.

See also:
Tequation, equation.c.

Definition in file equation.h.


Define Documentation

#define MAX_TERMS_SIMP   1

Maximum number of terms to be used in the simplifications.

This variable is defined for experimental purposes. Do not use a value larger than 1.

Definition at line 31 of file equation.h.

Referenced by IsSimplificable(), and SimplifyCuikSystem().

#define INIT_NUM_MONOMIALS   100

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

See also:
Tequation

Definition at line 40 of file equation.h.

Referenced by InitEquation().

#define LINEAR_EQUATION   0

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 51 of file equation.h.

Referenced by AddEquation2Simplex(), CopyEquationInfo(), CropEquation(), DeleteEquationInfo(), ErrorDueToVariable(), SetEquationInfo(), and UpdateSplitWeight().

#define CIRCLE_EQUATION   1

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 60 of file equation.h.

Referenced by AddEquation2Simplex(), CropEquation(), and SetEquationInfo().

#define SADDLE_EQUATION   2

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 69 of file equation.h.

Referenced by AddEquation2Simplex(), CropEquation(), and SetEquationInfo().

#define PARABOLA_EQUATION   3

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 78 of file equation.h.

Referenced by AddEquation2Simplex(), CropEquation(), and SetEquationInfo().

#define SPHERE_EQUATION   4

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 87 of file equation.h.

Referenced by AddEquation2Simplex(), CropEquation(), and SetEquationInfo().

#define BILINEAR_EQUATION   5

One of the possible type of equations according to the type of monomials it includes.

See also:
Tequation

Definition at line 97 of file equation.h.

#define GENERAL_EQUATION   6

One of the possible type of equations. This is used for equations not of the types listed above.

See also:
Tequation

Definition at line 106 of file equation.h.

Referenced by AddEquation2Simplex(), CropEquation(), and SetEquationInfo().

#define UNKNOWN_EQ_TYPE   7

Used for equations with non-assigned type, i.e., equations not fully processed.

See also:
Tequation

Definition at line 115 of file equation.h.

#define SYSTEM_EQ   0
#define COORD_EQ   1

One of the possible type of equations according its role in the cuiksytem.

See also:
TCuikSystem

Definition at line 134 of file equation.h.

Referenced by AddEquation(), CoordInequalitiesHold(), GenerateWorldEquationSystems(), and IsCoordEquation().

#define DUMMY_EQ   2

One of the possible type of equations according its role in the cuiksytem.

See also:
TCuikSystem

Definition at line 143 of file equation.h.

Referenced by AddEquation(), DummifyAndAddEquation(), GaussianElimination(), GenerateScaledParabolaEquation(), GenerateScaledSaddleEquation(), IsDummyEquation(), and UsedVarInNonDummyEquations().

#define DERIVED_EQ   3

One of the possible type of equations according its role in the cuiksytem. This is for equations resulting from a derivative.

See also:
TCuikSystem

Definition at line 153 of file equation.h.

Referenced by DeriveEquation().

#define NOTYPE_EQ   4

Used for equations with non assigned role yet.

See also:
TCuikSystem

Definition at line 161 of file equation.h.

Referenced by AddEquation(), GetEquationTypeN(), InitEquation(), and ResetEquation().

#define NOCMP   3

In a Tequation, the equation relational operator is not definet yet.

Definition at line 186 of file equation.h.

Referenced by AddEquation(), EvaluateEquation(), EvaluateEquationInt(), InitEquation(), PrintEquation(), and ResetEquation().


Function Documentation

void ResetEquation ( Tequation eq  ) 

Removes the information stored in the equation, but does not frees the memory. It is more efficient to use ResetEquation instead of DeleteEquation plus InitEquation again.

Parameters:
eq The equation to reset.

Definition at line 306 of file equation.c.

References Tequation::cmp, NOCMP, NOTYPE_EQ, Tequation::order, ResetEquationMonomials(), ResetVarSet(), Tequation::type, Tequation::value, and Tequation::vars.

Referenced by UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void EquationFromLinearConstraint ( TLinearConstraint lc,
Tequation eq 
)

Defines a new equation from a linear constraint. Only linear constraint with a constant right-hand term can be converted to equations. For other linear constraints this funtion triggers an error.

Parameters:
lc The linear constraint to convert to an equation.
eq The new equation

Definition at line 92 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), Tequation::cmp, DeleteMonomial(), EQU, Error(), GEQ, GetLinearConstraintCoefficient(), GetLinearConstraintError(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), INF, InitEquation(), InitMonomial(), IntervalCenter(), IntervalSize(), LEQ, LowerLimit(), UpperLimit(), and Tequation::value.

Referenced by RewriteEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void EquationFromLinearConstraintProduct ( TLinearConstraint lc1,
TLinearConstraint lc2,
Tequation eq 
)

Defines a new equation from the product of two linear constraint. Only linear constraint with a constant right-hand term are considered. For other linear constraints this funtion triggers an error.

Parameters:
lc1 The first linear constraint to multiply.
lc2 The second linear constraint to multiply.
eq The new equation

Definition at line 142 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), Error(), GetLinearConstraintCoefficient(), GetLinearConstraintError(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), InitEquation(), InitMonomial(), IntervalCenter(), and IntervalSize().

Referenced by RewriteEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void CopyEquation ( Tequation eq_dst,
Tequation eq_orig 
)

Creates one equation copying the information from another equation.

Parameters:
eq_dst The equation to create via copy.
eq_orig The equation from where to copy.

Definition at line 202 of file equation.c.

References AddMonomial(), Tequation::cmp, InitVarSet(), Tequation::maxMonomials, Tequation::monomials, NEW, Tequation::nMonomials, Tequation::order, Tequation::type, Tequation::value, and Tequation::vars.

Referenced by CopyCuikSystem(), CopyEquationInfo(), CuikSystemMerge(), GaussianElimination(), GetCSEquation(), PurgeEquation(), ReplaceVariableInEquation(), SetCSSearchMode(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

void RewriteEquation ( double  epsilon,
Tmapping map,
Tequation eqOut,
Tequation eq 
)

Transform an equation expressed in a given set of variables into an equation in the simplified set of variables. The relation between the two sets of variables is given by a mapping.

Parameters:
epsilon When replacing variables, monomials with a constant value below epsilon are removed.
map The mapping relating the two sets of variables.
eqOut The output of the re-write.
eq The equation in the original system.
See also:
Tmapping

Definition at line 221 of file equation.c.

References AccumulateEquations(), AddMonomial(), Tequation::cmp, DeleteEquation(), DeleteLinearConstraint(), EquationFromLinearConstraint(), EquationFromLinearConstraintProduct(), Error(), GetMonomialCt(), GetMonomialVariables(), GetOriginalVarRelation(), GetVariableN(), InitEquation(), MonomialOrder(), Tequation::monomials, Tequation::nMonomials, PurgeEquation(), Tequation::type, Tequation::value, and VariableSetSize().

Referenced by UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void AccumulateEquations ( Tequation eqn,
double  ct,
Tequation eq 
)

Adds a scaled equation to another equation.

Parameters:
eqn The equation to scale and add.
ct The scale factor.
eq The equation where to add the result.

Definition at line 290 of file equation.c.

References AddCt2Monomial(), AddMonomial(), CopyMonomial(), DeleteMonomial(), Tequation::monomials, Tequation::nMonomials, PurgeEquation(), and Tequation::value.

Referenced by AddTerm2SearchCriterion(), CuikSystemMerge(), GaussianElimination(), and RewriteEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int FixVariableInEquation ( double  epsilon,
unsigned int  nv,
double  b,
Tequation eq 
)

Removes a variable from an equation converting it into a constant. Note, that variables are indexed and that removing a variable shifts down the index of variables with index above the removed variable.

Parameters:
epsilon Monomials with a constant value below epsilon are removed.
nv Numerical identifier of the variable to remove.
b Value for the variable to remove.
eq The equation from where to remove the variable.

Definition at line 324 of file equation.c.

References AddCt2LinearConstraint(), DeleteLinearConstraint(), InitLinearConstraint(), and ReplaceVariableInEquation().

Referenced by RemoveEquationsWithVar().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int ReplaceVariableInEquation ( double  epsilon,
unsigned int  nv,
TLinearConstraint lc,
Tequation eq 
)

Replaces a variable from an equation converting it to a linear combination of variables.

Note, that variables are indexed and that removing a variable shifts down the index of variables with index above the removed variable.

Parameters:
epsilon Monomials with a constant value below epsilon are removed.
nv Numerical identifier of the variable to remove.
lc The linear constraint that replaces the equation.
eq The equation from where to remove the variable.

Definition at line 344 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), Tequation::cmp, CopyEquation(), CopyMonomial(), DeleteEquation(), DeleteMonomial(), EQU, Error(), FixVariableInMonomial(), GEQ, GetEquationCmp(), GetEquationType(), GetEquationValue(), GetLinearConstraintCoefficient(), GetLinearConstraintError(), GetLinearConstraintVariable(), GetMonomialVariables(), GetNumTermsInLinearConstraint(), GetPlaceinSet(), GetVariablePowerN(), InitEquation(), IntervalCenter(), IntervalSize(), LEQ, Tequation::monomials, Tequation::nMonomials, NO_UINT, NormalizeEquation(), SetEquationCmp(), SetEquationType(), SetEquationValue(), ShiftVarIndexes(), TRUE, Tequation::value, VariableSetSize(), and ZERO.

Referenced by FixVariableInEquation(), and ReplaceVariableInEquations().

Here is the call graph for this function:

Here is the caller graph for this function:

void CtScaleEquation ( double  ct,
Tequation eq 
)

Scales the equation by a constant factor.

Only equalities are scaled and if the scale factor is 0 this function triggers an error.

Parameters:
ct The factor to use as a scale factor.
eq The equation to scale.

Definition at line 485 of file equation.c.

References AddCt2Monomial(), Tequation::cmp, EQU, Error(), Tequation::monomials, Tequation::nMonomials, Tequation::value, and ZERO.

Here is the call graph for this function:

void VarScaleEquation ( unsigned int  v,
Tequation eq 
)

Scales the equation by a variable factor.

Only equalities are scaled.

Parameters:
v The variable to use as a scale factor.
eq The equation to scale.

Definition at line 502 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), Tequation::cmp, DeleteMonomial(), EQU, Error(), GetMonomialVariables(), InitMonomial(), Tequation::monomials, Tequation::nMonomials, ResetVarSet(), UnionVarSet(), Tequation::value, and Tequation::vars.

Here is the call graph for this function:

void NormalizeEquation ( Tequation eq  ) 

Simple form of normalization to avoid numerical inestabilities. If all monomials have the same ct (up to ZERO) we make them all equal to one. This helps in many cases when we replace variables to avoid transforming, for instance, a circle equation into a scaled circle equation (that is not identified as a circle!)

Parameters:
eq The equation to be normalized.

Definition at line 536 of file equation.c.

References AddCt2Monomial(), Tequation::cmp, EQU, GetMonomialCt(), Tequation::monomials, Tequation::nMonomials, PurgeEquation(), SetMonomialCt(), TRUE, Tequation::value, and ZERO.

Referenced by AddEquation(), and ReplaceVariableInEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean IsSimplificable ( unsigned int  simpLevel,
unsigned int  nTerms,
boolean systemVars,
unsigned int *  v,
TLinearConstraint lc,
Tequation eq 
)

Checks if a given variable can be remove from the system and replaced by a linear combination of the surving variables.

The output variables (v and lc) are only initilized if some simplification is possible (i.e., if the return is TRUE).

Parameters:
simpLevel Agressiveness of the simplification process:

  • 0 No simplification is applied.
  • 1 Only equations of the form $x=a$ or $x^2=0$ are considered (with x a variable and a a constant).
  • 2 Equations of the form $x + a y=b$ are also considered (with x and y variables and a and b constants).
  • 3 Equations of the form $a x + b y=c$ are also considered (with x and y variables and a and b constants).

The more the simplification the more the chances to get numerical problems.

nTerms Number of terms (i.e., variables) in the linear constraint to use in the simplification.
systemVars Array of booleans marking the main variables. We first try to remove the non-system variables (i.e., to put them in function of the system ones). If this is not possible we proceed to remove system variables.
v Output. The variable to eliminate from the system.
lc Output. The linear constraint to use to replace the eliminated variable.
eq The equation.
Returns:
TRUE if some variable can be eliminated.

Definition at line 585 of file equation.c.

References AddCt2LinearConstraint(), AddTerm2LinearConstraint(), Tequation::cmp, EQU, FALSE, GetEquationOrder(), GetMonomialCt(), GetMonomialVariables(), GetVariableN(), INF, InitLinearConstraint(), InvertLinearConstraint(), MAX_TERMS_SIMP, Tequation::monomials, Tequation::nMonomials, NO_UINT, ScaleLinearConstraint(), TRUE, Tequation::value, VariableSetSize(), and Tequation::vars.

Referenced by CSRemoveLCVars().

Here is the call graph for this function:

Here is the caller graph for this function:

void SetEquationCmp ( unsigned int  cmp,
Tequation eq 
)

Sets a new relational operator for the equation.

Parameters:
cmp The new relational operator.
eq The equation.

Definition at line 732 of file equation.c.

References Tequation::cmp, EQU, Error(), GEQ, and LEQ.

Referenced by AddTerm2SearchCriterion(), DummifyAndAddEquation(), GenerateCrossProductEquations(), GenerateDotProductEquation(), GenerateGeneralNormEquation(), GenerateJointEquations(), GenerateJointRangeEquations(), GenerateScaledParabolaEquation(), GenerateScaledSaddleEquation(), GenerateTransEquationsFromBranch(), and ReplaceVariableInEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void SetEquationType ( unsigned int  type,
Tequation eq 
)

Sets a new type for the equation.

Parameters:
type The new type.
eq The equation.

Definition at line 727 of file equation.c.

References Tequation::type.

Referenced by DummifyAndAddEquation(), GenerateCrossProductEquations(), GenerateDotProductEquation(), GenerateGeneralNormEquation(), GenerateJointEquations(), GenerateJointRangeEquations(), GenerateScaledParabolaEquation(), GenerateScaledSaddleEquation(), GenerateTransEquationsFromBranch(), and ReplaceVariableInEquation().

Here is the caller graph for this function:

void SetEquationValue ( double  v,
Tequation eq 
)

Sets a new rigth-hand value for the equation.

Parameters:
v The new right-hand value.
eq The equation.

Definition at line 740 of file equation.c.

References Tequation::value.

Referenced by DummifyAndAddEquation(), GenerateCrossProductEquations(), GenerateDotProductEquation(), GenerateGeneralNormEquation(), GenerateJointRangeEquations(), GenerateScaledParabolaEquation(), GenerateScaledSaddleEquation(), and ReplaceVariableInEquation().

Here is the caller graph for this function:

boolean LinearEquation ( Tequation eq  ) 

Identify linear equations.

Parameters:
eq The equation.
Returns:
TRUE if the given equation is linear.

Definition at line 745 of file equation.c.

References CtMonomial(), LinearMonomial(), Tequation::monomials, and TRUE.

Referenced by DummifyAndAddEquation(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean BilinearEquation ( Tequation eq  ) 

Identify bilinear equations.

Parameters:
eq The equation.
Returns:
TRUE if the given equation is bilinear.

Definition at line 758 of file equation.c.

References BilinearMonomial(), CtMonomial(), LinearMonomial(), Tequation::monomials, QuadraticMonomial(), and TRUE.

Here is the call graph for this function:

boolean CircleEquation ( Tequation eq  ) 

Identify circle equations.

Parameters:
eq The equation.
Returns:
TRUE if the given equation define a circle.

Definition at line 777 of file equation.c.

References FALSE, GetMonomialCt(), Tequation::monomials, Tequation::nMonomials, QuadraticMonomial(), TRUE, and Tequation::value.

Referenced by DummifyAndAddEquation(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean SphereEquation ( Tequation eq  ) 

Identify sphere equations.

Parameters:
eq The equation.
Returns:
TRUE if the given equation define a sphere.

Definition at line 792 of file equation.c.

References Tequation::cmp, EQU, FALSE, GetMonomialCt(), Tequation::monomials, Tequation::nMonomials, QuadraticMonomial(), TRUE, and Tequation::value.

Referenced by DummifyAndAddEquation(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean SaddleEquation ( Tequation eq  ) 

Identify scaled saddle equations, i.e., equations of the form $x y - \alpha z =0$.

Parameters:
eq The equation.
Returns:
TRUE if the given equation define a saddle.

Definition at line 807 of file equation.c.

References BilinearMonomial(), Tequation::cmp, EQU, FALSE, GetMonomialCt(), LinearMonomial(), Tequation::monomials, Tequation::nMonomials, TRUE, and Tequation::value.

Referenced by DummifyAndAddEquation(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean ParabolaEquation ( Tequation eq  ) 

Identify parabola equations, i.e., equations of the form $x^2 - \alpha z =0$.

Parameters:
eq The equation.
Returns:
TRUE if the given equation define a parabola.

Definition at line 821 of file equation.c.

References Tequation::cmp, EQU, FALSE, GetMonomialCt(), LinearMonomial(), Tequation::monomials, Tequation::nMonomials, QuadraticMonomial(), TRUE, and Tequation::value.

Referenced by DummifyAndAddEquation(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetEquationCmp ( Tequation eq  ) 

Gets the type of relational operator of the equation.

Parameters:
eq The equation.
Returns:
The type of relational operator of the equation.

Definition at line 835 of file equation.c.

References Tequation::cmp.

Referenced by AddEquation(), AddEquation2Simplex(), ComputeSimpCuikSystemJacobian(), CoordInequalitiesHold(), CropEquation(), DummifyAndAddEquation(), ErrorInInequalities(), ErrorInSolution(), GaussianElimination(), LinearizeCircleEquation(), LinearizeGeneralEquation(), ReplaceVariableInEquation(), and SetEquationInfo().

Here is the caller graph for this function:

unsigned int GetEquationType ( Tequation eq  ) 

Gets the equation type.

Parameters:
eq The equation.
Returns:
The equation type.

Definition at line 840 of file equation.c.

References Tequation::type.

Referenced by AddEquation(), CoordInequalitiesHold(), DummifyAndAddEquation(), ErrorInSolution(), GaussianElimination(), GetEquationTypeN(), IsCoordEquation(), IsDummyEquation(), IsSystemEquation(), ReplaceVariableInEquation(), and UsedVarInNonDummyEquations().

Here is the caller graph for this function:

double GetEquationValue ( Tequation eq  ) 

Gets the right-hand value of the equation.

Parameters:
eq The equation.
Returns:
The right-hand value of the equation.

Definition at line 845 of file equation.c.

References Tequation::value.

Referenced by AddEquation2Simplex(), CoordInequalitiesHold(), CropEquation(), DummifyAndAddEquation(), ErrorInInequalities(), ErrorInSolution(), EvaluateEqMin(), GetFirstOrderApproximationToEquation(), LinearizeCircleEquation(), LinearizeSphereEquation(), MoveWorld(), ReplaceVariableInEquation(), and SetEquationInfo().

Here is the caller graph for this function:

unsigned int GetEquationOrder ( Tequation eq  ) 

Gets the equation order: 1 for lineal, 2 for bilinear and quadratic.

Parameters:
eq The equation.
Returns:
The equation order.

Definition at line 850 of file equation.c.

References Tequation::order.

Referenced by CmpEquations(), IsSimplificable(), and LinearEquation2LinearConstraint().

Here is the caller graph for this function:

Tvariable_set* GetEquationVariables ( Tequation eq  ) 

Gets the set of variables equation used in the equation. Note, we return a pointer to the interval equation structures so be careful what you do with the pointer.

Parameters:
eq The equation.
Returns:
The equation variable set.

Definition at line 855 of file equation.c.

References Tequation::vars.

Referenced by AddEquation2Simplex(), CropEquation(), DummifyAndAddEquation(), ErrorDueToVariable(), GetEquationNumVariables(), GetFirstOrderApproximationToEquation(), LinearizeCircleEquation(), LinearizeGeneralEquation(), LinearizeGeneralEquationInt(), LinearizeSphereEquation(), RemoveEquationsWithVar(), SetEquationInfo(), UpdateSplitWeight(), UsedVarInEquations(), and UsedVarInNonDummyEquations().

Here is the caller graph for this function:

unsigned int GetEquationNumVariables ( Tequation eq  ) 

Gets the number of variables equation used in the equation.

Parameters:
eq The equation.
Returns:
The number of variables in the equation.

Definition at line 860 of file equation.c.

References GetEquationVariables(), and VariableSetSize().

Referenced by GaussianElimination().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int CmpEquations ( Tequation eq1,
Tequation eq2 
)

Returns 1 if eq1<eq2, 0 if eq1=eq2 or 2 if eq1>eq2. Equations are sorted according to

  • type
  • order
  • relational operator
  • number of monomials
Parameters:
eq1 The first equation to compare.
eq2 The second equation compare.
Returns:
The relative order between the equations.

Definition at line 865 of file equation.c.

References Tequation::cmp, CmpMonomial(), GetEquationOrder(), Tequation::monomials, Tequation::nMonomials, Tequation::type, and Tequation::value.

Referenced by AddEquation(), and HasEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateParabolaEquation ( unsigned int  vx,
unsigned int  vy,
Tequation eq 
)

Generates a parabola equation vx^2-vy=0.

Parameters:
vx Identifier of the x variable.
vy Identifier of the y variable.
eq The equation to generate.

Definition at line 1010 of file equation.c.

References GenerateScaledParabolaEquation().

Here is the call graph for this function:

void GenerateScaledParabolaEquation ( double  s,
unsigned int  vx,
unsigned int  vy,
Tequation eq 
)

Generates a parabola equation s*vx^2-vy=0.

Parameters:
s The scale to apply.
vx Identifier of the x variable.
vy Identifier of the y variable.
eq The equation to generate.

Definition at line 1015 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), DUMMY_EQ, EQU, Error(), InitEquation(), InitMonomial(), ResetMonomial(), SetEquationCmp(), SetEquationType(), and SetEquationValue().

Referenced by GenerateParabolaEquation(), and GenerateScaledSaddleEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateSaddleEquation ( unsigned int  vx,
unsigned int  vy,
unsigned int  vz,
Tequation eq 
)

Generates a saddle equation vx*vy-vz=0.

If vx is the same as vy a parabola equation is generated.

Parameters:
vx Identifier of the x variable.
vy Identifier of the y variable.
vz Identifier of the z variable.
eq The equation to generate.

Definition at line 1041 of file equation.c.

References GenerateScaledSaddleEquation().

Referenced by GenerateJointEquations().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateScaledSaddleEquation ( double  s,
unsigned int  vx,
unsigned int  vy,
unsigned int  vz,
Tequation eq 
)

Generates a saddle equation s*vx*vy-vz=0.

If vx is the same as vy a scaled parabola equation is generated.

Parameters:
s The scale to apply.
vx Identifier of the x variable.
vy Identifier of the y variable.
vz Identifier of the z variable.
eq The equation to generate.

Definition at line 1047 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), DUMMY_EQ, EQU, Error(), GenerateScaledParabolaEquation(), InitEquation(), InitMonomial(), ResetMonomial(), SetEquationCmp(), SetEquationType(), and SetEquationValue().

Referenced by GenerateSaddleEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateGeneralNormEquation ( unsigned int  nv,
unsigned int *  v,
double  n,
Tequation eq 
)

Generates an equation that is the norm of a vector with nv variables n. Thus, the equation created is

$\sum_{i=1}^{nv}v_i^2=n$
Parameters:
nv Number of variables.
v Array with the index of the variables to use.
n The value for the norm.
eq The equation.

Definition at line 1092 of file equation.c.

References AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), EQU, InitEquation(), InitMonomial(), ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), and SYSTEM_EQ.

Referenced by GenerateNormEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateNormEquation ( unsigned int  vx,
unsigned int  vy,
unsigned int  vz,
double  n,
Tequation eq 
)

This is a special case of GenerateGeneralNormEquation where the vector has only 3 variables.

Parameters:
vx The first variable of the 3d vector.
vy The second variable of the 3d vector.
vz The third variable of the 3d vector.
n The value for the norm.
eq The equation.

Definition at line 1080 of file equation.c.

References GenerateGeneralNormEquation().

Referenced by GenerateJointEquations(), and GenerateLinkRot().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateCrossProductEquations ( unsigned int  v1x,
unsigned int  v1y,
unsigned int  v1z,
unsigned int  v2x,
unsigned int  v2y,
unsigned int  v2z,
unsigned int  v3x,
unsigned int  v3y,
unsigned int  v3z,
unsigned int  vs,
double  s,
Tequation eq 
)

Generates the three equations of the cross product of two unitary vectors that give as a result a third vector (orthogonal to the two operated vectors) scaled by the sinus of the angle between these two vectors.
The equations result from

(v1x,v1y,v1z) X (v2x,v2y,v2z) =sin(v1,v2) * (v3x,v3y,v3z)


The sinus is given as a constant (parameter s) or as another variable (parameter vs).
The input vectors are assumed to be unitary (i.e., it is assumed that other equations already included in the system ensure they have norm one).
This function can be seen as a constructor of three equations at a time.

Parameters:
v1x The first variable of the first vector.
v1y The second variable of the first vector.
v1z The third variable of the first vector.
v2x The first variable of the second vector.
v2y The second variable of the second vector.
v2z The third variable of the second vector.
v3x The first variable of the third vector.
v3y The second variable of the third vector.
v3z The third variable of the third vector.
vs Variable representing the sinus of the angle between v1 and v2. NO_UINT if this sinus is constant (given by parameter s).
s Constant sinus between v1 and v2. Not used if vs is different from NO_UINT.
eq Array of three equations to be created.
See also:
GenerateNormEquation

Definition at line 1113 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), EQU, InitEquation(), InitMonomial(), NO_UINT, ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), and SYSTEM_EQ.

Referenced by GenerateLinkRot().

Here is the call graph for this function:

Here is the caller graph for this function:

void GenerateDotProductEquation ( unsigned int  v1x,
unsigned int  v1y,
unsigned int  v1z,
unsigned int  v2x,
unsigned int  v2y,
unsigned int  v2z,
unsigned int  vc,
double  c,
Tequation eq 
)

Generates the equation corresponding to the dot product of two unitary vectors that give as a result the cosinus of the angle between these two vectors.
The equation result from

(v1x,v1y,v1z) * (v2x,v2y,v2z) =cos(v1,v2)


The cosinus is given as a constant (parameter c) or as another variable (parameter vc).
The input vectors are assumed to be unitary (i.e., it is assumed that other equations already included in the system ensure they have norm one)..
This function can be seen as an equation constructor.

Parameters:
v1x The first variable of the first vector.
v1y The second variable of the first vector.
v1z The third variable of the first vector.
v2x The first variable of the second vector.
v2y The second variable of the second vector.
v2z The third variable of the second vector.
vc Variable representing the cosinus of the angle between v1 and v2. NO_UINT if this cosinus is constant (given by parameter s).
c Constant cosinus between v1 and v2. Not used if vc is different from NO_UINT.
eq The equation to be created.
See also:
GenerateNormEquation

Definition at line 1175 of file equation.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), EQU, InitEquation(), InitMonomial(), NO_UINT, ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), and SYSTEM_EQ.

Referenced by GenerateJointEquations(), GenerateJointRangeEquations(), and GenerateLinkRot().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int FindMonomial ( Tmonomial f,
Tequation eq 
)

Searches for a given monomial in the equation.
In this functions, monomials are compare equal taking into account only the variables they involve.

Parameters:
f The monomial to look for.
eq The equation where to look for.
Returns:
The identifier of the monomial in the equation of NO_UINT if the given monomial is not present in the equation.

Definition at line 1210 of file equation.c.

References CmpVarSet(), FALSE, GetMonomialVariables(), Tequation::monomials, NO_UINT, and TRUE.

Referenced by AddMonomial(), and GaussianElimination().

Here is the call graph for this function:

Here is the caller graph for this function:

Tmonomial* GetMonomial ( unsigned int  i,
Tequation eq 
)

Gets a monomial from an equation.

Parameters:
i The identifier of the monimial to retrive.
eq The equation.
Returns:
A pointer to the i-th monomial in the equation or NULL if the equation has less than i monomials.

Definition at line 1233 of file equation.c.

References Tequation::monomials.

Referenced by CropEquation(), DummifyAndAddEquation(), GaussianElimination(), LinearizeParabolaEquation(), LinearizeSaddleEquation(), and SetEquationInfo().

Here is the caller graph for this function:

unsigned int GetNumMonomials ( Tequation eq  ) 

Returns the number of monomials in an equation.

Parameters:
eq The equation.
Returns:
The number of monomials in an equation.

Definition at line 1241 of file equation.c.

References Tequation::nMonomials.

Referenced by AddEquation(), CropEquation(), DummifyAndAddEquation(), GaussianElimination(), SetEquationInfo(), and UpdateCuikSystem().

Here is the caller graph for this function:

void LinearEquation2LinearConstraint ( TLinearConstraint lc,
Tequation eq 
)

Converts a linear equation into a linear constraint.

A linear constraint is just a particular case of equation. We implemented the linear constraints as a different type just for convenience (i.e., to facilitate the simplex implementation).

If the input equation is not linear, the output is empty. To approximate a general equation with a linear constraint use GetFirstOrderApproximationToEquation.

Parameters:
lc The resulting linear constraint.
eq The equation to convert.

Definition at line 1246 of file equation.c.

References AddCt2LinearConstraint(), AddTerm2LinearConstraint(), GetEquationOrder(), GetMonomialCt(), GetMonomialVariables(), GetVariableN(), InitLinearConstraint(), Tequation::monomials, Tequation::nMonomials, and Tequation::value.

Here is the call graph for this function:

double EvaluateEquation ( double *  varValues,
Tequation eq 
)

Evaluates an equation in a given point.

NOTE: The right-hand side value of the equation is not used in the evaluation.

Parameters:
varValues Values defining the point where to evaluate the equation. The array must include values for all the variables in the system (from where the function selects the values for the variables included in the equation).
eq The equation.
Returns:
The value of the equation.

Definition at line 1264 of file equation.c.

References Tequation::cmp, Error(), EvaluateMonomial(), Tequation::monomials, Tequation::nMonomials, and NOCMP.

Referenced by ErrorInInequalities(), ErrorInSolution(), EvaluateEqMin(), and MoveWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

void EvaluateEquationInt ( Tinterval varValues,
Tinterval i_out,
Tequation eq 
)

Evaluates an equation for a given ranges of the variables using interval arithmetics.
NOTE: The right-hand side value of the equation is not used in the evaluation.

Parameters:
varValues Intervals for the variables in the system of equations. This function only uses the ranges for the variables in the equation.
i_out The result of the evalution.
eq The equation.

Definition at line 1280 of file equation.c.

References Tequation::cmp, Error(), EvaluateMonomialInt(), IntervalAdd(), Tequation::monomials, NewInterval(), Tequation::nMonomials, and NOCMP.

Referenced by AddEquation2Simplex(), CoordInequalitiesHold(), EvaluateEqMin(), and GetFirstOrderApproximationToEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeriveEquation ( unsigned int  nv,
Tequation d,
Tequation eq 
)

Derives an equation with respect to a given variable.

Parameters:
nv Identifier of the variable with respect to the one we have to derive.
d Output equation with the derivative.
eq The equation to derive.

Definition at line 1296 of file equation.c.

References AddMonomial(), Tequation::cmp, DeleteMonomial(), DERIVED_EQ, DeriveMonomial(), EQU, InitVarSet(), Tequation::maxMonomials, Tequation::monomials, NEW, Tequation::nMonomials, Tequation::order, Tequation::type, Tequation::value, and Tequation::vars.

Referenced by ComputeSimpCuikSystemJacobian(), GetCuikSystemJacobian(), and SetEquationInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintMonomials ( FILE *  f,
char **  varNames,
Tequation eq 
)

Writes an equation to a given stream as a sequence of monomials, i.e., without the equality and with the right-hand side at the left side.

This only works if the equation is a equality. Inequalities are always printed as a normal equations

Parameters:
f The stream where to print the equation.
varNames The 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.
eq The equation with the monomials to print.
See also:
PrintEquation

Definition at line 1322 of file equation.c.

References Tequation::cmp, EQU, Tequation::monomials, Tequation::nMonomials, PrintEquation(), PrintMonomial(), Tequation::value, and ZERO.

Referenced by PrintCuikSystem(), and PrintCuikSystemWithSimplification().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintEquation ( FILE *  f,
char **  varNames,
Tequation eq 
)

Writes an equation to a given stream.

Parameters:
f The stream where to print the equation.
varNames The 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.
eq The equation to print.
See also:
PrintMonomial PrintVarSet

Definition at line 1339 of file equation.c.

References Tequation::cmp, EQU, Error(), GEQ, LEQ, Tequation::monomials, Tequation::nMonomials, NOCMP, PrintMonomial(), and Tequation::value.

Referenced by AddEquation2Simplex(), CropEquation(), PrintEquations(), and PrintMonomials().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteEquation ( Tequation eq  ) 

Deletes the information stored in the equation and frees the allocated memory space.

Parameters:
eq The equation to delete.

Definition at line 1365 of file equation.c.

References DeleteVarSet(), Tequation::monomials, ResetEquationMonomials(), and Tequation::vars.

Referenced by AddTerm2SearchCriterion(), DeleteCuikSystemJacobian(), DeleteEquationInfo(), DeleteSimpCuikSystemJacobian(), DeleteWorld(), DummifyAndAddEquation(), GaussianElimination(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointRangeEquations(), GenerateLinkRot(), PurgeEquation(), ReplaceVariableInEquation(), RewriteEquation(), SetCSSearchMode(), SetEquationInfo(), and UnUpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function: