OCC Main Page | FoundationClasses | Toolkits | Packages | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FoundationClasses
TKMath
math


math_Matrix Class Reference

This class implements the real matrix abstract data type.
Matrixes can have an arbitrary range which must be defined
at the declaration and cannot be changed after this declaration
math_Matrix(-3,5,2,4); //a vector with range [-3..5, 2..4]
Matrix values may be initialized and
retrieved using indexes which must lie within the range
of definition of the matrix.
Matrix objects follow "value semantics", that is, they
cannot be shared and are copied through assignment
Matrices are copied through assignement:
math_Matrix M2(1, 9, 1, 3);
...
M2 = M1;
M1(1) = 2.0;//the matrix M2 will not be modified.

The exception RangeError is raised when trying to access
outside the range of a matrix :
M1(11, 1)=0.0// --> will raise RangeError.

The exception DimensionError is raised when the dimensions of
two matrices or vectors are not compatible.
math_Matrix M3(1, 2, 1, 2);
M3 = M1; // will raise DimensionError
M1.Add(M3) // --> will raise DimensionError.
A Matrix can be constructed with a a pointer to "c array".
It allows to carry the bounds inside the matrix.
Exemple :
Standard_Real tab1[10][20];
Standard_Real tab2[200];

math_Matrix A (tab1[0][0], 1, 10, 1, 20);
math_Matrix B (tab2[0], 1, 10, 1, 20);
.

#include <math_Matrix.hxx>


Public Member Functions

void * operator new (size_t, void *anAddress)
void * operator new (size_t size)
void operator delete (void *anAddress)
Standard_EXPORT math_Matrix (const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol)
 Constructs a non-initialized matrix of range [LowerRow..UpperRow,
LowerCol..UpperCol]
For the constructed matrix:
- LowerRow and UpperRow are the indexes of the
lower and upper bounds of a row, and
- LowerCol and UpperCol are the indexes of the
lower and upper bounds of a column.
.
Standard_EXPORT math_Matrix (const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol, const Standard_Real InitialValue)
 constructs a non-initialized matrix of range [LowerRow..UpperRow,
LowerCol..UpperCol]
whose values are all initialized with the value InitialValue.

Standard_EXPORT math_Matrix (const Standard_Address Tab, const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol)
 constructs a matrix of range [LowerRow..UpperRow,
LowerCol..UpperCol]
Sharing data with a "C array" pointed by Tab.

Standard_EXPORT math_Matrix (const math_Matrix &Other)
 constructs a matrix for copy in initialization.
An exception is raised if the matrixes have not the same dimensions.

Standard_EXPORT void Init (const Standard_Real InitialValue)
 Initialize all the elements of a matrix to InitialValue.
.
Standard_Integer RowNumber () const
 Returns the number of rows of this matrix.
Note that for a matrix A you always have the following relations:
- A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
- A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
- the length of a row of A is equal to the number of columns of A,
- the length of a column of A is equal to the number of
rows of A.returns the row range of a matrix.
.
Standard_Integer ColNumber () const
 Returns the number of rows of this matrix.
Note that for a matrix A you always have the following relations:
- A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
- A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
- the length of a row of A is equal to the number of columns of A,
- the length of a column of A is equal to the number of
rows of A.returns the row range of a matrix.
.
Standard_Integer LowerRow () const
 Returns the value of the Lower index of the row
range of a matrix.
.
Standard_Integer UpperRow () const
 Returns the Upper index of the row range
of a matrix.
.
Standard_Integer LowerCol () const
 Returns the value of the Lower index of the
column range of a matrix.
.
Standard_Integer UpperCol () const
 Returns the value of the upper index of the
column range of a matrix.
.
Standard_EXPORT Standard_Real Determinant () const
 Computes the determinant of a matrix.
An exception is raised if the matrix is not a square matrix.
.
Standard_EXPORT void Transpose ()
 Transposes a given matrix.
An exception is raised if the matrix is not a square matrix.
.
Standard_EXPORT void Invert ()
 Inverts a matrix using Gauss algorithm.
Exception NotSquare is raised if the matrix is not square.
Exception SingularMatrix is raised if the matrix is singular.
.
Standard_EXPORT void Multiply (const Standard_Real Right)
 Sets this matrix to the product of the matrix Left, and the matrix Right.
Example
math_Matrix A (1, 3, 1, 3);
math_Matrix B (1, 3, 1, 3);
// A = ... , B = ...
math_Matrix C (1, 3, 1, 3);
C.Multiply(A, B);
Exceptions
Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
- the number of columns of matrix Left, or the number of
rows of matrix TLeft is not equal to the number of rows
of matrix Right, or
- the number of rows of matrix Left, or the number of
columns of matrix TLeft is not equal to the number of
rows of this matrix, or
- the number of columns of matrix Right is not equal to
the number of columns of this matrix.
.
void operator *= (const Standard_Real Right)
Standard_EXPORT math_Matrix Multiplied (const Standard_Real Right) const
 multiplies all the elements of a matrix by the
value <right>.

math_Matrix operator * (const Standard_Real Right) const
Standard_EXPORT math_Matrix TMultiplied (const Standard_Real Right) const
 Sets this matrix to the product of the
transposed matrix TLeft, and the matrix Right.
Example
math_Matrix A (1, 3, 1, 3);
math_Matrix B (1, 3, 1, 3);
// A = ... , B = ...
math_Matrix C (1, 3, 1, 3);
C.Multiply(A, B);
Exceptions
Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
- the number of columns of matrix Left, or the number of
rows of matrix TLeft is not equal to the number of rows
of matrix Right, or
- the number of rows of matrix Left, or the number of
columns of matrix TLeft is not equal to the number of
rows of this matrix, or
- the number of columns of matrix Right is not equal to
the number of columns of this matrix.
.
Standard_EXPORT void Divide (const Standard_Real Right)
 divides all the elements of a matrix by the value <right>.
An exception is raised if <right> = 0.

void operator/= (const Standard_Real Right)
Standard_EXPORT math_Matrix Divided (const Standard_Real Right) const
 divides all the elements of a matrix by the value <right>.
An exception is raised if <right> = 0.

math_Matrix operator/ (const Standard_Real Right) const
Standard_EXPORT void Add (const math_Matrix &Right)
 adds the matrix <right> to a matrix.
An exception is raised if the dimensions are different.
Warning
In order to save time when copying matrices, it is
preferable to use operator += or the function Add
whenever possible.

void operator+= (const math_Matrix &Right)
Standard_EXPORT math_Matrix Added (const math_Matrix &Right) const
 adds the matrix <right> to a matrix.
An exception is raised if the dimensions are different.

math_Matrix operator+ (const math_Matrix &Right) const
Standard_EXPORT void Add (const math_Matrix &Left, const math_Matrix &Right)
 sets a matrix to the addition of <left> and <right>.
An exception is raised if the dimensions are different.

Standard_EXPORT void Subtract (const math_Matrix &Right)
 Subtracts the matrix <right> from <me>.
An exception is raised if the dimensions are different.
Warning
In order to avoid time-consuming copying of matrices, it
is preferable to use operator -= or the function
Subtract whenever possible.
.
void operator-= (const math_Matrix &Right)
Standard_EXPORT math_Matrix Subtracted (const math_Matrix &Right) const
 Returns the result of the subtraction of <right> from <me>.
An exception is raised if the dimensions are different.
.
math_Matrix operator- (const math_Matrix &Right) const
Standard_EXPORT void Set (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer J1, const Standard_Integer J2, const math_Matrix &M)
 Sets the values of this matrix,
- from index I1 to index I2 on the row dimension, and
- from index J1 to index J2 on the column dimension,
to those of matrix M.
Exceptions
Standard_DimensionError if:
- I1 is less than the index of the lower row bound of this matrix, or
- I2 is greater than the index of the upper row bound of this matrix, or
- J1 is less than the index of the lower column bound of this matrix, or
- J2 is greater than the index of the upper column bound of this matrix, or
- I2 - I1 + 1 is not equal to the number of rows of matrix M, or
- J2 - J1 + 1 is not equal to the number of columns of matrix M.
.
Standard_EXPORT void SetRow (const Standard_Integer Row, const math_Vector &V)
 Sets the row of index Row of a matrix to the vector <v>.
An exception is raised if the dimensions are different.
An exception is raises if <row> is inferior to the lower
row of the matrix or <row> is superior to the upper row.
.
Standard_EXPORT void SetCol (const Standard_Integer Col, const math_Vector &V)
 Sets the column of index Col of a matrix to the vector <v>.
An exception is raised if the dimensions are different.
An exception is raises if <col> is inferior to the lower
column of the matrix or <col> is superior to the upper
column.
.
Standard_EXPORT void SetDiag (const Standard_Real Value)
 Sets the diagonal of a matrix to the value <value>.
An exception is raised if the matrix is not square.
.
Standard_EXPORT math_Vector Row (const Standard_Integer Row) const
 Returns the row of index Row of a matrix.
.
Standard_EXPORT math_Vector Col (const Standard_Integer Col) const
 Returns the column of index <col> of a matrix.
.
Standard_EXPORT void SwapRow (const Standard_Integer Row1, const Standard_Integer Row2)
 Swaps the rows of index Row1 and Row2.
An exception is raised if <row1> or <row2> is out of range.
.
Standard_EXPORT void SwapCol (const Standard_Integer Col1, const Standard_Integer Col2)
 Swaps the columns of index <col1> and <col2>.
An exception is raised if <col1> or <col2> is out of range.
.
Standard_EXPORT math_Matrix Transposed () const
 Teturns the transposed of a matrix.
An exception is raised if the matrix is not a square matrix.
.
Standard_EXPORT math_Matrix Inverse () const
 Returns the inverse of a matrix.
Exception NotSquare is raised if the matrix is not square.
Exception SingularMatrix is raised if the matrix is singular.
.
Standard_EXPORT math_Matrix TMultiply (const math_Matrix &Right) const
 Returns the product of the transpose of a matrix with
the matrix <right>.
An exception is raised if the dimensions are different.
.
Standard_EXPORT void Multiply (const math_Vector &Left, const math_Vector &Right)
 Computes a matrix as the product of 2 vectors.
An exception is raised if the dimensions are different.
<me> = <left> * <right>.
.
Standard_EXPORT void Multiply (const math_Matrix &Left, const math_Matrix &Right)
 Computes a matrix as the product of 2 matrixes.
An exception is raised if the dimensions are different.
.
Standard_EXPORT void TMultiply (const math_Matrix &TLeft, const math_Matrix &Right)
 Computes a matrix to the product of the transpose of
the matrix <tleft> with the matrix <right>.
An exception is raised if the dimensions are different.
.
Standard_EXPORT void Subtract (const math_Matrix &Left, const math_Matrix &Right)
 Sets a matrix to the Subtraction of the matrix <right>
from the matrix <left>.
An exception is raised if the dimensions are different.
.
Standard_RealValue (const Standard_Integer Row, const Standard_Integer Col) const
 Accesses (in read or write mode) the value of index <row>
and <col> of a matrix.
An exception is raised if <row> and <col> are not
in the correct range.
.
Standard_Realoperator() (const Standard_Integer Row, const Standard_Integer Col) const
Standard_EXPORT math_MatrixInitialized (const math_Matrix &Other)
 Matrixes are copied through assignement.
An exception is raised if the dimensions are differents.
.
math_Matrixoperator= (const math_Matrix &Other)
Standard_EXPORT void Multiply (const math_Matrix &Right)
 Returns the product of 2 matrices.
An exception is raised if the dimensions are different.
.
void operator *= (const math_Matrix &Right)
Standard_EXPORT math_Matrix Multiplied (const math_Matrix &Right) const
 Returns the product of 2 matrices.
An exception is raised if the dimensions are different.
.
math_Matrix operator * (const math_Matrix &Right) const
Standard_EXPORT math_Vector Multiplied (const math_Vector &Right) const
 Returns the product of a matrix by a vector.
An exception is raised if the dimensions are different.
.
math_Vector operator * (const math_Vector &Right) const
Standard_EXPORT math_Matrix Opposite ()
 Returns the opposite of a matrix.
An exception is raised if the dimensions are different.
.
math_Matrix operator- ()
Standard_EXPORT void Dump (Standard_OStream &o) const
 Prints information on the current state of the object.
Is used to redefine the operator <<.
.

Protected Member Functions

Standard_EXPORT void SetLowerRow (const Standard_Integer LowerRow)
 The new lower row of the matrix is set to <lowerrow>
.
Standard_EXPORT void SetLowerCol (const Standard_Integer LowerCol)
 The new lower column of the matrix is set to the column
of range <lowercol>.
.
void SetLower (const Standard_Integer LowerRow, const Standard_Integer LowerCol)
 The new lower row of the matrix is set to <lowerrow>
and the new lower column of the matrix is set to the column
of range <lowercol>.
.

Private Attributes

Standard_Integer LowerRowIndex
Standard_Integer UpperRowIndex
Standard_Integer LowerColIndex
Standard_Integer UpperColIndex
math_DoubleTabOfReal Array

Friends

math_Matrix operator * (const Standard_Real Left, const math_Matrix &Right)


Constructor & Destructor Documentation

Standard_EXPORT math_Matrix::math_Matrix const Standard_Integer  LowerRow,
const Standard_Integer  UpperRow,
const Standard_Integer  LowerCol,
const Standard_Integer  UpperCol
 

Standard_EXPORT math_Matrix::math_Matrix const Standard_Integer  LowerRow,
const Standard_Integer  UpperRow,
const Standard_Integer  LowerCol,
const Standard_Integer  UpperCol,
const Standard_Real  InitialValue
 

Standard_EXPORT math_Matrix::math_Matrix const Standard_Address  Tab,
const Standard_Integer  LowerRow,
const Standard_Integer  UpperRow,
const Standard_Integer  LowerCol,
const Standard_Integer  UpperCol
 

Standard_EXPORT math_Matrix::math_Matrix const math_Matrix Other  ) 
 


Member Function Documentation

Standard_EXPORT void math_Matrix::Add const math_Matrix Left,
const math_Matrix Right
 

Standard_EXPORT void math_Matrix::Add const math_Matrix Right  ) 
 

Standard_EXPORT math_Matrix math_Matrix::Added const math_Matrix Right  )  const
 

Standard_EXPORT math_Vector math_Matrix::Col const Standard_Integer  Col  )  const
 

Standard_Integer math_Matrix::ColNumber  )  const [inline]
 

Standard_EXPORT Standard_Real math_Matrix::Determinant  )  const
 

Standard_EXPORT void math_Matrix::Divide const Standard_Real  Right  ) 
 

Standard_EXPORT math_Matrix math_Matrix::Divided const Standard_Real  Right  )  const
 

Standard_EXPORT void math_Matrix::Dump Standard_OStream o  )  const
 

Standard_EXPORT void math_Matrix::Init const Standard_Real  InitialValue  ) 
 

Standard_EXPORT math_Matrix& math_Matrix::Initialized const math_Matrix Other  ) 
 

Standard_EXPORT math_Matrix math_Matrix::Inverse  )  const
 

Standard_EXPORT void math_Matrix::Invert  ) 
 

Standard_Integer math_Matrix::LowerCol  )  const [inline]
 

Standard_Integer math_Matrix::LowerRow  )  const [inline]
 

Standard_EXPORT math_Vector math_Matrix::Multiplied const math_Vector Right  )  const
 

Standard_EXPORT math_Matrix math_Matrix::Multiplied const math_Matrix Right  )  const
 

Standard_EXPORT math_Matrix math_Matrix::Multiplied const Standard_Real  Right  )  const
 

Standard_EXPORT void math_Matrix::Multiply const math_Matrix Right  ) 
 

Standard_EXPORT void math_Matrix::Multiply const math_Matrix Left,
const math_Matrix Right
 

Standard_EXPORT void math_Matrix::Multiply const math_Vector Left,
const math_Vector Right
 

Standard_EXPORT void math_Matrix::Multiply const Standard_Real  Right  ) 
 

math_Vector math_Matrix::operator * const math_Vector Right  )  const [inline]
 

math_Matrix math_Matrix::operator * const math_Matrix Right  )  const [inline]
 

math_Matrix math_Matrix::operator * const Standard_Real  Right  )  const [inline]
 

void math_Matrix::operator *= const math_Matrix Right  )  [inline]
 

void math_Matrix::operator *= const Standard_Real  Right  )  [inline]
 

void math_Matrix::operator delete void *  anAddress  )  [inline]
 

void* math_Matrix::operator new size_t  size  )  [inline]
 

void* math_Matrix::operator new size_t  ,
void *  anAddress
[inline]
 

Standard_Real& math_Matrix::operator() const Standard_Integer  Row,
const Standard_Integer  Col
const [inline]
 

math_Matrix math_Matrix::operator+ const math_Matrix Right  )  const [inline]
 

void math_Matrix::operator+= const math_Matrix Right  )  [inline]
 

math_Matrix math_Matrix::operator-  )  [inline]
 

math_Matrix math_Matrix::operator- const math_Matrix Right  )  const [inline]
 

void math_Matrix::operator-= const math_Matrix Right  )  [inline]
 

math_Matrix math_Matrix::operator/ const Standard_Real  Right  )  const [inline]
 

void math_Matrix::operator/= const Standard_Real  Right  )  [inline]
 

math_Matrix& math_Matrix::operator= const math_Matrix Other  )  [inline]
 

Standard_EXPORT math_Matrix math_Matrix::Opposite  ) 
 

Standard_EXPORT math_Vector math_Matrix::Row const Standard_Integer  Row  )  const
 

Standard_Integer math_Matrix::RowNumber  )  const [inline]
 

Standard_EXPORT void math_Matrix::Set const Standard_Integer  I1,
const Standard_Integer  I2,
const Standard_Integer  J1,
const Standard_Integer  J2,
const math_Matrix M
 

Standard_EXPORT void math_Matrix::SetCol const Standard_Integer  Col,
const math_Vector V
 

Standard_EXPORT void math_Matrix::SetDiag const Standard_Real  Value  ) 
 

void math_Matrix::SetLower const Standard_Integer  LowerRow,
const Standard_Integer  LowerCol
[inline, protected]
 

Standard_EXPORT void math_Matrix::SetLowerCol const Standard_Integer  LowerCol  )  [protected]
 

Standard_EXPORT void math_Matrix::SetLowerRow const Standard_Integer  LowerRow  )  [protected]
 

Standard_EXPORT void math_Matrix::SetRow const Standard_Integer  Row,
const math_Vector V
 

Standard_EXPORT void math_Matrix::Subtract const math_Matrix Left,
const math_Matrix Right
 

Standard_EXPORT void math_Matrix::Subtract const math_Matrix Right  ) 
 

Standard_EXPORT math_Matrix math_Matrix::Subtracted const math_Matrix Right  )  const
 

Standard_EXPORT void math_Matrix::SwapCol const Standard_Integer  Col1,
const Standard_Integer  Col2
 

Standard_EXPORT void math_Matrix::SwapRow const Standard_Integer  Row1,
const Standard_Integer  Row2
 

Standard_EXPORT math_Matrix math_Matrix::TMultiplied const Standard_Real  Right  )  const
 

Standard_EXPORT void math_Matrix::TMultiply const math_Matrix TLeft,
const math_Matrix Right
 

Standard_EXPORT math_Matrix math_Matrix::TMultiply const math_Matrix Right  )  const
 

Standard_EXPORT void math_Matrix::Transpose  ) 
 

Standard_EXPORT math_Matrix math_Matrix::Transposed  )  const
 

Standard_Integer math_Matrix::UpperCol  )  const [inline]
 

Standard_Integer math_Matrix::UpperRow  )  const [inline]
 

Standard_Real & math_Matrix::Value const Standard_Integer  Row,
const Standard_Integer  Col
const [inline]
 


Friends And Related Function Documentation

math_Matrix operator * const Standard_Real  Left,
const math_Matrix Right
[friend]
 


Field Documentation

math_DoubleTabOfReal math_Matrix::Array [private]
 

Standard_Integer math_Matrix::LowerColIndex [private]
 

Standard_Integer math_Matrix::LowerRowIndex [private]
 

Standard_Integer math_Matrix::UpperColIndex [private]
 

Standard_Integer math_Matrix::UpperRowIndex [private]
 


The documentation for this class was generated from the following files:
Generated on Mon Aug 25 13:12:46 2008 for OpenCASCADE by  doxygen 1.4.1