Re: Problem using volk_32fc_s32fc_multiply_32fc function with vector params

2022-05-03 Thread George Edwards
Hi Johannes,

Thank you very much! Really appreciate your help.

George

On Tue, May 3, 2022 at 10:07 AM Johannes Demel 
wrote:

> Hi George,
>
> yes, you need to add `#include ` to use
> `volk::vector`. A `volk::vector` is a specially templated `std::vector`.
> You still use it with `.data()`.
> An example would be:
> ```
> #include 
> #include 
>
> ...
>
> volk::vector  my_val (240);
> volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);
> ```
>
> If you look at the `std::vector` docs:
> https://en.cppreference.com/w/cpp/container/vector
>
> You can see `std::vector` has a second template argument that defaults
> to `class Allocator = std::allocator`. `volk::vector` provides a
> different `Allocator` for it. Thus, you can use a `volk::vector` just
> like a `std::vector`. Be aware that different template arguments lead to
> different classes and thus, a function that accepts a `std::vector` will
> not accept a `volk::vector` and vice versa.
>
> Cheers
> Johannes
>
> On 03.05.22 16:01, George Edwards wrote:
> > Hi Johannes,
> >
> > Thank you very much! Thanks for also providing an alternative solution
> > if I were to define the vector as a volk vector. Please allow me to
> > confirm my understanding of how to use volk vectors. So with my current
> > definition using std::vector  my_val (240); you and Brian
> > suggested the solution should look as follows:
> > volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);
> >
> > Based on your volk vector suggested solution, my interpretation is that
> > I would write my code as follows:
> > volk::vector  my_val (240);
> > 
> > volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240); // Or do I
> > need to use _val
> > Also, my current code has the following: #include do I in
> > addition need to include #include   ?
> >
> > Thank you very much!
> > George
> >
> >
> > On Tue, May 3, 2022 at 3:35 AM Johannes Demel  > > wrote:
> >
> > Hi George,
> >
> > All VOLK functions require pointers as you already noticed. You can
> > access the underlying data structure of a vector via its `.data()`
> > method as Brian noted.
> > Moreover, you can use `volk::vector` if you want your vectors to be
> > aligned. `volk::vector` is almost a `std::vector` but uses its own
> > allocator that ensures alignment.
> > `volk::vector` is available in `volk/volk_alloc.hh`. Since it is a
> C++
> > only feature.
> >
> > Cheers
> > Johannes
> >
> > On 03.05.22 04:28, George Edwards wrote:
> >  > Hello GNURadio Community,
> >  >
> >  > I am having a problem using the above function with
> > vector parameters.
> >  > If I use an array say:
> >  > gr_complex my_val[240];
> >  > volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);
> >  >
> >  > It works! But if I change my_val to be a vector like below, it
> fails:
> >  > std::vector  my_val(240);
> >  >
> >  > The reason I need to use a vector is that with arrays, the size
> > must be
> >  > known at compile time, while with vectors one can build it at
> > runtime.
> >  >
> >  > I would appreciate any suggestions.
> >  > Thank you!
> >  >
> >  > George
> >
>


Re: Problem using volk_32fc_s32fc_multiply_32fc function with vector params

2022-05-03 Thread Johannes Demel

Hi George,

yes, you need to add `#include ` to use 
`volk::vector`. A `volk::vector` is a specially templated `std::vector`. 
You still use it with `.data()`.

An example would be:
```
#include 
#include 

...

volk::vector  my_val (240);
volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);
```

If you look at the `std::vector` docs:
https://en.cppreference.com/w/cpp/container/vector

You can see `std::vector` has a second template argument that defaults 
to `class Allocator = std::allocator`. `volk::vector` provides a 
different `Allocator` for it. Thus, you can use a `volk::vector` just 
like a `std::vector`. Be aware that different template arguments lead to 
different classes and thus, a function that accepts a `std::vector` will 
not accept a `volk::vector` and vice versa.


Cheers
Johannes

On 03.05.22 16:01, George Edwards wrote:

Hi Johannes,

Thank you very much! Thanks for also providing an alternative solution 
if I were to define the vector as a volk vector. Please allow me to 
confirm my understanding of how to use volk vectors. So with my current 
definition using std::vector  my_val (240); you and Brian 
suggested the solution should look as follows:

volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);

Based on your volk vector suggested solution, my interpretation is that 
I would write my code as follows:

volk::vector  my_val (240);

volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240); // Or do I 
need to use _val
Also, my current code has the following: #include do I in 
addition need to include #include   ?


Thank you very much!
George


On Tue, May 3, 2022 at 3:35 AM Johannes Demel > wrote:


Hi George,

All VOLK functions require pointers as you already noticed. You can
access the underlying data structure of a vector via its `.data()`
method as Brian noted.
Moreover, you can use `volk::vector` if you want your vectors to be
aligned. `volk::vector` is almost a `std::vector` but uses its own
allocator that ensures alignment.
`volk::vector` is available in `volk/volk_alloc.hh`. Since it is a C++
only feature.

Cheers
Johannes

On 03.05.22 04:28, George Edwards wrote:
 > Hello GNURadio Community,
 >
 > I am having a problem using the above function with
vector parameters.
 > If I use an array say:
 > gr_complex my_val[240];
 > volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);
 >
 > It works! But if I change my_val to be a vector like below, it fails:
 > std::vector  my_val(240);
 >
 > The reason I need to use a vector is that with arrays, the size
must be
 > known at compile time, while with vectors one can build it at
runtime.
 >
 > I would appreciate any suggestions.
 > Thank you!
 >
 > George





Re: Problem using volk_32fc_s32fc_multiply_32fc function with vector params

2022-05-03 Thread George Edwards
Hi Johannes,

Thank you very much! Thanks for also providing an alternative solution if I
were to define the vector as a volk vector. Please allow me to confirm my
understanding of how to use volk vectors. So with my current definition
using std::vector  my_val (240); you and Brian suggested the
solution should look as follows:

volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);

Based on your volk vector suggested solution, my interpretation is that I
would write my code as follows:
volk::vector  my_val (240);

volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);   // Or do I
need to use _val
Also, my current code has the following: #include  do I in
addition need to include #include   ?

Thank you very much!
George


On Tue, May 3, 2022 at 3:35 AM Johannes Demel 
wrote:

> Hi George,
>
> All VOLK functions require pointers as you already noticed. You can
> access the underlying data structure of a vector via its `.data()`
> method as Brian noted.
> Moreover, you can use `volk::vector` if you want your vectors to be
> aligned. `volk::vector` is almost a `std::vector` but uses its own
> allocator that ensures alignment.
> `volk::vector` is available in `volk/volk_alloc.hh`. Since it is a C++
> only feature.
>
> Cheers
> Johannes
>
> On 03.05.22 04:28, George Edwards wrote:
> > Hello GNURadio Community,
> >
> > I am having a problem using the above function with vector parameters.
> > If I use an array say:
> > gr_complex my_val[240];
> > volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);
> >
> > It works! But if I change my_val to be a vector like below, it fails:
> > std::vector  my_val(240);
> >
> > The reason I need to use a vector is that with arrays, the size must be
> > known at compile time, while with vectors one can build it at runtime.
> >
> > I would appreciate any suggestions.
> > Thank you!
> >
> > George
>
>


Re: Problem using volk_32fc_s32fc_multiply_32fc function with vector params

2022-05-03 Thread George Edwards
Hi Brian,

Thank you very much!

For my example, I will the following change:
volk_32fc_s32fc_multiply_32fc(my_val.data(), my_val.data(), scale, 240);

Thank you very much!

George

On Mon, May 2, 2022 at 10:51 PM Brian Padalino  wrote:

> On Mon, May 2, 2022 at 11:26 PM George Edwards 
> wrote:
>
>> Hello GNURadio Community,
>>
>> I am having a problem using the above function with vector parameters. If
>> I use an array say:
>> gr_complex my_val[240];
>> volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);
>>
>> It works! But if I change my_val to be a vector like below, it fails:
>> std::vector  my_val(240);
>>
>> The reason I need to use a vector is that with arrays, the size must be
>> known at compile time, while with vectors one can build it at runtime.
>>
>
> Get the pointer to your data in the array using the data() method:
>
>   https://www.cplusplus.com/reference/vector/vector/data/
>
> Brian
>
>>


Re: Problem using volk_32fc_s32fc_multiply_32fc function with vector params

2022-05-03 Thread Johannes Demel

Hi George,

All VOLK functions require pointers as you already noticed. You can 
access the underlying data structure of a vector via its `.data()` 
method as Brian noted.
Moreover, you can use `volk::vector` if you want your vectors to be 
aligned. `volk::vector` is almost a `std::vector` but uses its own 
allocator that ensures alignment.
`volk::vector` is available in `volk/volk_alloc.hh`. Since it is a C++ 
only feature.


Cheers
Johannes

On 03.05.22 04:28, George Edwards wrote:

Hello GNURadio Community,

I am having a problem using the above function with vector parameters. 
If I use an array say:

gr_complex my_val[240];
volk_32fc_s32fc_multiply_32fc(my_val, my_val, scale, 240);

It works! But if I change my_val to be a vector like below, it fails:
std::vector  my_val(240);

The reason I need to use a vector is that with arrays, the size must be 
known at compile time, while with vectors one can build it at runtime.


I would appreciate any suggestions.
Thank you!

George