Coverage Report

Created: 2023-09-25 07:08

/src/fftw3/dft/problem.c
Line
Count
Source (jump to first uncovered line)
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
3.49k
{
27
3.49k
     problem_dft *ego = (problem_dft *) ego_;
28
3.49k
     X(tensor_destroy2)(ego->vecsz, ego->sz);
29
3.49k
     X(ifree)(ego_);
30
3.49k
}
31
32
static void hash(const problem *p_, md5 *m)
33
3.78k
{
34
3.78k
     const problem_dft *p = (const problem_dft *) p_;
35
3.78k
     X(md5puts)(m, "dft");
36
3.78k
     X(md5int)(m, p->ri == p->ro);
37
3.78k
     X(md5INT)(m, p->ii - p->ri);
38
3.78k
     X(md5INT)(m, p->io - p->ro);
39
3.78k
     X(md5int)(m, X(ialignment_of)(p->ri));
40
3.78k
     X(md5int)(m, X(ialignment_of)(p->ii));
41
3.78k
     X(md5int)(m, X(ialignment_of)(p->ro));
42
3.78k
     X(md5int)(m, X(ialignment_of)(p->io));
43
3.78k
     X(tensor_md5)(m, p->sz);
44
3.78k
     X(tensor_md5)(m, p->vecsz);
45
3.78k
}
46
47
static void print(const problem *ego_, printer *p)
48
0
{
49
0
     const problem_dft *ego = (const problem_dft *) ego_;
50
0
     p->print(p, "(dft %d %d %d %D %D %T %T)", 
51
0
        ego->ri == ego->ro,
52
0
        X(ialignment_of)(ego->ri),
53
0
        X(ialignment_of)(ego->ro),
54
0
        (INT)(ego->ii - ego->ri), 
55
0
        (INT)(ego->io - ego->ro),
56
0
        ego->sz,
57
0
        ego->vecsz);
58
0
}
59
60
static void zero(const problem *ego_)
61
0
{
62
0
     const problem_dft *ego = (const problem_dft *) ego_;
63
0
     tensor *sz = X(tensor_append)(ego->vecsz, ego->sz);
64
0
     X(dft_zerotens)(sz, UNTAINT(ego->ri), UNTAINT(ego->ii));
65
0
     X(tensor_destroy)(sz);
66
0
}
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
3.07k
{
80
3.07k
     problem_dft *ego;
81
82
     /* enforce pointer equality if untainted pointers are equal */
83
3.07k
     if (UNTAINT(ri) == UNTAINT(ro))
84
811
    ri = ro = JOIN_TAINT(ri, ro);
85
3.07k
     if (UNTAINT(ii) == UNTAINT(io))
86
811
    ii = io = JOIN_TAINT(ii, io);
87
88
     /* more correctness conditions: */
89
3.07k
     A(TAINTOF(ri) == TAINTOF(ii));
90
3.07k
     A(TAINTOF(ro) == TAINTOF(io));
91
92
3.07k
     A(X(tensor_kosherp)(sz));
93
3.07k
     A(X(tensor_kosherp)(vecsz));
94
95
3.07k
     if (ri == ro || ii == io) {
96
    /* If either real or imag pointers are in place, both must be. */
97
811
    if (ri != ro || ii != io || !X(tensor_inplace_locations)(sz, vecsz))
98
0
         return X(mkproblem_unsolvable)();
99
811
     }
100
101
3.07k
     ego = (problem_dft *)X(mkproblem)(sizeof(problem_dft), &padt);
102
103
3.07k
     ego->sz = X(tensor_compress)(sz);
104
3.07k
     ego->vecsz = X(tensor_compress_contiguous)(vecsz);
105
3.07k
     ego->ri = ri;
106
3.07k
     ego->ii = ii;
107
3.07k
     ego->ro = ro;
108
3.07k
     ego->io = io;
109
110
3.07k
     A(FINITE_RNK(ego->sz->rnk));
111
3.07k
     return &(ego->super);
112
3.07k
}
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
3.07k
{
118
3.07k
     problem *p = X(mkproblem_dft)(sz, vecsz, ri, ii, ro, io);
119
3.07k
     X(tensor_destroy2)(vecsz, sz);
120
3.07k
     return p;
121
3.07k
}