tags:

views:

65

answers:

2

We are using Lapack++ for our matrix calculations. One of the features is the use of submatrixviews; objects that refer to the same spot in memory.

Example:

  LaGenMatDouble W = LaGenMatDouble::rand(3,4);
  LaGenMatDouble A = W(LaIndex(0,2), LaIndex(1,3));
  LaGenMatDouble b = W(LaIndex(0,2), LaIndex(0,0));

A and b are now submatrices of W.

How can I make b a LaVectorDouble to be able to perform some calculations with it?

+1  A: 

I suspect this routine does a deep-copy of the data:

http://lapackpp.sourceforge.net/html/classLaVectorDouble.html#be11700fe7c277501329b2d23f485630

This ref() routine might let you maintain the shared memory:

http://lapackpp.sourceforge.net/html/classLaVectorDouble.html#191850a7e8993a977a3a545b87dc7528

nsanders
A: 

The answer is to use the ref function.

LaVectorDouble b;
b.ref(W(LaIndex(0,2), LaIndex(0,0)));

All other functions are copying (like constructor, = and copy) or giving the wrong class (like the constructor with indices). The ref function is referencing to memory.

Peter Smit