annotate src/fftw-3.3.8/kernel/tensor4.c @ 168:ceec0dd9ec9c

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