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

The CuikSuite Project

box.h File Reference

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

#include "interval.h"
#include <stdio.h>
#include "boolean.h"
#include "interval.h"
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  Tbox
 A box. More...

Defines

#define EMPTY_BOX   0
 One of the possible results of reducing a box.
#define ERROR_IN_PROCESS   1
 One of the possible results of reducing a box.
#define REDUCED_BOX   2
 One of the possible results of reducing a box.
#define UNBOUNDED_BOX   3
 One of the possible results of reducing a box.
#define REDUCED_BOX_WITH_SOLUTION   4
 One of the possible results of reducing a box.
#define NOT_REDUCED_BOX   5
 One of the possible results of reducing a box.
#define BOX_OK   6

Functions

void InitBox (unsigned int dim, Tinterval *is, Tbox *b)
 Initializes a box.
unsigned int GetBoxBufferSize (Tbox *b)
 Returns the size of a box when converted to an array of doubles.
void Box2Buffer (unsigned int c, unsigned int n, double *buffer, Tbox *b)
 Converts a box into an array of doubles.
void Buffer2Box (unsigned int *c, unsigned int *n, double *buffer, Tbox *b)
 Converts a buffer of doubles into a box.
void CopyBox (void *b_out, void *b_in)
 Box copy operator.
void CopyBoxSubset (boolean *used, void *b_out, void *b_in)
 Creates a box from a sub-set of a given box.
void SetBoxIntervals (Tinterval *is, Tbox *b)
 Replaces the box intervals with a new set.
void SetBoxInterval (unsigned int n, Tinterval *is, Tbox *b)
 Replaces a particular interval in a box.
boolean BoxesIntersection (boolean *used, Tbox *b1, Tbox *b2, Tbox *bout)
 Computes the box intersection of two given boxes.
void BoxUnion (boolean *used, Tbox *b1, Tbox *b2, Tbox *b_out)
 Computes the box union of two given boxes.
boolean PointInBox (boolean *used, unsigned int n, double *v, Tbox *b)
 Checks if a point is included in a(sub-) box.
boolean PointInSubBox (boolean *used, Tvector *v, Tbox *b)
 Checks if a point is included in a (sub-)box.
double DistanceToSubBoxCenter (boolean *used, Tvector *v, Tbox *b)
 Computes the distance from a point to the center of a (sub-)box.
boolean IsPunctualBox (boolean *used, double epsilon, Tbox *b)
 Checks if a (sub-)box is (almost) punctual.
boolean BoxInclusion (boolean *used, Tbox *b1, Tbox *b2)
 Checks if a (sub-)box is fully included in another box.
TintervalGetBoxInterval (unsigned int n, Tbox *b)
 Returns a pointer to one of the intervals defining the box.
TintervalGetBoxIntervals (Tbox *b)
 Returns a pointer to the array of intervals defining the box.
double GetBoxSize (boolean *used, Tbox *b)
 Computes the size of the box.
double GetBoxMaxSizeVarSet (Tvariable_set *vars, Tbox *b)
 Computes the size of the box.
double GetBoxMinSizeVarSet (Tvariable_set *vars, Tbox *b)
 Computes the minimum size of the box.
double GetBoxDiagonal (boolean *used, Tbox *b)
 Computes the diagonal of a (sub-)box.
unsigned int GetBoxLevel (Tbox *b)
 Returns the box level.
double GetBoxCenterDistance (boolean *used, Tbox *b1, Tbox *b2)
 Computes distance between the center of two (sub-)boxes.
double GetBoxVolume (boolean *used, Tbox *b)
 Computes the volume of the box.
unsigned int GetBoxNIntervals (Tbox *b)
 Box dimensionality.
unsigned int GetBoxMaxDim (boolean *used, Tbox *b)
 The dimension of the (sub-)box along which the box has maximum size.
unsigned int GetBoxSplitDim (boolean *used, Tbox *b)
 Computes the box dimension for which it is better to split the box.
void SplitBox (unsigned int n, double r, Tbox *b1, Tbox *b2, Tbox *b)
 Splits a box.
void ScaleBox (double max_upper, Tbox *b)
 Scales a box.
boolean CmpBoxDepthFirst (void *b1, void *b2, void *userData)
 Determines which box to explore first in depth first mode.
boolean CmpBoxBreadthFirst (void *b1, void *b2, void *userData)
 Determines which box to explore first in breadth first mode.
void PrintBox (FILE *f, Tbox *b)
 Prints a box.
void PrintBoxSubset (FILE *f, boolean *used, char **varNames, Tbox *b)
 Prints a (sub-)box.
int ReadBox (FILE *f, Tbox *b)
 Reads a box from a file.
void SaveBox (FILE *f, Tbox *b)
 Saves a box in binary format.
void LoadBox (FILE *f, Tbox *b)
 Reads a box in binary format.
void DeleteBox (void *b)
 Destructor.

Detailed Description

Definition of the Tbox type and the associated functions.

See also:
Tbox, box.c.

Definition in file box.h.


Define Documentation

#define EMPTY_BOX   0

One of the possible results of reducing a box. The box includes no solution.

Definition at line 25 of file box.h.

Referenced by AddEquation2Simplex(), Box2Buffer(), Buffer2Box(), CropEquation(), CropLinearConstraint(), MaxKinematicReduction(), MaxReduction(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), ReduceRange(), SampleCuikSystemInBox(), and SimplexSolve().

#define ERROR_IN_PROCESS   1

One of the possible results of reducing a box. The simplex process trigered and error.

Definition at line 32 of file box.h.

Referenced by Box2Buffer(), Buffer2Box(), MPI_SolveCuikSystem(), PostProcessBox(), ReduceBox(), ReduceRange(), and SimplexSolve().

#define REDUCED_BOX   2

One of the possible results of reducing a box. The box reduced.

Definition at line 38 of file box.h.

Referenced by Box2Buffer(), Buffer2Box(), CropEquation(), CropLinearConstraint(), MPI_SolveCuikSystem(), ReduceBox(), ReduceBoxEquationWise(), ReduceRange(), and SimplexSolve().

#define UNBOUNDED_BOX   3

One of the possible results of reducing a box. The range that we are trying to reduce can not be bounded.

Definition at line 45 of file box.h.

Referenced by ReduceRange(), and SimplexSolve().

#define REDUCED_BOX_WITH_SOLUTION   4

One of the possible results of reducing a box. The box reduced and is validated to include a solution.

Definition at line 52 of file box.h.

Referenced by Box2Buffer(), Buffer2Box(), PostProcessBox(), and ReduceBox().

#define NOT_REDUCED_BOX   5

One of the possible results of reducing a box. The box did not significatively reduced.

Definition at line 59 of file box.h.

Referenced by CropEquation(), and CropLinearConstraint().

#define BOX_OK   6

One of the possible results of reducing a box.

Definition at line 65 of file box.h.


Function Documentation

void InitBox ( unsigned int  dim,
Tinterval is,
Tbox b 
)

Creates a new box with the given parameters.

Parameters:
dim Dimension of the new box (i.e., number of intervals).
is Vector of intervals used to initilize the new box. If the pointer is NULL the box intervals are set to [0,0].
b The box to initialize.

Definition at line 22 of file box.c.

References Tbox::is, Tbox::level, Tbox::n, NEW, and NewInterval().

Referenced by BoxFromVariables(), ListOfBoxesBB(), main(), MPI_SolveCuikSystem(), MPI_TreatBox(), and ReadBox().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetBoxBufferSize ( Tbox b  ) 

In a multiprocessors system, the master and the slave processors exchange boxes and they do so by converting boxes into arrays of doubles. This function returns the number of doubles that takes a box when converted to into doubles. Typically, in the array of doubles we store some heading information plus the lower and upper limits for each one of the intervals in the box.

Parameters:
b The box to convert to an array of doubles.
Returns:
The number of doubles that the box conversion will use.
See also:
Box2Buffer, Buffer2Box

Definition at line 42 of file box.c.

References Tbox::n.

Referenced by MPI_SolveCuikSystem(), and MPI_TreatBox().

Here is the caller graph for this function:

void Box2Buffer ( unsigned int  c,
unsigned int  n,
double *  buffer,
Tbox b 
)

Packs a box into an array of doubles and adds some heading information to the array.

Parameters:
c Status information related to the box (EMPTY_BOX, REDUCED_BOX, etc.).
n Process information related to the box. Right now this is used to store the number of time a box is reduced in a slave processors before it is returned to the master processors. The master collects this informations into a global statistics.
buffer The buffer of doubles where the box is to be stored. The size of this buffer should be, at least, the number returned by GetBoxBufferSize.
b The box to convert to an array of doubles.
See also:
GetBoxBufferSize

Definition at line 47 of file box.c.

References EMPTY_BOX, Error(), ERROR_IN_PROCESS, Tbox::is, Tbox::level, LowerLimit(), Tbox::n, REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, and UpperLimit().

Referenced by MPI_SolveCuikSystem(), and MPI_TreatBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffer2Box ( unsigned int *  c,
unsigned int *  n,
double *  buffer,
Tbox b 
)

Converts an array of doubles into a box.

This is not a box constructor. The box is to be initialized before calling this function and if the box size and the buffer size do not match this function will trigger an error. The idea is to convert a box into a buffer, send it to slave processor, and then update the box with the information sent by the slave.

Parameters:
c Recovers the box status (EMPTY_BOX, REDUCED_BOX, etc.) from the buffer.
n Recovers process information related to the box. Right now it returns the number box reductions applied in the slave processors in order to crop the box.
buffer The buffer from which the box is to be defined.
b The output box.
See also:
GetBoxBufferSize

Definition at line 88 of file box.c.

References EMPTY_BOX, Error(), ERROR_IN_PROCESS, Tbox::is, Tbox::level, Tbox::n, NewInterval(), REDUCED_BOX, and REDUCED_BOX_WITH_SOLUTION.

Referenced by MPI_SolveCuikSystem(), and MPI_TreatBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void CopyBox ( void *  b_out,
void *  b_in 
)

Copies one box into another. This is a copy constructor and, therefore, the output box is initialized inside the CopyBox (i.e., there is no need to init the box beforehand).
The parameters are given as a void pointers to define a generic copy function that is used in box list or box vectors.

Parameters:
b_out Output box. Box constructed by the copy.
b_in Input box. Box used to create b_out.

Definition at line 126 of file box.c.

References NEW.

Referenced by ConcatListOfBoxes(), CopyListOfBoxes(), Heap2List(), InitHeapOfBoxes(), ListOfBoxesBB(), ListOfBoxesCluster(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), ReverseListOfBoxes(), and SampleCuikSystemInBox().

Here is the caller graph for this function:

void CopyBoxSubset ( boolean used,
void *  b_out,
void *  b_in 
)

This is a constructor that builds a box form a subset of intervals of a given box.
The parameters are given as a void pointers to define a generic copy function that is used in box list or box vectors.

Parameters:
used Array of booleans, one for each interval of the input box (b_in). If the boolean is TRUE, the corresponding interval is used in the selective copy. If the given pointer is NULL, all intervals are used (i.e., in this case CopyBoxSubset is the same as CopyBox).
b_out Output box. Box constructed by the copy.
b_in Input box. Box used to create b_out.

Definition at line 141 of file box.c.

References CopyInterval(), and NEW.

Here is the call graph for this function:

void SetBoxIntervals ( Tinterval is,
Tbox b 
)

Replaces the box intervals with a new set of intervals.

Parameters:
is Array with the new set of intervals. The array must have as many elements as those in the box, otherwise the effect of SetBoxIntervals is undefined.
b The box to be modified.

Definition at line 169 of file box.c.

References Tbox::is, and Tbox::n.

void SetBoxInterval ( unsigned int  n,
Tinterval is,
Tbox b 
)

Replaces a particular interval in a box by the given one.

Parameters:
n The index of the interval to replace.
is The new interval.
b The box to be modified.

Definition at line 175 of file box.c.

References CopyInterval(), Error(), and Tbox::is.

Referenced by BoxFromVariables(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean BoxesIntersection ( boolean used,
Tbox b1,
Tbox b2,
Tbox bout 
)

The intersection of two boxes is a box (possibly empty). This function computes the intersection of two given boxes, along a sub-set of its intervals.
The two input boxes must have the same dimensionality.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the intersection. The non-used intervals are undefined in the output. If the given pointer is NULL, all intervals are used.
b1 The first box to be intersected.
b2 The second box to be intersected.
bout The box resulting from the intersection.
Returns:
Returns TRUE if the boxes actually intersect (i.e., if the output box is not empty).
See also:
Intersection

Definition at line 209 of file box.c.

References Error(), Intersection(), Tbox::is, Tbox::n, and TRUE.

Referenced by ListOfBoxesCluster().

Here is the call graph for this function:

Here is the caller graph for this function:

void BoxUnion ( boolean used,
Tbox b1,
Tbox b2,
Tbox b_out 
)

The union of two boxes is a box. This function computes the union of two given boxes, along a sub-set of its intervals.
The two input boxes must have the same dimensionality.
Note that the union of two boxes is never empty (if the input boxes are not empty).

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the intersection. The non-used intervals are undefined in the output. If the given pointer is NULL, all intervals are used.
b1 The first box to be intersected.
b2 The second box to be intersected.
b_out The box resulting from the intersection.
See also:
Union

Definition at line 230 of file box.c.

References Error(), Tbox::is, Tbox::n, and Union().

Referenced by ListOfBoxesBB(), and ListOfBoxesCluster().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean PointInBox ( boolean used,
unsigned int  n,
double *  v,
Tbox b 
)

Checks if a point (defined by an array of n doubles) is included in a box.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the check. If the given pointer is NULL, all intervals are used.
n Length of the array of doubles. It must be the same as the box dimensionality.
v The array of doubles defining the point.
b The box.
Returns:
TRUE if the point is inside the(sub-)box.

Definition at line 248 of file box.c.

References Error(), Tbox::is, IsInside(), Tbox::n, and TRUE.

Here is the call graph for this function:

boolean PointInSubBox ( boolean used,
Tvector v,
Tbox b 
)

Checks if a point (defined by an array of doubles) is included in a (sub-)box. The (sub-)box is selected using an array of flags.
The difference with PointInBox is that v only need to include as many elements as TRUE elements in the used array. Moreover, here the point is defined as a Tvector and not as an array of doubles. The Tvector is used to facilitate the queries from the sample structures that store the configurations in the form of vectors.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the check. If the given pointer is NULL, all intervals are used.
v The vector defining the point.
b The box.
Returns:
TRUE if the point is inside the (sub-)box.
See also:
PointInBox, Tvector, Tsample

Definition at line 270 of file box.c.

References GetVectorElement(), Tbox::is, IsInside(), and TRUE.

Here is the call graph for this function:

double DistanceToSubBoxCenter ( boolean used,
Tvector v,
Tbox b 
)

Computes the distance from a point to the center of a (sub-)box. The (sub-)box is selected using an array of flags.
The point is described using an vector of doubles with one entry for each one of the dimensions to be checked. The Tvector is used to facilitate the queries from the sample structures that store the configurations in the form of vectors.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the check. If the given pointer is NULL, all intervals are used.
v The vector defining the point.
b The box.
Returns:
The distance of the point to the center of the (sub-)box.
See also:
Tvector

Definition at line 291 of file box.c.

References GetVectorElement(), IntervalCenter(), Tbox::is, and Tbox::n.

Here is the call graph for this function:

boolean IsPunctualBox ( boolean used,
double  epsilon,
Tbox b 
)

Returns TRUE if the input box is (amost) punctual along the selected dimensions. A punctual interval is an interval whose size is below epsilon.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the check. If the given pointer is NULL, all intervals are used.
epsilon The threshold to decide when an interval is punctual.
b The box.
Returns:
TRUE if the all selected ranges in the (sub-)box have size below epsilon.

Definition at line 315 of file box.c.

References IntervalSize(), Tbox::is, and TRUE.

Here is the call graph for this function:

boolean BoxInclusion ( boolean used,
Tbox b1,
Tbox b2 
)

Returns TRUE if the the first box is fully included in the second box.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the check. If the given pointer is NULL, all intervals are used.
b1 The small box, the one to be fully sourrounded by b2.
b2 The box that is to include b1.
Returns:
TRUE b1 is fully included in b2.

Definition at line 335 of file box.c.

References IntervalInclusion(), Tbox::is, and Tbox::n.

Referenced by ReduceBox().

Here is the call graph for this function:

Here is the caller graph for this function:

Tinterval* GetBoxInterval ( unsigned int  n,
Tbox b 
)

Returns a pointer to the n interval of the box.

Parameters:
n The interval to retrive.
b The box.
Returns:
A pointer to the required interval or NULL if n is larger than the box dimensionality.
Note that we give access directly to the box internal structures. This allow to directly modify the interval. If you free the pointer, the behavior will be undefined.

Definition at line 186 of file box.c.

References Error(), and Tbox::is.

Referenced by CSRemoveVarsWithCtRange(), ErrorInInequalities(), ErrorInSolution(), EvaluateEqMin(), main(), MoveWorld(), PointInSystemBox(), ReduceBox(), ReduceBoxEquationWise(), ReduceRange(), SampleCuikSystemInBox(), SimpleFromOriginal(), SimplexGetOptimalValue(), SimplifyCuikSystem(), and UpdateOriginalFromSimple().

Here is the call graph for this function:

Here is the caller graph for this function:

Tinterval* GetBoxIntervals ( Tbox b  ) 

Returns a pointer to the intervals defining the box. This allows fast access to the whole set of intervals of the box, i.e., we do not have to access them one at a time.

Parameters:
b The box.
Returns:
A pointer to the array of intervals.
Note that we give access directly to the box internal structures. This allow to directly modify the interval. If you free the pointer, the behavior will be undefined.

Definition at line 200 of file box.c.

References Tbox::is.

Referenced by AddEquation2Simplex(), ComputeSplitDimInt(), CoordInequalitiesHold(), CropEquation(), CropLinearConstraint(), EvaluateEqMin(), GetFirstOrderApproximationToEquation(), LinearizeCircleEquation(), LinearizeGeneralEquation(), LinearizeGeneralEquationInt(), LinearizeParabolaEquation(), LinearizeSaddleEquation(), LinearizeSphereEquation(), SetSimplexBounds(), UpdateOriginalFromSimple(), and UpdateSplitWeight().

Here is the caller graph for this function:

double GetBoxSize ( boolean used,
Tbox b 
)

Determines the largest box side, among the sub-set of intervals selected via the array of booleans used.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b The box.
Returns:
The box size.

Definition at line 356 of file box.c.

References GetBoxMaxDim(), IntervalSize(), Tbox::is, and Tbox::n.

Referenced by HeapOfBoxesMaxSize(), ListOfBoxesMaxSize(), MaxKinematicReduction(), MPI_SolveCuikSystem(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

double GetBoxMaxSizeVarSet ( Tvariable_set vars,
Tbox b 
)

Determines the largest box side, among the sub-set of variables included in the variable set vars.

Parameters:
vars Set of variables (i.e., box dimensions) to be taken into account in the computation.
b The box.
Returns:
The box size.
See also:
Tvariable_set

Definition at line 365 of file box.c.

References GetVariableN(), IntervalSize(), Tbox::is, and VariableSetSize().

Referenced by GetFirstOrderApproximationToEquation(), and LinearizeGeneralEquationInt().

Here is the call graph for this function:

Here is the caller graph for this function:

double GetBoxMinSizeVarSet ( Tvariable_set vars,
Tbox b 
)

Determines the smallest box side, among the sub-set of variables included in the variable set vars.

Parameters:
vars Set of variables (i.e., box dimensions) to be taken into account in the computation.
b The box.
Returns:
The box size.
See also:
Tvariable_set

Definition at line 383 of file box.c.

References GetVariableN(), IntervalSize(), Tbox::is, and VariableSetSize().

Referenced by AddEquation2Simplex().

Here is the call graph for this function:

Here is the caller graph for this function:

double GetBoxDiagonal ( boolean used,
Tbox b 
)

Determines the diagonal of a sub-box of b determined using the array used.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b The box.
Returns:
The (sub-)box diagonal.

Definition at line 404 of file box.c.

References IntervalSize(), Tbox::is, and Tbox::n.

Referenced by HeapOfBoxesMaxDiagonal(), ListOfBoxesMaxDiagonal(), and PostProcessBox().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetBoxLevel ( Tbox b  ) 

Returns the box level, i.e., the number of bisections form the first box used to cretate this box.

Parameters:
b The box.
Returns:
The box level.

Definition at line 427 of file box.c.

References Tbox::level.

Referenced by MaxKinematicReduction(), MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the caller graph for this function:

double GetBoxCenterDistance ( boolean used,
Tbox b1,
Tbox b2 
)

Determines the distance between the cener of two (sub-)boxes determined using the array used.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b1 One of the boxes.
b2 The other box.
Returns:
The (sub-)box center distance.

Definition at line 436 of file box.c.

References Error(), IntervalCenter(), Tbox::is, and Tbox::n.

Here is the call graph for this function:

double GetBoxVolume ( boolean used,
Tbox b 
)

Determines the volume of a box (i.e., the product of the box sides), fpr a sub-set of intervals selected via the array of booleans used.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b The box.
Returns:
The box volume.

Definition at line 463 of file box.c.

References IntervalSize(), Tbox::is, and Tbox::n.

Referenced by HeapOfBoxesVolume(), ListOfBoxesVolume(), MPI_SolveCuikSystem(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetBoxNIntervals ( Tbox b  ) 

Returns the box dimensionality, i.e., the number of intervals defining the box.

Parameters:
b The box.
Returns:
The box dimensionality.

Definition at line 481 of file box.c.

References Tbox::n.

Referenced by AnimateWorld(), CoordInequalitiesHold(), CropEquation(), CropLinearConstraint(), ErrorInInequalities(), ErrorInSolution(), GetFirstOrderApproximationToEquation(), LinearizeCircleEquation(), LinearizeGeneralEquation(), LinearizeParabolaEquation(), LinearizeSaddleEquation(), LinearizeSphereEquation(), LoadCSState(), main(), PointInSystemBox(), SetSimplexBounds(), and UpdateSplitWeight().

Here is the caller graph for this function:

unsigned int GetBoxMaxDim ( boolean used,
Tbox b 
)

Returns dimension of the (sub-)box along which the box has maximum size.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b The box.
Returns:
The dimension of the box with maximal size. If the box is dimension-less this function returns NO_UINT.

Definition at line 489 of file box.c.

References IntervalSize(), Tbox::is, Tbox::n, and NO_UINT.

Referenced by GetBoxSize(), and GetBoxSplitDim().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetBoxSplitDim ( boolean used,
Tbox b 
)

Computes the box dimension for which it is better to split the box. Right now this function is an alias to GetBoxMaxDim.

Parameters:
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
b The box.
Returns:
The best split dimension for the given box.
See also:
GetBoxMaxDim

Definition at line 519 of file box.c.

References GetBoxMaxDim().

Here is the call graph for this function:

void SplitBox ( unsigned int  n,
double  r,
Tbox b1,
Tbox b2,
Tbox b 
)

Splits a given box in two sub-boxes. This can be seen as a constructor method, that is, the two sub-boxes are created (or initilized) inside this function.
If the dimension for which we want to split the box is larger than the box dimensionality this functions generates an error.
If the cut point is outside th box (i.e., r is below 0 or larger than 1) this functions generates an error.

Parameters:
n The dimension
r A double in (0,1) defining the cut point along dimension n given in relative to the box size along this dimension.
b1 The first resulting box. This is a copy of b but for dimension n where this box only includes the lower part of the original interval.
b2 The second resulting box.This is a copy of b but for dimension n where this box only includes the upper part of the original interval.
b The original box to split.

Definition at line 529 of file box.c.

References Error(), INF, Tbox::is, Tbox::level, LowerLimit(), Tbox::n, NEW, NewInterval(), and UpperLimit().

Referenced by PostProcessBox(), and SplitGlobalBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void ScaleBox ( double  max_upper,
Tbox b 
)

Scales a box for all its dimensions with the given scale factor.

Parameters:
max_upper The scale factor
b The box to scale.

Definition at line 584 of file box.c.

References IntervalScale(), Tbox::is, and Tbox::n.

Here is the call graph for this function:

boolean CmpBoxDepthFirst ( void *  b1,
void *  b2,
void *  userData 
)

Returns TRUE if box b1 is to be explored first in depth first.

This is to be used as a LessThan operator in a heap of boxes.

Parameters:
b1 The first box.
b2 The second box.
userData The pointer to the data to pass to the LessThan operator as a third parameter. In this particular LessThan this parameter is not used.
Returns:
TRUE if the first parameter is to be explored before than the second one when in depth first mode.
See also:
box_heap.h, Theap.

Definition at line 592 of file box.c.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the caller graph for this function:

boolean CmpBoxBreadthFirst ( void *  b1,
void *  b2,
void *  userData 
)

Returns TRUE if box b1 is to be explored first in breadth first.

This is to be used as a LessThan operator in a heap of boxes.

Parameters:
b1 The first box.
b2 The second box.
userData The pointer to the data to pass to the LessThan operator as a third parameter. In this particular LessThan this parameter is not used.
Returns:
TRUE if the first parameter is to be explored before than the second one when in breadth first mode.
See also:
box_heap.h, Theap.

Definition at line 597 of file box.c.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the caller graph for this function:

void PrintBox ( FILE *  f,
Tbox b 
)

Writes a box in file f, that can be stdout. The ouput is of the form {n [l1,u1]...[ln,un]} where n is the dimensionality of the box and [lx,ux] are the intervals defining the box.
All along CuikSuite print/read funtions are used to print/read in ASCII format and save/load are equivalen funcitions in binary format.

Parameters:
f The stream where to write.
b The box to write.

Definition at line 605 of file box.c.

References Tbox::is, Tbox::n, and PrintInterval().

Referenced by main(), MPI_SolveCuikSystem(), MPI_TreatBox(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), SampleCuikSystemInBox(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintBoxSubset ( FILE *  f,
boolean used,
char **  varNames,
Tbox b 
)

Writes a box in file f, that can be stdout. The ouput is of the form {n v1:[l1,u1]...vn:[ln,un]} where n is the dimensionality of the box vx is the name of the variable for dimension x and [lx,ux] is the corresponding interval. The variable names are only printed if vars is not NULL.
All along CuikSuite print/read funtions are used to print/read in ASCII format and save/load are equivalen funcitions in binary format.

Parameters:
f The stream where to write.
used Array of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the print. If the given pointer is NULL, all intervals are used.
varNames The name for variables.
b The box to write.

Definition at line 624 of file box.c.

References Tbox::is, Tbox::n, and PrintInterval().

Referenced by main(), PostProcessBox(), PrintHeapOfBoxes(), and PrintListOfBoxes().

Here is the call graph for this function:

Here is the caller graph for this function:

int ReadBox ( FILE *  f,
Tbox b 
)

Read a box from file f. The format of the boxes in the file is the same as that printed by PrintBox or PrintBoxSubset.
This function can be seen as a constructor, i.e., it generates a new box.

Parameters:
f The stream from which to read the box.
b The box to read.
Returns:
EOF if the file finishes before the box could be read.

Definition at line 657 of file box.c.

References Error(), InitBox(), NEW, and NewInterval().

Referenced by main(), and ReadListOfBoxes().

Here is the call graph for this function:

Here is the caller graph for this function:

void SaveBox ( FILE *  f,
Tbox b 
)

Writes a box in file f in binary format.

Parameters:
f The stream where to write.
b The box to write.

Definition at line 719 of file box.c.

References Tbox::is, Tbox::level, and Tbox::n.

Referenced by SaveListOfBoxes().

Here is the caller graph for this function:

void LoadBox ( FILE *  f,
Tbox b 
)

Reads a box from file f in binary format.
This function is a box constructor method.

Parameters:
f The stream from where to read.
b The box to write.

Definition at line 727 of file box.c.

References Tbox::is, Tbox::level, Tbox::n, and NEW.

Referenced by LoadListOfBoxes().

Here is the caller graph for this function:

void DeleteBox ( void *  b  ) 

Deletes a previously generated box (either via InitBox, ReadBox, CopyBox,...).

Parameters:
b The box to be deleted.

Definition at line 744 of file box.c.

Referenced by ComputeSplitDim(), DeleteListOfBoxes(), InitHeapOfBoxes(), ListOfBoxesCluster(), main(), MaxReduction(), MPI_SolveCuikSystem(), MPI_TreatBox(), PostProcessBox(), ReduceBox(), ReduceBoxEquationWise(), SampleCuikSystem(), SampleCuikSystemInBox(), SimplifyCuikSystem(), and SolveCuikSystem().

Here is the caller graph for this function: