Boost logo

Ublas :

Subject: Re: [ublas] indirect_array<> and resize()
From: Ralf Denzer (Ralf.Denzer_at_[hidden])
Date: 2008-09-21 06:11:09


Gunter, thanks for your fast reply!

> resizing an indirect_array is not supported. You have to use the
> compose() functions to create a new indirect_array with more indices.
> The reason is that the behavior of an indirect_vector or
> indirect_matrix would be undefined when the size of the underlying
> indirect_array is changes because the indirect_array loses some indices
> to gets new indices which might be out of range.

Ok, but I can do

ublas::matrix<double> M(5,5);
ublas::indirect_array<> ia(3);
ia(0) = 1; ia[1] = 2; ia[2] = 4;
ublas::matrix_indirect<ublas::matrix<double> > Mi(M, ia,ia);
M.resize(4,4);
std::cout << "after M.resize() Mi=\n" << Mi << std::endl; // bad index "bombs"

In any case, I have to take care about ranges during runtime.

The real cause for my question is that I like to initialize something like

ublas::vector<ublas::indirect_array<> > vec_ia;
vec_ia.resize(10);
for (unsigned i = 0; i < 10; ++i)
{
    vec_ia(i).resize( n(i) ); // n(i) are user given unsigned int's (size_t's)
    vec_ia(i)(1:n(i)) = ... // ok, matlab notation
}

With this data structure I'd like to do the usual gathering/scattering
process in a finite element code. For element "i" the corresponding indices are
stored in vec_ia(i) . Sorry, that I didn't mentioned this earlier.

Bye

Ralf

____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123