2
* Copyright (c) 2003, 2006 Matteo Frigo
3
* Copyright (c) 2003, 2006 Massachusetts Institute of Technology
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
tensor *X(mktensor_iodims)(int rank, const X(iodim) *dims, int is, int os)
26
tensor *x = X(mktensor)(rank);
28
if (FINITE_RNK(rank)) {
29
for (i = 0; i < rank; ++i) {
30
x->dims[i].n = dims[i].n;
31
x->dims[i].is = dims[i].is * is;
32
x->dims[i].os = dims[i].os * os;
38
static int iodims_kosherp(int rank, const X(iodim) *dims, int allow_minfty)
42
if (rank < 0) return 0;
45
if (!FINITE_RNK(rank)) return 1;
46
for (i = 0; i < rank; ++i)
47
if (dims[i].n < 0) return 0;
49
if (!FINITE_RNK(rank)) return 0;
50
for (i = 0; i < rank; ++i)
51
if (dims[i].n <= 0) return 0;
57
int X(guru_kosherp)(int rank, const X(iodim) *dims,
58
int howmany_rank, const X(iodim) *howmany_dims)
60
return (iodims_kosherp(rank, dims, 0) &&
61
iodims_kosherp(howmany_rank, howmany_dims, 1));