ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: ublas & custom containers?
by jhrwalter other posts by this author
Mar 18 2002 7:13AM messages near this date
Re: ublas and guidelines [was: Standardization of Boost libraries] | Re: ublas & assert
--- In boost@[...].. , Kresimir Fresl <fresl@[...]..>  wrote:
> 
>  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.

Yes, I remember, that I stopped seeing std::valarray as an option,
when I realized that and tried to imagine, how to work around it
under MSVC ;-)

>  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<>.

I imagine, that we could introduce here some (array_type_?)traits
classes, which define the iterators for valarray via partial
specialization.

>  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;

Yep, one of my usual problems: I'll add these, too. Thanks.

>  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;

Ok, if all agree, that it would be useful to have std::valarray as
another array_type option, I'll try to add some traits logic to
support it at least under the more standard conforming compilers.

>  BTW, did you measure what is more efficient: indexed_iterator<>
>  or iterator classes nested in numerics::vector<>?

Nested pointer based iterators result usually in tighter inner loops
than something like indexed_iterator<>  on the compilers I've seen so
far. They are only slower for small vector & matrix sizes, so that we
switch to assignment via subscription in such cases.

> 
>  Sincerely,
> 
>  fres

Regards

Joerg

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved