|
Boost : |
From: Kresimir Fresl (fresl_at_[hidden])
Date: 2002-03-14 09:29:41
jhrwalter wrote:
[...]
> (but I'm unsure, if valarray<> is a legal array_type of
> numerics::vector currently ;-).
It is ... with few minor modifications (at least with g++ 3.0.4).
std::valarray<> does not have `iterator' & `const_iterator'
types. Therefore `iterator_type' & `const_iterator_type'
in numerics::vector<> can't be defined. But they are not
needed if `indexed_iterator<>' is used instead of nested
iterator classes.
So, I first added
#ifndef NUMERICS_USE_INDEXED_ITERATOR
typedef typename A::const_iterator const_iterator_type;
typedef typename A::iterator iterator_type;
#endif
in numerics::vector<>.
But to compile some simple examples with macro
NUMERICS_USE_INDEXED_ITERATOR defined,
I had to add few typename's in `vector_pr.h':
line 184:
NUMERICS_TYPENAME vector_type::iterator::iterator_category> iterator;
instead of:
vector_type::iterator::iterator_category> iterator;
line 186:
NUMERICS_TYPENAME vector_type::const_iterator::iterator_category>
const_iterator;
line 664:
NUMERICS_TYPENAME vector_type::iterator::iterator_category> iterator;
and line 666:
NUMERICS_TYPENAME vector_type::const_iterator::iterator_category>
const_iterator;
Now this works:
#include <valarray>
#include <boost/numerics/ublas/vector.h>
typedef numerics::vector<double, std::valarray<double> > vector;
vector v1(10), v2(10), v3(10);
v3 = v1 + v2;
BTW, did you measure what is more efficient: indexed_iterator<>
or iterator classes nested in numerics::vector<>?
Sincerely,
fres
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk