Commit 759728f9 authored by Mert Burkay Çöteli's avatar Mert Burkay Çöteli
Browse files

initial commit for deployment

parent 53b7603f
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
typedef struct {
printer super;
size_t *cnt;
} P_cnt;
static void putchr_cnt(printer * p_, char c)
{
P_cnt *p = (P_cnt *) p_;
UNUSED(c);
++*p->cnt;
}
printer *X(mkprinter_cnt)(size_t *cnt)
{
P_cnt *p = (P_cnt *) X(mkprinter)(sizeof(P_cnt), putchr_cnt, 0);
p->cnt = cnt;
*cnt = 0;
return &p->super;
}
typedef struct {
printer super;
char *s;
} P_str;
static void putchr_str(printer * p_, char c)
{
P_str *p = (P_str *) p_;
*p->s++ = c;
*p->s = 0;
}
printer *X(mkprinter_str)(char *s)
{
P_str *p = (P_str *) X(mkprinter)(sizeof(P_str), putchr_str, 0);
p->s = s;
*s = 0;
return &p->super;
}
#include "guru.h"
#include "mktensor-iodims.h"
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
tensor *MKTENSOR_IODIMS(int rank, const IODIM *dims, int is, int os)
{
int i;
tensor *x = X(mktensor)(rank);
if (FINITE_RNK(rank)) {
for (i = 0; i < rank; ++i) {
x->dims[i].n = dims[i].n;
x->dims[i].is = dims[i].is * is;
x->dims[i].os = dims[i].os * os;
}
}
return x;
}
static int iodims_kosherp(int rank, const IODIM *dims, int allow_minfty)
{
int i;
if (rank < 0) return 0;
if (allow_minfty) {
if (!FINITE_RNK(rank)) return 1;
for (i = 0; i < rank; ++i)
if (dims[i].n < 0) return 0;
} else {
if (!FINITE_RNK(rank)) return 0;
for (i = 0; i < rank; ++i)
if (dims[i].n <= 0) return 0;
}
return 1;
}
int GURU_KOSHERP(int rank, const IODIM *dims,
int howmany_rank, const IODIM *howmany_dims)
{
return (iodims_kosherp(rank, dims, 0) &&
iodims_kosherp(howmany_rank, howmany_dims, 1));
}
#include "guru64.h"
#include "mktensor-iodims.h"
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
tensor *X(mktensor_rowmajor)(int rnk, const int *n,
const int *niphys, const int *nophys,
int is, int os)
{
tensor *x = X(mktensor)(rnk);
if (FINITE_RNK(rnk) && rnk > 0) {
int i;
A(n && niphys && nophys);
x->dims[rnk - 1].is = is;
x->dims[rnk - 1].os = os;
x->dims[rnk - 1].n = n[rnk - 1];
for (i = rnk - 1; i > 0; --i) {
x->dims[i - 1].is = x->dims[i].is * niphys[i];
x->dims[i - 1].os = x->dims[i].os * nophys[i];
x->dims[i - 1].n = n[i - 1];
}
}
return x;
}
static int rowmajor_kosherp(int rnk, const int *n)
{
int i;
if (!FINITE_RNK(rnk)) return 0;
if (rnk < 0) return 0;
for (i = 0; i < rnk; ++i)
if (n[i] <= 0) return 0;
return 1;
}
int X(many_kosherp)(int rnk, const int *n, int howmany)
{
return (howmany >= 0) && rowmajor_kosherp(rnk, n);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
#include "dft/dft.h"
X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, unsigned flags)
{
return X(plan_dft)(1, &n, in, out, sign, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
#include "dft/dft.h"
X(plan) X(plan_dft_2d)(int nx, int ny, C *in, C *out, int sign, unsigned flags)
{
int n[2];
n[0] = nx;
n[1] = ny;
return X(plan_dft)(2, n, in, out, sign, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
#include "dft/dft.h"
X(plan) X(plan_dft_3d)(int nx, int ny, int nz,
C *in, C *out, int sign, unsigned flags)
{
int n[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
return X(plan_dft)(3, n, in, out, sign, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_c2r_1d)(int n, C *in, R *out, unsigned flags)
{
return X(plan_dft_c2r)(1, &n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_c2r_2d)(int nx, int ny, C *in, R *out, unsigned flags)
{
int n[2];
n[0] = nx;
n[1] = ny;
return X(plan_dft_c2r)(2, n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_c2r_3d)(int nx, int ny, int nz,
C *in, R *out, unsigned flags)
{
int n[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
return X(plan_dft_c2r)(3, n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_c2r)(int rank, const int *n, C *in, R *out, unsigned flags)
{
return X(plan_many_dft_c2r)(rank, n, 1,
in, 0, 1, 1, out, 0, 1, 1, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_r2c_1d)(int n, R *in, C *out, unsigned flags)
{
return X(plan_dft_r2c)(1, &n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_r2c_2d)(int nx, int ny, R *in, C *out, unsigned flags)
{
int n[2];
n[0] = nx;
n[1] = ny;
return X(plan_dft_r2c)(2, n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_r2c_3d)(int nx, int ny, int nz,
R *in, C *out, unsigned flags)
{
int n[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
return X(plan_dft_r2c)(3, n, in, out, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft_r2c)(int rank, const int *n, R *in, C *out, unsigned flags)
{
return X(plan_many_dft_r2c)(rank, n, 1,
in, 0, 1, 1,
out, 0, 1, 1,
flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
X(plan) X(plan_dft)(int rank, const int *n,
C *in, C *out, int sign, unsigned flags)
{
return X(plan_many_dft)(rank, n, 1,
in, 0, 1, 1,
out, 0, 1, 1,
sign, flags);
}
#include "guru.h"
#include "plan-guru-dft-c2r.h"
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/api.h"
#include "rdft/rdft.h"
X(plan) XGURU(dft_c2r)(int rank, const IODIM *dims,
int howmany_rank, const IODIM *howmany_dims,
C *in, R *out, unsigned flags)
{
R *ri, *ii;
if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) return 0;
EXTRACT_REIM(FFT_SIGN, in, &ri, &ii);
if (out != ri)
flags |= FFTW_DESTROY_INPUT;
return X(mkapiplan)(
0, flags,
X(mkproblem_rdft2_d_3pointers)(
MKTENSOR_IODIMS(rank, dims, 2, 1),
MKTENSOR_IODIMS(howmany_rank, howmany_dims, 2, 1),
TAINT_UNALIGNED(out, flags),
TAINT_UNALIGNED(ri, flags),
TAINT_UNALIGNED(ii, flags), HC2R));
}
#include "guru.h"
#include "plan-guru-dft-r2c.h"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment