Boost logo

Ublas :

From: Kresimir Fresl (fresl_at_[hidden])
Date: 2006-12-18 03:06:40


Epic John wrote:

> Kresimir, do you mind giving a very brief descriptions of what can be
> accomplished with the matrix_indirect class as well (i.e. what you
> remember implementing, and what you remember not working)

matrix_indirect is a view into another matrix (dense or sparse).
Its elements are elements of the original matrix which are in
the intersections of rows and column enumerated in given
indirect_arrays. For example, if indirect_arrays are

    irow: 1, 4, 6
    icol: 2, 5

then matrix_indirect is a 3x2 matrix which "contains" following elements
of original matrix

    1,2 1,5
    4,2 4,5
    6,2 6,5

Code should be something like:

    ublas::matrix<double> m (10, 10);
    ublas::indirect_array<> irow (3), icol (2);
    ... fill m, irow, icol
    ublas::matrix_indirect<matrix<double> > mi (m, irow, icol);
    mi = ... something ...
    ... + mi ...
    ... + project (m, irow, icol) - ...
    project (m, irow, icol) = ...
    mi (0,1) = ...

Assignment to matrix_indirect or to its changes original matrix.
Eg. last line will change the value of m (1,5).

You can also combine matrix_indirect with matrix_range and matrix_slice
and, of course, matrix_indirect.

What does not work? I don't know.

Hope this helps,

fres