#include <matrix.h>
Inheritance diagram for PLib::Matrix< T >:
Public Member Functions | |
Matrix (const int r, const int c) | |
Matrix (const Matrix< T > &M) | |
Matrix (T *p, const int r, const int c) | |
Matrix< T > & | operator= (const Matrix< T > &) |
T | operator= (const T v) |
void | submatrix (int i, int j, Matrix< T > &) |
void | as (int rw, int cl, Matrix< T > &) |
Matrix< T > | get (int rw, int cl, int nr, int nc) const |
Matrix< T > & | operator+= (const Matrix< T > &) |
Matrix< T > & | operator-= (const Matrix< T > &) |
Matrix< T > & | operator+= (double d) |
Matrix< T > & | operator-= (double d) |
Matrix< T > & | operator *= (double d) |
Matrix< T > & | operator/= (double d) |
Matrix< T > | herm () const |
Matrix< T > | transpose () const |
Matrix< T > | flop () const |
T | trace () const |
double | norm (void) |
void | diag (const T fv) |
Vector< T > | getDiag () |
void | qSort () |
int | read (char *filename) |
int | read (char *filename, int rows, int cols) |
int | write (char *filename) |
int | writeRaw (char *filename) |
template<> | |
Matrix< char > & | operator *= (double a) |
template<> | |
Matrix< char > & | operator+= (double a) |
template<> | |
Matrix< char > & | operator-= (double a) |
template<> | |
Matrix< char > & | operator/= (double a) |
template<> | |
double | norm (void) |
template<> | |
Matrix< Complex > | herm () const |
template<> | |
void | qSort () |
template<> | |
void | qSort () |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
void | qSort () |
template<> | |
Matrix< int > & | operator *= (double a) |
template<> | |
Matrix< int > & | operator+= (double a) |
template<> | |
Matrix< int > & | operator-= (double a) |
template<> | |
Matrix< int > & | operator/= (double a) |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
double | norm (void) |
template<> | |
Matrix< unsigned char > & | operator *= (double a) |
template<> | |
Matrix< unsigned char > & | operator+= (double a) |
template<> | |
Matrix< unsigned char > & | operator-= (double a) |
template<> | |
Matrix< unsigned char > & | operator/= (double a) |
template<> | |
double | norm (void) |
template<> | |
int | read (char *filename, int r, int c) |
Friends | |
class | LAPACK |
Matrix< T > | operator+ (const Matrix< T > &, const Matrix< T > &) |
Matrix< T > | operator- (const Matrix< T > &, const Matrix< T > &) |
Matrix< T > | operator * (const Matrix< T > &, const Matrix< T > &) |
Matrix< T > | operator * (const double, const Matrix< T > &) |
Matrix< T > | operator * (const Complex &, const Matrix< T > &) |
Vector< T > | operator * (const Matrix< T > &, const Vector< T > &) |
int | operator== (const Matrix< T > &, const Matrix< T > &) |
int | operator!= (const Matrix< T > &a, const Matrix< T > &b) |
This is a matrix class which has basic mathematical operators and some routines for input/output.
Matrix< T > & PLib::Matrix< T >::operator= | ( | const Matrix< T > & | a | ) |
assignment operator
a | the matrix to copy |
Reimplemented in PLib::MatrixRT< T >.
void PLib::Matrix< T >::submatrix | ( | int | sr, | |
int | sc, | |||
Matrix< T > & | a | |||
) |
sets the submatrix (s_r,s_c) to a .
sr | the row of the submatrix | |
sc | the column of the submatrix | |
a | the submatrix to copy from |
void PLib::Matrix< T >::as | ( | int | rw, | |
int | cl, | |||
Matrix< T > & | a | |||
) |
copies a matrix into this matrix starting at index (rw,cl)
rw | the row to insert the matrix at | |
cl | the column to insert the matrix at | |
a | the matrix to insert |
Matrix< T > PLib::Matrix< T >::get | ( | int | rw, | |
int | cl, | |||
int | nr, | |||
int | nc | |||
) | const |
returns the matrix of size (nr,nc) starting at (rw,cl).
rw | the index of the row | |
cl | the index of the column | |
nr | the number of rows() of the matrix to generate | |
nc | the number of coluns of the matrix to generate |
Matrix< T > & PLib::Matrix< T >::operator+= | ( | const Matrix< T > & | a | ) |
adds a matrix to itself
a | the matrix to increment itself with |
Matrix< T > & PLib::Matrix< T >::operator-= | ( | const Matrix< T > & | a | ) |
self substraction
This will substract the matrix a from the matrix. The result is thus matrix = matrix - a.
a | the matrix to substract |
Matrix< T > & PLib::Matrix< T >::operator+= | ( | double | a | ) |
increase every elements by a double
a | the value to increase the elements by |
Matrix< T > & PLib::Matrix< T >::operator-= | ( | double | a | ) |
decrease every elements by a double
a | the value to decrease the elements by |
Matrix< T > & PLib::Matrix< T >::operator *= | ( | double | a | ) |
multiply every elements by a double
a | the value to mutiply the elements with |
Matrix< T > & PLib::Matrix< T >::operator/= | ( | double | a | ) |
divide every elements by a double
a | the value to divide the elements with |
Matrix< T > PLib::Matrix< T >::herm | ( | ) | const |
computes the hermitian of the matrix
This functions returns a matrix for which every elements (i,j) correspond to the element (j,i) of the original matrix.
a | the a matrix |
Matrix< T > PLib::Matrix< T >::transpose | ( | ) | const |
returns the transpose of the matrix
a | the matrix to transpose |
Matrix< T > PLib::Matrix< T >::flop | ( | ) | const |
returns the matrix flopped
The flop pixel (i,j) = (i,cols-j-1)
T PLib::Matrix< T >::trace | ( | ) | const |
The sum of all diagonal elements.
a | the matrix to trace |
double PLib::Matrix< T >::norm | ( | void | ) |
Finds the first norm of the matrix.
void PLib::Matrix< T >::diag | ( | const T | a | ) |
sets the diagonal of the matrix to a
Sets the diagonal points of the matrix to a. The diagonal points are (0,0),(1,1),(2,2),etc.
a | the value to set the diagonal to |
Vector< T > PLib::Matrix< T >::getDiag | ( | ) |
returns the diagonal of the matrix
Returns a vector with the component [i] being set to the component (i,i) of the matrix.
int PLib::Matrix< T >::read | ( | char * | filename | ) |
read a matrix file Reads a matrix file. The format of a file is { rows() cols() data...}, where rows() and cols() are int and data is a vector of the matrix type.
filename | the name of the file to read |
int PLib::Matrix< T >::read | ( | char * | filename, | |
int | r, | |||
int | c | |||
) |
read a raw file containing a matrix of size $(r,c)$ Reads a file containing raw data of a matrix of size $(r,c)$.
filename | the name of the file to read r the number of rows() c the number of columns |
int PLib::Matrix< T >::write | ( | char * | filename | ) |
write a matrix into a Matrix file Writes a matrix file. The format of the file is { rows() cols() data...}, where rows() and cols() are int and data is a vector of the matrix type.
filename | the name of the file to write to |
int PLib::Matrix< T >::writeRaw | ( | char * | filename | ) |
write the raw data to a file Writes the raw data to a file. The size information is {not} written to the file.
filename | the name of the file to write to |
the addition operator
a | the first matrix to add | |
b | the second matrix to add |
the substraction operator
a | the matrix to substract from | |
b | the matrix to substract |
the multiplication operator
a | a matrix | |
b | the matrix to multiply with |
multiplication of a double and a matrix
d | the double value to scale the matrix with | |
a | the matrix to scale with the double value $d$ |
multiplies a matrix with a complex value
d | a complex value | |
a | a matrix |
multiplies a matrix with a vector
a | the matrix | |
x | the vector |
the equality operator
Every elements are compared with each others. If one of them in matrix a is not equal to the one in matrix b, then the result is negative.
a | the first matrix to compare | |
b | the second matrix to compare |