Re: [Ublas] vector_view over (T*,size)
Cem Bassoy via ublas <[email protected]> Wed, 23 Jan 2019 10:18:22 +0100
| Newsgroups | gmane.comp.lib.boost.ublas |
|---|---|
| Message-ID | <CADrR+Ft3Wk+rUxioqbJ1QP0wq2kFqOmoJGRgMsGRqx0UAE8EDA@mail.gmail.com> |
--===============7934834035240221818== Content-Type: multipart/alternative; boundary="000000000000feef4c05801c9378" --000000000000feef4c05801c9378 Content-Type: text/plain; charset="UTF-8" Hi there, yes, it is possible to do something like this. Please have a look at Vector Proxies. <https://www.boost.org/doc/libs/1_69_0/libs/numeric/ublas/doc/vector_proxy.html> 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 < [email protected]>: > 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 > [email protected] > https://lists.boost.org/mailman/listinfo.cgi/ublas > Sent to: [email protected] > --000000000000feef4c05801c9378 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div>Hi there,</div><div><br></div><div>y= es, it is possible to do something like this. Please have a look at <a href= =3D"https://www.boost.org/doc/libs/1_69_0/libs/numeric/ublas/doc/vector_pro= xy.html">Vector Proxies.</a></div><div><br></div><div><br></div><div><pre>u= sing namespace boost::numeric::ublas;<br>using vtype =3D vector<double&= gt;;<br>using vrange =3D vector_range<vtype>;<br><br>auto v =3D vtyp= e(3); <br>auto r =3D range(0,v.size()); // complete range<br>auto vr =3D v= range(v,r); // no copy of v</pre></div><div><br></div><div>Best</div><div>C= B<br></div><div><br></div><div><br></div><div><br></div><div><br></div></di= v></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr= ">Am Mo., 21. Jan. 2019 um 11:28=C2=A0Uhr schrieb dariomt--- via ublas <= <a href=3D"mailto:[email protected]">[email protected]</a>>:<br>= </div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b= order-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi= list,<div><br></div><div>Say I have a (GSL-like) span (which is basically = a pointer and a length).</div><div><br></div><div>Is it possible to build a= vector-like view over that span, so that the result is usable within the u= blas expression template machinery? Some kind of ublas::vector_view(T*, siz= e)?</div><div><br></div><div>The objective is to avoid having to copy all t= hat data into a ublas::vector just to interoperate with other ublas code.</= div><div><br></div><div>Thanks in advance!</div></div> _______________________________________________<br> ublas mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]= t.org</a><br> <a href=3D"https://lists.boost.org/mailman/listinfo.cgi/ublas" rel=3D"noref= errer" target=3D"_blank">https://lists.boost.org/mailman/listinfo.cgi/ublas= </a><br> Sent to: <a href=3D"mailto:[email protected]" target=3D"_blank">cem.bass= [email protected]</a><br> </blockquote></div> --000000000000feef4c05801c9378-- --===============7934834035240221818== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline