annotate src/fftw-3.3.3/kernel/tensor4.c @ 70:9e21af8f0420

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