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

randomseries [NEW][WP]: start new program randomseries

parent bdb5ad13
......@@ -35,7 +35,8 @@
PROGRAMS=dispfield kette planefield coupledoscillators \
dispfieldx lamb lambx modeinterference \
siggen tesiff teswf hamres siggenx phasedsignals
siggen tesiff teswf hamres siggenx phasedsignals \
randomseries
# gez does not compile correctly
.PHONY: all
......@@ -109,6 +110,10 @@ siggenx: %x: %.o
modeinterference: modeinterference.o
$(FC) -o $@ $< -ltf $(TF_LINK_PGPLOT) $(LDFLAGS) -L$(LOCLIBDIR)
randomseries: randomseries.o
$(CXX) -o $@ $< -ltfxx -ldatrwxx -lsffxx -lgsexx -ltime++ -laff \
-lgsl -lgslcblas $(LDFLAGS) -L$(LOCLIBDIR)
.PHONY: list-libraries
list-libraries:
grep ' -l' Makefile | tr ' ' '\n' | egrep '^-l' |sort | uniq
......
/*! \file randomseries.cc
* \brief provide time series of incoherent random numbers
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 31/10/2019
*
* provide time series of incoherent random numbers
*
* Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 31/10/2019 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define RANDOMSERIES_VERSION \
"RANDOMSERIES V1.0 provide time series of incoherent random numbers"
#include <iostream>
#include <tfxx/commandline.h>
#include <tfxx/seitosh.h>
#include <datrwxx/writeany.h>
using std::cout;
using std::cerr;
using std::endl;
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
RANDOMSERIES_VERSION "\n"
"usage: randomseries filename [-v] [-t type] [-o]" "\n"
" [-nseries n] [-nsamples n]" "\n"
" [-std v] [-mean v] [-seed n]" "\n"
" or: randomseries --help|-h" "\n"
" or: randomseries --help|-h" "\n"
" or: randomseries --xhelp[=type]\n"
};
// define full help text
char help_text[]=
{
"-help print description\n"
"-xhelp[=type] print detailed information regarding file formats\n"
" if 'type' is specified, just print text for file format 'type'\n"
"\n"
"filename name of output file\n"
"-v be verbose\n"
"-o overwrite existing output file\n"
"-t type select output file type\n"
"-nseries n produce 'n' time series\n"
"-nsamples n produce 'n' samples per series\n"
"-seed n initialize random number generator with 'n'\n"
"-std v set standard deviation to 'v'\n"
"-mean v set mean value of samples to 'v'\n"
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: overwrite existing output file
{"o",arg_no,"-"},
// 3: select output file type
{"t",arg_yes,"sff"},
// 4: select output file type
{"nseries",arg_yes,"1"},
// 5: select output file type
{"nsamples",arg_yes,"10000"},
// 6: select output file type
{"seed",arg_yes,"1"},
// 7: select output file type
{"std",arg_yes,"1."},
// 8: select output file type
{"mean",arg_yes,"0."},
// 9: output file format
{"xhelp",arg_opt,"all"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << endl;
cerr << endl << tfxx::seitosh::repository_reference << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
cerr << endl;
cerr << "supported output data file types:" << endl;
datrw::supported_output_data_types(cerr);
cerr << endl << tfxx::seitosh::repository_reference << endl;
exit(0);
}
// help on file format details requested?
if (cmdline.optset(9))
{
cerr << usage_text << endl;
cerr << endl;
if (cmdline.string_arg(9) == "all")
{
datrw::online_help(cerr);
}
else
{
datrw::online_help(cmdline.string_arg(9), cerr);
}
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; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
}
/* ----- END OF randomseries.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