File: fftpack_support.h

package info (click to toggle)
healpix-cxx 3.50.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,008 kB
  • sloc: cpp: 13,882; ansic: 5,930; sh: 4,451; makefile: 216
file content (135 lines) | stat: -rw-r--r-- 3,830 bytes parent folder | download | duplicates (7)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 *  This file is part of libcxxsupport.
 *
 *  libcxxsupport is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  libcxxsupport is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with libcxxsupport; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/*
 *  libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
 *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
 *  (DLR).
 */

/*
 *  Copyright (C) 2004-2015 Max-Planck-Society
 *  \author Martin Reinecke
 */

#ifndef PLANCK_FFTPACK_SUPPORT_H
#define PLANCK_FFTPACK_SUPPORT_H

#include "ls_fft.h"
#include "arr.h"
#include "xcomplex.h"

class cfft
  {
  private:
    tsize n;
    complex_plan plan;

  public:
    cfft () : n(0), plan(0) {}
    cfft (tsize size_)
      : n(size_), plan(make_complex_plan(size_)) {}
    cfft (const cfft &orig)
      : n(orig.n), plan(copy_complex_plan(orig.plan)) {}
    ~cfft ()
      { if (plan!=0) kill_complex_plan (plan); }
    cfft &operator=(const cfft &orig)
      {
      if (n!=orig.n)
        {
        if (plan!=0) kill_complex_plan (plan);
        n=orig.n;
        plan = copy_complex_plan(orig.plan);
        }
      return *this;
      }
    void Set (tsize size_)
      {
      if (n==size_) return;
      if (plan!=0) kill_complex_plan (plan);
      n=size_;
      plan=make_complex_plan(size_);
      }

    tsize size() const
      { return n; }

    void forward (double *data)
      { complex_plan_forward(plan,data); }
    void backward (double *data)
      { complex_plan_backward(plan,data); }
    void forward (dcomplex *data)
      { complex_plan_forward(plan,reinterpret_cast<double *>(data)); }
    void backward (dcomplex *data)
      { complex_plan_backward(plan,reinterpret_cast<double *>(data)); }
    void forward (arr<dcomplex> &data)
      { forward(reinterpret_cast<double *>(&data[0])); }
    void backward (arr<dcomplex> &data)
      { backward(reinterpret_cast<double *>(&data[0])); }
  };

class rfft
  {
  private:
    tsize n;
    real_plan plan;

  public:
    rfft () : n(0), plan(0) {}
    rfft (const rfft &orig)
      : n(orig.n), plan(copy_real_plan(orig.plan)) {}
    rfft (tsize size_)
      : n(size_), plan(make_real_plan(size_)) {}
    ~rfft ()
      { if (plan!=0) kill_real_plan (plan); }
    rfft &operator=(const rfft &orig)
      {
      if (n!=orig.n)
        {
        if (plan!=0) kill_real_plan (plan);
        n=orig.n;
        plan = copy_real_plan(orig.plan);
        }
      return *this;
      }
    void Set (tsize size_)
      {
      if (n==size_) return;
      if (plan!=0) kill_real_plan (plan);
      n=size_;
      plan=make_real_plan(size_);
      }

    tsize size() const
      { return n; }

    void forward_fftpack (double *data)
      { real_plan_forward_fftpack(plan,data); }
    void backward_fftpack (double *data)
      { real_plan_backward_fftpack(plan,data); }
    void forward_fftpack (arr<double> &data)
      { forward_fftpack(&(data[0])); }
    void backward_fftpack (arr<double> &data)
      { backward_fftpack(&(data[0])); }
    void forward_c (arr<dcomplex> &data)
      { real_plan_forward_c(plan,reinterpret_cast<double *>(&data[0])); }
    void backward_c (arr<dcomplex> &data)
      { real_plan_backward_c(plan,reinterpret_cast<double *>(&data[0])); }
  };

#endif