hp2FEM
0.1
|
Public Member Functions | |
Matrix () | |
Constructor Empty. | |
Matrix (unsigned long NumberLines, unsigned long NumberColumns, double InitValue=0.0) | |
Constructor with parameters. | |
Matrix (Matrix &Instance) | |
Copy Constructor. | |
Matrix (FILE *File) | |
Constructor. | |
~Matrix () | |
Matrix & | operator= (Matrix &Instance) |
Assignment operation. | |
Matrix & | Equal (Matrix &Instance) |
Method to assign one object to another. Ex.: A.Equal(B). | |
operator double *const () | |
Convertion matrix to double* data type. | |
double & | operator() (long Row, long Column) |
Acess the elements (Row, Col), without verify the borders. | |
double & | GetElement (unsigned long Row, unsigned long Column) |
Acess the elements and checks if the element (i, j) belongs the matrix. | |
double & | GetEndElement () |
Acess the last element of the matrix. | |
void | SetElement (long Row, long Column, double Element) |
Acess the elements and checks if the element (i, j) belongs the matrix. | |
void | SetOrder (unsigned long NumberLines=0, unsigned long NumberColumns=0, double InitValue=0.0) |
Initialized the matrix order. | |
void | GetOrder (unsigned long &NumberLines, unsigned long &NumberColumns) |
Returns the matrix order. | |
long | GetNumberLines () |
Return the number of rows. | |
long | GetNumberColumns () |
Return the number of colums. | |
unsigned long | GetNumberElements () |
Return the elements number of the matrix. | |
long | SizeOf () |
Return the bytes number occuped by the matrix. | |
void | Reset (double Value=0.0) |
Reinitializes the Matrix Elements. | |
void | Identity () |
Creates Matrix Identity. | |
void | Transpose (Matrix &Transpost) |
Transposed Matrix. | |
void | Insert (Matrix &SubMatrix, long InitLine=0, long InitColumn=0) |
Insert sub-matrix from the parameters "InitLine" and "InitColumn" in the Matrix. | |
double | Maximum () |
Return the maximum value of the matrix. | |
double | Minimum () |
Return the minimum value of the Matrix. | |
double | EuclideanNorm () |
Returns the euclidean norm. | |
Matrix & | Product (double *A, unsigned long N, double b=1.0) |
double | Norm1 () |
Calculates the norm 1 of the Matrix - The absolute value of the maximum sum of columns. | |
double | NormInfinity () |
Return the absolute value of the largest sum of the rows. | |
Matrix & | Chs () |
Inverts the signal of elements of the matrix. | |
Matrix & | operator- () |
Inverts the signal of elements of the matrix. | |
Matrix & | Add (Matrix &A, Matrix &B) |
Matrix addition. | |
Matrix & | operator+= (Matrix &B) |
Matrix addition. | |
Matrix & | Add (Matrix &B) |
Matrix addition. | |
Matrix & | Subtract (Matrix &A, Matrix &B) |
Matrix subtraction. | |
Matrix & | operator-= (Matrix &B) |
Matrix subtraction. | |
Matrix & | Subtract (Matrix &B) |
Matrix subtraction. | |
Matrix & | Add (double Scalar) |
Adds a scalar in the matrix. | |
Matrix & | operator+= (double Scalar) |
Adds a scalar in the matrix. | |
Matrix & | Subtract (double Scalar) |
Subtracts a scalar in the matrix. | |
Matrix & | operator-= (double Scalar) |
Subtracts a scalar in the matrix. | |
Matrix & | Multiplicate (double Scalar) |
Multiplies the matrix by a scalar. | |
Matrix & | operator*= (double Scalar) |
Multiplies the matrix by a scalar. | |
double | ScalarProduct (Matrix &B) |
Scalar product between matrices. | |
void | TensorProduct (Matrix &A, Matrix &B) |
Tensor Product between matrices. | |
double | operator^ (Matrix &B) |
Scalar product between matrices. | |
Matrix & | Multiplicate (Matrix &A, Matrix &B) |
Matrix Multiplication. | |
Matrix & | Multiplicate (Matrix &A, SymmetricMatrix &B) |
Multiplication of a matrix by a symmetric matrix. | |
Matrix & | Multiplicate (SymmetricMatrix &A, Matrix &B) |
Multiplication of a symmetric matrix by a not symmetric matrix. | |
Matrix & | Multiplicate (SymmetricMatrix &A, SymmetricMatrix &B) |
Matrix Multiplication between two symmetric matrices. | |
Matrix & | TripleProduct (Matrix &A, Matrix &B) |
Triple product of matrices using full matrix. | |
void | Save (FILE *File) |
Saves the matrix in a binary file. | |
void | Save (char *TabName, int Version, char *Filename) |
Saves the matrix in the "acdp" database. | |
void | Restore (FILE *File) |
Reads the matrix from a binary file. | |
void | Restore (char *TabName, int Version, char *Filename) |
Reads the matrix from the "acdp" database. | |
void | Print (FILE *File, char *Title, char *Format) |
Prints the matrix in the file. | |
void | Print (FILE *File=stdout, const char *Message="", int NumMaxCols=5, int Mant=14, int Dec=7) |
Print matrix in ASCII format by columns. | |
void | Free () |
Frees space of memory allocated for the Matrix. | |
void | GaussSolver (double *U, double *B, double Precision) |
Gauss elimination method. | |
void | GaussSolver () |
Matrix triangulation by gauss method. | |
void | GaussSolver (double *U, double *B) |
Solves system by gauss method through back substitution. | |
void | GaussSeidel (double *U, double *B, long MaxNumberIter, double Omega, double Precision=1.0e-4, double RelaxFactor=1.81, NormDS_E Norm=EUCLID) |
Iteractive Method of Gauss-Seidel. | |
Protected Member Functions | |
void | Alloc (double InitValue=0.0) |
Assigns a value init for each element of the Matrix. | |
double | scalv (double *x, double *y, unsigned long dim) |
Calculates the product scalar between two vectors. | |
int | mitgsl (double *vetx, double *ma, double *vetb, long neq, long itmax, double eps, double beta, int codconvg) |
Resolves the system of linear equations by the iterative method of the Gauss - Seidel. | |
void | prmatba (double *ma, double *mb, long nlina, long ncola, double *mc) |
Multiplies two matrices of the double type stored by rows and pre-multiplies by the transposed of the first matrix. | |
int | mgausst1 (double *ma, unsigned long neq, long *step, long *vinfopiv, double *auxptr) |
Solves the system of linear equations by the Gaussian Elimination Method details Triangularizes the system matrix by Gaussian Elimination Method using partial pivoting technique. The system matrix and the full matrix are stored by rows. | |
void | solgauss1 (double *vetx, double *ma, double *vetb, long neq, long *vinfopiv) |
Solves the system of linear equations by the Gaussian Elimination Method. | |
Protected Attributes | |
int | GaussFlag |
An integer - Flag to identify the kind of Gauss Method that will be use. | |
unsigned long | NumLines |
A long integer - Stores number of rows of the matrix. | |
unsigned long | NumColumns |
A long integer - Stores number of columns of the matrix. | |
long * | VInfoPiv |
A long integer point - Vector permutations of the Gauss Method. | |
double * | FMatrix |
Point to double - Elements of the matrix. | |
double * | AuxPtr |
Point to double - auxiliary vector used to change rows of the matrix during the pivoted step. | |
char | ExtraMemory [SizeExtraMemM] |
Extra memory used in the memory alignment during allocation of class object. | |
Friends | |
Matrix | operator+ (Matrix &A, Matrix &B) |
Matrix addition. | |
Matrix | operator- (Matrix &A, Matrix &B) |
Matrix subtraction. | |
Matrix | operator* (Matrix &A, Matrix &B) |
Matrix Multiplication. | |
Matrix | operator* (Matrix &A, SymmetricMatrix &B) |
Multiplication of a matrix by a symmetric matrix. | |
Matrix | operator* (SymmetricMatrix &A, Matrix &B) |
Multiplication of a symmetric matrix by a not symmetric matrix. | |
Matrix | operator* (SymmetricMatrix &A, SymmetricMatrix &B) |
Matrix Multiplication between two symmetric matrices. Ex.: C = Asym * Bsym. | |
void | Multiplicate (Matrix &A, SymmetricMatrix &B, Matrix &C) |
Runs the operation of multiplication: A = B * C (A and C are full. B is symmetric). |
Matrix::Matrix | ( | unsigned long | NumberLines, |
unsigned long | NumberColumns, | ||
double | InitValue = 0.0 |
||
) |
Constructor with parameters.
Initialize the matrix, storing the number of rows, columns and a init value for each element of the matrix.
[in] | NumberLines | - Indicates the number of rows of matrix. |
[in] | NumberColumns | - Indicates the number of columns of matrix. |
[in] | InitValue | - Value that will be assigned for all elements of matrix. |
Matrix::Matrix | ( | Matrix & | Instance | ) |
Copy Constructor.
[in] | Instance | - Matrix type. |
Matrix::Matrix | ( | FILE * | File | ) |
Constructor.
Read the matrix values through of an ASCII file.
[in] | File | - A binary file. |
Matrix::~Matrix | ( | ) |
Matrix & Matrix::Add | ( | Matrix & | A, |
Matrix & | B | ||
) |
Matrix & Matrix::Add | ( | Matrix & | B | ) |
Matrix & Matrix::Add | ( | double | Scalar | ) |
Matrix & Matrix::Chs | ( | ) |
Inverts the signal of elements of the matrix.
Ex.: A.Chs().
Matrix & Matrix::Equal | ( | Matrix & | Instance | ) |
double Matrix::EuclideanNorm | ( | ) |
Returns the euclidean norm.
void Matrix::GaussSeidel | ( | double * | U, |
double * | B, | ||
long | MaxNumberIter, | ||
double | Omega, | ||
double | Precision = 1.0e-4 , |
||
double | RelaxFactor = 1.81 , |
||
NormDS_E | Norm = EUCLID |
||
) |
Iteractive Method of Gauss-Seidel.
[in] | U | - double pointer to answer vector. |
[in] | B | - double pointer to independent terms. |
[in] | MaxNumberIter | - Maximum number of iterations. |
[in] | Omega | - parameter of relaxation. |
[in] | Precision | - constant for the convergence test. |
[in] | RelaxFactor. | |
[in] | Norm | - Code to convergence type. 1 - Infinity norm 2 - Euclidean norm. |
void Matrix::GaussSolver | ( | double * | U, |
double * | B, | ||
double | Precision | ||
) |
Gauss elimination method.
Modifies the independent terms and makes step of the back substitution.
[in] | U | - double pointer to answer vector. |
[in] | B | - double pointer to independent terms. |
[in] | Precision. |
void Matrix::GaussSolver | ( | ) |
Matrix triangulation by gauss method.
That routine makes the matrix triangulation of the system using partial pivoting technique.
void Matrix::GaussSolver | ( | double * | U, |
double * | B | ||
) |
Solves system by gauss method through back substitution.
[in] | U | - double pointer to answer vector. |
[in] | B | - double pointer to independent terms. |
double & Matrix::GetElement | ( | unsigned long | Row, |
unsigned long | Column | ||
) |
double & Matrix::GetEndElement | ( | ) |
Acess the last element of the matrix.
long Matrix::GetNumberColumns | ( | ) |
Return the number of colums.
unsigned long Matrix::GetNumberElements | ( | ) |
Return the elements number of the matrix.
long Matrix::GetNumberLines | ( | ) |
Return the number of rows.
void Matrix::GetOrder | ( | unsigned long & | NumberLines, |
unsigned long & | NumberColumns | ||
) |
Returns the matrix order.
[out] | NumberLines | - Rows number allocated of matrix. |
[out] | NumberColumns | - Columns number allocated of matrix. |
void Matrix::Insert | ( | Matrix & | SubMatrix, |
long | InitLine = 0 , |
||
long | InitColumn = 0 |
||
) |
Insert sub-matrix from the parameters "InitLine" and "InitColumn" in the Matrix.
[in] | SubMatrix | - matrix to be inserted inside another. |
[in] | InitLine | - Indicates the initial row the matrix that the sub-matrix should be inserted |
[in] | InitColumn | - Indicates the initial column the matrix that the sub-matrix should be inserted |
double Matrix::Maximum | ( | ) |
Return the maximum value of the matrix.
int Matrix::mgausst1 | ( | double * | ma, |
unsigned long | neq, | ||
long * | step, | ||
long * | vinfopiv, | ||
double * | auxptr | ||
) | [protected] |
Solves the system of linear equations by the Gaussian Elimination Method details Triangularizes the system matrix by Gaussian Elimination Method using partial pivoting technique. The system matrix and the full matrix are stored by rows.
[in] | *ma | - pointer to the system matrix |
[in] | neq | - number of the equations |
[in] | *step | - the step 'k' of the proccess of the 'partial pivoting' and 'forward elimination' |
[in] | *vinfopiv | - vector of the permutations of the Gauss Method. |
[in] | *auxptr | - pointer to the auxiliary vector used to exchange of rows of the matrix 'ma' in the pivoting step. |
double Matrix::Minimum | ( | ) |
Return the minimum value of the Matrix.
int Matrix::mitgsl | ( | double * | vetx, |
double * | ma, | ||
double * | vetb, | ||
long | neq, | ||
long | itmax, | ||
double | eps, | ||
double | beta, | ||
int | codconvg | ||
) | [protected] |
Resolves the system of linear equations by the iterative method of the Gauss - Seidel.
Uses technique of on relaxation. The system matrix is filled stored by rows.
param[in] *vetx - pointer to answer vector. param[in] *ma - pointer to system matrix. param[in] *vetb - pointer to vector of the independent terms. param[in] neq - number of equations param[in] itmax - maximum number of the iterations param[in] eps - constant to convergence test. param[in] beta - parameter the on relaxation. (0 - 2) param[in] codconvg - the code of the type convergence: 1 - euclidean norm. 2 - infinity norm
Matrix & Matrix::Multiplicate | ( | double | Scalar | ) |
Matrix & Matrix::Multiplicate | ( | Matrix & | A, |
Matrix & | B | ||
) |
Matrix & Matrix::Multiplicate | ( | Matrix & | A, |
SymmetricMatrix & | B | ||
) |
Multiplication of a matrix by a symmetric matrix.
Ex.: C.Multiplicate(A, Bsym).
[in] | A | - a matrix used in multiplication. |
[in] | B | - a symmetric matrix used in multiplication. |
Matrix & Matrix::Multiplicate | ( | SymmetricMatrix & | A, |
Matrix & | B | ||
) |
Multiplication of a symmetric matrix by a not symmetric matrix.
Ex.: C.Multiplicate(Asym, B).
[in] | A | - a symmetric matrix used in multiplication. |
[in] | B | - a matrix used in multiplication. |
Matrix & Matrix::Multiplicate | ( | SymmetricMatrix & | A, |
SymmetricMatrix & | B | ||
) |
double Matrix::Norm1 | ( | ) |
Calculates the norm 1 of the Matrix - The absolute value of the maximum sum of columns.
Matrix::operator double *const | ( | ) |
Convertion matrix to double* data type.
double & Matrix::operator() | ( | long | Row, |
long | Column | ||
) |
Acess the elements (Row, Col), without verify the borders.
Matrix & Matrix::operator*= | ( | double | Scalar | ) |
Matrix & Matrix::operator+= | ( | double | Scalar | ) |
Matrix & Matrix::operator- | ( | ) |
Inverts the signal of elements of the matrix.
Ex.: -A.
Matrix & Matrix::operator-= | ( | double | Scalar | ) |
double Matrix::operator^ | ( | Matrix & | B | ) |
Scalar product between matrices.
Ex.: r = A ^ B.
[in] | B. |
void Matrix::Print | ( | FILE * | File, |
char * | Title, | ||
char * | Format | ||
) |
Prints the matrix in the file.
Ex.: A.Print(fp, "matrix", "%7.2lf").
[in] | File | - the file where will be printed the matrix data. |
[in] | Title | - this a header to indicate a operation type. |
[in] | Format | - the data format to be printed. |
void Matrix::Print | ( | FILE * | File = stdout , |
const char * | Message = "" , |
||
int | NumMaxCols = 5 , |
||
int | Mant = 14 , |
||
int | Dec = 7 |
||
) |
Print matrix in ASCII format by columns.
Ex.: A.Print(fp, "matrix", 4, 7, 2).
[in] | File | - the file where will be printed the matrix data. (the default is stdout) |
[in] | Message | - Indicates the operation type that was run. |
[in] | NumMaxCols | - the maximum value of columns that can printed by row. |
[in] | Mant | - Indicates the space size that should have between columns. |
[in] | Dec | - Indicates the size of the decimal part to be printed. |
void Matrix::prmatba | ( | double * | ma, |
double * | mb, | ||
long | nlina, | ||
long | ncola, | ||
double * | mc | ||
) | [protected] |
Multiplies two matrices of the double type stored by rows and pre-multiplies by the transposed of the first matrix.
Example: C = AT * B * A
[in] | *ma | - pointer to the 'ma' matrix. |
[in] | *mb | - pointer to the 'mb' matrix. |
[in] | nlina | - number of rows of the 'ma' matrix. |
[in] | ncola | - number of rows of the 'ma' matrix. |
[out] | *mc | - pointer to the resulting matrix |
Matrix & Matrix::Product | ( | double * | A, |
unsigned long | N, | ||
double | b = 1.0 |
||
) |
void Matrix::Reset | ( | double | Value = 0.0 | ) |
Reinitializes the Matrix Elements.
[in] | Value | - Used to initialize the elements of matrix. |
void Matrix::Restore | ( | FILE * | File | ) |
Reads the matrix from a binary file.
[in] | File | - the binary file where the matrix will read. |
void Matrix::Restore | ( | char * | TabName, |
int | Version, | ||
char * | Filename | ||
) |
Reads the matrix from the "acdp" database.
[in] | TabName | - the table name of the database to read matrix data. |
[in] | Version | - the version of the read data. |
[in] | Filename | - Stores the database name. |
void Matrix::Save | ( | FILE * | File | ) |
Saves the matrix in a binary file.
[in] | File | - the file to save the matrix data. |
void Matrix::Save | ( | char * | TabName, |
int | Version, | ||
char * | Filename | ||
) |
Saves the matrix in the "acdp" database.
[in] | TabName | - the table name of the database to saved matrix data. |
[in] | Version | - the version of the update data. |
[in] | Filename | - Stores the database name. |
double Matrix::ScalarProduct | ( | Matrix & | B | ) |
double Matrix::scalv | ( | double * | x, |
double * | y, | ||
unsigned long | dim | ||
) | [protected] |
Calculates the product scalar between two vectors.
[in] | *x | - first vector. |
[in] | *y | - second vector. |
[in] | dim | - dimension of vector x and y. |
void Matrix::SetElement | ( | long | Row, |
long | Column, | ||
double | Element | ||
) |
void Matrix::SetOrder | ( | unsigned long | NumberLines = 0 , |
unsigned long | NumberColumns = 0 , |
||
double | InitValue = 0.0 |
||
) |
Initialized the matrix order.
[in] | NumberLines | - Row number to matrix. |
[in] | NumberColumns | - Columns number to matrix. |
[in] | InitValue | - Initial value stored to all positions of matrix. |
long Matrix::SizeOf | ( | ) |
Return the bytes number occuped by the matrix.
void Matrix::solgauss1 | ( | double * | vetx, |
double * | ma, | ||
double * | vetb, | ||
long | neq, | ||
long * | vinfopiv | ||
) | [protected] |
Solves the system of linear equations by the Gaussian Elimination Method.
Solves the system of linear equations with multiples vectors of there independent terms of the Gaussian Elimination used partial pivoting technique and performing modification in the independent term according to with the result of the 'mgausst1' function and runs the step of the 'back substitution'
[out] | *vetx | - pointer to the answer vector. |
[in] | *ma | - pointer to the system matrix modified. |
[in] | *vetb | - pointer to the vector of the independent terms. |
[in] | neq | - number of equations. |
[in] | *vinfopiv | - vector of the permutations of the Gauss Method. |
Matrix & Matrix::Subtract | ( | Matrix & | A, |
Matrix & | B | ||
) |
Matrix & Matrix::Subtract | ( | Matrix & | B | ) |
Matrix & Matrix::Subtract | ( | double | Scalar | ) |
void Matrix::TensorProduct | ( | Matrix & | A, |
Matrix & | B | ||
) |
Tensor Product between matrices.
Ex.: Mat_C.TensorProduct(Mat_A, Mat_B)
[in] | A | - matrix type. |
[in] | B | - matrix type. |
void Matrix::Transpose | ( | Matrix & | Transpost | ) |
Transposed Matrix.
[out] | Transpost | - Stores the transposed matrix. |
Matrix & Matrix::TripleProduct | ( | Matrix & | A, |
Matrix & | B | ||
) |
Triple product of matrices using full matrix.
Ex.: C.TripleProduct(A, B).
[in] | A | - the matrix to be multiplicated. |
[in] | B | - the matrix to be multiplicated. |
void Multiplicate | ( | Matrix & | A, |
SymmetricMatrix & | B, | ||
Matrix & | C | ||
) | [friend] |
Runs the operation of multiplication: A = B * C (A and C are full. B is symmetric).
[in] | B | - the symmetric matrix to be multiplicated. |
[in] | C | - the matrix to be multiplicated. |
[out] | A | - the matrix that stores the result of multiplication. |
Matrix operator* | ( | Matrix & | A, |
SymmetricMatrix & | B | ||
) | [friend] |
Multiplication of a matrix by a symmetric matrix.
Ex.: C = A * B.
[in] | A | - a matrix used in multiplication. |
[in] | B | - a symmetric matrix used in multiplication. |
Matrix operator* | ( | SymmetricMatrix & | A, |
Matrix & | B | ||
) | [friend] |
Multiplication of a symmetric matrix by a not symmetric matrix.
Ex.: C = Asym * B.
[in] | A | - a symmetric matrix used in multiplication. |
[in] | B | - a matrix used in multiplication. |
Matrix operator* | ( | SymmetricMatrix & | A, |
SymmetricMatrix & | B | ||
) | [friend] |
int Matrix::GaussFlag [protected] |
An integer - Flag to identify the kind of Gauss Method that will be use.
Value 1 to triangularized matrix.
unsigned long Matrix::NumColumns [protected] |
A long integer - Stores number of columns of the matrix.
Details of Optimization: Use of the "unsigned" for number not negative.
unsigned long Matrix::NumLines [protected] |
A long integer - Stores number of rows of the matrix.
Details of Optimization: Use of the "unsigned" for number not negative.