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

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

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

Boost - uBLAS mailing list
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 <[hidden email]>
To: ublas mailing list <[hidden email]>
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.


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]
Reply | Threaded
Open this post in threaded view
|

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

Boost - uBLAS mailing list


Am Mi., 23. Jan. 2019 um 16:34 Uhr schrieb dariomt--- via ublas <[hidden email]>:
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 <[hidden email]>
To: ublas mailing list <[hidden email]>
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.


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]