Commit b3f1b7d8 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

just activated the C++ fftw testing code

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
result: library produces segmentation fault


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libenv201008
SVN Revision: 3199
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 1d3676dc
......@@ -233,7 +233,8 @@ cfftwtest: cfftwtest.c
$(CC) -o $@ $< -ldrfftw -ldfftw -lm
cxxfftwtest: cxxfftwtest.cc
$(CXX) -o $@ $< -ltfxx -ldrfftw -ldfftw -lm $(CPPFLAGS) $(LDFLAGS)
$(CXX) -o $@ $< -ltfxx -lfourierxx -laff -lfftw3 -lm \
$(CPPFLAGS) $(LDFLAGS)
#======================================================================
# documentation part
......
......@@ -13,23 +13,62 @@
*
* REVISIONS and CHANGES
* - 12/09/2007 V1.0 Thomas Forbriger
* - 07/10/2010 V1.1 just activated this code
*
* this currently is an unborn test program - no way to migrate...
*
* ============================================================================
*/
#define CXXFFTWTEST_VERSION \
"CXXFFTWTEST V1.0 a small test program for fftw when called from C++"
"CXXFFTWTEST V1.1 a small test program for fftw when called from C++"
#define CXXFFTWTEST_CVSID \
"$Id$"
#include <iostream>
#include <tfxx/commandline.h>
#include <fourier/fftwaff.h>
using std::cout;
using std::cerr;
using std::endl;
using namespace fourier::fft;
typedef DRFFTWAFF::Tseries Tseries;
typedef DRFFTWAFF::Tspectrum Tspectrum;
void fill(Tseries& a, int n, int m)
{
a=Tseries(n);
int k;
double f1, f2;
f1=3.141592653589/n;
f2=f1*m*2;
/* fill input array */
for (k=0; k<n; ++k)
{
a(k)=sin(k*f1)*sin(k*f1)*sin(k*f2);
}
}
/*----------------------------------------------------------------------*/
void process(int n, int m)
{
Tseries a(n);
fill(a, n, m);
DRFFTWAFF fftprocessor(n);
Tspectrum b=fftprocessor(a);
Tseries c=fftprocessor(b);
for (int i=0; i<n ; ++i)
{
cout << i << " " << a(i) << " " << c(i) << endl;
}
for (int i=0; i<b.size() ; ++i)
{
cout << i << " " << b(i) << endl;
}
}
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
{
......@@ -59,7 +98,7 @@ int main(int iargc, char* argv[])
};
// no arguments? print usage...
if (iargc<2)
if (iargc<1)
{
cerr << usage_text << endl;
exit(0);
......@@ -76,6 +115,7 @@ int main(int iargc, char* argv[])
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
......@@ -97,6 +137,10 @@ int main(int iargc, char* argv[])
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
process(50, 5);
process(50, 2);
}
/* ----- END OF cxxfftwtest.cc ----- */
Markdown is supported
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