File: comp_isepdgtreal.cc

package info (click to toggle)
octave-ltfat 2.3.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,712 kB
  • sloc: ansic: 30,379; cpp: 8,808; java: 1,499; objc: 345; makefile: 248; xml: 182; python: 124; sh: 18; javascript: 12
file content (93 lines) | stat: -rw-r--r-- 3,422 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#define TYPEDEPARGS 0
#define SINGLEARGS
#define MATCHEDARGS 1
#define COMPLEXARGS
#define OCTFILENAME comp_isepdgtreal // change to filename
#define OCTFILEHELP "This function calls the C-library\n\
                    c=comp_isepdgtreal(c,g,L,a,M,phasetype);\n\
                    Yeah.\n"


#include "ltfat_oct_template_helper.h"
// octave_idx_type is 32 or 64 bit signed integer

static inline void
fwd_idgtreal_fb(const Complex *coef, const double *gf,
                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 ptype,
                double *f)
{
    ltfat_idgtreal_fb_d(reinterpret_cast<const ltfat_complex_d*>(coef),
                  gf, L, gl, W, a, M,
                  static_cast<const ltfat_phaseconvention>(ptype),
                  f);
}

static inline void
fwd_idgtreal_fb(const FloatComplex *coef, const float *gf,
                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 ptype,
                float *f)
{
    ltfat_idgtreal_fb_s(reinterpret_cast<const ltfat_complex_s*>(coef),
                  gf, L, gl, W, a, M,
                  static_cast<const ltfat_phaseconvention>(ptype),
                  f);
}

static inline void
fwd_idgtreal_long(const Complex *coef, const double *gf,
                  const octave_idx_type L, const octave_idx_type W,
                  const octave_idx_type a, const octave_idx_type M,
                  const octave_idx_type ptype, double *f)
{
    ltfat_idgtreal_long_d(reinterpret_cast<const ltfat_complex_d*>(coef),
                    gf, L, W, a, M,
                    static_cast<const ltfat_phaseconvention>(ptype),
                    f);
}

static inline void
fwd_idgtreal_long(const FloatComplex *coef, const float *gf,
                  const octave_idx_type L, const octave_idx_type W,
                  const octave_idx_type a, const octave_idx_type M,
                  const octave_idx_type ptype, float *f)
{
    ltfat_idgtreal_long_s(reinterpret_cast<const ltfat_complex_s*>(coef),
                    gf, L, W, a, M,
                    static_cast<const ltfat_phaseconvention>(ptype),
                    f);
}

template <class LTFAT_TYPE, class LTFAT_REAL, class LTFAT_COMPLEX>
octave_value_list octFunction(const octave_value_list& args, int nargout)
{
    DEBUGINFO;

    MArray<LTFAT_TYPE> coef = ltfatOctArray<LTFAT_TYPE>(args(0));
    MArray<LTFAT_REAL> gf = ltfatOctArray<LTFAT_REAL>(args(1));
    const octave_idx_type L = args(2).int_value();
    const octave_idx_type a = args(3).int_value();
    const octave_idx_type M = args(4).int_value();
    const octave_idx_type ptype = args(5).int_value() == 1? LTFAT_TIMEINV: LTFAT_FREQINV;
    const octave_idx_type N = L / a;
    const octave_idx_type M2 = M / 2 + 1;
    const octave_idx_type W = coef.numel() / (N * M2);
    const octave_idx_type gl = gf.rows();

    MArray<LTFAT_REAL> f(dim_vector(L, W));

    if (gl < L)
    {
        fwd_idgtreal_fb(coef.data(), gf.data(), L, gl, W, a, M, ptype,
                        f.fortran_vec());
    }
    else
    {
        fwd_idgtreal_long(coef.data(), gf.data(), L, W, a, M, ptype,
                          f.fortran_vec());
    }
    return octave_value(f);
}