Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2006-11-30 04:22:27


Hello Max,

On Saturday, 18. November 2006 18:04, Max Weinberg wrote:
> Hello,
> it seems to be impossible to use any other type than std::size_t for the
> sparse indices. I looked at this because I wanted to extend the possible
> index range for sparse matrices/vectors by using an unlimited integer
> class.
>
> For example, this does not work:
>
> typedef long long IndexT;
> typedef boost::numeric::ublas::compressed_matrix<
> double,
> boost::numeric::ublas::column_major,
> 0, //index base
> boost::numeric::ublas::unbounded_array<IndexT>,
> boost::numeric::ublas::unbounded_array<double>
>
> > MatrixT;
>
> You can pass an index type to the index array, but it is not supported
> afterwards. Looks like this has never been tested.

In the containers the framework exisits for other index types. There is still
a fair bit of work required to complete the infrastructure however. In
particular 'functional.hpp' needs reworking.

I have started to take a look at this. I would like to get coordinate_matrix
working first. Since rows and columns treated identically this is easier.

> One of the problems is
> this line in matrix_sparse:
> // FIXME difference type for sparse storage iterators should it be
> in the container?
> typedef typename IA::difference_type difference_type;
> I tried a workaround by "typedef IA::value_type difference_type", which
> helps somewhat, but there are tons of other type-related problems, for
> example attempted conversions from size_type to array_size_type.

The difference_type is a big problem. We know the value_type of the indices
but the difference_type cannot be deduced. The difference_type is required by
the iterators. The difference between two iterators is often used in the
sparse algorithms for binary operations.

The correct solution would be to add yet another template parameter to the
sparse types which specify this when needed.

'compressed_matrix' also needs reworking. It actually needs two seperate
template parameter for the index array types. 'index1_data_' is an array of
offsets, only 'index2_data_' is an array of row/column indices.
'compressed_matrix' is a bit unusual as it is the only matrix which can make
use of different types for row and columns. Only one is actually compressed,
the other is dense.

So far I have got 'm = prod(m,m)' for coordinate_matrices to compile. See
attached test code.

I could check in the first set of experimental changes to Boost CVS head, or
possibly create a new branch to work on this.

All the best,
        Michael

-- 
___________________________________
Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering
    http://bayesclasses.sf.net
___________________________________