MTL 4: Transposed
Transposing a matrix can be realized by:
#include <iostream> #include <boost/numeric/mtl/mtl.hpp> int main(int, char**) { using namespace mtl; typedef std::complex<double> cdouble; const unsigned xd= 2, yd= 5, n= xd * yd; compressed2D<cdouble> A(n, n); matrix::laplacian_setup(A, xd, yd); // Fill imaginary part of the matrix A*= cdouble(1, -1); std::cout << "A is\n" << with_format(A, 7, 1) << "\n"; std::cout << "trace(A) is " << trace(A) << "\n\n"; std::cout << "conj(A) is\n" << with_format(conj(A), 7, 1) << "\n"; std::cout << "trans(A) is\n" << with_format(trans(A), 7, 1) << "\n"; std::cout << "hermitian(A) is\n" << with_format(hermitian(A), 7, 1) << "\n"; return 0; }
The function conj(A) does not change matrices but they return views on them. For the sake of reliability, we conserve the const-ness of the referred matrix. The transposed of a constant matrix is itself constant (this feature alone required a fair amount of non-trivial meta-programming). Only when the referred matrix is mutable the transposed will be:
Return to Conjugates Table of Content Proceed to Hermitian
Transposed -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine
-- Gen. with
rev. 7542
on 7 Apr 2011 by doxygen 1.5.9 -- © 2010 by SimuNova UG.