To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / src / fftw-3.3.8 / dft / problem.c @ 167:bd3cc4d1df30

History | View | Annotate | Download (3.45 KB)

1
/*
2
 * Copyright (c) 2003, 2007-14 Matteo Frigo
3
 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 */
20

    
21

    
22
#include "dft/dft.h"
23
#include <stddef.h>
24

    
25
static void destroy(problem *ego_)
26
{
27
     problem_dft *ego = (problem_dft *) ego_;
28
     X(tensor_destroy2)(ego->vecsz, ego->sz);
29
     X(ifree)(ego_);
30
}
31

    
32
static void hash(const problem *p_, md5 *m)
33
{
34
     const problem_dft *p = (const problem_dft *) p_;
35
     X(md5puts)(m, "dft");
36
     X(md5int)(m, p->ri == p->ro);
37
     X(md5INT)(m, p->ii - p->ri);
38
     X(md5INT)(m, p->io - p->ro);
39
     X(md5int)(m, X(ialignment_of)(p->ri));
40
     X(md5int)(m, X(ialignment_of)(p->ii));
41
     X(md5int)(m, X(ialignment_of)(p->ro));
42
     X(md5int)(m, X(ialignment_of)(p->io));
43
     X(tensor_md5)(m, p->sz);
44
     X(tensor_md5)(m, p->vecsz);
45
}
46

    
47
static void print(const problem *ego_, printer *p)
48
{
49
     const problem_dft *ego = (const problem_dft *) ego_;
50
     p->print(p, "(dft %d %d %d %D %D %T %T)", 
51
              ego->ri == ego->ro,
52
              X(ialignment_of)(ego->ri),
53
              X(ialignment_of)(ego->ro),
54
              (INT)(ego->ii - ego->ri), 
55
              (INT)(ego->io - ego->ro),
56
              ego->sz,
57
              ego->vecsz);
58
}
59

    
60
static void zero(const problem *ego_)
61
{
62
     const problem_dft *ego = (const problem_dft *) ego_;
63
     tensor *sz = X(tensor_append)(ego->vecsz, ego->sz);
64
     X(dft_zerotens)(sz, UNTAINT(ego->ri), UNTAINT(ego->ii));
65
     X(tensor_destroy)(sz);
66
}
67

    
68
static const problem_adt padt =
69
{
70
     PROBLEM_DFT,
71
     hash,
72
     zero,
73
     print,
74
     destroy
75
};
76

    
77
problem *X(mkproblem_dft)(const tensor *sz, const tensor *vecsz,
78
                          R *ri, R *ii, R *ro, R *io)
79
{
80
     problem_dft *ego;
81

    
82
     /* enforce pointer equality if untainted pointers are equal */
83
     if (UNTAINT(ri) == UNTAINT(ro))
84
          ri = ro = JOIN_TAINT(ri, ro);
85
     if (UNTAINT(ii) == UNTAINT(io))
86
          ii = io = JOIN_TAINT(ii, io);
87

    
88
     /* more correctness conditions: */
89
     A(TAINTOF(ri) == TAINTOF(ii));
90
     A(TAINTOF(ro) == TAINTOF(io));
91

    
92
     A(X(tensor_kosherp)(sz));
93
     A(X(tensor_kosherp)(vecsz));
94

    
95
     if (ri == ro || ii == io) {
96
          /* If either real or imag pointers are in place, both must be. */
97
          if (ri != ro || ii != io || !X(tensor_inplace_locations)(sz, vecsz))
98
               return X(mkproblem_unsolvable)();
99
     }
100

    
101
     ego = (problem_dft *)X(mkproblem)(sizeof(problem_dft), &padt);
102

    
103
     ego->sz = X(tensor_compress)(sz);
104
     ego->vecsz = X(tensor_compress_contiguous)(vecsz);
105
     ego->ri = ri;
106
     ego->ii = ii;
107
     ego->ro = ro;
108
     ego->io = io;
109

    
110
     A(FINITE_RNK(ego->sz->rnk));
111
     return &(ego->super);
112
}
113

    
114
/* Same as X(mkproblem_dft), but also destroy input tensors. */
115
problem *X(mkproblem_dft_d)(tensor *sz, tensor *vecsz,
116
                            R *ri, R *ii, R *ro, R *io)
117
{
118
     problem *p = X(mkproblem_dft)(sz, vecsz, ri, ii, ro, io);
119
     X(tensor_destroy2)(vecsz, sz);
120
     return p;
121
}