Re: [Ublas] vector_view over (T*,size) (Cem Bassoy)
dariomt--- via ublas <[email protected]> Wed, 23 Jan 2019 16:33:20 +0100
| Newsgroups | gmane.comp.lib.boost.ublas |
|---|---|
| Message-ID | <CAHq7APH43vML9pfGBZpbXMroHrNZwh7ond0RgMAbNezSOVyD4Q@mail.gmail.com> |
--===============4851680896312008518==
Content-Type: multipart/alternative; boundary="0000000000001d9f60058021d1e9"
--0000000000001d9f60058021d1e9
Content-Type: text/plain; charset="UTF-8"
Hello,
Thanks but I already know about vector proxies, and I don't think covers my
needs.
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
2) integrates in the ublas expression template machinery as a vector-like
expression
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?
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!
>>
>
--0000000000001d9f60058021d1e9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div>Hello,</div><div><b=
r></div><div>Thanks but I already know about vector proxies, and I don'=
t think covers my needs.</div><div><br></div><div>Let me rephrase the quest=
ion, given the function add, that takes a vector and a span (pointer=C2=A0+=
size)</div><div><br></div><div>ublas::vector<double> add(const ublas=
::vector<double>& v, const double* 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 r=
eturn v=C2=A0+ vector_view<double>(p, s);</div><div>}</div><div><br><=
/div><div>Is there something like vector_view already in Ublas that</div><d=
iv>1) does not copy the data pointed by p</div><div>2) integrates in the ub=
las expression template machinery as a vector-like expression</div><div><br=
></div><div>If there is not one already implemented, is it possible to impl=
ement one? Is it enough if I model the "Vector Expression" Concep=
t as described in=C2=A0<a href=3D"https://www.boost.org/doc/libs/1_69_0/lib=
s/numeric/ublas/doc/expression_concept.html#2VectorExpression">https://www.=
boost.org/doc/libs/1_69_0/libs/numeric/ublas/doc/expression_concept.html#2V=
ectorExpression</a> ? Do I also need to inherit from=C2=A0vector_expression=
?</div><div><br></div><div>Thanks!</div><br><div class=3D"gmail_quote"><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex">From:=C2=A0Cem Bassoy <<a =
href=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
</a>><br>To:=C2=A0ublas mailing list <<a href=3D"mailto:[email protected]=
oost.org" target=3D"_blank">[email protected]</a>><br>Cc:=C2=A0<br>B=
cc:=C2=A0<br>Date:=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 there,</div><div><br></div><div>yes, 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_proxy.html" target=3D"_blank=
">Vector Proxies.</a></div><div><br></div><div><br></div></div></div><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail-m_4744714021784741303g=
mail_attr">Am Mo., 21. Jan. 2019 um 11:28=C2=A0Uhr schrieb dariomt--- via u=
blas <<a href=3D"mailto:[email protected]" target=3D"_blank">ublas@l=
ists.boost.org</a>>:<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-le=
ft: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><di=
v>Is it possible to build a vector-like view over that span, so that the re=
sult is usable within the ublas expression template machinery? Some kind of=
ublas::vector_view(T*, size)?</div><div><br></div><div>The objective is to=
avoid having to copy all that data into a ublas::vector just to interopera=
te with other ublas code.</div><div><br></div><div>Thanks in advance!</div>=
</div></blockquote></div>
</blockquote></div></div></div></div>
--0000000000001d9f60058021d1e9--
--===============4851680896312008518==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline