Open CASCADE Technology 7.9.0
|
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 assignment: More...
#include <math_Matrix.hxx>
Public Member Functions | |
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: | |
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. | |
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. | |
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. | |
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: | |
Standard_Integer | ColNumber () const |
Returns the number of rows of this matrix. Note that for a matrix A you always have the following relations: | |
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_Real | Determinant () const |
Computes the determinant of a matrix. An exception is raised if the matrix is not a square matrix. | |
void | Transpose () |
Transposes a given matrix. An exception is raised if the matrix is not a square matrix. | |
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. | |
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: | |
void | operator*= (const Standard_Real Right) |
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 |
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: | |
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) |
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 |
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) |
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 |
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. | |
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) |
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 |
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,. | |
void | SetRow (const Standard_Integer Row, const math_VectorBase<> &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. | |
void | SetCol (const Standard_Integer Col, const math_VectorBase<> &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. | |
void | SetDiag (const Standard_Real Value) |
Sets the diagonal of a matrix to the value . An exception is raised if the matrix is not square. | |
math_VectorBase | Row (const Standard_Integer Row) const |
Returns the row of index Row of a matrix. | |
math_VectorBase | Col (const Standard_Integer Col) const |
Returns the column of index <Col> of a matrix. | |
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. | |
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. | |
math_Matrix | Transposed () const |
Teturns the transposed of a matrix. An exception is raised if the matrix is not a square matrix. | |
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. | |
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. | |
void | Multiply (const math_VectorBase<> &Left, const math_VectorBase<> &Right) |
Computes a matrix as the product of 2 vectors. An exception is raised if the dimensions are different. <me> = <Left> * <Right>. | |
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. | |
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. | |
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_Real & | Value (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_Real & | operator() (const Standard_Integer Row, const Standard_Integer Col) const |
math_Matrix & | Initialized (const math_Matrix &Other) |
Matrixes are copied through assignment. An exception is raised if the dimensions are different. | |
math_Matrix & | operator= (const math_Matrix &Other) |
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) |
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 |
math_VectorBase | Multiplied (const math_VectorBase<> &Right) const |
Returns the product of a matrix by a vector. An exception is raised if the dimensions are different. | |
math_VectorBase | operator* (const math_VectorBase<> &Right) const |
math_Matrix | Opposite () |
Returns the opposite of a matrix. An exception is raised if the dimensions are different. | |
math_Matrix | operator- () |
void | Dump (Standard_OStream &o) const |
Prints information on the current state of the object. Is used to redefine the operator <<. | |
Protected Member Functions | |
void | SetLowerRow (const Standard_Integer LowerRow) |
The new lower row of the matrix is set to <LowerRow> | |
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>. | |
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 assignment:
The exception RangeError is raised when trying to access outside the range of a matrix :
The exception DimensionError is raised when the dimensions of two matrices or vectors are not compatible.
A Matrix can be constructed with a pointer to "c array". It allows to carry the bounds inside the matrix. Example :
math_Matrix::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:
math_Matrix::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.
math_Matrix::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.
math_Matrix::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.
void math_Matrix::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.
void math_Matrix::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.
math_Matrix 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_VectorBase math_Matrix::Col | ( | const Standard_Integer | Col | ) | const |
Returns the column of index <Col> of a matrix.
Standard_Integer math_Matrix::ColNumber | ( | ) | const |
Returns the number of rows of this matrix. Note that for a matrix A you always have the following relations:
Standard_Real math_Matrix::Determinant | ( | ) | const |
Computes the determinant of a matrix. An exception is raised if the matrix is not a square matrix.
void math_Matrix::Divide | ( | const Standard_Real | Right | ) |
divides all the elements of a matrix by the value <Right>. An exception is raised if <Right> = 0.
math_Matrix 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.
void math_Matrix::Dump | ( | Standard_OStream & | o | ) | const |
Prints information on the current state of the object. Is used to redefine the operator <<.
void math_Matrix::Init | ( | const Standard_Real | InitialValue | ) |
Initialize all the elements of a matrix to InitialValue.
math_Matrix & math_Matrix::Initialized | ( | const math_Matrix & | Other | ) |
Matrixes are copied through assignment. An exception is raised if the dimensions are different.
math_Matrix 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.
void math_Matrix::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_Integer math_Matrix::LowerCol | ( | ) | const |
Returns the value of the Lower index of the column range of a matrix.
Standard_Integer math_Matrix::LowerRow | ( | ) | const |
Returns the value of the Lower index of the row range of a matrix.
math_Matrix math_Matrix::Multiplied | ( | const math_Matrix & | Right | ) | const |
Returns the product of 2 matrices. An exception is raised if the dimensions are different.
math_VectorBase math_Matrix::Multiplied | ( | const math_VectorBase<> & | Right | ) | const |
Returns the product of a matrix by a vector. An exception is raised if the dimensions are different.
math_Matrix math_Matrix::Multiplied | ( | const Standard_Real | Right | ) | const |
multiplies all the elements of a matrix by the value <Right>.
void math_Matrix::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.
void math_Matrix::Multiply | ( | const math_Matrix & | Right | ) |
Returns the product of 2 matrices. An exception is raised if the dimensions are different.
void math_Matrix::Multiply | ( | const math_VectorBase<> & | Left, |
const math_VectorBase<> & | Right ) |
Computes a matrix as the product of 2 vectors. An exception is raised if the dimensions are different. <me> = <Left> * <Right>.
void math_Matrix::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:
|
inline |
|
inline |
math_VectorBase math_Matrix::operator* | ( | const math_VectorBase<> & | Right | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
math_Matrix math_Matrix::Opposite | ( | ) |
Returns the opposite of a matrix. An exception is raised if the dimensions are different.
math_VectorBase math_Matrix::Row | ( | const Standard_Integer | Row | ) | const |
Returns the row of index Row of a matrix.
Standard_Integer math_Matrix::RowNumber | ( | ) | const |
Returns the number of rows of this matrix. Note that for a matrix A you always have the following relations:
void math_Matrix::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,.
void math_Matrix::SetCol | ( | const Standard_Integer | Col, |
const math_VectorBase<> & | 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.
void math_Matrix::SetDiag | ( | const Standard_Real | Value | ) |
Sets the diagonal of a matrix to the value . An exception is raised if the matrix is not square.
|
protected |
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>.
|
protected |
The new lower column of the matrix is set to the column of range <LowerCol>.
|
protected |
The new lower row of the matrix is set to <LowerRow>
void math_Matrix::SetRow | ( | const Standard_Integer | Row, |
const math_VectorBase<> & | 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.
void math_Matrix::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.
void math_Matrix::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.
math_Matrix 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.
void math_Matrix::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.
void math_Matrix::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.
math_Matrix 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:
math_Matrix 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.
void math_Matrix::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.
void math_Matrix::Transpose | ( | ) |
Transposes a given matrix. An exception is raised if the matrix is not a square matrix.
math_Matrix math_Matrix::Transposed | ( | ) | const |
Teturns the transposed of a matrix. An exception is raised if the matrix is not a square matrix.
Standard_Integer math_Matrix::UpperCol | ( | ) | const |
Returns the value of the upper index of the column range of a matrix.
Standard_Integer math_Matrix::UpperRow | ( | ) | const |
Returns the Upper index of the row range of a matrix.
Standard_Real & math_Matrix::Value | ( | 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.