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

operators work!

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/trunk
SVN Revision: 1481
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f7a546bf
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.45 2004-02-10 09:57:19 tforb Exp $
* $Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,7 +21,7 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.45 2004-02-10 09:57:19 tforb Exp $
$Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
\sa \ref page_project_status
......@@ -34,6 +34,7 @@
- started with operators:
arrayoperators.h, seriesoperators.h, and lib/operators.h
- introduced tests/operatortest.h
- basic operators work for aff::Array and aff::Series
- \b 07/02/2004 (thof)
- index limit set operations available through aff::Series
......@@ -204,7 +205,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.45 2004-02-10 09:57:19 tforb Exp $
$Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
\sa \ref page_changelog
......@@ -217,7 +218,7 @@
<TR><TD>libaff/README</TD>
<TD>has no code</TD><TD> </TD><TD>has no code</TD>
<TD>Explain Wolle's concept of multidimensional arrays.
The HOWTO page needs a revision and much more examples.
The HOWTO page needs a revision and many more examples.
</TD>
</TR>
<TR><TD>libaff/array.h</TD>
......@@ -230,6 +231,9 @@
<TR><TD>libaff/array_def.h</TD>
<TD>19/12/2002</TD><TD>20/12/2002</TD><TD>19/12/2002</TD><TD> </TD>
</TR>
<TR><TD>libaff/arrayoperators.h</TD>
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/binarray.h</TD>
<TD>8/12/02</TD><TD>20/12/2002</TD><TD> </TD><TD> </TD>
</TR>
......@@ -253,6 +257,9 @@
<TD>19/12/2003</TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/seriesoperators.h</TD>
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/shaper.h</TD>
<TD>12/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
......@@ -282,11 +289,14 @@
<TD>16/12/02</TD><TD>20/12/2002</TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/iteratable.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD>removed 10/02/2004</TD>
</TR>
<TR><TD>libaff/lib/linearshape.h</TD>
<TD>23/12/2003</TD><TD> </TD><TD>23/12/2003 </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/operators.h</TD>
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/range.h</TD>
<TD>13/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: operators.h,v 1.3 2004-02-10 11:45:28 tforb Exp $
* $Id: operators.h,v 1.4 2004-02-10 14:32:15 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
......@@ -48,9 +48,11 @@ namespace aff {
RETCONT operator OP(const INCONT& container, \
typename INCONT::Tconst_reference value) \
{ \
RETCONT retval; \
retval.copyin(container); \
retval OP ## = value; \
RETCONT retval(container.shape()); \
aff::Browser< typename INCONT::Tcontainer > i(container); \
aff::Iterator< typename RETCONT::Tcontainer > o(retval); \
while ( i.valid() && o. valid() ) \
{ (*o) = (*i) OP value; ++o; ++i; } \
return(retval); \
}
......@@ -70,16 +72,6 @@ namespace aff {
AFF_OPERATORS_THEBINOP( - )
#undef AFF_OPERATORS_THEBINOP
/*
#define AFF_OPERATORS_THEBINOP( OP ) \
AFF_OPERATORS_BINOP( AFF_OPERATORS_CONT , AFF_OPERATORS_CONT, OP )
AFF_OPERATORS_THEBINOP( + )
AFF_OPERATORS_THEBINOP( * )
AFF_OPERATORS_THEBINOP( / )
AFF_OPERATORS_THEBINOP( - )
#undef AFF_OPERATORS_THEBINOP
*/
#undef AFF_OPERATORS_UNOP
#undef AFF_OPERATORS_BINOP
#undef AFF_OPERATORS_CONSTCONT
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: operatortest.cc,v 1.2 2004-02-10 11:45:29 tforb Exp $
* $Id: operatortest.cc,v 1.3 2004-02-10 14:32:16 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
......@@ -19,18 +19,34 @@
#define OPERATORTEST_VERSION \
"OPERATORTEST V1.0 test operator functions"
#define OPERATORTEST_CVSID \
"$Id: operatortest.cc,v 1.2 2004-02-10 11:45:29 tforb Exp $"
"$Id: operatortest.cc,v 1.3 2004-02-10 14:32:16 tforb Exp $"
#include <iostream>
#include <complex>
#include <aff/array.h>
#include <aff/series.h>
#include <aff/dump.h>
#include <aff/arrayoperators.h>
#include <aff/seriesoperators.h>
#include <aff/subarray.h>
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*/
//! print headline
void section(const char* s, const char l='-')
{
cout << endl << s << endl;
const char* p=s;
while (*p) { cout << l; ++p; }
cout << endl;
}
/*======================================================================*/
/*! \example tests/operatortest.cc
*
* Here you can learn how to use operators with aff classes.
......@@ -52,23 +68,55 @@ int main(int iargc, char* argv[])
cout << OPERATORTEST_VERSION << endl;
cout << OPERATORTEST_CVSID << endl;
CODE(aff::Array<double> A(3,3);)
CODE(A=14.;)
section("Test array operators", '=');
section("Normal array with unary operator");
CODE(aff::Array<double> A(4,4));
CODE(A=14.);
CODE(dump_array(A));
CODE(aff::Array<double> B = A * 5.;)
CODE(A+=500.);
CODE(dump_array(A));
section("Access through subarray");
CODE(aff::Array<double> Asub=aff::subarray(A)(2,3)(2,3));
CODE(Asub/=200);
CODE(dump_array(A));
section("binary operator");
CODE(aff::Array<double> B(A));
CODE(B=A*5);
CODE(dump_array(B));
section("test implicit type conversion");
CODE(B=10.);
CODE(dump_array(B));
CODE(B*=0.2);
CODE(dump_array(B));
CODE(B*=4L);
CODE(dump_array(B));
CODE(B*=0xa0);
CODE(dump_array(B));
section("test advanced type conversion");
CODE(aff::Array<std::complex<double> > C(3,3);)
CODE(C=std::complex<double>(14.,2.);)
CODE(dump_array(C));
CODE(C*=0.2);
CODE(dump_array(C));
CODE(aff::ConstArray<double> D(B));
CODE(aff::Array<double> E(D*50.));
CODE(dump_array(B));
section("test binary operator with constant input");
CODE(aff::ConstArray<double> D(A));
CODE(aff::Array<double> E(D*2.));
CODE(dump_array(E));
section("mixed implicit operations");
CODE(dump_array((D*5.)-12L));
section("Test series operators", '=');
CODE(aff::Series<double> F(-3,3));
CODE(F=5.);
DUMP(F);
CODE(F/=25.);
DUMP(F);
}
/* ----- END OF operatortest.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