AFF --- A container for numbers (array) by Friederich and Forbriger.
tests/operatortest.cc

Here you can learn how to use operators with aff classes.

This test program gives an example of the usage of the following classes, functions, and preprocessor macros:

See also
tests/operatortest.cc
#define OPERATORTEST_VERSION \
"OPERATORTEST V1.1 test operator functions"
#include <iostream>
#include <complex>
#include <aff/array.h>
#include <aff/series.h>
#include <aff/dump.h>
#include <aff/subarray.h>
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*/
void section(const char* s, const char l='-')
{
cout << endl << s << endl;
const char* p=s;
while (*p) { cout << l; ++p; }
cout << endl;
}
/*======================================================================*/
int main(int iargc, char* argv[])
{
cout << OPERATORTEST_VERSION << endl;
section("Test array operators", '=');
section("Normal array with unary operator");
CODE(A=14.);
CODE(A+=500.);
section("Access through subarray");
CODE(Asub/=200);
section("binary operator");
CODE(B=A*5);
section("test implicit type conversion");
CODE(B=10.);
CODE(B*=0.2);
CODE(B*=4L);
CODE(B*=0xa0);
section("test advanced type conversion");
CODE(aff::Array<std::complex<double> > C(3,3);)
CODE(C=std::complex<double>(14.,2.);)
CODE(C*=0.2);
section("test binary operator with constant input");
section("mixed implicit operations");
CODE(dump_array((D*5.)-12L));
section("Test series operators", '=');
section("test scalar operators");
CODE(F=5.);
DUMP(F);
CODE(F/=25.);
DUMP(F);
section("test vector operators");
CODE(G=5.);
DUMP(G);
DUMP(F+G);
CODE(H=F+G);
DUMP(H);
CODE(H -= F);
DUMP(H);
DUMP((H *= G + 0.2) + 0.2);
DUMP(H);
DUMP(100+H);
DUMP(H+100);
CODE(const aff::Series<double> CH(H));
DUMP(CH+100);
DUMP(CH -= 10);
DUMP(CH);
}
/* ----- END OF operatortest.cc ----- */