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

initial commit for deployment

parent 53b7603f
# README #
This README would normally document whatever steps are necessary to get your application up and running.
### What is this repository for? ###
* Quick summary
Analysis tranform is an AIM used for transferring the time domain microphone array signals into the frequency domain. This file is introduces the setup for the standalone application.
* Version
01.01.220708
* [Technical specifications MPAI-CAE v1.3](https://mpai.community/standards/resources/)
### How do I get set up? ###
* Summary of set up
The development language is C++. C++11 and its newer versions support for compiling the code. See the list of C++ compilers. (https://en.wikipedia.org/wiki/List_of_compilers#C++_compilers)
This software uses a third-party fftw-3.3.9 that can be also downloaded from the link. (https://fftw.org/)
* Configuration
Default constructor is configured through the following parameters. If these parameters are needed to be updated the alternative constructor can be set.
windowsize=2048, signallength=20480, hopsize=1024, nofmics=32
* Dependencies
include : \include
libs :
#if DEBUG
\libs\Windows_x64\Debug;\libs\Windows_x86\Debug;\libs\Linux\Debug
#else
\libs\Windows_x64\Release;\libs\Windows_x86\Release;\libs\Linux\Release
#endif
* Database configuration
This software doesnot use a database.
* How to run tests
[Conformance Testing Document MPAI-CAE](https://mpai.community/standards/resources/)
* Deployment instructions
***********Standalone usage of this AIM (code script)
// For analysis of 20480 samples with fftsize=2048 and overlap=1024
// The output will be Interleaved Nofchannelsx10x1024 real and imaginary parts.
// Input and output data formats can be followed from MPAI-CAE v1.3
analysistransform* m_fft = new analysistransform();
int NofChannels = 32;
float* signal; // Data acquired from each microphone channel
float* realpart; // Real part to be malloc
float* imagpart; // Imaginary part to be malloc
for (int channel = 0; channel < NofChannels; channel++)
{
m_fft->STFT(signal, realpart+channel, imagpart+channel)
}
### Who do I talk to? ###
* Repo owner or admin
Mert Burkay Çöteli , mbcoteli@aselsan.com.tr, Aselsan
* Other community or team contact
MPAI secreteriat , secretariat@mpai.community , MPAI
\ No newline at end of file
#include "analysistransform.h"
// Create a constructor for analysis transform
analysistransform::analysistransform()
{
this->signallength = 20480;
this->windowsize = 2048;
this->overlap = 1024;
this->nofmics = 32;
int lngth = (windowsize / 2 + 1) * (signallength / (overlap));
outputsignal = (std::complex <float> *) malloc(sizeof(std::complex <float>) * lngth);
}
// Create a constructor for analysis transform
analysistransform::analysistransform(int windowsize=2048, int signallength=20480, int hopsize=1024,int nofmics=32)
{
this->signallength = signallength;
this->windowsize = windowsize;
this->overlap = hopsize;
this->nofmics = nofmics;
int lngth = (windowsize / 2 + 1) * (signallength / (hopsize));
outputsignal = (std::complex <float> *) malloc(sizeof(std::complex <float>) * lngth);
}
// Create a hamming window of windowLength samples in buffer
void analysistransform::hamming(int windowLength, float* buffer) {
for (int i = 0; i < windowLength; i++) {
buffer[i] = 0.54 - (0.46 * cos(2 * PI * (i / ((windowLength - 1) * 1.0))));
}
}
/*
Signal in : x[0] to x[signalLength - 1]
realpart : fft_real[0] to fft_real[N/2 -1]
imagpart : imagpart[0] to imagpart[N/2 -1]
*/
void* analysistransform::STFT(float* signal, float* realpart, float* imagpart) {
double* data;
fftw_complex* fft_result;
fftw_plan plan_forward, plan_backward;
int i;
data = (double*)fftw_malloc(sizeof(double) * this->windowsize);
fft_result = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * this->windowsize);
int outputcounter = 0;
plan_forward = fftw_plan_dft_r2c_1d(this->windowsize, data, fft_result, FFTW_ESTIMATE);
// Create a hamming window of appropriate length
float* window = (float*)malloc(sizeof(float) * this->windowsize);
hamming(this->windowsize, window);
int chunkPosition = 0;
int readIndex;
// Should we stop reading in chunks?
int bStop = 0;
// Process each chunk of the signal
while (chunkPosition < this->signallength && !bStop) {
// Copy the chunk into our buffer
for (i = 0; i < this->windowsize; i++) {
readIndex = chunkPosition + i;
if (readIndex < this->signallength) {
// Note the windowing!
data[i] = signal[readIndex] * window[i];
}
else {
// we have read beyond the signal, so zero-pad it!
data[i] = 0.0;
bStop = 1;
}
}
// Perform the FFT on our chunk
fftw_execute(plan_forward);
// Copy the first (windowSize/2 + 1) data points into your spectrogram.
// We do this because the FFT output is mirrored about the nyquist
// frequency, so the second half of the data is redundant. This is how
// Matlab's spectrogram routine works.
for (i = 0; i < this->windowsize / 2; i++) {
*(realpart + outputcounter) = fft_result[i][0];
*(imagpart + outputcounter) = fft_result[i][1];
outputcounter += this->nofmics;
}
chunkPosition += this->overlap;
} // Excuse the formatting, the while ends here.
fftw_destroy_plan(plan_forward);
fftw_free(data);
fftw_free(fft_result);
free(window);
return 0;
}
#pragma once
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
#include <complex>
#include "fftw3.h"
using namespace std;
class analysistransform
{
public:
analysistransform();
analysistransform(int windowsize, int signallength, int hopsize,int nofmics);
void* STFT(float* signal, float* realpart, float* imagpart);
private:
void hamming(int windowLength, float* buffer);
std::complex <float>* outputsignal;
int signallength;
int windowsize;
int overlap;
int nofmics;
};
AM_CPPFLAGS = -I $(top_srcdir)
AM_CFLAGS = $(STACK_ALIGN_CFLAGS)
EXTRA_DIST = f03api.sh genf03.pl fftw3.f03.in
include_HEADERS = fftw3.h fftw3.f fftw3l.f03 fftw3q.f03
nodist_include_HEADERS = fftw3.f03
noinst_LTLIBRARIES = libapi.la
libapi_la_SOURCES = apiplan.c configure.c execute-dft-c2r.c \
execute-dft-r2c.c execute-dft.c execute-r2r.c execute-split-dft-c2r.c \
execute-split-dft-r2c.c execute-split-dft.c execute.c \
export-wisdom-to-file.c export-wisdom-to-string.c export-wisdom.c \
f77api.c flops.c forget-wisdom.c import-system-wisdom.c \
import-wisdom-from-file.c import-wisdom-from-string.c import-wisdom.c \
malloc.c map-r2r-kind.c mapflags.c mkprinter-file.c mkprinter-str.c \
mktensor-iodims.c mktensor-rowmajor.c plan-dft-1d.c plan-dft-2d.c \
plan-dft-3d.c plan-dft-c2r-1d.c plan-dft-c2r-2d.c plan-dft-c2r-3d.c \
plan-dft-c2r.c plan-dft-r2c-1d.c plan-dft-r2c-2d.c plan-dft-r2c-3d.c \
plan-dft-r2c.c plan-dft.c plan-guru-dft-c2r.c plan-guru-dft-r2c.c \
plan-guru-dft.c plan-guru-r2r.c plan-guru-split-dft-c2r.c \
plan-guru-split-dft-r2c.c plan-guru-split-dft.c plan-many-dft-c2r.c \
plan-many-dft-r2c.c plan-many-dft.c plan-many-r2r.c plan-r2r-1d.c \
plan-r2r-2d.c plan-r2r-3d.c plan-r2r.c print-plan.c rdft2-pad.c \
the-planner.c version.c api.h f77funcs.h fftw3.h x77.h guru.h \
guru64.h mktensor-iodims.h plan-guru-dft-c2r.h plan-guru-dft-r2c.h \
plan-guru-dft.h plan-guru-r2r.h plan-guru-split-dft-c2r.h \
plan-guru-split-dft-r2c.h plan-guru-split-dft.h plan-guru64-dft-c2r.c \
plan-guru64-dft-r2c.c plan-guru64-dft.c plan-guru64-r2r.c \
plan-guru64-split-dft-c2r.c plan-guru64-split-dft-r2c.c \
plan-guru64-split-dft.c mktensor-iodims64.c
BUILT_SOURCES = fftw3.f fftw3.f03.in fftw3.f03 fftw3l.f03 fftw3q.f03
CLEANFILES = fftw3.f03
fftw3.f03: fftw3.f03.in
(echo "! Generated automatically. DO NOT EDIT!"; echo; \
echo " integer, parameter :: C_FFTW_R2R_KIND = @C_FFTW_R2R_KIND@"; \
grep -v "Generated automatically" $(srcdir)/fftw3.f03.in) > $@
if MAINTAINER_MODE
# convert constants to F77 PARAMETER statements
fftw3.f: fftw3.h
rm -f $@
perl -pe 's/([A-Z0-9_]+)=([+-]?[0-9]+)/\n INTEGER \1\n PARAMETER (\1=\2)\n/g' $< |egrep 'PARAMETER|INTEGER' > $@
perl -pe 's/#define +([A-Z0-9_]+) +\(([+-]?[0-9]+)U?\)/\n INTEGER \1\n PARAMETER (\1=\2)\n/g' $< |egrep 'PARAMETER|INTEGER' >> $@
perl -pe 'if (/#define +([A-Z0-9_]+) +\(([0-9]+)U? *<< *([0-9]+)\)/) { print "\n INTEGER $$1\n PARAMETER ($$1=",$$2 << $$3,")\n"; }' $< |egrep 'PARAMETER|INTEGER' >> $@
fftw3.f03.in: fftw3.h f03api.sh genf03.pl
sh $(srcdir)/f03api.sh d f > $@
fftw3l.f03: fftw3.h f03api.sh genf03.pl
sh $(srcdir)/f03api.sh l | grep -v parameter > $@
fftw3q.f03: fftw3.h f03api.sh genf03.pl
sh $(srcdir)/f03api.sh q | grep -v parameter > $@
endif # MAINTAINER_MODE
This diff is collapsed.
/*
* 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
*
*/
/* internal API definitions */
#ifndef __API_H__
#define __API_H__
#ifndef CALLING_FFTW /* defined in hook.c, when calling internal functions */
# define COMPILING_FFTW /* used for DLL symbol exporting in fftw3.h */
#endif
/* When compiling with GNU libtool on Windows, DLL_EXPORT is #defined
for compiling the shared-library code. In this case, we'll #define
FFTW_DLL to add dllexport attributes to the specified functions in
fftw3.h.
If we don't specify dllexport explicitly, then libtool
automatically exports all symbols. However, if we specify
dllexport explicitly for any functions, then libtool apparently
doesn't do any automatic exporting. (Not documented, grrr, but
this is the observed behavior with libtool 1.5.8.) Thus, using
this forces us to correctly dllexport every exported symbol, or
linking bench.exe will fail. This has the advantage of forcing
us to mark things correctly, which is necessary for other compilers
(such as MS VC++). */
#ifdef DLL_EXPORT
# define FFTW_DLL
#endif
/* just in case: force <fftw3.h> not to use C99 complex numbers
(we need this for IBM xlc because _Complex_I is treated specially
and is defined even if <complex.h> is not included) */
#define FFTW_NO_Complex
#include "api/fftw3.h"
#include "kernel/ifftw.h"
#include "rdft/rdft.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/* the API ``plan'' contains both the kernel plan and problem */
struct X(plan_s) {
plan *pln;
problem *prb;
int sign;
};
/* shorthand */
typedef struct X(plan_s) apiplan;
/* complex type for internal use */
typedef R C[2];
#define EXTRACT_REIM(sign, c, r, i) X(extract_reim)(sign, (c)[0], r, i)
#define TAINT_UNALIGNED(p, flg) TAINT(p, ((flg) & FFTW_UNALIGNED) != 0)
tensor *X(mktensor_rowmajor)(int rnk, const int *n,
const int *niphys, const int *nophys,
int is, int os);
tensor *X(mktensor_iodims)(int rank, const X(iodim) *dims, int is, int os);
tensor *X(mktensor_iodims64)(int rank, const X(iodim64) *dims, int is, int os);
const int *X(rdft2_pad)(int rnk, const int *n, const int *nembed,
int inplace, int cmplx, int **nfree);
int X(many_kosherp)(int rnk, const int *n, int howmany);
int X(guru_kosherp)(int rank, const X(iodim) *dims,
int howmany_rank, const X(iodim) *howmany_dims);
int X(guru64_kosherp)(int rank, const X(iodim64) *dims,
int howmany_rank, const X(iodim64) *howmany_dims);
/* Note: FFTW_EXTERN is used for "internal" functions used in tests/hook.c */
FFTW_EXTERN printer *X(mkprinter_file)(FILE *f);
printer *X(mkprinter_cnt)(size_t *cnt);
printer *X(mkprinter_str)(char *s);
FFTW_EXTERN planner *X(the_planner)(void);
void X(configure_planner)(planner *plnr);
void X(mapflags)(planner *, unsigned);
apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb);
rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind);
typedef void (*planner_hook_t)(void);
void X(set_planner_hooks)(planner_hook_t before, planner_hook_t after);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* __API_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"
static planner_hook_t before_planner_hook = 0, after_planner_hook = 0;
void X(set_planner_hooks)(planner_hook_t before, planner_hook_t after)
{
before_planner_hook = before;
after_planner_hook = after;
}
static plan *mkplan0(planner *plnr, unsigned flags,
const problem *prb, unsigned hash_info,
wisdom_state_t wisdom_state)
{
/* map API flags into FFTW flags */
X(mapflags)(plnr, flags);
plnr->flags.hash_info = hash_info;
plnr->wisdom_state = wisdom_state;
/* create plan */
return plnr->adt->mkplan(plnr, prb);
}
static unsigned force_estimator(unsigned flags)
{
flags &= ~(FFTW_MEASURE | FFTW_PATIENT | FFTW_EXHAUSTIVE);
return (flags | FFTW_ESTIMATE);
}
static plan *mkplan(planner *plnr, unsigned flags,
const problem *prb, unsigned hash_info)
{
plan *pln;
pln = mkplan0(plnr, flags, prb, hash_info, WISDOM_NORMAL);
if (plnr->wisdom_state == WISDOM_NORMAL && !pln) {
/* maybe the planner failed because of inconsistent wisdom;
plan again ignoring infeasible wisdom */
pln = mkplan0(plnr, force_estimator(flags), prb,
hash_info, WISDOM_IGNORE_INFEASIBLE);
}
if (plnr->wisdom_state == WISDOM_IS_BOGUS) {
/* if the planner detected a wisdom inconsistency,
forget all wisdom and plan again */
plnr->adt->forget(plnr, FORGET_EVERYTHING);
A(!pln);
pln = mkplan0(plnr, flags, prb, hash_info, WISDOM_NORMAL);
if (plnr->wisdom_state == WISDOM_IS_BOGUS) {
/* if it still fails, plan without wisdom */
plnr->adt->forget(plnr, FORGET_EVERYTHING);
A(!pln);
pln = mkplan0(plnr, force_estimator(flags),
prb, hash_info, WISDOM_IGNORE_ALL);
}
}
return pln;
}
apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb)
{
apiplan *p = 0;
plan *pln;
unsigned flags_used_for_planning;
planner *plnr;
static const unsigned int pats[] = {FFTW_ESTIMATE, FFTW_MEASURE,
FFTW_PATIENT, FFTW_EXHAUSTIVE};
int pat, pat_max;
double pcost = 0;
if (before_planner_hook)
before_planner_hook();
plnr = X(the_planner)();
if (flags & FFTW_WISDOM_ONLY) {
/* Special mode that returns a plan only if wisdom is present,
and returns 0 otherwise. This is now documented in the manual,
as a way to detect whether wisdom is available for a problem. */
flags_used_for_planning = flags;
pln = mkplan0(plnr, flags, prb, 0, WISDOM_ONLY);
} else {
pat_max = flags & FFTW_ESTIMATE ? 0 :
(flags & FFTW_EXHAUSTIVE ? 3 :
(flags & FFTW_PATIENT ? 2 : 1));
pat = plnr->timelimit >= 0 ? 0 : pat_max;
flags &= ~(FFTW_ESTIMATE | FFTW_MEASURE |
FFTW_PATIENT | FFTW_EXHAUSTIVE);
plnr->start_time = X(get_crude_time)();
/* plan at incrementally increasing patience until we run
out of time */
for (pln = 0, flags_used_for_planning = 0; pat <= pat_max; ++pat) {
plan *pln1;
unsigned tmpflags = flags | pats[pat];
pln1 = mkplan(plnr, tmpflags, prb, 0u);
if (!pln1) {
/* don't bother continuing if planner failed or timed out */
A(!pln || plnr->timed_out);
break;
}
X(plan_destroy_internal)(pln);
pln = pln1;
flags_used_for_planning = tmpflags;
pcost = pln->pcost;
}
}
if (pln) {
/* build apiplan */
p = (apiplan *) MALLOC(sizeof(apiplan), PLANS);
p->prb = prb;
p->sign = sign; /* cache for execute_dft */
/* re-create plan from wisdom, adding blessing */
p->pln = mkplan(plnr, flags_used_for_planning, prb, BLESSING);
/* record pcost from most recent measurement for use in X(cost) */
p->pln->pcost = pcost;
if (sizeof(trigreal) > sizeof(R)) {
/* this is probably faster, and we have enough trigreal
bits to maintain accuracy */
X(plan_awake)(p->pln, AWAKE_SQRTN_TABLE);
} else {
/* more accurate */
X(plan_awake)(p->pln, AWAKE_SINCOS);
}
/* we don't use pln for p->pln, above, since by re-creating the
plan we might use more patient wisdom from a timed-out mkplan */
X(plan_destroy_internal)(pln);
} else
X(problem_destroy)(prb);
/* discard all information not necessary to reconstruct the plan */
plnr->adt->forget(plnr, FORGET_ACCURSED);
#ifdef FFTW_RANDOM_ESTIMATOR
X(random_estimate_seed)++; /* subsequent "random" plans are distinct */
#endif
if (after_planner_hook)
after_planner_hook();
return p;
}
void X(destroy_plan)(X(plan) p)
{
if (p) {
if (before_planner_hook)
before_planner_hook();
X(plan_awake)(p->pln, SLEEPY);
X(plan_destroy_internal)(p->pln);
X(problem_destroy)(p->prb);
X(ifree)(p);
if (after_planner_hook)
after_planner_hook();
}
}
int X(alignment_of)(R *p)
{
return X(ialignment_of(p));
}
/*
* 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"
#include "rdft/rdft.h"
#include "reodft/reodft.h"
void X(configure_planner)(planner *plnr)
{
X(dft_conf_standard)(plnr);
X(rdft_conf_standard)(plnr);
X(reodft_conf_standard)(plnr);
}
/*
* 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"
/* guru interface: requires care in alignment, r - i, etcetera. */
void X(execute_dft_c2r)(const X(plan) p, C *in, R *out)
{
plan_rdft2 *pln = (plan_rdft2 *) p->pln;
problem_rdft2 *prb = (problem_rdft2 *) p->prb;
pln->apply((plan *) pln, out, out + (prb->r1 - prb->r0), in[0], in[0]+1);
}
/*
* 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"
/* guru interface: requires care in alignment, r - i, etcetera. */
void X(execute_dft_r2c)(const X(plan) p, R *in, C *out)
{
plan_rdft2 *pln = (plan_rdft2 *) p->pln;
problem_rdft2 *prb = (problem_rdft2 *) p->prb;
pln->apply((plan *) pln, in, in + (prb->r1 - prb->r0), out[0], out[0]+1);
}
/*
* 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"
/* guru interface: requires care in alignment etcetera. */
void X(execute_dft)(const X(plan) p, C *in, C *out)
{
plan_dft *pln = (plan_dft *) p->pln;
if (p->sign == FFT_SIGN)
pln->apply((plan *) pln, in[0], in[0]+1, out[0], out[0]+1);
else
pln->apply((plan *) pln, in[0]+1, in[0], out[0]+1, out[0]);
}
/*
* 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"
/* guru interface: requires care in alignment, etcetera. */
void X(execute_r2r)(const X(plan) p, R *in, R *out)
{
plan_rdft *pln = (plan_rdft *) p->pln;
pln->apply((plan *) pln, in, out);
}
/*
* 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"
/* guru interface: requires care in alignment, r - i, etcetera. */
void X(execute_split_dft_c2r)(const X(plan) p, R *ri, R *ii, R *out)
{
plan_rdft2 *pln = (plan_rdft2 *) p->pln;
problem_rdft2 *prb = (problem_rdft2 *) p->prb;
pln->apply((plan *) pln, out, out + (prb->r1 - prb->r0), ri, ii);
}
/*
* 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"
/* guru interface: requires care in alignment, r - i, etcetera. */
void X(execute_split_dft_r2c)(const X(plan) p, R *in, R *ro, R *io)
{
plan_rdft2 *pln = (plan_rdft2 *) p->pln;
problem_rdft2 *prb = (problem_rdft2 *) p->prb;
pln->apply((plan *) pln, in, in + (prb->r1 - prb->r0), ro, io);
}
/*
* 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"
/* guru interface: requires care in alignment, r - i, etcetera. */
void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, R *ro, R *io)
{
plan_dft *pln = (plan_dft *) p->pln;
pln->apply((plan *) pln, ri, ii, ro, io);
}
/*
* 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"
void X(execute)(const X(plan) p)
{
plan *pln = p->pln;
pln->adt->solve(pln, p->prb);
}
/*
* 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"
void X(export_wisdom_to_file)(FILE *output_file)
{
printer *p = X(mkprinter_file)(output_file);
planner *plnr = X(the_planner)();
plnr->adt->exprt(plnr, p);
X(printer_destroy)(p);
}
int X(export_wisdom_to_filename)(const char *filename)
{
FILE *f = fopen(filename, "w");
int ret;
if (!f) return 0; /* error opening file */
X(export_wisdom_to_file)(f);
ret = !ferror(f);
if (fclose(f)) ret = 0; /* error closing file */
return ret;
}
/*
* 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"
char *X(export_wisdom_to_string)(void)
{
printer *p;
planner *plnr = X(the_planner)();
size_t cnt;
char *s;
p = X(mkprinter_cnt)(&cnt);
plnr->adt->exprt(plnr, p);
X(printer_destroy)(p);
s = (char *) malloc(sizeof(char) * (cnt + 1));
if (s) {
p = X(mkprinter_str)(s);
plnr->adt->exprt(plnr, p);
X(printer_destroy)(p);
}
return s;
}
/*
* 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;
void (*write_char)(char c, void *);
void *data;
} P;
static void putchr_generic(printer * p_, char c)
{
P *p = (P *) p_;
(p->write_char)(c, p->data);
}
void X(export_wisdom)(void (*write_char)(char c, void *), void *data)
{
P *p = (P *) X(mkprinter)(sizeof(P), putchr_generic, 0);
planner *plnr = X(the_planner)();
p->write_char = write_char;
p->data = data;
plnr->adt->exprt(plnr, (printer *) p);
X(printer_destroy)((printer *) p);
}
#! /bin/sh
# Script to generate Fortran 2003 interface declarations for FFTW from
# the fftw3.h header file.
# This is designed so that the Fortran caller can do:
# use, intrinsic :: iso_c_binding
# implicit none
# include 'fftw3.f03'
# and then call the C FFTW functions directly, with type checking.
echo "! Generated automatically. DO NOT EDIT!"
echo
# C_FFTW_R2R_KIND is determined by configure and inserted by the Makefile
# echo " integer, parameter :: C_FFTW_R2R_KIND = @C_FFTW_R2R_KIND@"
# Extract constants
perl -pe 's/([A-Z0-9_]+)=([+-]?[0-9]+)/\n integer\(C_INT\), parameter :: \1 = \2\n/g' < fftw3.h | grep 'integer(C_INT)'
perl -pe 's/#define +([A-Z0-9_]+) +\(([+-]?[0-9]+)U?\)/\n integer\(C_INT\), parameter :: \1 = \2\n/g' < fftw3.h | grep 'integer(C_INT)'
perl -pe 'if (/#define +([A-Z0-9_]+) +\(([0-9]+)U? *<< *([0-9]+)\)/) { print "\n integer\(C_INT\), parameter :: $1 = ",$2 << $3,"\n"; }' < fftw3.h | grep 'integer(C_INT)'
# Extract function declarations
for p in $*; do
if test "$p" = "d"; then p=""; fi
echo
cat <<EOF
type, bind(C) :: fftw${p}_iodim
integer(C_INT) n, is, os
end type fftw${p}_iodim
type, bind(C) :: fftw${p}_iodim64
integer(C_INTPTR_T) n, is, os
end type fftw${p}_iodim64
EOF
echo
echo " interface"
gcc -D__GNUC__=5 -D__i386__ -E fftw3.h |grep "fftw${p}_plan_dft" |tr ';' '\n' | grep -v "fftw${p}_execute(" | perl genf03.pl
echo " end interface"
done
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