variables.c File Reference

Detailed Description

Implementation of the functions operating on box Tvariables.

See Also
Tvariables, variables.h.

Definition in file variables.c.

Functions

void InitVariables (Tvariables *vs)
 Constructor. More...
 
void CopyVariables (Tvariables *vs_dst, Tvariables *vs_src)
 Copy onstructor. More...
 
unsigned int NVariables (Tvariables *vs)
 Gets the number of variables in a set. More...
 
unsigned int GetNumCartesianVariables (Tvariables *vs)
 Gets the number of cartesian variables in a set. More...
 
unsigned int GetNumDummyVariables (Tvariables *vs)
 Gets the number of dummy variables in a set. More...
 
unsigned int GetNumSystemVariables (Tvariables *vs)
 Gets the number of system variables in a set. More...
 
unsigned int GetNumSecondaryVariables (Tvariables *vs)
 Gets the number of secondary variables in a set. More...
 
boolean IsSystemVariable (unsigned int n, Tvariables *vs)
 Identifies system variables in a set. More...
 
boolean IsSecondaryVariable (unsigned int n, Tvariables *vs)
 Identifies secondary variables in a set. More...
 
boolean IsDummyVariable (unsigned int n, Tvariables *vs)
 Identifies dummy variables in a set. More...
 
boolean IsCartesianVariable (unsigned int n, Tvariables *vs)
 Identifies cartesian variables in a set. More...
 
unsigned int GetVariableTypeN (unsigned int n, Tvariables *vs)
 Gets the type of a particular variable. More...
 
unsigned int AddVariable (Tvariable *v, Tvariables *vs)
 Adds a variable to the set. More...
 
TvariableGetVariableWithName (char *name, Tvariables *vs)
 Gets the information of a variable given the name of this variable. More...
 
TvariableGetVariable (unsigned int n, Tvariables *vs)
 Gets the information of a variable given its number in the set (i.e., its identifier). More...
 
unsigned int GetVariableID (char *name, Tvariables *vs)
 Gets the variable identifier (i.e., its position in the set) given a variable name. More...
 
unsigned int GetVariablesTopology (unsigned int **t, Tvariables *vs)
 Gets the topology for the variables in the set. More...
 
void GetVariableNames (char **varNames, Tvariables *vs)
 Gets the name for all the variables in the set. More...
 
char * VariableName (unsigned int i, Tvariables *vs)
 Gets the name for a particular variable. More...
 
void RemoveVariable (unsigned int n, Tvariables *vs)
 Removes a variable from a set. More...
 
void BoxFromVariables (Tbox *b, Tvariables *vs)
 Creates a box from the ranges of a set of variables. More...
 
void PointFromVariables (double **p, Tvariables *vs)
 Creates a point from the center of the ranges of a set of variables. More...
 
void VariablesFromBox (Tbox *b, Tvariables *vs)
 Define the range for the variables from a box. More...
 
void PrintVariables (FILE *f, Tvariables *vs)
 Prints a set of variables to an stream. More...
 
void DeleteVariables (Tvariables *vs)
 Destructor. More...
 

Function Documentation

void InitVariables ( Tvariables vs)

Defines an empty set of variables.

Parameters
vsThe variable set to initalize.

Definition at line 24 of file variables.c.

References Tvariables::car, Tvariables::dum, INIT_NUM_VARIABLES, Tvariables::max_variables, Tvariables::n, NEW, Tvariables::sec, Tvariables::sys, and Tvariables::vs.

Referenced by InitCuikSystem().

void CopyVariables ( Tvariables vs_dst,
Tvariables vs_src 
)

Defines a set of variables from another set

Parameters
vs_dstThe variable set to initalize.
vs_srcThe variable set from where to copy.

Definition at line 40 of file variables.c.

References Tvariables::car, CopyVariable(), Tvariables::dum, Tvariables::max_variables, Tvariables::n, NEW, Tvariables::sec, Tvariables::sys, and Tvariables::vs.

Referenced by CopyCuikSystem(), CopyMapping(), CuikSystemMerge(), GetCSVariables(), InitMapping(), and SimplifyCuikSystem().

unsigned int GetNumCartesianVariables ( Tvariables vs)

Returns the number of cartesian variables in a variable set.

Parameters
vsThe variable set to query.
Returns
The number of cartesian variables in the set.

Definition at line 77 of file variables.c.

References Tvariables::car.

unsigned int GetNumDummyVariables ( Tvariables vs)

Returns the number of dummy variables in a variable set.

Parameters
vsThe variable set to query.
Returns
The number of dummy variables in the set.

Definition at line 82 of file variables.c.

References Tvariables::dum.

Referenced by CuikNewtonInBox(), and GetCSNumNonDummyVariables().

unsigned int GetNumSystemVariables ( Tvariables vs)

Returns the number of system variables in a variable set.

Parameters
vsThe variable set to query.
Returns
The number of system variables in the set.

Definition at line 90 of file variables.c.

References Tvariables::sys.

Referenced by GetCSNumSystemVariables(), and PrintCuikSystemWithSimplification().

unsigned int GetNumSecondaryVariables ( Tvariables vs)

Returns the number of secondary variables in a variable set.

Parameters
vsThe variable set to query.
Returns
The number of secondary variables in the set.

Definition at line 98 of file variables.c.

References Tvariables::sec.

Referenced by GetCSNumSystemVariables(), and PrintCuikSystemWithSimplification().

boolean IsSystemVariable ( unsigned int  n,
Tvariables vs 
)

Identifies system variables in a set.

Parameters
nThe number of variable to query
vsThe variable set to query.
Returns
TRUE if variable number n is a system variable.

Definition at line 103 of file variables.c.

References GetVariableType(), SYSTEM_VAR, and Tvariables::vs.

Referenced by CSRemoveLCVars(), GetCSSystemVars(), IncrementalSampleCuikSystemInBox(), IsSystemVarInSimpCS(), and UpdateCuikSystem().

boolean IsSecondaryVariable ( unsigned int  n,
Tvariables vs 
)

Identifies secondary variables in a set.

Parameters
nThe number of variable to query
vsThe variable set to query.
Returns
TRUE if variable number n is a secondary variable.

Definition at line 108 of file variables.c.

References GetVariableType(), SECONDARY_VAR, and Tvariables::vs.

Referenced by GetCSSystemVars(), IsSystemVarInSimpCS(), and UpdateCuikSystem().

boolean IsDummyVariable ( unsigned int  n,
Tvariables vs 
)

Identifies dummy variables in a set.

Parameters
nThe number of variable to query
vsThe variable set to query.
Returns
TRUE if variable number n is a dummy variable.

Definition at line 113 of file variables.c.

References DUMMY_VAR, GetVariableType(), and Tvariables::vs.

Referenced by PointInSystemBox(), RegenerateSolution(), and UpdateCuikSystem().

boolean IsCartesianVariable ( unsigned int  n,
Tvariables vs 
)

Identifies cartesian variables in a set.

Parameters
nThe number of variable to query
vsThe variable set to query.
Returns
TRUE if variable number n is a cartesian variable.

Definition at line 118 of file variables.c.

References CARTESIAN_VAR, GetVariableType(), and Tvariables::vs.

Referenced by RegenerateSolution().

unsigned int GetVariableTypeN ( unsigned int  n,
Tvariables vs 
)

Returns the type of a given variable in the set.

If the set has less than n variables, this function triggers an error.

Parameters
nThe number of variable to query
vsThe variable set to query.
Returns
The type of variable n.

Definition at line 123 of file variables.c.

References Error(), GetVariableType(), Tvariables::n, and Tvariables::vs.

Referenced by CropEquation(), CropLinearConstraint(), CSRemoveUnusedVars(), SampleCuikSystemInBox(), and UpdateCuikSystem().

unsigned int AddVariable ( Tvariable v,
Tvariables vs 
)
Tvariable* GetVariableWithName ( char *  name,
Tvariables vs 
)

Returns a pointer to the variable information given the name of the variable to query.

Parameters
nameThe name of the variable to retrive.
vsThe variable set to query.
Returns
A pointer to the information relative to the variable with the given name. NULL if there is no variable with the given name.

Definition at line 175 of file variables.c.

References GetVariableID(), NO_UINT, and Tvariables::vs.

Referenced by AddVariable().

Tvariable* GetVariable ( unsigned int  n,
Tvariables vs 
)

Returns a pointer to the variable information given its position in the set (i.e., its identifier). If the set has less than n variables, this function triggers an error.

Parameters
nThe number of the variable to retrive.
vsThe variable set to query.
Returns
A pointer to the information relative to the variable with the given name.

Definition at line 189 of file variables.c.

References Error(), Tvariables::n, and Tvariables::vs.

Referenced by BoxFromVariables(), CSRemoveLCVars(), CSRemoveVarsWithCtRange(), CuikSystemMerge(), DummifyAndAddEquation(), GetCSVariable(), GetCSVarTopology(), InitMapping(), IsInSimple(), PointFromVariables(), PrintVariables(), SampleCuikSystemInBox(), SetCSVariableRange(), SimplifyCuikSystem(), and VariablesFromBox().

unsigned int GetVariableID ( char *  name,
Tvariables vs 
)

Returns the variable identifier (i.e., its position in the set) given a variable name.

Parameters
nameThe name of the variable whose identifier we want to retrive.
vsThe variable set to query.
Returns
The variable indentifier or NO_UINT if there is not a variable with the given name in the set.

Definition at line 201 of file variables.c.

References FALSE, GetVariableName(), NO_UINT, TRUE, and Tvariables::vs.

Referenced by AddVariable2CS(), CSRemoveLCVars(), CSRemoveVarsWithCtRange(), DummifyAndAddEquation(), GetCSVariableID(), GetVariableWithName(), InitMapping(), IsInSimple(), IsSystemVarInSimpCS(), and SimplifyCuikSystem().

unsigned int GetVariablesTopology ( unsigned int **  t,
Tvariables vs 
)

Gets an array with the topology of the variables in the set. The array is allocated inside the call and must be deallocated by the caller.

Parameters
tThe topology array to allocate and initialze.
vsThe variable set to query.

Definition at line 222 of file variables.c.

References GetVariableTopology(), Tvariables::n, NEW, and Tvariables::vs.

Referenced by GetSimpCSTopology(), and UpdateCuikSystem().

void GetVariableNames ( char **  varNames,
Tvariables vs 
)

Gets a pointer to the name for all the variables in the set.

Parameters
varNamesSpace for the pointers to the variable names.
vsThe variable set to query.

Definition at line 234 of file variables.c.

References GetVariableName(), Tvariables::n, and Tvariables::vs.

Referenced by AddSimplifiedJacobianEquations(), CopyCuikSystem(), CSRemoveLCVars(), CSRemoveVarsWithCtRange(), GetCSVariableNames(), PrintCuikSystem(), PrintCuikSystemWithSimplification(), PrintMapping(), SimplifyCuikSystem(), and UpdateCuikSystem().

char* VariableName ( unsigned int  i,
Tvariables vs 
)

Gets a pointer to the name if a particular variable.

Parameters
iThe identifier of the variable.
vsThe variable set to query.
Returns
The pointer to the variable name or NULL if the identifier does not correspond to a valid variable.

Definition at line 242 of file variables.c.

References GetVariableName(), and Tvariables::vs.

Referenced by AddSimplifiedJacobianEquations(), and GetCSVariableName().

void RemoveVariable ( unsigned int  n,
Tvariables vs 
)

Removes a variable from a set. After removing, the variable set is compacted, i.e., the gap of the remove variable is eliminated and this changes the variable indentifiers for the variables stored above the removed variable.

Parameters
nThe identifier of the variable to remove.
vsThe variable set to update.

Definition at line 257 of file variables.c.

References Tvariables::car, CARTESIAN_VAR, DeleteVariable(), Tvariables::dum, DUMMY_VAR, GetVariableType(), Tvariables::n, Tvariables::sec, SECONDARY_VAR, Tvariables::sys, SYSTEM_VAR, and Tvariables::vs.

Referenced by CSRemoveLCVars(), CSRemoveUnusedVars(), and CSRemoveVarsWithCtRange().

void BoxFromVariables ( Tbox b,
Tvariables vs 
)

Creates a box from the ranges of a set of variables.

Parameters
bThe box to be created.
vsThe variable set.

Definition at line 283 of file variables.c.

References GetVariable(), GetVariableInterval(), InitBox(), NVariables(), and SetBoxInterval().

Referenced by CuikNewtonInBox(), GenerateInitialBox(), GenerateSimpInitialBox(), IncrementalSampleCuikSystemInBox(), MPI_SolveCuikSystem(), PostProcessBox(), RegenerateOriginalBox(), SimpleFromOriginal(), SimplifyCuikSystem(), and SolveCuikSystem().

void PointFromVariables ( double **  p,
Tvariables vs 
)

Creates a point from the center of the ranges of a set of variables.

Parameters
pThe point to be created. The space for this point is allocated inside this function but must be deallocated externally.
vsThe variable set.

Definition at line 294 of file variables.c.

References GetVariable(), GetVariableInterval(), IntervalCenter(), NEW, and NVariables().

Referenced by RegenerateOriginalPoint(), and SimplePointFromOriginal().

void VariablesFromBox ( Tbox b,
Tvariables vs 
)

Changes the ranges for all variables from the ranges given in a box. This is the function complementary to BoxFromVariables.

Parameters
bThe box from where to take the ranges.
vsThe set of variables whose ranges to changes.

Definition at line 305 of file variables.c.

References GetBoxInterval(), GetVariable(), NVariables(), and SetVariableInterval().

Referenced by IncrementalSampleCuikSystemInBox().

void PrintVariables ( FILE *  f,
Tvariables vs 
)

Prints a set of variables to an stream, that can be stdout. Variables are printed in a format that can be properly parsed by the .cuik file parser.

Parameters
fThe stream where to print.
vsThe variable set to print.
See Also
readcuiksystem.l, readcuiksystem.y.

Definition at line 318 of file variables.c.

References CARTESIAN_VAR, DUMMY_VAR, Error(), GetVariable(), GetVariableType(), Tvariables::n, PrintVariable(), SECONDARY_VAR, SYSTEM_VAR, and Tvariables::vs.

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

void DeleteVariables ( Tvariables vs)

Deletes the Tvariables structure and frees the allocated memory.

Parameters
vsThe variable set to delete.

Definition at line 354 of file variables.c.

References DeleteVariable(), Tvariables::n, and Tvariables::vs.

Referenced by DeleteCuikSystem(), DeleteMapping(), GenerateWorldEquations(), and UnUpdateCuikSystem().