Commit 1f5c547e authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP][FEATURE]: provide test program

parent e35d1807
......@@ -141,7 +141,7 @@ OBJFILES=pairs_adapter.o \
triples.o \
write_name_series.o
croposp: \
croposptest croposp: \
%: %.o $(OBJFILES)
$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
-lpsdxx -lfourierxx $(LIBTSIOXX) -lfftw3
......
/*! \file croposptest.cc
* \brief a program just to test components of croposp
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 07/02/2019
*
* a program just to test components of croposp
*
* Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 07/02/2019 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define CROPOSPTEST_VERSION \
"CROPOSPTEST V1.0 a program just to test components of croposp"
#include "croposp.h"
#include <iostream>
#include <tfxx/commandline.h>
#include <tfxx/misc.h>
using std::cout;
using std::cerr;
using std::endl;
struct Options {
bool pairs, verbose;
unsigned int npairs;
}; // struct Options
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
CROPOSPTEST_VERSION "\n"
"usage: croposptest [-v] [-pairs n]" "\n"
" or: croposptest --help|-h" "\n"
};
// define full help text
char help_text[]=
{
" "
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: test pairs
{"pairs",arg_yes,"4"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << 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;
exit(0);
}
Options opt;
opt.verbose=cmdline.optset(1);
opt.pairs=cmdline.optset(2);
opt.npairs=cmdline.int_arg(2);
// ----------------------------------------------------------------------
if (opt.pairs)
{
croposp::Pairs pairs(opt.npairs);
cout << TFXX_value(opt.npairs) << " "
<< TFXX_value(pairs.size()) << " "
<< TFXX_value(pairs.pairs()) << endl;
cout << endl << "unique combinations" << endl;
for (unsigned int k=0; k<(opt.npairs-1); ++k)
{
for (unsigned int j=k+1; j<opt.npairs; ++j)
{
cout << TFXX_value(k) << " " << TFXX_value(j) << " "
<< TFXX_value(pairs(k,j)) << endl;
}
}
cout << endl << "all combinations" << endl;
for (unsigned int k=0; k<opt.npairs; ++k)
{
for (unsigned int j=0; j<opt.npairs; ++j)
{
if (k!=j)
{
cout << TFXX_value(k) << " " << TFXX_value(j) << " "
<< TFXX_value(pairs(k,j));
if (pairs.swap(k,j))
{
cout << " swap";
}
cout << endl;
}
}
}
} // if opt.pairs
}
/* ----- END OF croposptest.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