annotate src/fftw-3.3.5/kernel/tensor4.c @ 156:1bf23f5aebc4

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