Logo MTL4

Type Multivector

There are another useful class in MTL4: the multi_vector. A multi-vector is a kind of matrix that is composed of coluum vectors. This type is very helpful if you want to store many vectors of the same length. To initialize a multi-vector, there are 2 different types: 1.Constructor by number of rows and columns
        mtl::multi_vector<Vector>       A(2, 3);

2.Constructor by number of rows and column vector for initialization

        mtl::multi_vector<Vector>       A(Vector(3), 2);

In the first method, you get a matrix which has 2 rows and 3 columns (see matrix initialization). In the 2nd method, you get a matrix with 2 rows and 3 columns.

To find out the number of rows use

  unsigned r= num_rows(A);
It returns an unsigned integer (more precisely the size_type of the vector type). Likewise the number of columns is given
  unsigned c= num_cols(A);

To edit 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 turned around.

        mtl::multi_vector<Vector>       A(2, 3);
        Vector                          v(2), w(2);
        A.vector(k)= v;
        v=  A.vector(k);
You can also specify the row and column of the entry to be changed.
        A[1][1]= 3.5;

operations with multi-vectors On the one hand we can consider a multi-vector as separate vectors, but also as a matrix. Thus, there are many multi-vector operations.

        Matrix                          B(2,2), C(3,2), D(3,3);
        B= A * C;                       //Matrix= multi_vector * Matrix
        D= C * A;                       //Matrix= Matrix * multi_vector
        v= B * A.vector(1);             //vector= Matrix * vector 
        A.vector(0)= B* A.vector(1);    //vector= Matrix * vector

The multi-vector is a kind of matrix, therefore the following matixoperations are defined: trace(A), conj(A), trans(A), hermitian(A).

Return to Matrix Types                                Table of Content                                Proceed to Vector Insertion


Type Multivector -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine -- Generated on 13 Nov 2009 by Doxygen 1.5.2 -- Copyright 2008-09 by TU Dresden and the Trustees of Indiana University.