CPP Linear Algebra ToolBox  0.1.0
matrix.cpp File Reference
Include dependency graph for matrix.cpp:

Functions

bool operator== (const Matrix &lhs, const Matrix &rhs)
 Overload of operator == Two matrices are equal if and only they have the same dimensions and the same elements. More...
 
Matrix operator* (const Matrix &lhs, const Matrix &rhs)
 Overload operator * for multiplication of Matrices. More...
 
Vector operator* (const Vector &v, const Matrix &A)
 Overload operator * for left multiplication of covector with Matrix. More...
 
Vector operator* (const Matrix &A, const Vector &v)
 Overload operator * for right multiplication of Matrix with Vector. More...
 
Matrix operator* (const double k, const Matrix &B)
 Overload operator * for multiplication of a scalar with Matrix. More...
 
Matrix operator* (const Matrix &B, const double k)
 Overload operator * for multiplication of a Matrix with scalar. More...
 
Matrix operator+ (const Matrix &lhs, const Matrix &rhs)
 Overload operator + for addition of Matrices. More...
 
Matrix operator+ (const double k, const Matrix &B)
 Overload operator + for addition of scalar with Matrix. More...
 
Matrix operator+ (const Matrix &B, const double k)
 Overload operator + for addition of Matrix with scalar. More...
 
Matrix operator- (const Matrix &lhs, const Matrix &rhs)
 Overload operator - for soustraction of Matrices. More...
 
Matrix operator- (const Matrix &B, const double k)
 Overload operator - for soustraction of Matrix with scalar. More...
 
Matrix operator- (const double k, const Matrix &B)
 Overload operator - for soustraction of scalar with Matrix. More...
 
Matrix operator/ (const Matrix &B, const double k)
 Overload operator / for division of Matrix by scalar. More...
 
std::ostream & operator<< (std::ostream &os, const Matrix &M)
 Overload output stream operator for Matrix object. More...
 

Function Documentation

◆ operator*() [1/5]

Matrix operator* ( const double  k,
const Matrix B 
)

Overload operator * for multiplication of a scalar with Matrix.

Parameters
kA scalar.
BA Matrix object.
Returns
Matrix Matrix whose coefficients are those of B multiplied by k

◆ operator*() [2/5]

Vector operator* ( const Matrix A,
const Vector v 
)

Overload operator * for right multiplication of Matrix with Vector.

Parameters
vA Vector object of dimension n
AA Matrix object of dimension (m,n)
Returns
Vector A Vector object of dimension m
Warning
Vector v must have the length equla to the number of columns of A

◆ operator*() [3/5]

Matrix operator* ( const Matrix B,
const double  k 
)

Overload operator * for multiplication of a Matrix with scalar.

Parameters
BA Matrix object.
kA scalar.
Returns
Matrix Matrix whose coefficients are those of B multiplied by k

◆ operator*() [4/5]

Matrix operator* ( const Matrix lhs,
const Matrix rhs 
)

Overload operator * for multiplication of Matrices.

Parameters
lhsLeft Hand Side
rhsRight Hand Side
Returns
Matrix Matrix equal to lhs*rhs
Warning
lhs must have the same number of cols as the number of cols of rhs

◆ operator*() [5/5]

Vector operator* ( const Vector v,
const Matrix A 
)

Overload operator * for left multiplication of covector with Matrix.

Parameters
vA Vector object of dimension n (actually a covector)
AA Matrix object of dimension (n,m)
Returns
Vector A Vector object of dimension m (actually a covector)
Warning
Vector v must have the length equal to the number of rows of A

◆ operator+() [1/3]

Matrix operator+ ( const double  k,
const Matrix B 
)

Overload operator + for addition of scalar with Matrix.

Parameters
kA scalar.
BA Matrix.
Returns
Matrix Matrix whose coefficients are those of B plus k

◆ operator+() [2/3]

Matrix operator+ ( const Matrix B,
const double  k 
)

Overload operator + for addition of Matrix with scalar.

Parameters
BA Matrix.
kA scalar.
Returns
Matrix Matrix whose coefficients are those of B plus k

◆ operator+() [3/3]

Matrix operator+ ( const Matrix lhs,
const Matrix rhs 
)

Overload operator + for addition of Matrices.

Parameters
lhsLeft Hand Side
rhsRight Hand Side
Returns
Matrix Sum of lhs and rhs, i.e. lhs+rhs
Warning
lhs and rhs must have the same dimensions

◆ operator-() [1/3]

Matrix operator- ( const double  k,
const Matrix B 
)

Overload operator - for soustraction of scalar with Matrix.

Parameters
kA scalar.
BA Matrix.
Returns
Matrix Matrix whose coefficients are k minus B

◆ operator-() [2/3]

Matrix operator- ( const Matrix B,
const double  k 
)

Overload operator - for soustraction of Matrix with scalar.

Parameters
BA Matrix.
kA scalar.
Returns
Matrix Matrix whose coefficients are those of B minus k

◆ operator-() [3/3]

Matrix operator- ( const Matrix lhs,
const Matrix rhs 
)

Overload operator - for soustraction of Matrices.

Parameters
lhsLeft Hand Side
rhsRight Hand Side
Returns
Matrix Sum of lhs and rhs, i.e. lhs-rhs
Warning
lhs and rhs must have the same dimensions

◆ operator/()

Matrix operator/ ( const Matrix B,
const double  k 
)

Overload operator / for division of Matrix by scalar.

Parameters
BA Matrix.
kA scalar (non-zero).
Returns
Matrix Matrix whose coefficients are those of B divided by k
Warning
k must be non-zero.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const Matrix M 
)

Overload output stream operator for Matrix object.

Parameters
osOutput stream.
MMatrix object.
Returns
std::ostream & updated output stream

◆ operator==()

bool operator== ( const Matrix lhs,
const Matrix rhs 
)

Overload of operator == Two matrices are equal if and only they have the same dimensions and the same elements.

Parameters
lhsLeft Hand Side
rhsRight Hand Side
Returns
true if this matrix is equal to B
false if this matrix is different than B