Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.8/kernel/tensor4.c @ 167:bd3cc4d1df30
Add FFTW 3.3.8 source, and a Linux build
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 19 Nov 2019 14:52:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
166:cbd6d7e562c7 | 167:bd3cc4d1df30 |
---|---|
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 "kernel/ifftw.h" | |
23 | |
24 INT X(tensor_max_index)(const tensor *sz) | |
25 { | |
26 int i; | |
27 INT ni = 0, no = 0; | |
28 | |
29 A(FINITE_RNK(sz->rnk)); | |
30 for (i = 0; i < sz->rnk; ++i) { | |
31 const iodim *p = sz->dims + i; | |
32 ni += (p->n - 1) * X(iabs)(p->is); | |
33 no += (p->n - 1) * X(iabs)(p->os); | |
34 } | |
35 return X(imax)(ni, no); | |
36 } | |
37 | |
38 #define tensor_min_xstride(sz, xs) { \ | |
39 A(FINITE_RNK(sz->rnk)); \ | |
40 if (sz->rnk == 0) return 0; \ | |
41 else { \ | |
42 int i; \ | |
43 INT s = X(iabs)(sz->dims[0].xs); \ | |
44 for (i = 1; i < sz->rnk; ++i) \ | |
45 s = X(imin)(s, X(iabs)(sz->dims[i].xs)); \ | |
46 return s; \ | |
47 } \ | |
48 } | |
49 | |
50 INT X(tensor_min_istride)(const tensor *sz) tensor_min_xstride(sz, is) | |
51 INT X(tensor_min_ostride)(const tensor *sz) tensor_min_xstride(sz, os) | |
52 | |
53 INT X(tensor_min_stride)(const tensor *sz) | |
54 { | |
55 return X(imin)(X(tensor_min_istride)(sz), X(tensor_min_ostride)(sz)); | |
56 } | |
57 | |
58 int X(tensor_inplace_strides)(const tensor *sz) | |
59 { | |
60 int i; | |
61 A(FINITE_RNK(sz->rnk)); | |
62 for (i = 0; i < sz->rnk; ++i) { | |
63 const iodim *p = sz->dims + i; | |
64 if (p->is != p->os) | |
65 return 0; | |
66 } | |
67 return 1; | |
68 } | |
69 | |
70 int X(tensor_inplace_strides2)(const tensor *a, const tensor *b) | |
71 { | |
72 return X(tensor_inplace_strides(a)) && X(tensor_inplace_strides(b)); | |
73 } | |
74 | |
75 /* return true (1) iff *any* strides of sz decrease when we | |
76 tensor_inplace_copy(sz, k). */ | |
77 static int tensor_strides_decrease(const tensor *sz, inplace_kind k) | |
78 { | |
79 if (FINITE_RNK(sz->rnk)) { | |
80 int i; | |
81 for (i = 0; i < sz->rnk; ++i) | |
82 if ((sz->dims[i].os - sz->dims[i].is) | |
83 * (k == INPLACE_OS ? (INT)1 : (INT)-1) < 0) | |
84 return 1; | |
85 } | |
86 return 0; | |
87 } | |
88 | |
89 /* Return true (1) iff *any* strides of sz decrease when we | |
90 tensor_inplace_copy(k) *or* if *all* strides of sz are unchanged | |
91 but *any* strides of vecsz decrease. This is used in indirect.c | |
92 to determine whether to use INPLACE_IS or INPLACE_OS. | |
93 | |
94 Note: X(tensor_strides_decrease)(sz, vecsz, INPLACE_IS) | |
95 || X(tensor_strides_decrease)(sz, vecsz, INPLACE_OS) | |
96 || X(tensor_inplace_strides2)(p->sz, p->vecsz) | |
97 must always be true. */ | |
98 int X(tensor_strides_decrease)(const tensor *sz, const tensor *vecsz, | |
99 inplace_kind k) | |
100 { | |
101 return(tensor_strides_decrease(sz, k) | |
102 || (X(tensor_inplace_strides)(sz) | |
103 && tensor_strides_decrease(vecsz, k))); | |
104 } |