[Ublas] vector_view over (T*,size)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Ublas] vector_view over (T*,size)

Boost - uBLAS mailing list
Hi list,

Say I have a (GSL-like) span (which is basically a pointer and a length).

Is it possible to build a vector-like view over that span, so that the result is usable within the ublas expression template machinery? Some kind of ublas::vector_view(T*, size)?

The objective is to avoid having to copy all that data into a ublas::vector just to interoperate with other ublas code.

Thanks in advance!

_______________________________________________
ublas mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [Ublas] vector_view over (T*,size)

Boost - uBLAS mailing list
Hi there,

yes, it is possible to do something like this. Please have a look at Vector Proxies.


using namespace boost::numeric::ublas;
using vtype = vector<double>;
using vrange = vector_range<vtype>;

auto v = vtype(3);
auto r = range(0,v.size()); // complete range
auto vr = vrange(v,r); // no copy of v

Best
CB





Am Mo., 21. Jan. 2019 um 11:28 Uhr schrieb dariomt--- via ublas <[hidden email]>:
Hi list,

Say I have a (GSL-like) span (which is basically a pointer and a length).

Is it possible to build a vector-like view over that span, so that the result is usable within the ublas expression template machinery? Some kind of ublas::vector_view(T*, size)?

The objective is to avoid having to copy all that data into a ublas::vector just to interoperate with other ublas code.

Thanks in advance!
_______________________________________________
ublas mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]

_______________________________________________
ublas mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]