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

proceedign

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: 2185
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 7c773911
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.20 2006-06-29 12:43:48 tforb Exp $
# $Id: Makefile,v 1.21 2006-11-21 12:16:42 tforb Exp $
#
# Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
#
......@@ -33,7 +33,8 @@
HEADERS=$(shell find . -name \*.h)
LIBSRC=tsxx.cc filter.cc seifexx.cc seifeclass.cc \
anyfilter.cc filterbase.cc ipo.cc ipolin.cc sffheaders.cc random.cc
anyfilter.cc filterbase.cc ipo.cc ipolin.cc sffheaders.cc random.cc \
dropcontainer.cc
INCINSTALLPATH=$(LOCINCLUDEDIR)/tsxx
LIBINSTALLPATH=$(LOCLIBDIR)
......@@ -159,7 +160,7 @@ doxyview: doxyfullview doxybrief
# ---------
tstest: tstest.cc
$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) -ltsxx -laff -L$(LOCLIBDIR) \
$(CXX) $(FLAGS) -o $@ $< -I$(LOCINCLUDEDIR) -ltsxx -laff -L$(LOCLIBDIR) \
-ltfxx -lgsl -lgslcblas
tests: tstest; $<; rm -fv $<
......
/*! \file dropcontainer.cc
* \brief a container to drop samples into it (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: dropcontainer.cc,v 1.1 2006-11-21 12:16:43 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
* a container to drop samples into it (implementation)
*
* Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
* REVISIONS and CHANGES
* - 21/11/2006 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_DROPCONTAINER_CC_VERSION \
"TF_DROPCONTAINER_CC V1.0 "
#define TF_DROPCONTAINER_CC_CVSID \
"$Id: dropcontainer.cc,v 1.1 2006-11-21 12:16:43 tforb Exp $"
#include <tsxx/dropcontainer.h>
namespace ts {
} // namespace ts
/* ----- END OF dropcontainer.cc ----- */
/*! \file dropcontainer.h
* \brief a container to drop samples into it (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: dropcontainer.h,v 1.1 2006-11-21 12:16:43 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
* a container to drop samples into it (prototypes)
*
* Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
* REVISIONS and CHANGES
* - 21/11/2006 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_DROPCONTAINER_H_VERSION
#define TF_DROPCONTAINER_H_VERSION \
"TF_DROPCONTAINER_H V1.0"
#define TF_DROPCONTAINER_H_CVSID \
"$Id: dropcontainer.h,v 1.1 2006-11-21 12:16:43 tforb Exp $"
#include<tsxx/tsxx.h>
namespace ts {
namespace drop {
/*! abstract base class
*
*/
template<class T>
class DropContainer {
public:
typedef T Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
typedef aff::Series<Tvalue> Tseries;
DropContainer(): Moutput(0) { }
~DropContainer()
{ if (Moutput != 0) { delete Moutput; } }
//! initialize for n samples input
virtual void initialize(const int& n);
//! this function accepts samples
virtual void drop(const Tvalue& v)=0;
void attach(const DropContainer& c)
{ Moutput=c.clone(); }
virtual Tseries container() const
{ return(attached()->container()); }
protected:
virtual PDropContainer clone() const=0;
virtual void initializenext(const int& n)=0;
PDropContainer attached() const
{
TSXX_assert(Moutput != 0,
"DropContainer: not properly initialized!");
return(Moutput);
}
PDropContainer Moutput;
}; // class DropContainer
template<class T>
class SeriesDropContainer: public DropContainer<T> {
public:
typedef DropContainer<T> Tbase;
typedef typename Tbase::Tvalue Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
typedef typename Tbase::Tseries Tseries;
typedef aff::Tsubscript Tsubscript;
SeriesDropContainer(const int& n): Ms(n) { }
virtual void drop(const Tvalue& v)
{
TSXX_assert(Mi <= Ms.l(),
"SeriesDropContainer: index out of bounds");
Ms(Mi)=v;
++Mi;
}
protected:
virtual PDropContainer clone() const
{ PDropContainer retval(new SeriesDropContainer(Ms.size())); }
virtual void initializenext(const int& n)
{ Ms=Tseries(n); Mi=Ms.f(); }
virtual Tseries container() const { return(Ms); }
private:
Tseries Ms;
Tsubscript Mi;
}; // class SeriesDropContainer
template<class T>
class DropDropContainer: public DropContainer<T> {
public:
typedef DropContainer<T> Tbase;
typedef typename Tbase::Tvalue Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
DropDropContainer(const int& n): Mn(n) { }
virtual void drop(const Tvalue& v)
{
++Mi;
if (Mi>=Mn)
{
Mi=0;
attached()->drop(v);
}
}
protected:
virtual PDropContainer clone() const
{ PDropContainer retval(new DropDropContainer(Mn)); }
virtual void initializenext(const int& n)
{ Moutput->initialize(n/Mn); Mi=0; }
private:
int Mn, Mi;
}; // class DropDropContainer
template<class T>
void DropContainer<T>::initialize(const int& n)
{
if (Moutput == 0)
{ Moutput=new SeriesDropContainer<T>(n); } else
{ this->initializenext(n); }
}
} // namespace drop
} // namespace ts
#endif // TF_DROPCONTAINER_H_VERSION (includeguard)
/* ----- END OF dropcontainer.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tstest.cc,v 1.4 2006-06-29 12:43:48 tforb Exp $
* $Id: tstest.cc,v 1.5 2006-11-21 12:16:43 tforb Exp $
* \author Thomas Forbriger
* \date 20/12/2003
*
......@@ -31,19 +31,21 @@
* - 20/12/2003 V1.0 Thomas Forbriger
* - 27/06/2006 V1.1 did not work anymore; deleted old code and filled
* with convolution test
* - 21/11/2006 V1.2 test drop containers
*
* ============================================================================
*/
#define TSTEST_VERSION \
"TSTEST V1.1 test time series modules"
"TSTEST V1.2 test time series modules"
#define TSTEST_CVSID \
"$Id: tstest.cc,v 1.4 2006-06-29 12:43:48 tforb Exp $"
"$Id: tstest.cc,v 1.5 2006-11-21 12:16:43 tforb Exp $"
#include <iostream>
#include <tsxx/tsxx.h>
#include <aff/dump.h>
#include <tsxx/convolve.h>
#include <tsxx/random.h>
#include <tsxx/dropcontainer.h>
using std::cout;
using std::cerr;
......@@ -52,6 +54,7 @@ using std::endl;
struct Options {
bool convtest1, convtest2;
bool randomnoise;
bool droptest;
}; // struct Options
int main(int iargc, char* argv[])
......@@ -61,7 +64,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
TSTEST_VERSION "\n"
"usage: tstest [-c1] [-c2] [-r]" "\n"
"usage: tstest [-c1] [-c2] [-r] [-drop]" "\n"
" or: tstest --help|-h" "\n"
};
......@@ -71,6 +74,7 @@ int main(int iargc, char* argv[])
"-c1 convolution test 1" "\n"
"-c2 convolution test 2" "\n"
"-r random noise test" "\n"
"-drop drop container test" "\n"
"\n"
TSTEST_CVSID
};
......@@ -89,6 +93,8 @@ int main(int iargc, char* argv[])
{"c2",arg_no,"-"},
// 4: random noise test
{"r",arg_no,"-"},
// 5: drop container test
{"drop",arg_no,"-"},
{NULL}
};
......@@ -138,6 +144,9 @@ int main(int iargc, char* argv[])
opt.convtest1=cmdline.optset(2);
opt.convtest2=cmdline.optset(3);
opt.randomnoise=cmdline.optset(4);
opt.droptest=cmdline.optset(5);
/*======================================================================*/
if (opt.convtest1)
{
......@@ -159,6 +168,8 @@ int main(int iargc, char* argv[])
DUMP( ts::convolve(c,d) );
}
/*======================================================================*/
if (opt.convtest2)
{
aff::Series<double> a(-2,2), b(-3,3);
......@@ -171,12 +182,30 @@ int main(int iargc, char* argv[])
DUMP( ts::convolve(a,b) );
}
/*======================================================================*/
if (opt.randomnoise)
{
cout << "test random noise generation" << endl;
ts::rnd::Tdseries s=ts::rnd::dugauss(30);
DUMP( s );
}
/*======================================================================*/
if (opt.droptest)
{
cout << "test drop containers" << endl;
aff::Series<int> a(36);
for (int i=a.f(); i<=a.l(); ++i) { a(i)=i; }
ts::drop::DropDropContainer<int> d1(3);
ts::drop::DropDropContainer<int> d2(2);
d1.attach(d2);
d1.initialize(a.size());
for (int i=a.f(); i<=a.l(); ++i) { d1.drop(a(i)); }
DUMP( a );
DUMP( d1.container() );
}
}
/* ----- END OF tstest.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