|
Ublas : |
From: Ott Toomet (otoomet_at_[hidden])
Date: 2005-09-14 02:06:28
Dear Vardan and Michael,
unfortunately shallow_array_adaptor does not work for me. If I
declare
#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR
it results compiler errors:
g++ -c aakatse.c++ -O2 -Wall -Wno-unknown-pragmas -I/usr/include
In file included from /usr/include/boost/numeric/ublas/vector.hpp:23,
from aakatse.c++:4:
/usr/include/boost/numeric/ublas/storage.hpp:707: error: declaration of `class T'
/usr/include/boost/numeric/ublas/storage.hpp:703: error: shadows template parm `class T'
even without any additonal code.
Is it a problem with boost 1.32/gcc 3.4 or do I have to do someting in
a different way?
Best,
Ott
| Hi Ott,
|
| You should be using shallow_array_adaptor as in
| http://lists.boost.org/MailArchives/ublas/2005/07/0530.php
|
| Note that shallow_array_adaptor has been removed from boost-1.33, and
| a new adaptor carray_adaptor has been introduced. So if you update to
| boost-1.33 you may need change your code accordingly.
|
| Regards
| -Vardan
|
| On 9/13/05, Ott Toomet <otoomet_at_[hidden]> wrote:
| > Dear list,
| >
| > I would like to write some functions in c++ which will be called from
| > R. The matrix data will be passed and returned as double* array. The
| > problem is to force a matrix to share the same memory as double*
| > array. Examples in a similar thread
| >
| > http://lists.boost.org/MailArchives/boost-users/msg02507.php
| >
| > seem not to work for me, the array contents will be copied to matrix
| > at it's initialisation but later changes are not reflected there any
| > more. E.g.
| >
| >
| > #define BOOST_UBLAS_SIMPLE_ARRAY_ADAPTOR
| >
| > #include <boost/numeric/ublas/vector.hpp>
| > #include <boost/numeric/ublas/matrix.hpp>
| > #include <boost/numeric/ublas/io.hpp>
| >
| > using namespace boost::numeric::ublas;
| >
| > int main() {
| > double a[] = {-11, -12, -13, -14};
| > array_adaptor<double> st (4, a);
| > vector<double, array_adaptor<double> > v(4, st);
| > unsigned i;
| > //
| > a[1] = 100;
| > std::cout << "before initialisation: v " << v << std::endl;
| > for(i = 0; i < 4; ++i)
| > v(i) = i + 0.1;
| > std::cout << "after " << v << std::endl;
| > std::cout << a[1] << std::endl;
| > }
| >
| > results in
| >
| > siim_at_hugo:~/tyyq/newmat$ ./aakatse
| > before initialisation: v [4](-11,-12,-13,-14)
| > after [4](0.1,1.1,2.1,3.1)
| > 100
| >
| > Note that a[1] (still equal to 100) is not overwritten by v(1).
| >
| > Do I miss something?
| >
| >
| > The compilation was performed by
| >
| > g++ -c aakatse.c++ -O2 -Wall -Wno-unknown-pragmas -I/usr/include
| > g++ aakatse.o -O2 -Wall -Wno-unknown-pragmas -L/usr/lib -lm -o aakatse
| >
| > I have
| >
| > boost-1.32.0-1.rhel4
| > g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)