Boost logo

Ublas :

From: Franck Perignon (Franck.Perignon_at_[hidden])
Date: 2006-10-17 12:03:54


Hello,

Here is my problem, hope someone can help me:

I have a virtual base class, named MyVector, with 2 derived classes
SimpleVector and BlockVector.

SimpleVector is based on Boost dense and sparse vectors:

typedef boost::numeric::ublas::vector<double,std::vector<double> >
DenseVect;
typedef compressed_vector<double,0, Index, std::vector<double> > SparseVect;

union MyVect{
  DenseVect *Dense;
  SparseVect *Sparse;
};

class SimpleVector: public MyVector
{
 private:
 ...
 MyVect vect;
...
}
And BlockVector class:

typedef std::vector<MyVector*> blocksVect;
or
typedef compressed_vector<MyVector*> blocksVect; ??? (any other
suggestion?)

class BlockVector: public MyVector
{
 private:
 ...
  blockVect vect;
...
}

BlockVector is supposed to allow me to handle several SimpleVectors, but
without new memory allocation (ie no copy)
that's why I use a container of pointers to MyVector.
For BlockVector, I need classical operators ( prod, + ...) and the
possibility to add or remove some MyVector* from the container.

First question: since I'm a newbie in boost an uBlas, maybe you have
better suggestions in how to define block vectors?

Second: I need to pass MyVector object as input to Fortran subroutines.
And then I have to give the address of the first element of my "array" (
a std::vector<double> in the case of SimpleVectors)
But for BlockVector it fails since data of all the SimpleVector are not
contiguous in memory.
What I 'd like to do is:
 - create a pointer to SimpleVector (dense for instance) named v1
- create a pointer to SimpleVector named v2, with memory allocation
starting at the end of the place where v1 is saved and so on for v3, v4
- insert all these pointer to vectors into a BlockVector

So is there a way to allocate memory for Dense or any kind of boost
vectors by specifying where I want to reserve this memory?

I hope my questions are clear enough ...

Thanks

Franck