csmapping.c File Reference

Detailed Description

Implementation of the functions operating on Tmapping.

See Also
Tmapping, csmapping.h.

Definition in file csmapping.c.

Functions

void InitMapping (Tvariables *o, Tvariables *s, Tmapping *m)
 Constructor. More...
 
void CopyMapping (Tmapping *m_dst, Tmapping *m_src)
 Copy constructor. More...
 
void SetOriginalVarRelation (unsigned int nvo, TLinearConstraint *lc, Tmapping *m)
 Set a relation for a variable in the original set. More...
 
void GetOriginalVarRelation (unsigned int nvo, TLinearConstraint *lc, Tmapping *m)
 Gets the relation for a variable in the original set with the variables in the simple set. More...
 
unsigned int GetSizeOriginal (Tmapping *m)
 Size of the variable set in the original system. More...
 
unsigned int GetSizeSimple (Tmapping *m)
 Size of the variable set in the simplified system. More...
 
boolean IsInSimple (unsigned int v, Tmapping *m)
 Identify original variables also present in the simple system. More...
 
unsigned int GetVarIDInOriginal (unsigned int v, Tmapping *m)
 Gets the original identifier of a simplified variable. More...
 
void SimpleFromOriginal (Tbox *o, Tbox *s, Tmapping *m)
 Gets a simple box from an original one. More...
 
void SimplePointFromOriginal (double *o, double **s, Tmapping *m)
 Gets a simple point from an original one. More...
 
void UpdateOriginalFromSimple (Tbox *s, Tbox *o, Tmapping *m)
 Gets a original box from an simplified one. More...
 
void UpdateOriginalPointFromSimple (double *s, double *o, Tmapping *m)
 Gets a original point from an simplified one. More...
 
void PrintMapping (FILE *f, Tmapping *m)
 Prints a mapping. More...
 
void LoadMapping (FILE *f, Tmapping *m)
 Constructor. Loads the mapping information from a file. More...
 
void SaveMapping (FILE *f, Tmapping *m)
 Saves the mapping information into a file. More...
 
void DeleteMapping (Tmapping *m)
 Destructor. More...
 

Function Documentation

void InitMapping ( Tvariables o,
Tvariables s,
Tmapping m 
)

Generates a trivial mapping between two variable sets. The mapping is defined by checking which variables in one set are also present in the other. We identify variables using their name.
The mapping includes a copy of the variable sets. In this way, posterior modificications of the sets does not affect the mapping. The variable sets, though, are only used to pretty print the mappings.

Parameters
oVariables in the original system.
sVariables in the simplified system.
mThe mapping to initialize.

Definition at line 14 of file csmapping.c.

References AddTerm2LinearConstraint(), CopyVariables(), GetVariable(), GetVariableID(), GetVariableName(), InitLinearConstraint(), Tmapping::lc, NEW, NO_UINT, NVariables(), Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by SimplifyCuikSystem().

void CopyMapping ( Tmapping m_dst,
Tmapping m_src 
)

Copies one mapping into another.

Parameters
m_dstThe mapping to create via copy.
m_srcThe original mapping.

Definition at line 64 of file csmapping.c.

References CopyLinearConstraint(), CopyVariables(), Tmapping::lc, NEW, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by CopyCuikSystem().

void SetOriginalVarRelation ( unsigned int  nvo,
TLinearConstraint lc,
Tmapping m 
)

Links a variable in the original problem with a variable in the simplified problem via a linear relation

nvo=a*nvs+b
Parameters
nvoNumerical identifier of the variable in the original set.
lcThe linear combination defining the relation.
mThe mapping where to store the relation.

Definition at line 100 of file csmapping.c.

References CopyLinearConstraint(), DeleteLinearConstraint(), Error(), Tmapping::lc, Tmapping::related, and TRUE.

Referenced by SimplifyCuikSystem().

void GetOriginalVarRelation ( unsigned int  nvo,
TLinearConstraint lc,
Tmapping m 
)

Returns the linear constraint of variables in the simple set that defines a variable in the original set.

The output linear constraint is defined inside this function.

Parameters
nvoNumerical identifier of the variable in the original set.
lcThe output linear combination defining the relation.
mThe mapping to query.

Definition at line 112 of file csmapping.c.

References CopyLinearConstraint(), InitLinearConstraint(), Tmapping::lc, and Tmapping::related.

Referenced by AddSimplifiedJacobianEquations(), and RewriteEquation2Simp().

unsigned int GetSizeOriginal ( Tmapping m)

Size of the variable set in the original system.

Parameters
mThe mapping to query.
Returns
The number of variables in the set of variables in the original system.

Definition at line 120 of file csmapping.c.

References Tmapping::sizeO.

unsigned int GetSizeSimple ( Tmapping m)

Size of the variable set in the simplified system.

Parameters
mThe mapping to query.
Returns
The number of variables in the set of variables in the simplified system.

Definition at line 125 of file csmapping.c.

References Tmapping::sizeS.

boolean IsInSimple ( unsigned int  v,
Tmapping m 
)

Returns TRUE if there is a variable in the simple system with the same name as variable v in the original system.

Parameters
vIdentifier of the variable in the original system.
mThe mapping to query.
Returns
TRUE if there is a variable in the simple system with the same name as variable v in the original system.

Definition at line 130 of file csmapping.c.

References GetVariable(), GetVariableID(), GetVariableName(), NO_UINT, Tmapping::original, and Tmapping::simple.

Referenced by IncrementalSampleCuikSystemInBox().

unsigned int GetVarIDInOriginal ( unsigned int  v,
Tmapping m 
)

Gets the numerical identifier in the original set of variables corresponding to a variable in the simplified set (given by its numerical identifier).

Parameters
vIdentifier of the variable in the simplified set.
mThe mapping from where to get the relation.
Returns
The numerical identifier of the variable in the original set corresponding to the given variable identifier in the simplified set.

Definition at line 135 of file csmapping.c.

References NO_UINT, and Tmapping::orig.

Referenced by ComputeSplitDim(), and RewriteEquation2Orig().

void SimpleFromOriginal ( Tbox o,
Tbox s,
Tmapping m 
)

Applies the mapping to define a box corresponding to the simple system from a box corresponding to the original system. We simply get the sub-set of the original variables used in the simplified one and join them into a box.

The box s is create inside this function.

Parameters
oThe box in the original system.
sThe box in the simplified system.
mThe mapping to apply.

Definition at line 143 of file csmapping.c.

References BoxFromVariables(), CopyInterval(), GetBoxInterval(), NO_UINT, Tmapping::orig, Tmapping::simple, and Tmapping::sizeS.

Referenced by ComputeSplitDim(), CuikNewtonInBox(), MaxReduction(), MPI_SolveCuikSystem(), SimplifyCuikSystem(), and SolveCuikSystem().

void SimplePointFromOriginal ( double *  o,
double **  s,
Tmapping m 
)

The same as SimpleFromOriginal but operating on points and not on boxes.

Parameters
oThe point in the original system.
sThe point in the simplified system. The space for this point is allocated inside this function.
mThe mapping to apply.

Definition at line 165 of file csmapping.c.

References NO_UINT, Tmapping::orig, PointFromVariables(), Tmapping::simple, and Tmapping::sizeS.

Referenced by GenerateSimplifiedPoint().

void UpdateOriginalFromSimple ( Tbox s,
Tbox o,
Tmapping m 
)

Applies the mapping to define a box corresponding to the original system from a box corresponding to the simple system.
In this case, the values of the box in the simple system override the values of the given box in the original system. The rationale is that if we take care of the simplified box to be defined properly, then we do not need to take care of undoing the mapping.

Variables in the original, not included in the simplification are not changed.

Note the difference with SimpleFromOriginal : here the output box o is just updated and not created from scratch.

Parameters
sThe box in the simplified system.
oThe box in the original system.
mThe mapping to apply.

Definition at line 177 of file csmapping.c.

References EvaluateLinearConstraintInt(), GetBoxInterval(), GetBoxIntervals(), GetLinearConstraintError(), Intersection(), IntervalAdd(), IntervalInvert(), Tmapping::lc, Tmapping::related, SetBoxInterval(), and Tmapping::sizeO.

Referenced by CuikNewtonInBox(), MaxReduction(), PostProcessBox(), and RegenerateOriginalBox().

void UpdateOriginalPointFromSimple ( double *  s,
double *  o,
Tmapping m 
)

The same as UpdateOriginalFromSimple but operating on points instead of on boxes.

Parameters
sThe point in the simplified system.
oThe point in the original system.
mThe mapping to apply.

Definition at line 199 of file csmapping.c.

References EvaluateLinearConstraint(), GetLinearConstraintError(), IntervalCenter(), Tmapping::lc, Tmapping::related, and Tmapping::sizeO.

Referenced by RegenerateOriginalPoint().

void PrintMapping ( FILE *  f,
Tmapping m 
)

Prints a the linear relations defining a mapping into a stream, possibly stdout. The mapping is printed in the form

vo=a*vs+b


or

vo=b

where vo is an original variable and vs is a simplifed one.

Parameters
fThe stream where to print the mapping
mThe mapping to apply.

Definition at line 218 of file csmapping.c.

References FALSE, GetVariableNames(), Tmapping::lc, NEW, Tmapping::original, PRINT_VARIABLE_NAME, PrintLinearConstraint(), Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by PrintCuikSystemWithSimplification().

void LoadMapping ( FILE *  f,
Tmapping m 
)

Loads the mapping information into a file.

Note that the variable sets are load from the file and, thus, the mappings build from a file have no access to the variable names (this is used only for pretty printing the mappings).

Parameters
fThe file from where to read the mapping.
mThe mapping to defined.

Definition at line 266 of file csmapping.c.

References InitLinearConstraint(), Tmapping::lc, LoadLinearConstraint(), NEW, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

void SaveMapping ( FILE *  f,
Tmapping m 
)

Saves the mapping information into a file.

Note that the variable sets are not stored in the files. See LoadMapping for more about the consequences of this.

Parameters
fThe file where to store the mapping.
mThe mapping to save.

Definition at line 291 of file csmapping.c.

References Tmapping::lc, Tmapping::orig, Tmapping::related, SaveLinearConstraint(), Tmapping::sizeO, and Tmapping::sizeS.

Referenced by SaveCuikSystemSimplification().

void DeleteMapping ( Tmapping m)

Deletes a mapping.

Parameters
mThe mapping to delete.

Definition at line 310 of file csmapping.c.

References DeleteLinearConstraint(), DeleteVariables(), Tmapping::lc, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, and Tmapping::sizeO.

Referenced by UnUpdateCuikSystem().