1 #define TYPEDEPARGS 0, 1
2 #define SINGLEARGS
3 #define REALARGS
4 #define OCTFILENAME comp_sepdgtreal // change to filename
5 #define OCTFILEHELP "This function calls the C-library\n\
6                      Usage: c=comp_sepdgtreal(f,g,a,M,phasetype);\n\
7                      Yeah."
8 
9 
10 #include "ltfat_oct_template_helper.h"
11 /*
12    dgtreal_fb forwarders
13 */
14 
15 static inline void
fwd_dgtreal_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 a,const octave_idx_type M,const octave_idx_type phasetype,Complex * cout)16 fwd_dgtreal_fb(const double *f, const double *g,
17                const octave_idx_type L, const octave_idx_type gl,
18                const octave_idx_type W, const octave_idx_type a,
19                const octave_idx_type M, const octave_idx_type phasetype,
20                Complex *cout)
21 {
22     ltfat_dgtreal_fb_d(f, g, L, gl, W, a, M,
23                  static_cast<ltfat_phaseconvention>(phasetype),
24                  reinterpret_cast<ltfat_complex_d*>(cout));
25 }
26 
27 static inline void
fwd_dgtreal_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 a,const octave_idx_type M,const octave_idx_type phasetype,FloatComplex * cout)28 fwd_dgtreal_fb(const float *f, const float *g,
29                const octave_idx_type L, const octave_idx_type gl,
30                const octave_idx_type W, const octave_idx_type a,
31                const octave_idx_type M, const octave_idx_type phasetype,
32                FloatComplex *cout)
33 {
34     ltfat_dgtreal_fb_s(f, g, L, gl, W, a, M,
35                  static_cast<ltfat_phaseconvention>(phasetype),
36                  reinterpret_cast<ltfat_complex_s*>(cout));
37 }
38 
39 static inline void
fwd_dgtreal_long(const double * f,const double * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type a,const octave_idx_type M,const octave_idx_type phasetype,Complex * cout)40 fwd_dgtreal_long(const double *f, const double *g, const octave_idx_type L,
41                  const octave_idx_type W, const octave_idx_type a,
42                  const octave_idx_type M, const octave_idx_type phasetype,
43                  Complex *cout)
44 {
45     ltfat_dgtreal_long_d(f, g, L, W, a, M,
46                    static_cast<ltfat_phaseconvention>(phasetype),
47                    reinterpret_cast<ltfat_complex_d*>(cout));
48 }
49 
50 static inline void
fwd_dgtreal_long(const float * f,const float * g,const octave_idx_type L,const octave_idx_type W,const octave_idx_type a,const octave_idx_type M,const octave_idx_type phasetype,FloatComplex * cout)51 fwd_dgtreal_long(const float *f, const float *g, const octave_idx_type L,
52                  const octave_idx_type W, const octave_idx_type a,
53                  const octave_idx_type M, const octave_idx_type phasetype,
54                  FloatComplex *cout)
55 {
56     ltfat_dgtreal_long_s(f, g, L, W, a, M,
57                    static_cast<ltfat_phaseconvention>(phasetype),
58                    reinterpret_cast<ltfat_complex_s*>(cout));
59 }
60 template <class LTFAT_TYPE, class LTFAT_REAL, class LTFAT_COMPLEX>
octFunction(const octave_value_list & args,int nargout)61 octave_value_list octFunction(const octave_value_list& args, int nargout)
62 {
63     DEBUGINFO;
64     const octave_idx_type a = args(2).int_value();
65     const octave_idx_type M = args(3).int_value();
66     const octave_idx_type phasetype = args(4).int_value()== 1? LTFAT_TIMEINV: LTFAT_FREQINV;
67     const octave_idx_type M2 = M / 2 + 1;
68 
69     MArray<LTFAT_TYPE> f = ltfatOctArray<LTFAT_TYPE>(args(0));
70     MArray<LTFAT_TYPE> g = ltfatOctArray<LTFAT_TYPE>(args(1));
71     const octave_idx_type L  = f.rows();
72     const octave_idx_type W  = f.columns();
73     const octave_idx_type gl = g.rows();
74     const octave_idx_type N = L / a;
75 
76     dim_vector dims_out(M2, N, W);
77     dims_out.chop_trailing_singletons();
78 
79     MArray<LTFAT_COMPLEX> cout(dims_out);
80 
81     if (gl < L)
82     {
83         fwd_dgtreal_fb(f.data(), g.data(), L, gl, W, a, M, phasetype,
84                        cout.fortran_vec());
85     }
86     else
87     {
88         fwd_dgtreal_long(f.data(), g.data(), L, W, a, M, phasetype,
89                          cout.fortran_vec());
90     }
91 
92     return octave_value(cout);
93 }
94