Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel for folding vector #317

Open
ast opened this issue Dec 12, 2019 · 5 comments
Open

Kernel for folding vector #317

ast opened this issue Dec 12, 2019 · 5 comments
Labels
Enhancement new kernel entirely or for some specific ARCH

Comments

@ast
Copy link
Contributor

ast commented Dec 12, 2019

There doesn't seem to be a kernel for folding a vector by a divisor. This is essential for decimation in the frequency domain.

% Example, Matlab notation
Fx_alias = (Fx(1:256) + Fx(257:512) + Fx(513:768) + Fx(769:1024)) / 4;
@jdemel
Copy link
Contributor

jdemel commented Dec 12, 2019

Could you rewrite your example in Python?

Do you suggest a kernel that looks smth like this

void volk_32fc_fold_32fc(result, src, integer_fold, num_points)

Essentially a combination of volk_32f_x2_add_32f and volk_32f_s32f_multiply_32f. Complex values are handled by reinterpreting complex pointers as float pointers with 2 * num_points.

@jdemel jdemel added the Enhancement new kernel entirely or for some specific ARCH label Dec 12, 2019
@ast
Copy link
Contributor Author

ast commented Dec 12, 2019

void fold(const float complex* in, float complex *out, const float scale, int fold, int len) {
    const int N = len/fold;
    for (int offset = N; offset < len; offset+=N) {
        volk_32fc_x2_add_32fc(out, out, &in[offset], N);
    }
    volk_32f_s32f_multiply_32f((float*)out, (float*)out, scale, 2*N);
}

@jdemel
Copy link
Contributor

jdemel commented Dec 13, 2019

So the function signature should look like this?

void volk_32fc_fold_32fc(float complex* out, const float complex *in, 
                         const float scale, const int fold, 
                         const unsigned int num_points)
  1. Should we fix to const float scale = 1. / fold;?
  2. Is fold a good name for this kernel?

@ast
Copy link
Contributor Author

ast commented Dec 13, 2019

Everything is up for discussion really, maybe this kernel doesn't even make sense? But this is a common operation when you decimate in the frequency domain if you want it to be equivalent to decimation in the time domain.

@michaelld
Copy link
Contributor

"fold" seems to be more general than this suggested kernel -- which I like the idea of, BTW. MATLAB "fold" recursively applies a function to a set of data, like what "reduce" in Octave does. Hence I'd suggest we use some other name ... it can include "fold", but it should be more precise.

@jdemel jdemel changed the title Kernel for folding vector label:Enhancement Kernel for folding vector May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement new kernel entirely or for some specific ARCH
Projects
None yet
Development

No branches or pull requests

3 participants