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

array declarations compile

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: 1217
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 9c2a024a
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.6 2002-12-18 18:49:29 uid1201 Exp $
* $Id: README.changelog,v 1.7 2002-12-19 12:03:40 forbrig Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -20,8 +20,14 @@
/*! \page page_changelog ChangeLog
\sa \ref sec_changelog_files
Major changes in the interface of the library are marked by \b !!.
- \b 19/12/2002 (thof)
- \b !! aff::Array provides access to base classes through access
functions and not through conversion operators.
- \b 18/12/2002 (thof)
- defined dump function for Strided
- started with tests/shapetest.cc
......@@ -41,6 +47,119 @@
- introduced tests/seriestest.cc
- introduced dump function for class Series
\section sec_changelog_files File status
<TABLE>
<TR><TD><B>Filename</B></TD>
<TD><B>code is complete</B></TD>
<TD><B>docu is complete</B></TD>
<TD><B>code is tested</B></TD>
<TD><B>deserves revision</B></TD>
<TR><TD>libaff/README</TD>
<TD>has no code</TD><TD> </TD><TD>has no code</TD><TD> </TD>
</TR>
<TR><TD>libaff/array.h</TD>
<TD>8/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/array_dec.h</TD>
<TD>19/12/2002</TD><TD> </TD><TD> </TD>
<TD>should pass stepper to iterator</TD>
</TR>
<TR><TD>libaff/array_def.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/binarray.h</TD>
<TD>8/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/dump.cc</TD>
<TD>18/12/2002</TD><TD> </TD><TD>18/12/2002</TD><TD> </TD>
</TR>
<TR><TD>libaff/dump.h</TD>
<TD>19/12/2002</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/iterator.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/series.h</TD>
<TD>17/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/shaper.h</TD>
<TD>12/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/slice.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/subarray.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/README</TD>
<TD>has no code</TD><TD> </TD><TD>has no code</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/error.cc</TD>
<TD>16/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/error.h</TD>
<TD>16/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/range.h</TD>
<TD>13/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/rawarfun.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>15/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/sharedheap.h</TD>
<TD>13/12/02</TD><TD>13/12/02</TD><TD>16/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/sharedheap_def.h</TD>
<TD>13/12/02</TD><TD>13/12/02</TD><TD>16/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/simplearray.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>15/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/strided.cc</TD>
<TD>13/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/strided.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/stridedstepper.cc</TD>
<TD>18/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/stridedstepper.h</TD>
<TD>18/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/types.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>15/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/tests/arraytest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/binarraytest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/rangetest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/reprtest.cc</TD>
<TD>16/12/02</TD><TD> </TD><TD>16/12/02</TD>
<TD>does not check pathological cases</TD>
</TR>
<TR><TD>libaff/tests/seriestest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/shapetest.cc</TD>
<TD>18/12/02</TD><TD> </TD><TD>18/12/02</TD>
<TD>does not check pathological cases</TD>
</TR>
<TR><TD>libaff/tests/simplearraytest.cc</TD>
<TD>15/12/02</TD><TD> </TD><TD>15/12/02</TD>
<TD>does not check pathological cases</TD>
</TR>
</TABLE>
*/
// ----- END OF README.changelog -----
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.10 2002-12-17 19:21:56 forbrig Exp $
* $Id: array_dec.h,v 1.11 2002-12-19 12:03:41 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -22,6 +22,10 @@
* references for const element type
* - 17/12/2002 V1.2 (thof)
* - introduced access declarations
* - 19/12/2002 V1.3 (thof)
* - provide read access to base classes
* and read/write access to representation of
* non-const array
*
* ============================================================================
*/
......@@ -30,9 +34,9 @@
#ifndef AFF_ARRAY_DEC_H_VERSION
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.2"
"AFF_ARRAY_DEC_H V1.3"
#define AFF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.10 2002-12-17 19:21:56 forbrig Exp $"
"$Id: array_dec.h,v 1.11 2002-12-19 12:03:41 forbrig Exp $"
#include <aff/lib/sharedheap.h>
#include <aff/lib/strided.h>
......@@ -124,9 +128,9 @@ namespace prebuilt {
*/
typedef Tbase Tcoc;
//! Type of representation
typedef Tbase::Trepresentation Trepresentation;
typedef SharedHeap<T> Trepresentation;
//! Type of subscriptor
typedef Tbase::Tshape Tshape;
typedef Strided Tshape;
//! Element type
typedef T Tvalue;
//! Type of pointer to element
......@@ -180,15 +184,12 @@ namespace prebuilt {
Tbase::operator();
Tbase::operator=;
Tbase::copyin;
Tbase::shape;
//@}
//! tricky: only this class allows the conversion
operator Trepresentation()
{ return (Trepresentation(this->Tbase)); }
//! return a copy(!) of the shape
operator Tshape() const
{ Tshape retval(Tbase(*this)); return(retval); }
//! return full access representation
Trepresentation& representation()
{ return (this->Tbase::representation); }
}; // class Array
......@@ -356,14 +357,14 @@ namespace prebuilt {
Tshape::last;
Tshape::size;
//@}
//! offer conversion only to constant version of representation
operator Trepresentation::Tcoc() const
{ return (*this); }
//! return a copy(!) of the shape
operator Tshape() const
{ Tshape retval(*this); return(retval); }
//! provide access to const shape
const Tshape& shape() const
{ return(*this); }
//! provide restricted access representation
const SharedHeap<const T>& representation()
{ return (*this); }
/*-----------------------------------------------------------------*/
// here starts the PROTECTED section!
......@@ -434,9 +435,9 @@ namespace prebuilt {
//@}
/*-----------------------------------------------------------------*/
//! conversion to full representation is protected
operator Trepresentation()
//! return full access representation
Trepresentation& representation()
{ return (*this); }
}; // class Array<const T>
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_def.h,v 1.7 2002-12-18 18:51:55 forbrig Exp $
* $Id: array_def.h,v 1.8 2002-12-19 12:03:41 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -41,9 +41,10 @@
#define AFF_ARRAY_DEF_H_VERSION \
"AFF_ARRAY_DEF_H V1.2"
#define AFF_ARRAY_DEF_H_CVSID \
"$Id: array_def.h,v 1.7 2002-12-18 18:51:55 forbrig Exp $"
"$Id: array_def.h,v 1.8 2002-12-19 12:03:41 forbrig Exp $"
#include<aff/lib/error.h>
#include<aff/lib/stridedstepper.h>
namespace aff {
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.8 2002-12-18 18:43:43 uid1201 Exp $
* $Id: dump.h,v 1.9 2002-12-19 12:03:41 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
......@@ -21,6 +21,8 @@
* - no need to place this in namespace prebuilt
* - 17/12/2002 V1.2 (thof)
* - introduced dump for class Series
* - 19/12/2002 V1.3 (thof)
* - added array dump functions
*
* ============================================================================
*/
......@@ -31,11 +33,10 @@
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.1"
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.8 2002-12-18 18:43:43 uid1201 Exp $"
"$Id: dump.h,v 1.9 2002-12-19 12:03:41 forbrig Exp $"
#include<iostream>
#include<aff/lib/simplearray.h>
#include<aff/lib/strided.h>
#include<aff/array.h>
#include<aff/series.h>
namespace aff {
......@@ -116,14 +117,105 @@ void dump(const SimpleRigidArray<T,N>& array, std::ostream& os=std::cout)
/*----------------------------------------------------------------------*/
namespace {
//! recursive usage tests all access functions
template<class T>
void dump_array_helper(const aff::Array<const T>& array,
const Tdim& i, const Tdim& j,
Strided::TIndexVec& index,
std::ostream& os)
{
if (i>1)
{
for (index[i]=array.f(i); index[i]<=array.l(i); index[i]++)
{
os << " dimension ";
os << i << ": [" << index[i] << "]";
dump_map_helper(array, i-1, j, index, os);
}
}
else if (i>0)
{
if (i<j) os << endl;
os.width(6); os << " ";
for (int k=array.f(1); k<=array.l(1); k++)
{
os.width(5); os << k;
}
os << endl;
for (index[0]=array.f(0); index[0]<=array.l(0); index[0]++)
{
os.width(5); os << index[0];
for (index[1]=array.f(1); index[1]<=array.l(1); index[1]++)
{
os.width(5);
if (j==0)
{ os << array(index[0]); }
else if (j==1)
{ os << array(index[0], index[1]); }
else if (j==2)
{ os << array(index[0], index[1], index[2]); }
else if (j==3)
{ os << array(index[0], index[1], index[2], index[3]); }
else
{ os << array(index); }
os << "#";
}
os << endl;
}
}
else
{
for (index[0]=array.f(0); index[0]<=array.l(0); index[0]++)
{
os.width(5); os << index[0];
os.width(5);
if (j==0)
{ os << array(index[0]); }
else if (j==1)
{ os << array(index[0], index[1]); }
else if (j==2)
{ os << array(index[0], index[1], index[2]); }
else if (j==3)
{ os << array(index[0], index[1], index[2], index[3]); }
else
{ os << array(index); }
os << "#" << endl;
}
}
}
}
/*! \brief Dump array values
*
* \ingroup group_helpers
*/
/*
template<class T>
void dump(const Array<T>::Tcoc& array, std::ostream& os=std::cout);
*/
void dump_array(const Array<const T>& array,
const Tdim& i=(Strided::Mmax_dimen-1),
std::ostream& os=std::cout)
{
AFF_assert((i<Strided::Mmax_dimen),
"ERROR (dump_map): illegal dimensionality");
dump(array);
os << " elements through " << i+1 << "dimensional access:" << endl;
Strided::TIndexVec index(array.first());
dump_array_helper(array, i, i, index, os);
}
/*! \brief Dump array shape
*
* \ingroup group_helpers
*/
template<class T>
void dump(const Array<const T>& array, std::ostream& os=std::cout)
{
os << "dump of a Array object layout:" << endl;
os << "=============================:" << endl;
dump(array.shape());
dump(array.representation());
}
/*----------------------------------------------------------------------*/
......
/*! \file slice.h
* \brief external class to create slices (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: slice.h,v 1.1 2002-12-19 12:03:41 forbrig Exp $
* \author Thomas Forbriger
* \date 19/12/2002
*
* external class to create slices (prototypes)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 19/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_SLICE_H_VERSION
#define AFF_SLICE_H_VERSION \
"AFF_SLICE_H V1.0 "
#define AFF_SLICE_H_CVSID \
"$Id: slice.h,v 1.1 2002-12-19 12:03:41 forbrig Exp $"
namespace aff {
}
#endif // AFF_SLICE_H_VERSION (includeguard)
/* ----- END OF slice.h ----- */
/*! \file subarray.h
* \brief external class to create subarrays (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: subarray.h,v 1.1 2002-12-19 12:03:41 forbrig Exp $
* \author Thomas Forbriger
* \date 19/12/2002
*
* external class to create subarrays (prototypes)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 19/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_SUBARRAY_H_VERSION
#define AFF_SUBARRAY_H_VERSION \
"AFF_SUBARRAY_H V1.0 "
#define AFF_SUBARRAY_H_CVSID \
"$Id: subarray.h,v 1.1 2002-12-19 12:03:41 forbrig Exp $"
namespace aff {
}
#endif // AFF_SUBARRAY_H_VERSION (includeguard)
/* ----- END OF subarray.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: arraytest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $
* $Id: arraytest.cc,v 1.2 2002-12-19 12:03:42 forbrig Exp $
* \author Thomas Forbriger
* \date 09/06/2002
*
......@@ -26,108 +26,49 @@
* \sa tests/arraytest.cc
*/
#define TF_ARRAYTEST_CC_VERSION \
"TF_ARRAYTEST_CC V1.1 "
#define TF_ARRAYTEST_CC_CVSID \
"$Id: arraytest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $"
#define AFF_ARRAYTEST_CC_VERSION \
"AFF_ARRAYTEST_CC V1.1"
#define AFF_ARRAYTEST_CC_CVSID \
"$Id: arraytest.cc,v 1.2 2002-12-19 12:03:42 forbrig Exp $"
#define CONT_INDEXCHECK
#include<iostream>
#include <contxx/array.h>
#include <contxx/shape/shaper.h>
#include <contxx/shaper/fortran.h>
#include <aff/dump.h>
using std::cout;
using std::endl;
using namespace contxx::shape;
using namespace aff;
typedef contxx::Array<float, 3> Tarray;
typedef contxx::shaper::Fortran<3> Tshaper;
/*! \example tests/arraytest.cc
*
* Test and example for aff::Array usage.
*
* \sa tests/arraytest.cc
*/
//! echo
#define CODE( C ) cout << #C << endl; C
void print(const Tarray::Tcontainer_of_const& array, const char* name)
//! print headline
void section(const char* s, const char l='-')
{
cout << endl << s << endl;
const char* p=s;
while (*p) { cout << l; ++p; }
cout << endl;
cout << "Array \"" << name << "\"" << endl;
cout << "dimensionality: " << array.dimensionality() << endl;
for (int i=0; i<3; i++) {
cout << "dimension " << i+1 << ": [" <<
array.first(i) << ":" <<
array.last(i) << "]" << endl;
}
for (int i=array.first(2); i<=array.last(2); i++) {
cout << endl;
cout << "slice " << i << ":" << endl;
cout.width(8); cout << " ";
for (int l=array.first(1); l<=array.last(1); l++) {
cout.width(8);
cout << l << " ";
}
cout << endl;
for (int k=array.first(0); k<=array.last(0); k++) {
cout.width(8);
cout << k;
for (int l=array.first(1); l<=array.last(1); l++) {
cout.width(8);
cout << array(k,l,i) << " ";
}
cout << endl;
}
}
}
#define PRINT( array ) print(array, #array);
//! test array functionality
int main()
{
cout << TF_ARRAYTEST_CC_VERSION << endl;
cout << TF_ARRAYTEST_CC_CVSID << endl;
Tarray::Trange r1(3,6), r2(0,4), r3(-2,2);
Tarray::Tranges rng(tuple(r1, r2, r3));
typedef Tarray::Trange Tr;
Tarray E(tuple(Tr(0,6),Tr(0,2),Tr(0,1)));
Tarray D(tuple(Tarray::Trange(3,6),Tarray::Trange(8,9),Tarray::Trange(1,2)));
Tarray C(tuple(r1,r2,r3));
Tarray A(rng);
cout << AFF_ARRAYTEST_CC_VERSION << endl;
cout << AFF_ARRAYTEST_CC_CVSID << endl;
PRINT(D)
PRINT(C)
PRINT(A)
section("Test constructors", '=');
A(4,2,1)=10.;
PRINT(A)
PRINT(E)
{ Tarray B(Tshaper(-2,2)); PRINT(B) }
{ Tarray B(Tshaper(-2,2)(4)(0,3)); PRINT(B) }
{ Tarray B(Tshaper(-2,2)(4)(0,3)(1,2)(0,2)); PRINT(B) }
Tarray B(Tshaper(3));
for (int i=1; i<=B.last(0); i++)
{
for (int j=1; j<=B.last(1); j++)
{
for (int k=1; k<=B.last(2); k++)
{
B(i,j,k)=float(100*i+10*j+k);
}
}
}
PRINT(B)
Tarray::Trepresentation RB(B);
for (int i=0; i<int(RB.size()); i++)
{
cout << RB[i] << " ";
}
cout << endl;
{ Tarray copyB(B); }
{ Tarray copyB; copyB=B; }
section("Test access", '=');
B=134.2;
PRINT(B)
section("Test copy", '=');
}
/* ----- END OF arraytest.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