annotate src/fftw-3.3.3/kernel/tensor4.c @ 161:4797bbf470e7

No, that isn't going to end well. Back it out.
author Chris Cannam <cannam@all-day-breakfast.com>
date Sat, 16 Feb 2019 18:32:35 +0000
parents 89f5e221ed7b
children
rev   line source
cannam@95 1 /*
cannam@95 2 * Copyright (c) 2003, 2007-11 Matteo Frigo
cannam@95 3 * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology
cannam@95 4 *
cannam@95 5 * This program is free software; you can redistribute it and/or modify
cannam@95 6 * it under the terms of the GNU General Public License as published by
cannam@95 7 * the Free Software Foundation; either version 2 of the License, or
cannam@95 8 * (at your option) any later version.
cannam@95 9 *
cannam@95 10 * This program is distributed in the hope that it will be useful,
cannam@95 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@95 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@95 13 * GNU General Public License for more details.
cannam@95 14 *
cannam@95 15 * You should have received a copy of the GNU General Public License
cannam@95 16 * along with this program; if not, write to the Free Software
cannam@95 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@95 18 *
cannam@95 19 */
cannam@95 20
cannam@95 21
cannam@95 22 #include "ifftw.h"
cannam@95 23
cannam@95 24 INT X(tensor_max_index)(const tensor *sz)
cannam@95 25 {
cannam@95 26 int i;
cannam@95 27 INT ni = 0, no = 0;
cannam@95 28
cannam@95 29 A(FINITE_RNK(sz->rnk));
cannam@95 30 for (i = 0; i < sz->rnk; ++i) {
cannam@95 31 const iodim *p = sz->dims + i;
cannam@95 32 ni += (p->n - 1) * X(iabs)(p->is);
cannam@95 33 no += (p->n - 1) * X(iabs)(p->os);
cannam@95 34 }
cannam@95 35 return X(imax)(ni, no);
cannam@95 36 }
cannam@95 37
cannam@95 38 #define tensor_min_xstride(sz, xs) { \
cannam@95 39 A(FINITE_RNK(sz->rnk)); \
cannam@95 40 if (sz->rnk == 0) return 0; \
cannam@95 41 else { \
cannam@95 42 int i; \
cannam@95 43 INT s = X(iabs)(sz->dims[0].xs); \
cannam@95 44 for (i = 1; i < sz->rnk; ++i) \
cannam@95 45 s = X(imin)(s, X(iabs)(sz->dims[i].xs)); \
cannam@95 46 return s; \
cannam@95 47 } \
cannam@95 48 }
cannam@95 49
cannam@95 50 INT X(tensor_min_istride)(const tensor *sz) tensor_min_xstride(sz, is)
cannam@95 51 INT X(tensor_min_ostride)(const tensor *sz) tensor_min_xstride(sz, os)
cannam@95 52
cannam@95 53 INT X(tensor_min_stride)(const tensor *sz)
cannam@95 54 {
cannam@95 55 return X(imin)(X(tensor_min_istride)(sz), X(tensor_min_ostride)(sz));
cannam@95 56 }
cannam@95 57
cannam@95 58 int X(tensor_inplace_strides)(const tensor *sz)
cannam@95 59 {
cannam@95 60 int i;
cannam@95 61 A(FINITE_RNK(sz->rnk));
cannam@95 62 for (i = 0; i < sz->rnk; ++i) {
cannam@95 63 const iodim *p = sz->dims + i;
cannam@95 64 if (p->is != p->os)
cannam@95 65 return 0;
cannam@95 66 }
cannam@95 67 return 1;
cannam@95 68 }
cannam@95 69
cannam@95 70 int X(tensor_inplace_strides2)(const tensor *a, const tensor *b)
cannam@95 71 {
cannam@95 72 return X(tensor_inplace_strides(a)) && X(tensor_inplace_strides(b));
cannam@95 73 }
cannam@95 74
cannam@95 75 /* return true (1) iff *any* strides of sz decrease when we
cannam@95 76 tensor_inplace_copy(sz, k). */
cannam@95 77 static int tensor_strides_decrease(const tensor *sz, inplace_kind k)
cannam@95 78 {
cannam@95 79 if (FINITE_RNK(sz->rnk)) {
cannam@95 80 int i;
cannam@95 81 for (i = 0; i < sz->rnk; ++i)
cannam@95 82 if ((sz->dims[i].os - sz->dims[i].is)
cannam@95 83 * (k == INPLACE_OS ? (INT)1 : (INT)-1) < 0)
cannam@95 84 return 1;
cannam@95 85 }
cannam@95 86 return 0;
cannam@95 87 }
cannam@95 88
cannam@95 89 /* Return true (1) iff *any* strides of sz decrease when we
cannam@95 90 tensor_inplace_copy(k) *or* if *all* strides of sz are unchanged
cannam@95 91 but *any* strides of vecsz decrease. This is used in indirect.c
cannam@95 92 to determine whether to use INPLACE_IS or INPLACE_OS.
cannam@95 93
cannam@95 94 Note: X(tensor_strides_decrease)(sz, vecsz, INPLACE_IS)
cannam@95 95 || X(tensor_strides_decrease)(sz, vecsz, INPLACE_OS)
cannam@95 96 || X(tensor_inplace_strides2)(p->sz, p->vecsz)
cannam@95 97 must always be true. */
cannam@95 98 int X(tensor_strides_decrease)(const tensor *sz, const tensor *vecsz,
cannam@95 99 inplace_kind k)
cannam@95 100 {
cannam@95 101 return(tensor_strides_decrease(sz, k)
cannam@95 102 || (X(tensor_inplace_strides)(sz)
cannam@95 103 && tensor_strides_decrease(vecsz, k)));
cannam@95 104 }