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

Cem Bassoy via ublas <[email protected]> Wed, 23 Jan 2019 17:42:00 +0100
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <CADrR+FuozncoiUFa2jn_gwU2ETQOXPPeM+fKfFPExZsv4LyN7g@mail.gmail.com>
--===============3864185638147685514==
Content-Type: multipart/alternative; boundary="00000000000095c104058022c624"

--00000000000095c104058022c624
Content-Type: text/plain; charset="UTF-8"

Am Mi., 23. Jan. 2019 um 16:34 Uhr schrieb dariomt--- via ublas <
[email protected]>:

> Hello,
>
> Thanks but I already know about vector proxies, and I don't think covers
> my needs.
>

True because all proxies constructors require container types.


>
> Let me rephrase the question, given the function add, that takes a vector
> and a span (pointer + size)
>
> ublas::vector<double> add(const ublas::vector<double>& v, const double* p,
> size_t s)
> {
>     assert(v.size() == s);
>     return v + vector_view<double>(p, s);
> }
>

> Is there something like vector_view already in Ublas that
> 1) does not copy the data pointed by p
>

No. It should be in the proxy (view) class template.


> 2) integrates in the ublas expression template machinery as a vector-like
> expression
>

See (1)


>
> If there is not one already implemented, is it possible to implement one?
> Is it enough if I model the "Vector Expression" Concept as described in
> https://www.boost.org/doc/libs/1_69_0/libs/numeric/ublas/doc/expression_concept.html#2VectorExpression
> ? Do I also need to inherit from vector_expression?
>

You could locally extend vector_range by a constructor.
You could implement a vector_view similar to vector_range. Then yes you
need to inherit from vector_expression.


>
> Thanks!
>

> From: Cem Bassoy <[email protected]>
>> To: ublas mailing list <[email protected]>
>> Cc:
>> Bcc:
>> Date: Wed, 23 Jan 2019 10:18:22 +0100
>> Subject: Re: [ublas] [Ublas] vector_view over (T*,size)
>> 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>
>>
>>
>> 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]
>

--00000000000095c104058022c624
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">Am Mi., 23. Jan. 2019 um 16:34=C2=A0U=
hr schrieb dariomt--- via ublas &lt;<a href=3D"mailto:[email protected]=
">[email protected]</a>&gt;:<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div>He=
llo,</div><div><br></div><div>Thanks but I already know about vector proxie=
s, and I don&#39;t think covers my needs.</div></div></div></div></blockquo=
te><div><br></div><div>True because all proxies constructors require contai=
ner types.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddin=
g-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div><br></d=
iv><div>Let me rephrase the question, given the function add, that takes a =
vector and a span (pointer=C2=A0+ size)</div><div><br></div><div>ublas::vec=
tor&lt;double&gt; add(const ublas::vector&lt;double&gt;&amp; v, const doubl=
e* p, size_t s)<br></div><div>{</div><div>=C2=A0 =C2=A0 assert(v.size() =3D=
=3D s);</div><div>=C2=A0 =C2=A0 return v=C2=A0+ vector_view&lt;double&gt;(p=
, s);</div><div>}=C2=A0 <br></div></div></div></div></blockquote><blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s=
olid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><=
div dir=3D"ltr"><div><br></div><div>Is there something like vector_view alr=
eady in Ublas that</div><div>1) does not copy the data pointed by p</div></=
div></div></div></blockquote><div><br></div><div>No. It should be in the pr=
oxy (view) class template.<br></div><div>=C2=A0</div><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"l=
tr"><div>2) integrates in the ublas expression template machinery as a vect=
or-like expression</div></div></div></div></blockquote><div><br></div><div>=
See (1)<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div><br></di=
v><div>If there is not one already implemented, is it possible to implement=
 one? Is it enough if I model the &quot;Vector Expression&quot; Concept as =
described in=C2=A0<a href=3D"https://www.boost.org/doc/libs/1_69_0/libs/num=
eric/ublas/doc/expression_concept.html#2VectorExpression" target=3D"_blank"=
>https://www.boost.org/doc/libs/1_69_0/libs/numeric/ublas/doc/expression_co=
ncept.html#2VectorExpression</a> ? Do I also need to inherit from=C2=A0vect=
or_expression?</div></div></div></div></blockquote><div><br></div><div>You =
could locally extend vector_range by a constructor.</div><div>You could imp=
lement a vector_view similar to vector_range. Then yes you need to inherit =
from vector_expression.<br></div><div>=C2=A0</div><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20=
4,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"=
><div><br></div><div>Thanks! <br></div></div></div></div></blockquote><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"l=
tr"><div dir=3D"ltr"><br><div class=3D"gmail_quote"><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,=
204,204);padding-left:1ex">From:=C2=A0Cem Bassoy &lt;<a href=3D"mailto:cem.=
[email protected]" target=3D"_blank">[email protected]</a>&gt;<br>To:=C2=
=A0ublas mailing list &lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>&gt;<br>Cc:=C2=A0<br>Bcc:=C2=A0<br>Dat=
e:=C2=A0Wed, 23 Jan 2019 10:18:22 +0100<br>Subject:=C2=A0Re: [ublas] [Ublas=
] vector_view over (T*,size)<br><div dir=3D"ltr"><div dir=3D"ltr"><div>Hi t=
here,</div><div><br></div><div>yes, it is possible to do something like thi=
s. Please have a look at <a href=3D"https://www.boost.org/doc/libs/1_69_0/l=
ibs/numeric/ublas/doc/vector_proxy.html" target=3D"_blank">Vector Proxies.<=
/a></div><div><br></div><div><br></div></div></div><div class=3D"gmail_quot=
e"><div dir=3D"ltr" class=3D"gmail-m_-4817775590245818927gmail-m_4744714021=
784741303gmail_attr">Am Mo., 21. Jan. 2019 um 11:28=C2=A0Uhr schrieb dariom=
t--- via ublas &lt;<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a>&gt;:<br></div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-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 t=
hat the result is usable within the ublas expression template machinery? So=
me kind of ublas::vector_view(T*, size)?</div><div><br></div><div>The objec=
tive is to avoid having to copy all that data into a ublas::vector just to =
interoperate with other ublas code.</div><div><br></div><div>Thanks in adva=
nce!</div></div></blockquote></div>
</blockquote></div></div></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></div>

--00000000000095c104058022c624--

--===============3864185638147685514==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline