GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
GOAT::maths::Matrix< T > Class Template Reference

This class represents a threedimensional (numeric) Matrix as a template. More...

#include <matrix.h>

Public Member Functions

void binRead (std::ifstream &is)
void binWrite (std::ofstream &os)
void clear ()
 Matrix ()
 Matrix (Vector< T > a, Vector< T > b, Vector< T > c)
 Main constructor for the template class Matrix. This constructor uses three vectors as parameters, which represents the three columns of the matrix.
bool operator!= (const Matrix &M)
T & operator() (int i, int j)
 This operator returns the value of the j-th element in the i-th column.
Matrixoperator= (const Matrix &A)
bool operator== (const Matrix &A)

Public Attributes

M [3][3]

Friends

Matrix cutMatrix (const Matrix &M, int i, int j)
 This function returns a matrix where all elements of the i-th column and the j-th row set to zero.
det (const Matrix &A)
 Calculates the determinant of the matrix A.
Matrix invert (const Matrix< T > &A)
 Calculates the inverse of a matrix, if possible.
Matrix invert (const Matrix< T > &A, bool &invertable)
 Calculates the inverse of a matrix, if possible.
std::ostream & operator<< (std::ostream &os, const Matrix &A)
 Output of the matrix into an ostream Output in the form: M00 M01 M02 M10 M11 M12 M20 M21 M22.
std::istream & operator>> (std::istream &is, Matrix &A)
 Input of the matrix from an istream.
trace (const Matrix &A)
 Calculates the trace of matrix A, i.e. the sum over all diagonal elements.
Matrix transpose (const Matrix &A)
 Calculates the transpose of the matrix A.

special operators

These operators are the common definitions of the corresponding matrix operations

Matrix operator+ (const Matrix &A)
Matrixoperator+= (const Matrix &A)
Matrix operator- ()
Matrixoperator-= (const Matrix &A)
Matrixoperator*= (const Matrix &A)
Matrixoperator/= (const T &x)
Matrixoperator*= (const T &x)
Matrix operator- (const Matrix &A, const Matrix &B)
Matrix operator* (const Matrix &A, const Matrix &B)
Matrix operator* (const Matrix &A, const T &x)
Matrix operator* (const T &x, const Matrix &A)
Vector< T > operator* (const Matrix &A, const Vector< T > &r)
Vector< T > operator* (const Vector< T > &r, const Matrix &A)
Matrix operator/ (const Matrix &A, const T &x)

Detailed Description

template<class T>
class GOAT::maths::Matrix< T >

This class represents a threedimensional (numeric) Matrix as a template.

The Matrix class represents a template class for 3x3 numeric matrices. Operators for standard matrix operation are provided. This class is intended to work with the Vector template class defined in this SDK.

Definition at line 22 of file matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<class T>
GOAT::maths::Matrix< T >::Matrix ( )
inline

Definition at line 25 of file matrix.h.

◆ Matrix() [2/2]

template<class T>
GOAT::maths::Matrix< T >::Matrix ( Vector< T > a,
Vector< T > b,
Vector< T > c )
inline

Main constructor for the template class Matrix. This constructor uses three vectors as parameters, which represents the three columns of the matrix.

Parameters
afirst column
bsecond column
cthird column

Definition at line 54 of file matrix.h.

Member Function Documentation

◆ binRead()

template<class T>
void GOAT::maths::Matrix< T >::binRead ( std::ifstream & is)
inline
Parameters
isreads the Matrix from a binary file, represented by is

Definition at line 39 of file matrix.h.

◆ binWrite()

template<class T>
void GOAT::maths::Matrix< T >::binWrite ( std::ofstream & os)
inline
Parameters
oswrites the Matrix into a binary file, represented by os

Definition at line 32 of file matrix.h.

◆ clear()

template<class T>
void GOAT::maths::Matrix< T >::clear ( )
inline

Definition at line 378 of file matrix.h.

◆ operator!=()

template<class T>
bool GOAT::maths::Matrix< T >::operator!= ( const Matrix< T > & M)
inline
Parameters
Mnegative comparison operator, returns false, if at least one of the components are not equal

Definition at line 82 of file matrix.h.

◆ operator()()

template<class T>
T & GOAT::maths::Matrix< T >::operator() ( int i,
int j )
inline

This operator returns the value of the j-th element in the i-th column.

Parameters
iindex of the column
jindex of the row

Definition at line 96 of file matrix.h.

◆ operator*=() [1/2]

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator*= ( const Matrix< T > & A)
inline
Parameters
Amultiplication with matrix A

Definition at line 136 of file matrix.h.

◆ operator*=() [2/2]

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator*= ( const T & x)
inline
Parameters
xmultiplication with a scalar

Definition at line 160 of file matrix.h.

◆ operator+()

template<class T>
Matrix GOAT::maths::Matrix< T >::operator+ ( const Matrix< T > & A)
inline
Parameters
Aadding two matrices (same type)

Definition at line 102 of file matrix.h.

◆ operator+=()

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator+= ( const Matrix< T > & A)
inline
Parameters
Asubtract one matrix from this matrix

Definition at line 111 of file matrix.h.

◆ operator-()

template<class T>
Matrix GOAT::maths::Matrix< T >::operator- ( )
inline

Definition at line 119 of file matrix.h.

◆ operator-=()

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator-= ( const Matrix< T > & A)
inline
Parameters
Asubtraction operator

Definition at line 128 of file matrix.h.

◆ operator/=()

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator/= ( const T & x)
inline
Parameters
xdivision by a scalar

Definition at line 152 of file matrix.h.

◆ operator=()

template<class T>
Matrix & GOAT::maths::Matrix< T >::operator= ( const Matrix< T > & A)
inline
Parameters
Aassignment operator

Definition at line 64 of file matrix.h.

◆ operator==()

template<class T>
bool GOAT::maths::Matrix< T >::operator== ( const Matrix< T > & A)
inline
Parameters
Acomparison operator (two matrices are equal, if all components are exactly the same)

Definition at line 73 of file matrix.h.

◆ cutMatrix

template<class T>
Matrix cutMatrix ( const Matrix< T > & M,
int i,
int j )
friend

This function returns a matrix where all elements of the i-th column and the j-th row set to zero.

Parameters
MMatrix
icolumn
jrow
Returns
Exchanged matrix

Definition at line 319 of file matrix.h.

◆ det

template<class T>
T det ( const Matrix< T > & A)
friend

Calculates the determinant of the matrix A.

Parameters
AMatrix
Returns
Determinant of A

Definition at line 302 of file matrix.h.

◆ invert [1/2]

template<class T>
Matrix invert ( const Matrix< T > & A)
friend

Calculates the inverse of a matrix, if possible.

Parameters
AMatrix to invert
Returns
Inverse of matrix A, if A is invertable, otherwise the function returns a zero matrix.

Definition at line 372 of file matrix.h.

◆ invert [2/2]

template<class T>
Matrix invert ( const Matrix< T > & A,
bool & invertable )
friend

Calculates the inverse of a matrix, if possible.

Parameters
[in]AMatrix to invert
[out]invertabletrue, if A is invertable otherwise false
Returns
Inverse of matrix A, if A is invertable, otherwise the function returns a zero matrix.

Definition at line 342 of file matrix.h.

◆ operator* [1/5]

template<class T>
Matrix operator* ( const Matrix< T > & A,
const Matrix< T > & B )
friend
Parameters
Bmultiplication of two matrices (same type)

Definition at line 178 of file matrix.h.

◆ operator* [2/5]

template<class T>
Matrix operator* ( const Matrix< T > & A,
const T & x )
friend
Parameters
xmultiplication of matrix with a scalar

Definition at line 188 of file matrix.h.

◆ operator* [3/5]

template<class T>
Vector< T > operator* ( const Matrix< T > & A,
const Vector< T > & r )
friend
Parameters
rmultiplication of a matrix with a vector

Definition at line 206 of file matrix.h.

◆ operator* [4/5]

template<class T>
Matrix operator* ( const T & x,
const Matrix< T > & A )
friend
Parameters
Amultiplication of scalar with a matrix

Definition at line 197 of file matrix.h.

◆ operator* [5/5]

template<class T>
Vector< T > operator* ( const Vector< T > & r,
const Matrix< T > & A )
friend
Parameters
Amultiplication of a vector with a matrix

Definition at line 215 of file matrix.h.

◆ operator-

template<class T>
Matrix operator- ( const Matrix< T > & A,
const Matrix< T > & B )
friend
Parameters
Bsubtraction of two matrices (same type)

Definition at line 169 of file matrix.h.

◆ operator/

template<class T>
Matrix operator/ ( const Matrix< T > & A,
const T & x )
friend
Parameters
xdivision of a matrix with a scalar

Definition at line 224 of file matrix.h.

◆ operator<<

template<class T>
std::ostream & operator<< ( std::ostream & os,
const Matrix< T > & A )
friend

Output of the matrix into an ostream Output in the form: M00 M01 M02 M10 M11 M12 M20 M21 M22.

Parameters
osstream
Amatrix
Returns
changed stream

Definition at line 244 of file matrix.h.

◆ operator>>

template<class T>
std::istream & operator>> ( std::istream & is,
Matrix< T > & A )
friend

Input of the matrix from an istream.

Parameters
isstream
Amatrix
Returns
changed stream

Definition at line 258 of file matrix.h.

◆ trace

template<class T>
T trace ( const Matrix< T > & A)
friend

Calculates the trace of matrix A, i.e. the sum over all diagonal elements.

Parameters
AMatrix
Returns
trace

Definition at line 288 of file matrix.h.

◆ transpose

template<class T>
Matrix transpose ( const Matrix< T > & A)
friend

Calculates the transpose of the matrix A.

Parameters
AMatrix to be transposed (represented by Aij)
Returns
transposed matrix (=Aji)

Definition at line 273 of file matrix.h.

Member Data Documentation

◆ M

template<class T>
T GOAT::maths::Matrix< T >::M[3][3]

Definition at line 385 of file matrix.h.


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