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

The CuikSuite Project

variables.c File Reference

Implementation of the functions operating on box Tvariables. More...

#include "variables.h"
#include "error.h"
#include "boolean.h"
#include "defines.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

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

Detailed Description

Implementation of the functions operating on box Tvariables.

See also:
Tvariables, variables.h.

Definition in file variables.c.


Function Documentation

void InitVariables ( Tvariables vs  ) 

Defines an empty set of variables.

Parameters:
vs The 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().

Here is the caller graph for this function:

void CopyVariables ( Tvariables vs_dst,
Tvariables vs_src 
)

Defines a set of variables from another set

Parameters:
vs_dst The variable set to initalize.
vs_src The 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().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int NVariables ( Tvariables vs  ) 
unsigned int GetNumCartesianVariables ( Tvariables vs  ) 

Returns the number of cartesian variables in a variable set.

Parameters:
vs The 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:
vs The 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 GetCSNumNonDummyVariables().

Here is the caller graph for this function:

unsigned int GetNumSystemVariables ( Tvariables vs  ) 

Returns the number of system variables in a variable set.

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

Definition at line 90 of file variables.c.

References Tvariables::sys.

unsigned int GetNumSecondaryVariables ( Tvariables vs  ) 

Returns the number of secondary variables in a variable set.

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

Definition at line 98 of file variables.c.

References Tvariables::sec.

boolean IsSystemVariable ( unsigned int  n,
Tvariables vs 
)

Identifies system variables in a set.

Parameters:
n The number of variable to query
vs The 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(), and UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean IsSecondaryVariable ( unsigned int  n,
Tvariables vs 
)

Identifies secondary variables in a set.

Parameters:
n The number of variable to query
vs The 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().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean IsDummyVariable ( unsigned int  n,
Tvariables vs 
)

Identifies dummy variables in a set.

Parameters:
n The number of variable to query
vs The 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(), and UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean IsCartesianVariable ( unsigned int  n,
Tvariables vs 
)

Identifies cartesian variables in a set.

Parameters:
n The number of variable to query
vs The 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.

Here is the call graph for this function:

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:
n The number of variable to query
vs The 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 CSRemoveUnusedVars(), SampleCuikSystemInBox(), and UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int AddVariable ( Tvariable v,
Tvariables vs 
)

Adds a variable to the set.

Parameters:
v The variable to add.
vs The variable set to update.

Definition at line 138 of file variables.c.

References Tvariables::car, CARTESIAN_VAR, CopyVariable(), Tvariables::dum, DUMMY_VAR, Error(), GetVariableName(), GetVariableType(), GetVariableWithName(), Tvariables::max_variables, MEM_DUP, Tvariables::n, NEW, Tvariables::sec, SECONDARY_VAR, Tvariables::sys, SYSTEM_VAR, and Tvariables::vs.

Referenced by AddVariable2CS(), and DummifyAndAddEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

Tvariable* GetVariableWithName ( char *  name,
Tvariables vs 
)

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

Parameters:
name The name of the variable to retrive.
vs The 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
n The number of the variable to retrive.
vs The 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(), InitMapping(), PrintVariables(), SampleCuikSystemInBox(), SetCSVariableRange(), and SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetVariableID ( char *  name,
Tvariables vs 
)

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

Parameters:
name The name of the variable whose identifier we want to retrive.
vs The 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(), and SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void GetVariableNames ( char **  varNames,
Tvariables vs 
)

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

Parameters:
varNames Space for the pointers to the variable names.
vs The variable set to query.

Definition at line 222 of file variables.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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:
n The identifier of the variable to remove.
vs The variable set to update.

Definition at line 237 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void BoxFromVariables ( Tbox b,
Tvariables vs 
)

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

Parameters:
b The box to be created.
vs The variable set.

Definition at line 263 of file variables.c.

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

Referenced by GenerateInitialBox(), MPI_SolveCuikSystem(), PostProcessBox(), ReGenerateOriginalBox(), SimpleFromOriginal(), SimplifyCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
f The stream where to print.
vs The variable set to print.
See also:
readcuiksystem.l, readcuiksystem.y.

Definition at line 277 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteVariables ( Tvariables vs  ) 

Deletes the Tvariables structure and frees the allocated memory.

Parameters:
vs The variable set to delete.

Definition at line 313 of file variables.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function: