MTL 4: Type Multivector
To create a multi-vector, there are two ways:
mtl::multi_vector<Vector> A(2, 3);
mtl::multi_vector<Vector> A(Vector(3), 2);
In the 2nd method, you get a matrix with 2 rows and 3 columns. Remark: in older versions, before revision 6957, the arguments were reversed.
To find out the number of rows use
unsigned r= num_rows(A);
unsigned c= num_cols(A);
To modify individual entries of the multi-vector, there are several possibilities. You can write a vector (same length) in the k-th column of the multi-vector, and vice versa.
mtl::multi_vector<Vector> A(2, 3); Vector v(2), w(2); A.vector(k)= v; v= A.vector(k);
A[1][1]= 3.5;
// File: multi_vector.cpp #include <iostream> #include <boost/numeric/mtl/mtl.hpp> int main(int, char**) { using namespace mtl; typedef dense_vector<double> Vector; Vector v(2, 3.4), w(3, 2.5); mtl::multi_vector<Vector> A(2, 3); dense2D<double> B(2,2), C(3,2), D(3,3); // Initialize matrices A= 3.0; B= 4.0; C= 5.0; D= 6.0; // vector= multi_vector * vector v= A * w; // vector= transposed multi_vector * vector w= trans(A) * v; // vector= matrix * vector v= B * A.vector(1); // vector= matrix * vector A.vector(0)= B * A.vector(1); // Orthogonalize multi_vector orth(A); return 0; }
The multi-vector is a matrix, therefore the following matrix operations are defined: trace(A), conj(A), trans(A), hermitian(A). The interface is nevertheless minimalistic and not the same functionality as for other matrix types is provided. More functions will be implemented when needed.
Return to Matrix Types Table of Content Proceed to Vector Insertion
Type Multivector -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine
-- Gen. with
rev. 7542
on 7 Apr 2011 by doxygen 1.5.9 -- © 2010 by SimuNova UG.