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

so many nice new features - included vector operators

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: 1482
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 0476e2a5
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
* $Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,7 +21,7 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
$Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
\sa \ref page_project_status
......@@ -35,6 +35,7 @@
arrayoperators.h, seriesoperators.h, and lib/operators.h
- introduced tests/operatortest.h
- basic operators work for aff::Array and aff::Series
- added operators combining containers
- \b 07/02/2004 (thof)
- index limit set operations available through aff::Series
......@@ -205,7 +206,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.46 2004-02-10 14:32:14 tforb Exp $
$Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
\sa \ref page_changelog
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: operators.h,v 1.4 2004-02-10 14:32:15 tforb Exp $
* $Id: operators.h,v 1.5 2004-02-10 15:27:40 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
......@@ -56,6 +56,33 @@ namespace aff {
return(retval); \
}
#define AFF_OPERATORS_UNOPB( RETCONT, INCONT, OP ) \
template<class A , class B > \
RETCONT< A >& operator OP ## =(RETCONT< A >& container1, \
const INCONT< B >& container2) \
{ \
aff::Iterator< RETCONT< A > > i1(container1); \
aff::Browser< INCONT< B > > i2(container2); \
while ( i1.valid() && i2.valid() ) \
{ (*i1) OP ## = (*i2); ++i1; ++i2; } \
return(container1); \
}
#define AFF_OPERATORS_BINOPB( RETCONT, INCONT, OP ) \
template<class A , class B > \
RETCONT< A > operator OP(const INCONT< A >& container1, \
const INCONT< B >& container2) \
{ \
RETCONT< A > retval(container1.shape()); \
retval=A(0); \
aff::Browser< INCONT< A > > i1(container1); \
aff::Browser< INCONT< B > > i2(container2); \
aff::Iterator< RETCONT< A > > o(retval); \
while ( i1.valid() && o.valid() && i2.valid() ) \
{ (*o) = (*i1) OP (*i2); ++o; ++i1; ++i2; } \
return(retval); \
}
#define AFF_OPERATORS_THEUNOP( OP ) \
AFF_OPERATORS_UNOP( AFF_OPERATORS_CONT , OP )
AFF_OPERATORS_THEUNOP( + )
......@@ -72,8 +99,25 @@ namespace aff {
AFF_OPERATORS_THEBINOP( - )
#undef AFF_OPERATORS_THEBINOP
#define AFF_OPERATORS_THEBINOP( OP ) \
AFF_OPERATORS_BINOPB( AFF_OPERATORS_CLASS , AFF_OPERATORS_CONSTCLASS , OP )
AFF_OPERATORS_THEBINOP( + )
AFF_OPERATORS_THEBINOP( * )
AFF_OPERATORS_THEBINOP( / )
AFF_OPERATORS_THEBINOP( - )
#undef AFF_OPERATORS_THEBINOP
#define AFF_OPERATORS_THEUNOP( OP ) \
AFF_OPERATORS_UNOPB( AFF_OPERATORS_CLASS , AFF_OPERATORS_CONSTCLASS , OP )
AFF_OPERATORS_THEUNOP( + )
AFF_OPERATORS_THEUNOP( * )
AFF_OPERATORS_THEUNOP( / )
AFF_OPERATORS_THEUNOP( - )
#undef AFF_OPERATORS_THEUNOP
#undef AFF_OPERATORS_UNOP
#undef AFF_OPERATORS_BINOP
#undef AFF_OPERATORS_BINOPB
#undef AFF_OPERATORS_CONSTCONT
#undef AFF_OPERATORS_CONT
#undef AFF_OPERATORS_TEMPAR
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: series.h,v 1.14 2004-02-07 22:14:20 tforb Exp $
* $Id: series.h,v 1.15 2004-02-10 15:27:39 tforb Exp $
* \author Thomas Forbriger
* \date 17/12/2002
*
......@@ -57,7 +57,7 @@
#define AFF_SERIES_H_VERSION \
"AFF_SERIES_H V1.8"
#define AFF_SERIES_H_CVSID \
"$Id: series.h,v 1.14 2004-02-07 22:14:20 tforb Exp $"
"$Id: series.h,v 1.15 2004-02-10 15:27:39 tforb Exp $"
#include <aff/lib/sharedheap.h>
#include <aff/lib/linearshape.h>
......@@ -285,6 +285,13 @@ namespace aff {
Mrepresentation=Trepresentation(newshape.memory_size());
Tbase::operator=(Tbase(newshape, Mrepresentation));
}
//! construct from shape
Series(const Tshape& shape)
{
Tshape newshape(shape.first(), shape.last(), 0);
Mrepresentation=Trepresentation(newshape.memory_size());
this->Tbase::operator=(Tbase(newshape, Mrepresentation));
}
//! construct from shape and representation
Series(const Tshape& shape,
const Trepresentation& representation):
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: operatortest.cc,v 1.3 2004-02-10 14:32:16 tforb Exp $
* $Id: operatortest.cc,v 1.4 2004-02-10 15:27:40 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
......@@ -19,7 +19,7 @@
#define OPERATORTEST_VERSION \
"OPERATORTEST V1.0 test operator functions"
#define OPERATORTEST_CVSID \
"$Id: operatortest.cc,v 1.3 2004-02-10 14:32:16 tforb Exp $"
"$Id: operatortest.cc,v 1.4 2004-02-10 15:27:40 tforb Exp $"
#include <iostream>
#include <complex>
......@@ -112,11 +112,25 @@ int main(int iargc, char* argv[])
CODE(dump_array((D*5.)-12L));
section("Test series operators", '=');
section("test scalar operators");
CODE(aff::Series<double> F(-3,3));
CODE(F=5.);
DUMP(F);
CODE(F/=25.);
DUMP(F);
section("test vector operators");
CODE(aff::Series<double> G(5));
CODE(G=5.);
DUMP(G);
DUMP(F+G);
CODE(aff::Series<double> H);
CODE(H=F+G);
DUMP(H);
CODE(H -= F);
DUMP(H);
DUMP((H *= G + 0.2) + 0.2);
DUMP(H);
}
/* ----- 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