21 #ifndef RFFGEN_LINEAR_ALGEBRA_TRANSPOSE_HH
22 #define RFFGEN_LINEAR_ALGEBRA_TRANSPOSE_HH
24 #include <type_traits>
26 #include "extractRowsAndCols.hh"
27 #include "../Util/zero.hh"
28 #include "../Util/at.hh"
29 #include "../Util/staticChecks.hh"
30 #include "../Util/staticChecks_nRows_nCols.hh"
34 namespace LinearAlgebra
40 template <
class Matrix,
class TransposedMatrix = Matrix ,
41 class = std::enable_if_t<std::is_same<Matrix,TransposedMatrix>::value> ,
42 class = std::enable_if_t<Checks::isConstantSizeMatrix<Matrix>()> >
46 for(
int i=0; i<numberOfRows<Matrix>(); ++i)
47 for(
int j=i+1; j<numberOfColumns<Matrix>(); ++j)
50 at(A,i,j) = at(A,j,i);
61 template <
class TransposedMatrix,
class Matrix ,
62 class = std::enable_if_t<!std::is_same<Matrix,TransposedMatrix>::value> ,
63 class = std::enable_if_t<Checks::isConstantSizeMatrix<Matrix>() && Checks::isConstantSizeMatrix<TransposedMatrix>()> >
66 TransposedMatrix B = zero<TransposedMatrix>();
67 for(
int i=0; i<numberOfRows<Matrix>(); ++i)
68 for(
int j=0; j<numberOfColumns<Matrix>(); ++j)
78 template <
class Matrix ,
79 class = std::enable_if_t<!Checks::isConstantSizeMatrix<Matrix>()> ,
80 class = std::enable_if_t<Checks::isDynamicMatrix<Matrix>()> >
83 assert(rows(A) == cols(A));
84 using Index = decltype(rows(std::declval<Matrix>()));
85 auto a = std::remove_const_t<std::remove_reference_t<decltype(at(A,0,0))> >(0.);
86 for(Index i=0; i<rows(A); ++i)
87 for(Index j=i+1; j<cols(A); ++j)
90 at(A,i,j) = at(A,j,i);
99 #endif // RFFGEN_LINEAR_ALGEBRA_TRANSPOSE_HH
Matrix transpose(Matrix A)
Compute transpose of square matrix.
Definition: transpose.hh:81