Commit d58dc4e4 authored by thomas.forbriger's avatar thomas.forbriger

libpsdxx [FEATURE]: add test mode -tab to testpsdxx

The log_frequency scale cannot contain exactly the requested number of
values for the lowest decade. This test mode allows to check whether the
higher value decades are affected by this. They are not.

The reason for not producing the requested number of value is, that the
smallest frequency on the logarithmic scale than would be smaller than
the smallest value on the linear scale. So log_frequency lets the
smallest value of the logarithmic scale be as small as the smallest
value of the linear scale, but not smaller.
parent df9e28bd
......@@ -16,7 +16,7 @@
* ============================================================================
*/
#define TESTPSDXX_VERSION \
"TESTPSDXX V1.0 test library functions"
"TESTPSDXX V1.1 test library functions"
#include <iostream>
#include <tfxx/commandline.h>
......@@ -31,8 +31,9 @@ using std::endl;
struct Options
{
bool verbose, logfrequency, logindex, logtaper;
int taperindex;
bool verbose, logfrequency, logindex, logtaper, logfreqtable;
int taperindex, nsamples, nperdec;
double fmin;
}; // Options
/* ====================================================================== */
......@@ -57,6 +58,7 @@ int main(int iargc, char* argv[])
{
TESTPSDXX_VERSION "\n"
"usage: testpsdxx [-lf] [-li] [-lt [i]]" "\n"
" [-tab] [-fmin f] [-nsamples n] [-nperdec n]\n"
" or: testpsdxx --help|-h" "\n"
};
......@@ -67,6 +69,11 @@ int main(int iargc, char* argv[])
"-li test function class LogIndex\n"
"-lt [i] test function class LogTaper, center taper on\n"
" frequency with index i on logarithmic scale\n"
"-tab test function log_frequency with adjustable parameters\n"
"\n"
"-fmin f set frequency interval on linear scale to f\n"
"-nsamples n set number of samples to n\n"
"-nperdec n set number of values per decade to n\n"
};
// define commandline options
......@@ -83,6 +90,14 @@ int main(int iargc, char* argv[])
{"li",arg_no,"-"},
// 4: log taper
{"lt",arg_opt,"5"},
// 5: log scale with adjusted parameters
{"tab",arg_no,"-"},
// 6: smallest frequency
{"fmin",arg_yes,"0.1"},
// 7: number of samples
{"nsamples",arg_yes,"10000"},
// 8: number of values per decade
{"nperdec",arg_yes,"5"},
{NULL}
};
......@@ -110,6 +125,10 @@ int main(int iargc, char* argv[])
opt.logindex=cmdline.optset(3);
opt.logtaper=cmdline.optset(4);
opt.taperindex=cmdline.int_arg(4);
opt.logfreqtable=cmdline.optset(5);
opt.fmin=cmdline.double_arg(6);
opt.nsamples=cmdline.int_arg(7);
opt.nperdec=cmdline.int_arg(8);
if (opt.logfrequency)
{
......@@ -166,6 +185,23 @@ int main(int iargc, char* argv[])
}
cerr << PSDXX_value( logt.sum() ) << endl;
} // if (opt.logtaper)
/* ---------------------------------------------------------------------- */
if (opt.logfreqtable)
{
cout << "test log_frequency with adjustable parameters" << endl;
cout << " " << PSDXX_value( opt.fmin ) << endl;
cout << " " << PSDXX_value( opt.nsamples ) << endl;
cout << " " << PSDXX_value( opt.nperdec ) << endl;
CODE( psd::TDseries ls1=psd::log_frequency(opt.fmin,opt.nsamples,opt.nperdec) );
DUMP( ls1 );
for (int i=ls1.f(); i<=ls1.l(); ++i)
{
cout << "i=" << i << " f=" << ls1(i) << " nu= " <<
std::log(ls1(i)/ls1(ls1.f()))/std::log(10.) << endl;
}
} // if (opt.logfreqtable)
}
/* ----- END OF testpsdxx.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