annotate src/fftw-3.3.8/kernel/tensor5.c @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 /*
Chris@82 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@82 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@82 4 *
Chris@82 5 * This program is free software; you can redistribute it and/or modify
Chris@82 6 * it under the terms of the GNU General Public License as published by
Chris@82 7 * the Free Software Foundation; either version 2 of the License, or
Chris@82 8 * (at your option) any later version.
Chris@82 9 *
Chris@82 10 * This program is distributed in the hope that it will be useful,
Chris@82 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@82 13 * GNU General Public License for more details.
Chris@82 14 *
Chris@82 15 * You should have received a copy of the GNU General Public License
Chris@82 16 * along with this program; if not, write to the Free Software
Chris@82 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@82 18 *
Chris@82 19 */
Chris@82 20
Chris@82 21
Chris@82 22 #include "kernel/ifftw.h"
Chris@82 23
Chris@82 24 static void dimcpy(iodim *dst, const iodim *src, int rnk)
Chris@82 25 {
Chris@82 26 int i;
Chris@82 27 if (FINITE_RNK(rnk))
Chris@82 28 for (i = 0; i < rnk; ++i)
Chris@82 29 dst[i] = src[i];
Chris@82 30 }
Chris@82 31
Chris@82 32 tensor *X(tensor_copy)(const tensor *sz)
Chris@82 33 {
Chris@82 34 tensor *x = X(mktensor)(sz->rnk);
Chris@82 35 dimcpy(x->dims, sz->dims, sz->rnk);
Chris@82 36 return x;
Chris@82 37 }
Chris@82 38
Chris@82 39 /* like X(tensor_copy), but makes strides in-place by
Chris@82 40 setting os = is if k == INPLACE_IS or is = os if k == INPLACE_OS. */
Chris@82 41 tensor *X(tensor_copy_inplace)(const tensor *sz, inplace_kind k)
Chris@82 42 {
Chris@82 43 tensor *x = X(tensor_copy)(sz);
Chris@82 44 if (FINITE_RNK(x->rnk)) {
Chris@82 45 int i;
Chris@82 46 if (k == INPLACE_OS)
Chris@82 47 for (i = 0; i < x->rnk; ++i)
Chris@82 48 x->dims[i].is = x->dims[i].os;
Chris@82 49 else
Chris@82 50 for (i = 0; i < x->rnk; ++i)
Chris@82 51 x->dims[i].os = x->dims[i].is;
Chris@82 52 }
Chris@82 53 return x;
Chris@82 54 }
Chris@82 55
Chris@82 56 /* Like X(tensor_copy), but copy all of the dimensions *except*
Chris@82 57 except_dim. */
Chris@82 58 tensor *X(tensor_copy_except)(const tensor *sz, int except_dim)
Chris@82 59 {
Chris@82 60 tensor *x;
Chris@82 61
Chris@82 62 A(FINITE_RNK(sz->rnk) && sz->rnk >= 1 && except_dim < sz->rnk);
Chris@82 63 x = X(mktensor)(sz->rnk - 1);
Chris@82 64 dimcpy(x->dims, sz->dims, except_dim);
Chris@82 65 dimcpy(x->dims + except_dim, sz->dims + except_dim + 1,
Chris@82 66 x->rnk - except_dim);
Chris@82 67 return x;
Chris@82 68 }
Chris@82 69
Chris@82 70 /* Like X(tensor_copy), but copy only rnk dimensions starting
Chris@82 71 with start_dim. */
Chris@82 72 tensor *X(tensor_copy_sub)(const tensor *sz, int start_dim, int rnk)
Chris@82 73 {
Chris@82 74 tensor *x;
Chris@82 75
Chris@82 76 A(FINITE_RNK(sz->rnk) && start_dim + rnk <= sz->rnk);
Chris@82 77 x = X(mktensor)(rnk);
Chris@82 78 dimcpy(x->dims, sz->dims + start_dim, rnk);
Chris@82 79 return x;
Chris@82 80 }
Chris@82 81
Chris@82 82 tensor *X(tensor_append)(const tensor *a, const tensor *b)
Chris@82 83 {
Chris@82 84 if (!FINITE_RNK(a->rnk) || !FINITE_RNK(b->rnk)) {
Chris@82 85 return X(mktensor)(RNK_MINFTY);
Chris@82 86 } else {
Chris@82 87 tensor *x = X(mktensor)(a->rnk + b->rnk);
Chris@82 88 dimcpy(x->dims, a->dims, a->rnk);
Chris@82 89 dimcpy(x->dims + a->rnk, b->dims, b->rnk);
Chris@82 90 return x;
Chris@82 91 }
Chris@82 92 }