permutation(v)
returns permutation matrix from corresponding vector.
See: mtl::matrix::permutation
P= permutation(v);
For example:
#include <iostream> #include <boost/numeric/mtl/mtl.hpp> int main(int, char**) { using namespace mtl; double array[][3]= {{1., 2., 3.}, {4., 5., 6.}, {7., 8., 9.}}; dense2D<double> A(array), A2, A3; // Creating a permutation matrix from a vector (or an array respectively) int indices[]= {1, 2, 0}; matrix::traits::permutation<>::type P= matrix::permutation(indices); std::cout << "\nP =\n" << P; // Permutating rows A2= P * A; std::cout << "\nP * A =\n" << A2; // Permutating columns A3= A2 * trans(P); std::cout << "\nA2 * trans(P) =\n" << A3; dense_vector<double> v(array[2]), w(P * v); std::cout << "\nP * v =\n" << w << "\n"; return 0; }
For a more detailed explanation see Permutations and Reordering.
Return to Overview Table of Content
permutation(v) -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine
-- Gen. with
rev. 7542
on Sat Aug 11 2012 by doxygen 1.7.6.1 -- © 2010 by SimuNova UG.