1 #define TYPEDEPARGS 0, 1
2 #define SINGLEARGS
3 #define COMPLEXINDEPENDENT
4 #define OCTFILENAME comp_dwilt // change to filename
5 #define OCTFILEHELP "This function calls the C-library\n\
6                      coef=comp_dwilt(f,g,M);\n\
7                      Yeah."
8 
9 
10 #include "ltfat_oct_template_helper.h"
11 // octave_idx_type is 32 or 64 bit signed integer
12 /*
13   dgtreal_ola forwarders
14 */
15 
16 static inline void
fwd_dwilt_fb(const Complex * f,const Complex * g,const octave_idx_type L,const octave_idx_type gl,const octave_idx_type W,const octave_idx_type M,Complex * cout)17 fwd_dwilt_fb(const Complex *f, const Complex *g,
18              const octave_idx_type L, const octave_idx_type gl,
19              const octave_idx_type W, const octave_idx_type M,
20              Complex *cout)
21 {
22     ltfat_dwilt_fb_dc(reinterpret_cast<const ltfat_complex_d*>(f),
23                 reinterpret_cast<const ltfat_complex_d*>(g),
24                 L, gl, W, M, reinterpret_cast<ltfat_complex_d*>(cout));
25 }
26 
27 static inline void
fwd_dwilt_fb(const FloatComplex * f,const FloatComplex * g,const octave_idx_type L,const octave_idx_type gl,const octave_idx_type W,const octave_idx_type M,FloatComplex * cout)28 fwd_dwilt_fb(const FloatComplex *f, const FloatComplex *g,
29              const octave_idx_type L,  const octave_idx_type gl,
30              const octave_idx_type W, const octave_idx_type M,
31              FloatComplex *cout)
32 {
33     ltfat_dwilt_fb_sc(reinterpret_cast<const ltfat_complex_s*>(f),
34                 reinterpret_cast<const ltfat_complex_s*>(g),
35                 L, gl, W, M,
36                 reinterpret_cast<ltfat_complex_s*>(cout));
37 }
38 
39 static inline void
fwd_dwilt_fb(const double * f,const double * g,const octave_idx_type L,const octave_idx_type gl,const octave_idx_type W,const octave_idx_type M,double * cout)40 fwd_dwilt_fb(const double *f, const double *g,
41              const octave_idx_type L,  const octave_idx_type gl,
42              const octave_idx_type W, const octave_idx_type M,
43              double *cout)
44 {
45     ltfat_dwilt_fb_d(f, g, L, gl, W, M, cout);
46 }
47 
48 static inline void
fwd_dwilt_fb(const float * f,const float * g,const octave_idx_type L,const octave_idx_type gl,const octave_idx_type W,const octave_idx_type M,float * cout)49 fwd_dwilt_fb(const float *f, const float *g,
50              const octave_idx_type L,  const octave_idx_type gl,
51              const octave_idx_type W, const octave_idx_type M,
52              float *cout)
53 {
54     ltfat_dwilt_fb_s(f, g, L, gl, W, M, cout);
55 }
56 
57 static inline void
fwd_dwilt_long(const Complex * f,const Complex * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type M,Complex * cout)58 fwd_dwilt_long(const Complex *f, const Complex *g,
59                const octave_idx_type L, const octave_idx_type W,
60                const octave_idx_type M, Complex *cout)
61 {
62     ltfat_dwilt_long_dc(reinterpret_cast<const ltfat_complex_d*>(f),
63                   reinterpret_cast<const ltfat_complex_d*>(g),
64                   L, W, M, reinterpret_cast<ltfat_complex_d*>(cout));
65 }
66 
67 static inline void
fwd_dwilt_long(const FloatComplex * f,const FloatComplex * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type M,FloatComplex * cout)68 fwd_dwilt_long(const FloatComplex *f, const FloatComplex *g,
69                const octave_idx_type L, const octave_idx_type W,
70                const octave_idx_type M, FloatComplex *cout)
71 {
72     ltfat_dwilt_long_sc(reinterpret_cast<const ltfat_complex_s*>(f),
73                   reinterpret_cast<const ltfat_complex_s*>(g),
74                   L, W, M, reinterpret_cast<ltfat_complex_s*>(cout));
75 }
76 
77 static inline void
fwd_dwilt_long(const double * f,const double * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type M,double * cout)78 fwd_dwilt_long(const double *f, const double *g,
79                const octave_idx_type L, const octave_idx_type W,
80                const octave_idx_type M, double *cout)
81 {
82     ltfat_dwilt_long_d(f, g, L, W, M, cout);
83 }
84 
85 static inline void
fwd_dwilt_long(const float * f,const float * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type M,float * cout)86 fwd_dwilt_long(const float *f, const float *g,
87                const octave_idx_type L, const octave_idx_type W,
88                const octave_idx_type M, float *cout)
89 {
90     ltfat_dwilt_long_s(f, g, L, W, M, cout);
91 }
92 
93 template <class LTFAT_TYPE, class LTFAT_REAL, class LTFAT_COMPLEX>
octFunction(const octave_value_list & args,int nargout)94 octave_value_list octFunction(const octave_value_list& args, int nargout)
95 {
96     DEBUGINFO;
97     const octave_idx_type M = args(2).int_value();
98 
99     MArray<LTFAT_TYPE> f = ltfatOctArray<LTFAT_TYPE>(args(0));
100     MArray<LTFAT_TYPE> g = ltfatOctArray<LTFAT_TYPE>(args(1));
101     const octave_idx_type gl = g.numel();
102     const octave_idx_type W = f.columns();
103     const octave_idx_type L = f.rows();
104     const octave_idx_type N = L / M;
105 
106 
107     dim_vector dims_out(2 * M, N / 2, W);
108     dims_out.chop_trailing_singletons();
109 
110     MArray<LTFAT_TYPE> cout(dims_out);
111 
112     if (gl < L)
113     {
114         fwd_dwilt_fb(f.data(), g.data(), L, gl, W, M, cout.fortran_vec());
115     }
116     else
117     {
118         fwd_dwilt_long(f.data(), g.data(), L, W, M, cout.fortran_vec());
119     }
120 
121     return octave_value(cout);
122 }
123 
124