Public Member Functions | Public Attributes | Private Attributes | List of all members
MatrixType Class Reference

a data structure to represent a MatrixType object (from which we derive OSMatrix and MatrixBlock) More...

#include <OSMatrix.h>

Inheritance diagram for MatrixType:
Inheritance graph
[legend]
Collaboration diagram for MatrixType:
Collaboration graph
[legend]

Public Member Functions

 MatrixType ()
 -------— Methods for class MatrixType -------— More...
 
virtual ~MatrixType ()
 
virtual bool alignsOnBlockBoundary (int firstRow, int firstColumn, int nRows, int nCols)
 A method to check whether a matrix or block is diagonal. More...
 
bool matrixHasBase ()
 Several tools to parse the constructor list of a matrix. More...
 
bool matrixHasElements ()
 
bool matrixHasTransformations ()
 
bool matrixHasBlocks ()
 
int getNumberOfElementConstructors ()
 
int getNumberOfTransformationConstructors ()
 
int getNumberOfBlocksConstructors ()
 
GeneralSparseMatrixgetMatrixCoefficientsInColumnMajor ()
 
GeneralSparseMatrixgetMatrixCoefficientsInRowMajor ()
 
GeneralSparseMatrixgetMatrixBlockInColumnMajorForm (int columnIdx, int rowIdx)
 
bool printExpandedMatrix (bool rowMajor)
 a utility routine to print the expanded matrix or block. More...
 
int getRowPartitionSize ()
 get the size of the row partition of a matrix More...
 
intgetRowPartition ()
 get the row partition of the matrix More...
 
int getColumnPartitionSize ()
 get the size of the column partition of a matrix More...
 
intgetColumnPartition ()
 get the column partition of the matrix More...
 
virtual bool expandElements (bool rowMajor)
 A method to expand a matrix or block The result is a GeneralSparseMatrix object of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed). More...
 
GeneralSparseMatrixconvertToOtherMajor (bool isColumnMajor)
 A method to convert a matrix to the other major. More...
 
bool processBlockPartition ()
 A method to determine the block structure of a matrixType as defined by the <blocks> element or elements. More...
 
virtual bool processBlocks (bool rowMajor, ENUM_MATRIX_SYMMETRY symmetry)
 A method to process a matrixType into a block structure defined by the <blocks> element or elements. More...
 
virtual bool processBlocks (int *rowOffset, int rowOffsetSize, int *colOffset, int colOffsetSize, bool rowMajor, ENUM_MATRIX_SYMMETRY symmetry)
 A method to process a matrixType into a specific block structure. More...
 
GeneralSparseMatrixextractBlock (int firstrow, int firstcol, int lastrow, int lastcol, bool rowMajor, ENUM_MATRIX_SYMMETRY symmetry)
 A method to extract a block from a larger matrix The result is a sparse matrix object, depending on the matrixType, of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed). More...
 
ExpandedMatrixBlocksgetBlocks (int *rowPartition, int rowPartitionSize, int *colPartition, int colPartitionSize, bool rowMajor, bool appendToBlockArray)
 A method to extract a block from a larger matrix The result is a sparse matrix object, depending on the matrixType, of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed). More...
 
ExpandedMatrixBlocksdisassembleMatrix (int *rowPartition, int rowPartitionSize, int *colPartition, int colPartitionSize, bool rowMajor, ENUM_MATRIX_SYMMETRY symmetry)
 A method to disassemble a MatrixType into individual blocks of specific structure. More...
 
bool IsEqual (MatrixType *that)
 A function to check for the equality of two objects. More...
 
bool setRandom (double density, bool conformant, int iMin, int iMax)
 A function to make a random instance of this class. More...
 
bool deepCopyFrom (MatrixType *that)
 A function to make a deep copy of an instance of this class. More...
 
- Public Member Functions inherited from MatrixNode
 MatrixNode ()
 default constructor More...
 
virtual ~MatrixNode ()
 destructor More...
 
virtual
ENUM_MATRIX_CONSTRUCTOR_TYPE 
getNodeType ()
 
virtual ENUM_MATRIX_TYPE getMatrixType ()=0
 
virtual std::string getNodeName ()=0
 
virtual std::string getMatrixNodeInXML ()=0
 
std::vector< MatrixNode * > getPrefixFromNodeTree ()
 
std::vector< MatrixNode * > preOrderMatrixNodeTraversal (std::vector< MatrixNode * > *prefixVector)
 
std::vector< MatrixNode * > getPostfixFromNodeTree ()
 
std::vector< MatrixNode * > postOrderMatrixNodeTraversal (std::vector< MatrixNode * > *postfixVector)
 
virtual MatrixNodecloneMatrixNode ()=0
 
virtual bool IsEqual (MatrixNode *that)
 A function to check for the equality of two objects. More...
 
bool setRandom (double density, bool conformant, int iMin, int iMax)
 A function to make a random instance of this class. More...
 
bool deepCopyFrom (MatrixNode *that)
 A function to make a deep copy of an instance of this class. More...
 

Public Attributes

ENUM_MATRIX_SYMMETRY symmetry
 To track the type of symmetry present in the matrix or block. More...
 
ENUM_MATRIX_TYPE type
 To track the type of values present in the matrix or block. More...
 
int numberOfRows
 
int numberOfColumns
 
GeneralSparseMatrixExpandedMatrixInRowMajorForm
 The matrix can be held in expanded form by rows or by columns and in a number of ways stored by blocks. More...
 
GeneralSparseMatrixExpandedMatrixInColumnMajorForm
 
std::vector
< ExpandedMatrixBlocks * > 
ExpandedMatrixByBlocks
 
- Public Attributes inherited from MatrixNode
ENUM_MATRIX_TYPE matrixType
 matrixType tracks the type of elements contained in this MatrixNode, which may be useful in solver selection For an enumeration of the possible types see OSParameters.h More...
 
ENUM_MATRIX_CONSTRUCTOR_TYPE nType
 nType is a unique integer assigned to each type of matrix node (see OSParameters.h) More...
 
unsigned int inumberOfChildren
 inumberOfChildren is the number of MatrixNode child elements For the matrix types (OSMatrix and MatrixBlock) this number is not fixed and is temporarily set to 0 More...
 
MatrixNode ** m_mChildren
 m_mChildren holds all the children, that is, nodes used in the definition or construction of the current node. More...
 

Private Attributes

intm_miRowPartition
 m_miRowPartition is the partition vector of the matrix rows into blocks More...
 
int m_iRowPartitionSize
 m_iRowPartitionSize gives the size of the m_miRowPartition array, which is one more than the number of blocks in each row More...
 
intm_miColumnPartition
 m_miColumnPartition is the partition vector of the matrix columns into blocks More...
 
int m_iColumnPartitionSize
 m_iColumnPartitionSize gives the size of the m_miColumnPartition array, which is one more than the number of blocks in each column More...
 
bool m_bHaveRowPartition
 m_bHaveRowPartition tracks whether the row partition has been determined from the constructor list and stored in m_miRowPartition More...
 
bool m_bHaveColumnPartition
 m_bHaveColumnPartition tracks whether the column partition has been determined from the constructor list and stored in m_miColumnPartition More...
 

Detailed Description

a data structure to represent a MatrixType object (from which we derive OSMatrix and MatrixBlock)

Definition at line 1889 of file OSMatrix.h.

Constructor & Destructor Documentation

MatrixType::MatrixType ( )

-------— Methods for class MatrixType -------—

Definition at line 163 of file OSMatrix.cpp.

MatrixType::~MatrixType ( )
virtual

Definition at line 184 of file OSMatrix.cpp.

Member Function Documentation

bool MatrixType::alignsOnBlockBoundary ( int  firstRow,
int  firstColumn,
int  nRows,
int  nCols 
)
virtual

A method to check whether a matrix or block is diagonal.

Check whether a submatrix aligns with the block partition of a matrix or block or other constructor

Parameters
firstRowgives the number of the first row in the submatrix (zero-based)
firstColumngives the number of the first column in the submatrix (zero-based)
nRowsgives the number of rows in the submatrix
nColumnsgives the number of columns in the submatrix
Returns
true if the submatrix aligns with the boundaries of a block

Implements MatrixNode.

Reimplemented in MatrixBlock, and OSMatrix.

Definition at line 191 of file OSMatrix.cpp.

bool MatrixType::matrixHasBase ( )

Several tools to parse the constructor list of a matrix.

Definition at line 196 of file OSMatrix.cpp.

bool MatrixType::matrixHasElements ( )

Definition at line 202 of file OSMatrix.cpp.

bool MatrixType::matrixHasTransformations ( )

Definition at line 217 of file OSMatrix.cpp.

bool MatrixType::matrixHasBlocks ( )

Definition at line 227 of file OSMatrix.cpp.

int MatrixType::getNumberOfElementConstructors ( )

Definition at line 237 of file OSMatrix.cpp.

int MatrixType::getNumberOfTransformationConstructors ( )

Definition at line 253 of file OSMatrix.cpp.

int MatrixType::getNumberOfBlocksConstructors ( )

Definition at line 264 of file OSMatrix.cpp.

GeneralSparseMatrix * MatrixType::getMatrixCoefficientsInColumnMajor ( )

Definition at line 275 of file OSMatrix.cpp.

GeneralSparseMatrix * MatrixType::getMatrixCoefficientsInRowMajor ( )

Definition at line 1028 of file OSMatrix.cpp.

GeneralSparseMatrix * MatrixType::getMatrixBlockInColumnMajorForm ( int  columnIdx,
int  rowIdx 
)

Definition at line 2261 of file OSMatrix.cpp.

bool MatrixType::printExpandedMatrix ( bool  rowMajor)

a utility routine to print the expanded matrix or block.

Parameters
rowMajorcontrols whether the matrix should be printed in row or column major.
Returns
whether the operation was successful
Remarks
if the expanded matrix does not exist, return false

Definition at line 1785 of file OSMatrix.cpp.

int MatrixType::getRowPartitionSize ( )

get the size of the row partition of a matrix

Returns
an corresponding to the number of partition points of the rows of this matrix (which is one more than the number of blocks in one row)

Definition at line 2101 of file OSMatrix.cpp.

int * MatrixType::getRowPartition ( )

get the row partition of the matrix

Returns
a vector of int corresponding to the partition points of the rows of this matrix

Definition at line 2111 of file OSMatrix.cpp.

int MatrixType::getColumnPartitionSize ( )

get the size of the column partition of a matrix

Returns
an corresponding to the number of partition points of the columns of this matrix (which is one more than the number of blocks in one column)

Definition at line 2121 of file OSMatrix.cpp.

int * MatrixType::getColumnPartition ( )

get the column partition of the matrix

Returns
a vector of int corresponding to the partition points of the columns of this matrix

Definition at line 2131 of file OSMatrix.cpp.

bool MatrixType::expandElements ( bool  rowMajor)
virtual

A method to expand a matrix or block The result is a GeneralSparseMatrix object of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed).

(Values depend on the matrixType.) Duplicate elements are removed according to the rules formulated in the OSiL schema.

Parameters
rowMajorcan be used to store the objects in row major form.
Returns
whether the operation was successful or not.

Reimplemented in MatrixBlock, and OSMatrix.

Definition at line 1780 of file OSMatrix.cpp.

GeneralSparseMatrix * MatrixType::convertToOtherMajor ( bool  isColumnMajor)

A method to convert a matrix to the other major.

Parameters
isColumnMajorholds whether the matrix is stored by column. If true, the matrix is converted to row major form. If false, the matrix is stored by row and is converted to column major.
Returns
A pointer to the matrix in the other major. Return null if input matrix not valid.

Definition at line 1914 of file OSMatrix.cpp.

bool MatrixType::processBlockPartition ( )

A method to determine the block structure of a matrixType as defined by the <blocks> element or elements.

If multiple partitions are found, they are consolidated into the coarsest partition (intersection of all partition sets).

Returns
whether the operation was successful
Remarks
This method sets m_iRowPartition, m_iRowPartitionSize, m_iColumnPartition and m_iColumnPartitionSize, but does not expand any of the blocks themselves.

Definition at line 2142 of file OSMatrix.cpp.

bool MatrixType::processBlocks ( bool  rowMajor,
ENUM_MATRIX_SYMMETRY  symmetry 
)
virtual

A method to process a matrixType into a block structure defined by the <blocks> element or elements.

Parameters
rowMajorindicates whether the blocks should be stored in row major (if true) or column major.
symmetrycan be used to store only the upper or lower triangle, depending on the parameter value — see OSParameters.h for definitions
Returns
whether the operation was successful
Remarks
The blocks are stored into a std::vector of type expandedMatrixBlocks so that they can be retrieved later using extractBlocks (see below). It is possible (though probably not advisable) to maintain multiple decompositions with different row and column partitions (see next method)

Definition at line 2304 of file OSMatrix.cpp.

bool MatrixType::processBlocks ( int rowOffset,
int  rowOffsetSize,
int colOffset,
int  colOffsetSize,
bool  rowMajor,
ENUM_MATRIX_SYMMETRY  symmetry 
)
virtual

A method to process a matrixType into a specific block structure.

Parameters
rowOffsetdefines a partition of the matrix rows into the blocks
rowOffsetSizegives the number of elements in the rowOffset array
colOffsetdefines a partition of the matrix columns into the blocks
colOffsetSizegives the number of elements in the colOffset array
rowMajorcontrols whether the blocks are stored by row or by column
symmetrycan be used to store only the upper or lower triangle, depending on the parameter value — see OSParameters.h for definitions
Returns
whether the operation was successful
Remarks
The blocks are stored into a std::vector of type expandedMatrixBlocks so that they can be retrieved later using extractBlock (see below). It is possible (though probably not advisable) to maintain multiple decompositions with different row and column partitions

Definition at line 2313 of file OSMatrix.cpp.

GeneralSparseMatrix * MatrixType::extractBlock ( int  firstrow,
int  firstcol,
int  lastrow,
int  lastcol,
bool  rowMajor,
ENUM_MATRIX_SYMMETRY  symmetry 
)

A method to extract a block from a larger matrix The result is a sparse matrix object, depending on the matrixType, of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed).

Duplicate elements are removed according to the rules formulated in the OSiL schema.

Parameters
firstrowgives the first row of the block
firstcolgives the first column of the block
lastrowgives the last row of the block
lastcolgives the last column of the block
rowMajorcan be used to store the objects in row major form.
symmetrycan be used to store only the upper or lower triangle, depending on the parameter value — see OSParameters.h for definitions
Returns
the block as a general sparse matrix
Remarks
Before extracting a block it is necessary to call processBlocks() in order to make sure that a block partition conformal to the block dimensions and positions has been defined or prepared.

Definition at line 2807 of file OSMatrix.cpp.

ExpandedMatrixBlocks * MatrixType::getBlocks ( int rowPartition,
int  rowPartitionSize,
int colPartition,
int  colPartitionSize,
bool  rowMajor,
bool  appendToBlockArray 
)

A method to extract a block from a larger matrix The result is a sparse matrix object, depending on the matrixType, of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed).

Duplicate elements are removed according to the rules formulated in the OSiL schema.

Parameters
rowPartitiondefines the partition of the set of rows into the blocks
rowPartitionSizegives the size of the rowPartition array
colPartitiondefines the partition of the set of columns into the blocks
colPartitionSizegives the size of the colPartition array
rowMajorindicates whether the blocks are stored in row major form or not.
appendToBlockArraydetermines whether the blocks should be created if not found.
Returns
the blocks as an ExpandedMatrixBlocks object, which is essentially an array of general sparse matrices.
Remarks
If blocks corresponding to the indicated partition do not exist, this method can try to create them. This can be quite storage-intensive and is controlled by the parameter appendToBlockArray. If no blocks found (and appending is inhibited) return NULL.

Definition at line 2269 of file OSMatrix.cpp.

ExpandedMatrixBlocks * MatrixType::disassembleMatrix ( int rowPartition,
int  rowPartitionSize,
int colPartition,
int  colPartitionSize,
bool  rowMajor,
ENUM_MATRIX_SYMMETRY  symmetry 
)

A method to disassemble a MatrixType into individual blocks of specific structure.

Parameters
rowPartitiondefines the partition of the set of rows into the blocks
rowPartitionSizegives the size of the rowPartition array
colPartitiondefines the partition of the set of columns into the blocks
colPartitionSizegives the size of the colPartition array
rowMajorindicates whether the blocks are stored in row major form or not.
symmetrydetermines what kind of symmetry to use in representing the blocks.
Returns
the blocks as an ExpandedMatrixBlocks object, which is essentially an array of general sparse matrices.

Definition at line 2595 of file OSMatrix.cpp.

bool MatrixType::IsEqual ( MatrixType that)

A function to check for the equality of two objects.

bool MatrixType::setRandom ( double  density,
bool  conformant,
int  iMin,
int  iMax 
)

A function to make a random instance of this class.

Parameters
density,:corresponds to the probability that a particular child element is created
conformant,:if true enforces side constraints not enforceable in the schema (e.g., agreement of "numberOfXXX" attributes and <XXX> children)
iMin,:lowest index value (inclusive) that a variable reference in this matrix can take
iMax,:greatest index value (inclusive) that a variable reference in this matrix can take
bool MatrixType::deepCopyFrom ( MatrixType that)

A function to make a deep copy of an instance of this class.

Parameters
that,:the instance from which information is to be copied
Returns
whether the copy was created successfully

Member Data Documentation

ENUM_MATRIX_SYMMETRY MatrixType::symmetry

To track the type of symmetry present in the matrix or block.

Remarks
for definitions, see OSParameters.h

Definition at line 1896 of file OSMatrix.h.

ENUM_MATRIX_TYPE MatrixType::type

To track the type of values present in the matrix or block.

Remarks
for definitions, see OSParameters.h

Definition at line 1902 of file OSMatrix.h.

int MatrixType::numberOfRows

Definition at line 1904 of file OSMatrix.h.

int MatrixType::numberOfColumns

Definition at line 1905 of file OSMatrix.h.

GeneralSparseMatrix* MatrixType::ExpandedMatrixInRowMajorForm

The matrix can be held in expanded form by rows or by columns and in a number of ways stored by blocks.

Definition at line 1911 of file OSMatrix.h.

GeneralSparseMatrix* MatrixType::ExpandedMatrixInColumnMajorForm

Definition at line 1912 of file OSMatrix.h.

std::vector<ExpandedMatrixBlocks*> MatrixType::ExpandedMatrixByBlocks

Definition at line 1913 of file OSMatrix.h.

int* MatrixType::m_miRowPartition
private

m_miRowPartition is the partition vector of the matrix rows into blocks

Remarks
This only tracks the top-level partition and does not recurse

Definition at line 1919 of file OSMatrix.h.

int MatrixType::m_iRowPartitionSize
private

m_iRowPartitionSize gives the size of the m_miRowPartition array, which is one more than the number of blocks in each row

Definition at line 1924 of file OSMatrix.h.

int* MatrixType::m_miColumnPartition
private

m_miColumnPartition is the partition vector of the matrix columns into blocks

Remarks
This only tracks the top-level partition and does not recurse

Definition at line 1929 of file OSMatrix.h.

int MatrixType::m_iColumnPartitionSize
private

m_iColumnPartitionSize gives the size of the m_miColumnPartition array, which is one more than the number of blocks in each column

Definition at line 1934 of file OSMatrix.h.

bool MatrixType::m_bHaveRowPartition
private

m_bHaveRowPartition tracks whether the row partition has been determined from the constructor list and stored in m_miRowPartition

Definition at line 1939 of file OSMatrix.h.

bool MatrixType::m_bHaveColumnPartition
private

m_bHaveColumnPartition tracks whether the column partition has been determined from the constructor list and stored in m_miColumnPartition

Definition at line 1944 of file OSMatrix.h.


The documentation for this class was generated from the following files: