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

absmax correction

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: 3014
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent aa00e9d4
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: absmax.h,v 1.1 2010-03-09 20:45:15 tforb Exp $
* $Id: absmax.h,v 1.2 2010-03-10 13:46:13 tforb Exp $
* \author Thomas Forbriger
* \date 09/03/2010
*
......@@ -40,7 +40,7 @@
#define AFF_ABSMAX_H_VERSION \
"AFF_ABSMAX_H V1.0 "
#define AFF_ABSMAX_H_CVSID \
"$Id: absmax.h,v 1.1 2010-03-09 20:45:15 tforb Exp $"
"$Id: absmax.h,v 1.2 2010-03-10 13:46:13 tforb Exp $"
#include<aff/lib/collector.h>
......@@ -65,11 +65,14 @@ namespace aff {
public:
typedef Tvalue Tretval;
//! initialize member data
Extractabsmax(const Tcont& c): Mval(c(c.first())) { }
Extractabsmax(const Tcont& c): Mval(c(c.first()))
{
if (Mval<0) { Mval = -Mval; }
}
//! collect another value
void operator() (const Tvalue& v)
{
Tvalue av = av < 0 ? -av : av;
Tvalue av = v < 0 ? -v : v;
Mval = Mval > av ? Mval : av;
}
//! return result of operation
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: functionstest.cc,v 1.11 2007-06-13 15:24:10 tforb Exp $
* $Id: functionstest.cc,v 1.12 2010-03-10 13:46:13 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
......@@ -36,7 +36,7 @@
#define FUNCTIONSTEST_VERSION \
"FUNCTIONSTEST V1.1 test function templates"
#define FUNCTIONSTEST_CVSID \
"$Id: functionstest.cc,v 1.11 2007-06-13 15:24:10 tforb Exp $"
"$Id: functionstest.cc,v 1.12 2010-03-10 13:46:13 tforb Exp $"
#include <iostream>
#include <aff/dump.h>
......@@ -46,6 +46,7 @@
#include <aff/functions/avg.h>
#include <aff/functions/min.h>
#include <aff/functions/max.h>
#include <aff/functions/absmax.h>
#include <aff/functions/rms.h>
#include <aff/functions/sum.h>
#include <aff/functions/sqrsum.h>
......@@ -68,12 +69,13 @@ int main(int iargc, char* argv[])
CODE( Tarray::Tcoc AC=A );
CODE( subarray(A)(1,1)(2,4)=2. );
CODE( subarray(A)(2,3)(1,2)=1. );
CODE( subarray(A)(2,3)(3,4)=-4. );
CODE( subarray(A)(2,3)(3,4)=-7. );
CODE( dump_array(A) );
CODE( cout << aff::func::avg(A) << endl );
CODE( cout << aff::func::rms(A) << endl );
CODE( cout << aff::func::max(A) << endl );
CODE( cout << aff::func::min(A) << endl );
CODE( cout << aff::func::absmax(A) << endl );
CODE( cout << aff::func::min(AC) << endl );
CODE( cout << aff::func::sum(A) << endl );
CODE( cout << aff::func::sqrsum(A) << endl );
......
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