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

resolved some type problems

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: 1207
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 562ee968
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.1 2002-12-17 19:19:54 forbrig Exp $
* $Id: README.changelog,v 1.2 2002-12-17 19:41:21 forbrig Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -25,6 +25,8 @@
- Array now inherits privately from Strided
- use access declarations to declare base class functions that should be
visible in the public interface of aff::Array and aff::SharedHeap
- introduced tests/seriestest.cc
- introduced dump function for class Series
*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.5 2002-12-16 21:03:25 uid1201 Exp $
* $Id: dump.h,v 1.6 2002-12-17 19:41:21 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
......@@ -19,6 +19,8 @@
* - 12/12/2002 V1.0 Thomas Forbriger
* - 15/12/2002 V1.1 (thof)
* - no need to place this in namespace prebuilt
* - 17/12/2002 V1.2 (thof)
* - introduced dump for class Series
*
* ============================================================================
*/
......@@ -29,11 +31,11 @@
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.1"
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.5 2002-12-16 21:03:25 uid1201 Exp $"
"$Id: dump.h,v 1.6 2002-12-17 19:41:21 forbrig Exp $"
#include<iostream>
#include<aff/lib/sharedheap.h>
#include<aff/lib/simplearray.h>
#include<aff/series.h>
namespace aff {
......@@ -44,6 +46,31 @@ using std::endl;
/*----------------------------------------------------------------------*/
/*! \brief Dump series contents
*
* \ingroup group_helpers
*/
template<typename T>
void dump(const aff::Series<const T>& series,
std::ostream& os=std::cout)
{
os << "dump of a Series object:" << endl;
os << " size: " << series.size() << endl;
os << " index range: [" << series.f() << ":" << series.l() << "]" << endl;
os << " elements:" << endl;
int i=0;
for (aff::Tsubscript k=series.f(); k<=series.l(); k++)
{
if (!i) { os << " "; }
os.width(8);
os << series(k) << " ";
if (++i>7) { i=0; os << endl; }
}
os << endl;
}
/*----------------------------------------------------------------------*/
/*! \brief Dump heap contents
*
* \ingroup group_helpers
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: series.h,v 1.2 2002-12-17 19:24:43 forbrig Exp $
* $Id: series.h,v 1.3 2002-12-17 19:41:21 forbrig Exp $
* \author Thomas Forbriger
* \date 17/12/2002
*
......@@ -23,7 +23,7 @@
#define AFF_SERIES_H_VERSION \
"AFF_SERIES_H V1.0"
#define AFF_SERIES_H_CVSID \
"$Id: series.h,v 1.2 2002-12-17 19:24:43 forbrig Exp $"
"$Id: series.h,v 1.3 2002-12-17 19:41:21 forbrig Exp $"
#include<aff/lib/sharedheap.h>
#include<aff/lib/error.h>
......@@ -66,7 +66,7 @@ namespace aff {
*/
typedef Tbase Tcoc;
//! Type of representation
typedef Tbase::Trepresentation Trepresentation;
typedef aff::SharedHeap<T> Trepresentation;
//! Element type
typedef T Tvalue;
//! Type of pointer to element
......@@ -271,7 +271,7 @@ namespace aff {
Series copyout() const;
//! offer conversion only to constant version of representation
operator Trepresentation::Tcoc() const
operator aff::SharedHeap<const T>() const
{ return (*this); }
/*-----------------------------------------------------------------*/
......
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2002-12-15 20:48:02 forbrig Exp $
# $Id: Makefile,v 1.5 2002-12-17 19:41:23 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -10,6 +10,7 @@
#
# REVISIONS and CHANGES
# 06/12/2002 V1.0 Thomas Forbriger (copied from libcontxx)
# 17/12/2002 V1.1 introduced seriestest
#
# ============================================================================
#
......@@ -35,7 +36,8 @@ clean: ;
-/bin/rm -vf flist
-find . -type f -perm +0111 | xargs --no-run-if-empty /bin/rm -v
STANDARDTEST=arraytest subscriptortest shapetest simplearraytest reprtest
STANDARDTEST=arraytest subscriptortest shapetest simplearraytest reprtest \
seriestest
BINARYTEST=binarraytest
$(addsuffix .o,$(STANDARDTEST) $(BINARYTEST)): %.o: %.cc
......
/*! \file seriestest.cc
* \brief test aff::Series class (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: seriestest.cc,v 1.1 2002-12-17 19:41:23 forbrig Exp $
* \author Thomas Forbriger
* \date 17/12/2002
*
* test aff::Series class (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 17/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define AFF_SERIESTEST_CC_VERSION \
"AFF_SERIESTEST_CC V1.1"
#define AFF_SERIESTEST_CC_CVSID \
"$Id: seriestest.cc,v 1.1 2002-12-17 19:41:23 forbrig Exp $"
#include <aff/series.h>
#include <aff/dump.h>
using std::cout;
using std::endl;
//! echo
#define CODE( C ) cout << #C << endl; C
//! print headline
void section(const char* s)
{
cout << endl
<< s << endl;
const char* p=s;
while (*p) {
cout << "-";
++p;
}
cout << endl;
}
//! testing SharedHeap
int main()
{
cout << AFF_SERIESTEST_CC_VERSION << endl;
cout << AFF_SERIESTEST_CC_CVSID << endl;
section("array dimensions");
CODE( const int N=10; )
CODE( const int N2=23; )
section("instantiate arrays");
CODE( aff::SharedHeap<int> A(N); )
CODE( aff::SharedHeap<int> B(N2); )
CODE( aff::SharedHeap<const int> C(N2); )
CODE( aff::SharedHeap<float> D(N2); )
section("create a const reference to D");
CODE( aff::SharedHeap<float>::Tcoc E(D); )
section("const int array should share memory with int array");
CODE( C=B; )
section("fill arrays");
CODE( for (int i=0; i<N; i++) { A[i]=(i+1)*10; } )
CODE( for (int i=0; i<N2; i++) { B[i]=(i+4)*3; } )
CODE( for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; } )
section("dump contents - C is filled through B and E is filled through D");
DUMP( aff::SharedHeap<int>::Tcontainer_of_const(A) );
DUMP( B );
DUMP( C );
DUMP( E );
section("modify C through B");
CODE( B[8]=632; )
DUMP( C );
#ifdef ILLEGAL1
// you may activate this section by passing -DILLEGAL1 to the compiler
section("modify C directly - is illegal");
C[9]=354;
DUMP( C );
#endif
section("make B a reference to A");
CODE( B=A; )
section("modification should be visible through B");
CODE( A[5]=453; )
DUMP( B );
section("but C holds the original values");
DUMP( C );
}
/* ----- END OF seriestest.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