Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-02-08 02:50:07


On Thursday 08 February 2007 03:12, Richard_Harding_at_[hidden]
wrote:
> Is it possible to create a matrix_range from a sparse matrix?
>
> typedef ublas::compressed_matrix<double, ublas::column_major, 0,
> ublas::unbounded_array<int>,
> ublas::unbounded_array<double> >
> SparseMatrix;
>
> SparseMatrix A(7, 7, 12);
> ublas::matrix_range<SparseMatrix> submat(A, ublas::range(0, 4),
> ublas::range(0, 4));

this creates a mutable range which is difficult for sparse matrices because it
may create nonzeros when elements are accessed. However, both of these lines
compile with g++ 4.1.2:

  matrix_range<compressed_matrix<double> > submat(mat, range(0,3),
range(0,3));
  matrix_range<const compressed_matrix<double> > submat(mat, range(0,3),
range(0,3));

Did you try to use the copy constructor?

matrix_range< ... > sub( ( project(A, range(..), range(..) ) );

mfg
Gunter