Linear Algebra  arduino
Accessible implementations of linear algebra algorithms
Functions

Detailed Description

Matrix and vector transposition.

+ Collaboration diagram for Transposition:

Functions

Matrix explicit_transpose (const Matrix &in)
 Matrix transpose for general matrices. More...
 
Matrix transpose (const Matrix &in)
 Matrix transpose for rectangular or square matrices and row or column vectors. More...
 
Matrix && transpose (Matrix &&in)
 Matrix transpose for rectangular or square matrices and row or column vectors. More...
 
SquareMatrix transpose (const SquareMatrix &in)
 Square matrix transpose. More...
 
SquareMatrix && transpose (SquareMatrix &&in)
 Square matrix transpose. More...
 
RowVector transpose (const Vector &in)
 Vector transpose. More...
 
RowVector transpose (Vector &&in)
 Vector transpose. More...
 
Vector transpose (const RowVector &in)
 Vector transpose. More...
 
Vector transpose (RowVector &&in)
 Vector transpose. More...
 
PermutationMatrix transpose (const PermutationMatrix &P)
 Transpose a permutation matrix (inverse permutation). More...
 
PermutationMatrix && transpose (PermutationMatrix &&P)
 Transpose a permutation matrix (inverse permutation). More...
 

Function Documentation

◆ explicit_transpose()

Matrix explicit_transpose ( const Matrix in)

Matrix transpose for general matrices.

Implementation

Matrix out(in.cols(), in.rows());
for (size_t n = 0; n < in.rows(); ++n)
for (size_t m = 0; m < in.cols(); ++m)
out(m, n) = in(n, m);
return out;
}
General matrix class.
Definition: Matrix.hpp:34
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 explicit_transpose(const Matrix &in)
Matrix transpose for general matrices.
Definition: Matrix.cpp:1050

Definition at line 1050 of file Matrix.cpp.

◆ transpose() [1/10]

Matrix transpose ( const Matrix in)

Matrix transpose for rectangular or square matrices and row or column vectors.

Implementation

Matrix transpose(const Matrix &in) {
if (in.rows() == 1 || in.cols() == 1) { // Vectors
Matrix out = in;
out.reshape(in.cols(), in.rows());
return out;
} else { // General matrices (square and rectangular)
return explicit_transpose(in);
}
}
void reshape(size_t newrows, size_t newcols)
Reshape the matrix.
Definition: Matrix.cpp:78
Matrix transpose(const Matrix &in)
Matrix transpose for rectangular or square matrices and row or column vectors.
Definition: Matrix.cpp:1064
Examples
Basics.cpp.

Definition at line 1064 of file Matrix.cpp.

◆ transpose() [2/10]

Matrix&& transpose ( Matrix &&  in)

Matrix transpose for rectangular or square matrices and row or column vectors.

Implementation

if (in.rows() == in.cols()) // Square matrices
SquareMatrix::transpose_inplace(in); // → reuse storage
else if (in.rows() == 1 || in.cols() == 1) // Vectors
in.reshape(in.cols(), in.rows()); // → reshape row ↔ column
else // General rectangular matrices
in = explicit_transpose(in); // → full transpose
return std::move(in);
}
void transpose_inplace()
Transpose the matrix in-place.
Definition: Matrix.hpp:615

Definition at line 1080 of file Matrix.cpp.

◆ transpose() [3/10]

SquareMatrix transpose ( const SquareMatrix in)

Square matrix transpose.

Definition at line 1091 of file Matrix.cpp.

◆ transpose() [4/10]

SquareMatrix&& transpose ( SquareMatrix &&  in)

Square matrix transpose.

Definition at line 1096 of file Matrix.cpp.

◆ transpose() [5/10]

RowVector transpose ( const Vector in)

Vector transpose.

Definition at line 1101 of file Matrix.cpp.

◆ transpose() [6/10]

RowVector transpose ( Vector &&  in)

Vector transpose.

Definition at line 1102 of file Matrix.cpp.

◆ transpose() [7/10]

Vector transpose ( const RowVector in)

Vector transpose.

Definition at line 1103 of file Matrix.cpp.

◆ transpose() [8/10]

Vector transpose ( RowVector &&  in)

Vector transpose.

Definition at line 1104 of file Matrix.cpp.

◆ transpose() [9/10]

PermutationMatrix transpose ( const PermutationMatrix P)
inline

Transpose a permutation matrix (inverse permutation).

Definition at line 358 of file PermutationMatrix.hpp.

◆ transpose() [10/10]

PermutationMatrix&& transpose ( PermutationMatrix &&  P)
inline

Transpose a permutation matrix (inverse permutation).

Definition at line 364 of file PermutationMatrix.hpp.