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

programs run successfully

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.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libenv201008
SVN Revision: 3200
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b3f1b7d8
......@@ -232,7 +232,7 @@ install-include: $(INSTHEADER)
cfftwtest: cfftwtest.c
$(CC) -o $@ $< -ldrfftw -ldfftw -lm
cxxfftwtest: cxxfftwtest.cc
cxxfftwtest: cxxfftwtest.cc libfourierxx.a
$(CXX) -o $@ $< -ltfxx -lfourierxx -laff -lfftw3 -lm \
$(CPPFLAGS) $(LDFLAGS)
......
......@@ -25,6 +25,7 @@
#include <iostream>
#include <tfxx/commandline.h>
#include <fourier/fftwaff.h>
#include <fourier/error.h>
using std::cout;
using std::cerr;
......@@ -44,29 +45,52 @@ void fill(Tseries& a, int n, int m)
/* fill input array */
for (k=0; k<n; ++k)
{
a(k)=sin(k*f1)*sin(k*f1)*sin(k*f2);
a(a.f()+k)=sin(k*f1)*sin(k*f1)*sin(k*f2);
}
cout << "array filled" << endl;
}
/*----------------------------------------------------------------------*/
void process(int n, int m)
void process(int n, int m, const bool& verbose, const bool& debug)
{
cout << "test with " << n << " samples" << endl;
cout << "test with frequency " << m << endl;
Tseries a(n);
fill(a, n, m);
if (verbose) { cout << "array is filled " << endl; }
DRFFTWAFF fftprocessor(n);
Tspectrum b=fftprocessor(a);
Tseries c=fftprocessor(b);
if (verbose) { cout << "processor is created " << endl; }
Tspectrum b=fftprocessor(a, debug);
if (verbose) { cout << "forward transform is finished" << endl; }
Tseries c=fftprocessor(b, debug);
if (verbose) { cout << "backward transform is finished" << endl; }
cout << "time series:" << endl;
for (int i=0; i<n ; ++i)
{
cout << i << " " << a(i) << " " << c(i) << endl;
cout.width(4);
cout << i << " ";
cout.width(15);
cout.precision(6);
cout << a(i) << " ";
cout.width(15);
cout.precision(6);
cout << c(i) << endl;
}
cout << "power spectrum:" << endl;
for (int i=0; i<b.size() ; ++i)
{
cout << i << " " << b(i) << endl;
cout.width(4);
cout << i << " " << abs(b(i)*conj(b(i))) << endl;
}
}
/*----------------------------------------------------------------------*/
struct Options {
bool verbose, debug;
int n, m;
}; // Options
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
......@@ -94,6 +118,12 @@ int main(int iargc, char* argv[])
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: debug mode
{"DEBUG",arg_no,"-"},
// 3: number of samples
{"n",arg_yes,"50"},
// 4: frequency
{"m",arg_yes,"3"},
{NULL}
};
......@@ -115,32 +145,16 @@ int main(int iargc, char* argv[])
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
Options opt;
opt.verbose=cmdline.optset(1);
opt.debug=cmdline.optset(2);
opt.n=cmdline.int_arg(3);
opt.m=cmdline.int_arg(4);
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
FOURIER_assert(opt.n>0, "illegal number of samples")
FOURIER_assert(opt.m>0, "illegal frequency")
process(50, 5);
process(50, 2);
process(opt.n, opt.m, opt.verbose, opt.debug);
}
/* ----- END OF cxxfftwtest.cc ----- */
......@@ -134,7 +134,7 @@ namespace fourier {
"could not create series array!")
Mseries=Tseries(Tseries::Trepresentation(Mseriesarray, Msize));
Mspectrumarray = (fftw_complex *)
fftw_malloc(sizeof(double)*this->ssize());
fftw_malloc(sizeof(fftw_complex)*this->ssize());
FOURIER_assert(Mspectrumarray!=0,
"Error (DRFFTWAFF::create_plan_forward): "
"could not create spectrum array!")
......
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