| 1 | /* Copyright (c) 2006-2012 Filip Wasilewski <http://en.ig.ma/> |
| 2 | * Copyright (c) 2012-2016 The PyWavelets Developers |
| 3 | * <https://github.com/PyWavelets/pywt> |
| 4 | * See COPYING for license details. |
| 5 | */ |
| 6 | |
| 7 | #include "templating.h" |
| 8 | |
| 9 | |
| 10 | #ifndef REAL_TYPE |
| 11 | #error REAL_TYPE must be defined here. |
| 12 | #else |
| 13 | |
| 14 | #ifndef TYPE |
| 15 | #error TYPE must be defined here. |
| 16 | #else |
| 17 | |
| 18 | #include "common.h" |
| 19 | |
| 20 | #if defined _MSC_VER |
| 21 | #define restrict __restrict |
| 22 | #elif defined __GNUC__ |
| 23 | #define restrict __restrict__ |
| 24 | #endif |
| 25 | |
| 26 | /* Performs convolution of input with filter and downsamples by taking every |
| 27 | * step-th element from the result. |
| 28 | * |
| 29 | * input - input data |
| 30 | * N - input data length |
| 31 | * filter - filter data |
| 32 | * F - filter data length |
| 33 | * output - output data |
| 34 | * step - decimation step |
| 35 | * mode - signal extension mode |
| 36 | */ |
| 37 | |
| 38 | /* memory efficient version */ |
| 39 | |
| 40 | int CAT(TYPE, _downsampling_convolution)(const TYPE * const restrict input, const size_t N, |
| 41 | const REAL_TYPE * const restrict filter, const size_t F, |
| 42 | TYPE * const restrict output, const size_t step, |
| 43 | MODE mode); |
| 44 | |
| 45 | |
| 46 | /* downsampling convolution routine specific to periodization mode. |
| 47 | * |
| 48 | * input - input data |
| 49 | * N - input data length |
| 50 | * filter - filter data |
| 51 | * F - filter data length |
| 52 | * output - output data |
| 53 | * step - decimation step |
| 54 | * fstep - step size between non-zero entries in filter |
| 55 | * (used to improve performance for the multilevel swt) |
| 56 | */ |
| 57 | int CAT(TYPE, _downsampling_convolution_periodization)( |
| 58 | const TYPE * const restrict input, const size_t N, |
| 59 | const REAL_TYPE * const restrict filter, const size_t F, |
| 60 | TYPE * const restrict output, const size_t step, |
| 61 | const size_t fstep); |
| 62 | |
| 63 | /* |
| 64 | * Performs normal (full) convolution of "upsampled" input coeffs array with |
| 65 | * filter Requires zero-filled output buffer (adds values instead of |
| 66 | * overwriting - can be called many times with the same output). |
| 67 | * |
| 68 | * input - input data |
| 69 | * N - input data length |
| 70 | * filter - filter data |
| 71 | * F - filter data length |
| 72 | * output - output data |
| 73 | * O - output length (currently not used) |
| 74 | * mode - signal extension mode |
| 75 | */ |
| 76 | |
| 77 | int CAT(TYPE, _upsampling_convolution_full)(const TYPE * const restrict input, const size_t N, |
| 78 | const REAL_TYPE * const restrict filter, const size_t F, |
| 79 | TYPE * const restrict output, const size_t O); |
| 80 | |
| 81 | /* Performs valid convolution (signals must overlap) |
| 82 | * Extends (virtually) input for MODE_PERIODIZATION. |
| 83 | */ |
| 84 | |
| 85 | int CAT(TYPE, _upsampling_convolution_valid_sf)(const TYPE * const restrict input, const size_t N, |
| 86 | const REAL_TYPE * const restrict filter, const size_t F, |
| 87 | TYPE * const restrict output, const size_t O, |
| 88 | MODE mode); |
| 89 | |
| 90 | /* TODO |
| 91 | * for SWT |
| 92 | * int upsampled_filter_convolution(const TYPE * const restrict input, const int N, |
| 93 | * const REAL_TYPE * const restrict filter, const int F, |
| 94 | * TYPE * const restrict output, int step, int mode); |
| 95 | */ |
| 96 | |
| 97 | |
| 98 | |
| 99 | #undef restrict |
| 100 | #endif /* REAL_TYPE */ |
| 101 | #endif /* TYPE */ |