annotate src/fftw-3.3.5/kernel/tensor5.c @ 58:eab3b14ddc95

Further win32 build updates
author Chris Cannam
date Mon, 09 Jan 2017 13:51:38 +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 static void dimcpy(iodim *dst, const iodim *src, int rnk)
Chris@42 25 {
Chris@42 26 int i;
Chris@42 27 if (FINITE_RNK(rnk))
Chris@42 28 for (i = 0; i < rnk; ++i)
Chris@42 29 dst[i] = src[i];
Chris@42 30 }
Chris@42 31
Chris@42 32 tensor *X(tensor_copy)(const tensor *sz)
Chris@42 33 {
Chris@42 34 tensor *x = X(mktensor)(sz->rnk);
Chris@42 35 dimcpy(x->dims, sz->dims, sz->rnk);
Chris@42 36 return x;
Chris@42 37 }
Chris@42 38
Chris@42 39 /* like X(tensor_copy), but makes strides in-place by
Chris@42 40 setting os = is if k == INPLACE_IS or is = os if k == INPLACE_OS. */
Chris@42 41 tensor *X(tensor_copy_inplace)(const tensor *sz, inplace_kind k)
Chris@42 42 {
Chris@42 43 tensor *x = X(tensor_copy)(sz);
Chris@42 44 if (FINITE_RNK(x->rnk)) {
Chris@42 45 int i;
Chris@42 46 if (k == INPLACE_OS)
Chris@42 47 for (i = 0; i < x->rnk; ++i)
Chris@42 48 x->dims[i].is = x->dims[i].os;
Chris@42 49 else
Chris@42 50 for (i = 0; i < x->rnk; ++i)
Chris@42 51 x->dims[i].os = x->dims[i].is;
Chris@42 52 }
Chris@42 53 return x;
Chris@42 54 }
Chris@42 55
Chris@42 56 /* Like X(tensor_copy), but copy all of the dimensions *except*
Chris@42 57 except_dim. */
Chris@42 58 tensor *X(tensor_copy_except)(const tensor *sz, int except_dim)
Chris@42 59 {
Chris@42 60 tensor *x;
Chris@42 61
Chris@42 62 A(FINITE_RNK(sz->rnk) && sz->rnk >= 1 && except_dim < sz->rnk);
Chris@42 63 x = X(mktensor)(sz->rnk - 1);
Chris@42 64 dimcpy(x->dims, sz->dims, except_dim);
Chris@42 65 dimcpy(x->dims + except_dim, sz->dims + except_dim + 1,
Chris@42 66 x->rnk - except_dim);
Chris@42 67 return x;
Chris@42 68 }
Chris@42 69
Chris@42 70 /* Like X(tensor_copy), but copy only rnk dimensions starting
Chris@42 71 with start_dim. */
Chris@42 72 tensor *X(tensor_copy_sub)(const tensor *sz, int start_dim, int rnk)
Chris@42 73 {
Chris@42 74 tensor *x;
Chris@42 75
Chris@42 76 A(FINITE_RNK(sz->rnk) && start_dim + rnk <= sz->rnk);
Chris@42 77 x = X(mktensor)(rnk);
Chris@42 78 dimcpy(x->dims, sz->dims + start_dim, rnk);
Chris@42 79 return x;
Chris@42 80 }
Chris@42 81
Chris@42 82 tensor *X(tensor_append)(const tensor *a, const tensor *b)
Chris@42 83 {
Chris@42 84 if (!FINITE_RNK(a->rnk) || !FINITE_RNK(b->rnk)) {
Chris@42 85 return X(mktensor)(RNK_MINFTY);
Chris@42 86 } else {
Chris@42 87 tensor *x = X(mktensor)(a->rnk + b->rnk);
Chris@42 88 dimcpy(x->dims, a->dims, a->rnk);
Chris@42 89 dimcpy(x->dims + a->rnk, b->dims, b->rnk);
Chris@42 90 return x;
Chris@42 91 }
Chris@42 92 }