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

proceeding

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: 1675
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 0bb1bda4
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: avg.h,v 1.1 2005-03-21 09:35:33 tforb Exp $
* $Id: avg.h,v 1.2 2005-04-21 07:14:55 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
......@@ -23,11 +23,46 @@
#define AFF_AVG_H_VERSION \
"AFF_AVG_H V1.0 "
#define AFF_AVG_H_CVSID \
"$Id: avg.h,v 1.1 2005-03-21 09:35:33 tforb Exp $"
"$Id: avg.h,v 1.2 2005-04-21 07:14:55 tforb Exp $"
namespace tf {
}
#include<aff/lib/collector.h>
namespace aff {
namespace func {
namespace util {
template<class C>
class Extractavg {
typedef typename C::Tcoc Tcont;
typedef typename C::Tvalue Tvalue;
public:
Extractavg(const Tcont c): Msum(0), Mn(0) { }
void operator() (const Tvalue& v) { Msum+=v; }
Tvalue result() const { return(Msum/Tvalue(Mn)); }
private:
Tvalue Msum;
int Mn;
}; // class Extractavg
} // namespace util
template<class T>
template<class C>
T avg(const typename C::Tcoc& c)
{
/*
return(aff::func::util::collect<C, T,
aff::func::util::Extractavg>(c));
*/
return(-18);
} // avg()
} // namespace func
} // namespace aff
#endif // AFF_AVG_H_VERSION (includeguard)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: collector.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* $Id: collector.h,v 1.2 2005-04-21 07:14:55 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
......@@ -18,12 +18,14 @@
*/
// include guard
#ifndef TF_COLLECTOR_H_VERSION
#ifndef AFF_COLLECTOR_H_VERSION
#define TF_COLLECTOR_H_VERSION \
"TF_COLLECTOR_H V1.0 "
#define TF_COLLECTOR_H_CVSID \
"$Id: collector.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
#define AFF_COLLECTOR_H_VERSION \
"AFF_COLLECTOR_H V1.0 "
#define AFF_COLLECTOR_H_CVSID \
"$Id: collector.h,v 1.2 2005-04-21 07:14:55 tforb Exp $"
#include<aff/iterator.h>
namespace aff {
......@@ -31,18 +33,18 @@ namespace aff {
namespace util {
template<class C, class T>
class Collector {
public:
typedef T Tvalue;
typedef C<T>::Tcontainer;
typedef Tvalue (*Tfunction) (const Tvalue&, const Tvalue&);
Collector(Tfunction, function, const Tvalue& v=Tvalue()):
Mfunction(function), Mvalue(v) { }
private:
Tfunction Mfunction;
Tvalue Mvalue;
}; // class Collector
template<class C, template<class> class F>
typename C::Tvalue collect(const typename C::Tcoc& c)
{
F<C> exfun(c);
aff::Browser<C> browser(c);
while(browser.valid)
{
exfun(*browser);
++browser;
}
return(exfun.result());
}; // collect
} // namespace util
......@@ -50,6 +52,6 @@ namespace aff {
} // namespace aff
#endif // TF_COLLECTOR_H_VERSION (includeguard)
#endif // AFF_COLLECTOR_H_VERSION (includeguard)
/* ----- END OF collector.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: mapper.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* $Id: mapper.h,v 1.2 2005-04-21 07:14:55 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
......@@ -18,17 +18,17 @@
*/
// include guard
#ifndef TF_MAPPER_H_VERSION
#ifndef AFF_MAPPER_H_VERSION
#define TF_MAPPER_H_VERSION \
"TF_MAPPER_H V1.0 "
#define TF_MAPPER_H_CVSID \
"$Id: mapper.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
#define AFF_MAPPER_H_VERSION \
"AFF_MAPPER_H V1.0 "
#define AFF_MAPPER_H_CVSID \
"$Id: mapper.h,v 1.2 2005-04-21 07:14:55 tforb Exp $"
namespace tf {
}
#endif // TF_MAPPER_H_VERSION (includeguard)
#endif // AFF_MAPPER_H_VERSION (includeguard)
/* ----- END OF mapper.h ----- */
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.11 2004-02-10 09:57:20 tforb Exp $
# $Id: Makefile,v 1.12 2005-04-21 07:14:56 tforb Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -39,7 +39,7 @@ clean: ;
-find . -type f -perm +0111 | xargs --no-run-if-empty /bin/rm -v
STANDARDTEST=arraytest subscriptortest shapetest simplearraytest reprtest \
seriestest helpertest operatortest
seriestest helpertest operatortest functionstest
BINARYTEST=binarraytest
F77TEST=f77test
EXECUTABLES=$(STANDARDTEST) $(BINARYTEST) $(F77TEST)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: functionstest.cc,v 1.1 2005-03-21 09:35:35 tforb Exp $
* $Id: functionstest.cc,v 1.2 2005-04-21 07:14:56 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
......@@ -19,10 +19,16 @@
#define FUNCTIONSTEST_VERSION \
"FUNCTIONSTEST V1.0 test function templates"
#define FUNCTIONSTEST_CVSID \
"$Id: functionstest.cc,v 1.1 2005-03-21 09:35:35 tforb Exp $"
"$Id: functionstest.cc,v 1.2 2005-04-21 07:14:56 tforb Exp $"
#include <iostream>
#include <tfxx/commandline.h>
#include <aff/dump.h>
#include <aff/array.h>
#include <aff/shaper.h>
#include <aff/subarray.h>
#include <aff/functions/avg.h>
using namespace aff;
using std::cout;
using std::cerr;
......@@ -30,71 +36,14 @@ using std::endl;
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
FUNCTIONSTEST_VERSION "\n"
"usage: functionstest" "\n"
" or: functionstest --help|-h" "\n"
};
// define full help text
char help_text[]=
{
FUNCTIONSTEST_CVSID
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
{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);
}
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
CODE( typedef aff::Array<double> Tarray );
CODE( Tarray A(3,4) );
CODE( A=5 );
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( dump_array(A) );
cout << aff::func::avg<Tarray::Tvalue>(A);
}
/* ----- END OF functionstest.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