annotate src/fftw-3.3.5/kernel/tensor4.c @ 73:02caadb7509e

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