Linear Algebra  arduino
Accessible implementations of linear algebra algorithms
Functions

Detailed Description

Matrix-matrix, matrix-vector and vector-vector multiplication.

+ Collaboration diagram for Matrix multiplication:

Functions

Matrix operator* (const Matrix &A, const Matrix &B)
 Matrix multiplication. More...
 
Matrix operator* (Matrix &&A, const Matrix &B)
 Matrix multiplication. More...
 
Matrix operator* (const Matrix &A, Matrix &&B)
 Matrix multiplication. More...
 
Matrix operator* (Matrix &&A, Matrix &&B)
 Matrix multiplication. More...
 
SquareMatrix operator* (const SquareMatrix &A, const SquareMatrix &B)
 Square matrix multiplication. More...
 
SquareMatrix operator* (SquareMatrix &&A, const SquareMatrix &B)
 Square matrix multiplication. More...
 
SquareMatrix operator* (const SquareMatrix &A, SquareMatrix &&B)
 Square matrix multiplication. More...
 
SquareMatrix operator* (SquareMatrix &&A, SquareMatrix &&B)
 Square matrix multiplication. More...
 
Vector operator* (const Matrix &A, const Vector &b)
 Matrix-vector multiplication. More...
 
Vector operator* (Matrix &&A, const Vector &b)
 Matrix-vector multiplication. More...
 
Vector operator* (const Matrix &A, Vector &&b)
 Matrix-vector multiplication. More...
 
Vector operator* (Matrix &&A, Vector &&b)
 Matrix-vector multiplication. More...
 
RowVector operator* (const RowVector &a, const Matrix &B)
 Matrix-vector multiplication. More...
 
RowVector operator* (RowVector &&a, const Matrix &B)
 Matrix-vector multiplication. More...
 
RowVector operator* (const RowVector &a, Matrix &&B)
 Matrix-vector multiplication. More...
 
RowVector operator* (RowVector &&a, Matrix &&B)
 Matrix-vector multiplication. More...
 
double operator* (const RowVector &a, const Vector &b)
 Vector-vector multiplication. More...
 
double operator* (RowVector &&a, const Vector &b)
 Vector-vector multiplication. More...
 
double operator* (const RowVector &a, Vector &&b)
 Vector-vector multiplication. More...
 
double operator* (RowVector &&a, Vector &&b)
 Vector-vector multiplication. More...
 
Matrix operator* (const PermutationMatrix &P, const Matrix &A)
 Left application of permutation matrix (P permutes rows of A). More...
 
Matrix && operator* (const PermutationMatrix &P, Matrix &&A)
 Left application of permutation matrix (P permutes rows of A). More...
 
Matrix operator* (const Matrix &A, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of A). More...
 
Matrix && operator* (Matrix &&A, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of A). More...
 
SquareMatrix operator* (const PermutationMatrix &P, const SquareMatrix &A)
 Left application of permutation matrix (P permutes rows of A). More...
 
SquareMatrix && operator* (const PermutationMatrix &P, SquareMatrix &&A)
 Left application of permutation matrix (P permutes rows of A). More...
 
SquareMatrix operator* (const SquareMatrix &A, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of A). More...
 
SquareMatrix && operator* (SquareMatrix &&A, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of A). More...
 
Vector operator* (const PermutationMatrix &P, const Vector &v)
 Left application of permutation matrix (P permutes rows of v). More...
 
Vector && operator* (const PermutationMatrix &P, Vector &&v)
 Left application of permutation matrix (P permutes rows of v). More...
 
RowVector operator* (const RowVector &v, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of v). More...
 
RowVector && operator* (RowVector &&v, const PermutationMatrix &P)
 Right application of permutation matrix (P permutes columns of v). More...
 

Function Documentation

◆ operator*() [1/32]

Matrix operator* ( const Matrix A,
const Matrix B 
)

Matrix multiplication.

Implementation

Matrix operator*(const Matrix &A, const Matrix &B) {
assert(A.cols() == B.rows() && "Inner dimensions don't match");
Matrix C = Matrix::zeros(A.rows(), B.cols());
for (size_t j = 0; j < B.cols(); ++j)
for (size_t k = 0; k < A.cols(); ++k)
for (size_t i = 0; i < A.rows(); ++i)
C(i, j) += A(i, k) * B(k, j);
return C;
}
General matrix class.
Definition: Matrix.hpp:34
static Matrix zeros(size_t rows, size_t cols)
Create a matrix filled with zeros.
Definition: Matrix.cpp:152
size_t rows() const
Get the number of rows of the matrix.
Definition: Matrix.hpp:81
size_t cols() const
Get the number of columns of the matrix.
Definition: Matrix.hpp:83
Matrix operator*(const Matrix &A, const Matrix &B)
Matrix multiplication.
Definition: Matrix.cpp:622

Definition at line 622 of file Matrix.cpp.

◆ operator*() [2/32]

Matrix operator* ( Matrix &&  A,
const Matrix B 
)

Matrix multiplication.

Definition at line 633 of file Matrix.cpp.

◆ operator*() [3/32]

Matrix operator* ( const Matrix A,
Matrix &&  B 
)

Matrix multiplication.

Definition at line 640 of file Matrix.cpp.

◆ operator*() [4/32]

Matrix operator* ( Matrix &&  A,
Matrix &&  B 
)

Matrix multiplication.

Definition at line 647 of file Matrix.cpp.

◆ operator*() [5/32]

SquareMatrix operator* ( const SquareMatrix A,
const SquareMatrix B 
)

Square matrix multiplication.

Definition at line 655 of file Matrix.cpp.

◆ operator*() [6/32]

SquareMatrix operator* ( SquareMatrix &&  A,
const SquareMatrix B 
)

Square matrix multiplication.

Definition at line 659 of file Matrix.cpp.

◆ operator*() [7/32]

SquareMatrix operator* ( const SquareMatrix A,
SquareMatrix &&  B 
)

Square matrix multiplication.

Definition at line 663 of file Matrix.cpp.

◆ operator*() [8/32]

SquareMatrix operator* ( SquareMatrix &&  A,
SquareMatrix &&  B 
)

Square matrix multiplication.

Definition at line 667 of file Matrix.cpp.

◆ operator*() [9/32]

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

Matrix-vector multiplication.

Definition at line 672 of file Matrix.cpp.

◆ operator*() [10/32]

Vector operator* ( Matrix &&  A,
const Vector b 
)

Matrix-vector multiplication.

Definition at line 675 of file Matrix.cpp.

◆ operator*() [11/32]

Vector operator* ( const Matrix A,
Vector &&  b 
)

Matrix-vector multiplication.

Definition at line 678 of file Matrix.cpp.

◆ operator*() [12/32]

Vector operator* ( Matrix &&  A,
Vector &&  b 
)

Matrix-vector multiplication.

Definition at line 681 of file Matrix.cpp.

◆ operator*() [13/32]

RowVector operator* ( const RowVector a,
const Matrix B 
)

Matrix-vector multiplication.

Definition at line 685 of file Matrix.cpp.

◆ operator*() [14/32]

RowVector operator* ( RowVector &&  a,
const Matrix B 
)

Matrix-vector multiplication.

Definition at line 688 of file Matrix.cpp.

◆ operator*() [15/32]

RowVector operator* ( const RowVector a,
Matrix &&  B 
)

Matrix-vector multiplication.

Definition at line 691 of file Matrix.cpp.

◆ operator*() [16/32]

RowVector operator* ( RowVector &&  a,
Matrix &&  B 
)

Matrix-vector multiplication.

Definition at line 694 of file Matrix.cpp.

◆ operator*() [17/32]

double operator* ( const RowVector a,
const Vector b 
)

Vector-vector multiplication.

Definition at line 698 of file Matrix.cpp.

◆ operator*() [18/32]

double operator* ( RowVector &&  a,
const Vector b 
)

Vector-vector multiplication.

Definition at line 701 of file Matrix.cpp.

◆ operator*() [19/32]

double operator* ( const RowVector a,
Vector &&  b 
)

Vector-vector multiplication.

Definition at line 704 of file Matrix.cpp.

◆ operator*() [20/32]

double operator* ( RowVector &&  a,
Vector &&  b 
)

Vector-vector multiplication.

Definition at line 707 of file Matrix.cpp.

◆ operator*() [21/32]

Matrix operator* ( const PermutationMatrix P,
const Matrix A 
)
inline

Left application of permutation matrix (P permutes rows of A).

Definition at line 281 of file PermutationMatrix.hpp.

◆ operator*() [22/32]

Matrix&& operator* ( const PermutationMatrix P,
Matrix &&  A 
)
inline

Left application of permutation matrix (P permutes rows of A).

Definition at line 287 of file PermutationMatrix.hpp.

◆ operator*() [23/32]

Matrix operator* ( const Matrix A,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of A).

Definition at line 292 of file PermutationMatrix.hpp.

◆ operator*() [24/32]

Matrix&& operator* ( Matrix &&  A,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of A).

Definition at line 298 of file PermutationMatrix.hpp.

◆ operator*() [25/32]

SquareMatrix operator* ( const PermutationMatrix P,
const SquareMatrix A 
)
inline

Left application of permutation matrix (P permutes rows of A).

Definition at line 304 of file PermutationMatrix.hpp.

◆ operator*() [26/32]

SquareMatrix&& operator* ( const PermutationMatrix P,
SquareMatrix &&  A 
)
inline

Left application of permutation matrix (P permutes rows of A).

Definition at line 311 of file PermutationMatrix.hpp.

◆ operator*() [27/32]

SquareMatrix operator* ( const SquareMatrix A,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of A).

Definition at line 316 of file PermutationMatrix.hpp.

◆ operator*() [28/32]

SquareMatrix&& operator* ( SquareMatrix &&  A,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of A).

Definition at line 323 of file PermutationMatrix.hpp.

◆ operator*() [29/32]

Vector operator* ( const PermutationMatrix P,
const Vector v 
)
inline

Left application of permutation matrix (P permutes rows of v).

Definition at line 329 of file PermutationMatrix.hpp.

◆ operator*() [30/32]

Vector&& operator* ( const PermutationMatrix P,
Vector &&  v 
)
inline

Left application of permutation matrix (P permutes rows of v).

Definition at line 335 of file PermutationMatrix.hpp.

◆ operator*() [31/32]

RowVector operator* ( const RowVector v,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of v).

Definition at line 341 of file PermutationMatrix.hpp.

◆ operator*() [32/32]

RowVector&& operator* ( RowVector &&  v,
const PermutationMatrix P 
)
inline

Right application of permutation matrix (P permutes columns of v).

Definition at line 347 of file PermutationMatrix.hpp.