Boost logo

Ublas :

From: Dima Sorkin (dsorkin_at_[hidden])
Date: 2008-06-01 08:47:18


Quoting Hongzheng Wang <wanghz_at_[hidden]>:
> > AFAIK, it is to adapt a raw array and then use its contents (by copying).
> > Otherwise how would you create a ublas::vector from a raw data ?
>
> My doubt is why not just use std::copy like algorithm to initialize
> ublas::vector from raw data, given that the data is eventually copied.
uBLAS is not always used with built in scalars (int,double,complex etc).
Some applications may have "scalars" with non-trivial default constructor,
or even with private default constructor.
In such cases initialization before copying can be costly or impossible.

> After all, ublas::vector/matrix seem to be STL-compatible containers.
Seem to be to me too. I'm not sure that it is for 100%.
std:copy works indeed.

> Are there any special considerations in design?
Probably a good implementation of vector should provide a constructor

   vector<T>::vector(T const * const ptr_to_data,
                     unsigned length)

or in case there are problems with templates, something like

   vector<T>::vector( Hint_RawPtr<T> (T const * const ptr_to_data,
                                      unsigned length))
 
> I think
> shallow_array_adaptor is the answer I am looking for, although its
> syntax and semantics is not so stable yet, just as you warned against.
It did not change for at least 5 years, I think.
There were "side projects" :)

Regards,
  Dima.