Commit 0d30b529 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: 1193
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent e270b822
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap_def.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $
* $Id: sharedheap_def.h,v 1.6 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -31,7 +31,9 @@
#define AFF_SHAREDHEAP_DEF_H_VERSION \
"AFF_SHAREDHEAP_DEF_H V1.0 "
#define AFF_SHAREDHEAP_DEF_H_CVSID \
"$Id: sharedheap_def.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $"
"$Id: sharedheap_def.h,v 1.6 2002-12-15 19:32:52 forbrig Exp $"
#include<iostream>
namespace aff {
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: simplearray.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $
* $Id: simplearray.h,v 1.6 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -31,7 +31,7 @@
#define AFF_SIMPLEARRAY_H_VERSION \
"AFF_SIMPLEARRAY_H V1.1 "
#define AFF_SIMPLEARRAY_H_CVSID \
"$Id: simplearray.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $"
"$Id: simplearray.h,v 1.6 2002-12-15 19:32:52 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/rawarfun.h>
......@@ -94,36 +94,34 @@ namespace prebuilt {
/*-----------------------------------------------------------------*/
/*! \name Constructors
*
* \note
* The order of declaration matters in template expansion!
*/
//@{
//! construct without initializing
SimpleRigidArray() { }
//! set constructor
template<class TT>
explicit SimpleRigidArray(const TT& value)
{
aff::util::Inline2<T, TT, N>::set(Marray, value);
}
//! copy with deep inline copy
template<class TT>
SimpleRigidArray(const SimpleRigidArray<TT, N>& array)
{
aff::util::Inline2<TT, T, N>::copy(array.pointer(), Marray);
}
//! set constructor
explicit SimpleRigidArray(const T& value)
{
aff::util::Inline<T, N>::set(Marray, value);
}
//@}
/*-----------------------------------------------------------------*/
/*! \name Operators
*
* \note
* The order of declaration matters in template expansion!
*/
//@{
//! copy with deep inline copy
template<class TT>
SimpleRigidArray& operator=(const SimpleRigidArray<TT, N>& array)
{
aff::util::Inline2<TT, T, N>::copy(array.pointer(), Marray);
return(*this);
}
//! copy a value to all positions
template<class TT>
SimpleRigidArray& operator=(const TT& value)
......@@ -131,6 +129,13 @@ namespace prebuilt {
aff::util::Inline2<T, TT, N>::set(Marray, value);
return(*this);
}
//! copy with deep inline copy
template<class TT>
SimpleRigidArray& operator=(const SimpleRigidArray<TT, N>& array)
{
aff::util::Inline2<TT, T, N>::copy(array.pointer(), Marray);
return(*this);
}
//@}
/*-----------------------------------------------------------------*/
......
/*! \file strided_def.h
* \brief shape of a strided array (definitions) (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: strided.cc,v 1.1 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
* shape of a strided array (definitions) (prototypes)
* \sa aff::Strided
*
* \note
* Never include this header directly. Here you find code factored out from
* the aff::Strided class. This code may be compiled into a binary library.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
* - 11/12/2002 V1.1 major revision (thof)
* - removed template parameter
* - calculates base for index operator of
* each dimensionality
* - 12/12/2002 V1.2 (thof)
* - added shrink and collapse
* - 13/12/2002 V1.3 (thof)
* - reworked shape definition and mapping
* - added straightforward implementations for
* subarrays and slicing
*
* ============================================================================
*/
#ifndef AFF_STRIDED_H_VERSION
#error "include this only through strided.h"
#endif
// include guard
#ifndef AFF_STRIDED_DEF_H_VERSION
#define AFF_STRIDED_DEF_H_VERSION \
"AFF_STRIDED_DEF_H V1.3"
#define AFF_STRIDED_DEF_H_CVSID \
"$Id: strided.cc,v 1.1 2002-12-15 19:32:52 forbrig Exp $"
#include<aff/lib/error.h>
namespace aff {
#ifdef AFF_PREBUILT
namespace prebuilt {
#endif
#ifdef AFF_PREBUILT
#ifndef AFF_COMPILING_LIBRARY
#error "definition read in prebuilt mode and not during library compilation"
#endif
#endif
/*----------------------------------------------------------------------*/
//! instantiate static member (otherwise the linker won't find it)
const Tdim Strided::Mmax_dimen;
/*----------------------------------------------------------------------*/
//! construct do given size and first index
Strided::Strided(const TSizeVec& size,
const Tsubscript& first,
const Tsubscript& shift)
{
TSizeVec one(1);
AFF_assert((!inline_anylarger(one,size)),
"ERROR (Strided): size must be at least one");
Mfirst=first;
Mstride[0]=1;
Mlast[0]=Mfirst[0]+size[0]-1;
for(Tdim i=1; i<Mmax_dimen; i++)
{
Mstride[i]=Mstride[i-1]*size[i-1];
Mlast[i]=Mfirst[i]+size[i]-1;
}
calculate_base(shift);
}
/*----------------------------------------------------------------------*/
//! construct do given first and last index
Strided::Strided(const TIndexVec& first, const TIndexVec& last,
const Tsubscript& shift)
{
AFF_assert((!inline_anylarger(first,last)),
"ERROR (Strided): first index must be smaller than last");
Mfirst=first;
Mlast=last;
Mstride[0]=1;
for(Tdim i=1; i<Mmax_dimen; i++)
{
Mstride[i]=Mstride[i-1]*(1+Mlast[i-1]-Mfirst[i-1]);
}
calculate_base(shift);
}
/*----------------------------------------------------------------------*/
//! construct do given first and last index
void Strided::calculate_base(const Tsubscript& offset)
{
Mbase[0]=offset-Mfirst[0]*Mstride[0];
for (Tdim i=1; i<Mmax_dimen; i++)
{
Mbase[i]=Mbase[i-1]-Mfirst[i]*Mstride[i];
}
}
/*----------------------------------------------------------------------*/
//! calculate total size
Tsize Strided::size() const
{
// could be done more elegant by inlining - but this will do it here
TSizeVec size(Mlast);
for (int i=0; i<Mmax_dimen; i++) { size[i]-=(Mfirst[i]-1); }
return (inline_product(size));
}
/*----------------------------------------------------------------------*/
//! subarray
Strided& Strided::shrink(const TIndexVec& last)
{
AFF_assert((!inline_anysmaller(last,Mfirst)),
"ERROR (Strided::shrink): index must not be smaller than first");
AFF_assert((!inline_anylarger(last,Mlast)),
"ERROR (Strided::shrink): index must not be larger than last");
Mlast=last;
return(*this);
}
/*----------------------------------------------------------------------*/
//! subarray
Strided& Strided::shrink(const TIndexVec& first, const TIndexVec& last)
{
AFF_assert((!(inline_anysmaller(last,Mfirst)
||inline_anylarger(last,Mlast))),
"ERROR (Strided::shrink): illegal last index vector");
AFF_assert((!(inline_anysmaller(first,Mfirst)
||inline_anylarger(first,Mlast))),
"ERROR (Strided::shrink): illegal first index vector");
AFF_assert((!inline_anysmaller(last,first)),
"ERROR (Strided::shrink): last must not be smaller than first");
Tsubscript offset=this->offset(first);
Mfirst=first;
Mlast=last;
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
//! subarray
Strided& Strided::shrink(const Tdim& i,
const Tsubscript& first,
const Tsubscript& last)
{
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::shrink): illegal dimension");
AFF_assert(((Mfirst[i]<=first)&&(first<=last)&&(last<=Mlast[i])),
"ERROR (Strided::shrink): index range erres");
// take the long way home
TIndexVec newfirst(Mfirst);
newfirst[i]=first;
Tsubscript offset=this->offset(newfirst);
Mfirst[i]=first;
Mlast[i]=last;
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
//! subarray
Strided& Strided::shrink(const Tdim& i,
const Tsubscript& last)
{
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::shrink): illegal dimension");
AFF_assert(((Mfirst[i]<=last)&&(last<=Mlast[i])),
"ERROR (Strided::shrink): illegal index value");
Mlast[i]=last;
return(*this);
}
/*----------------------------------------------------------------------*/
/*! \brief slice
* \todo
* This is implementation of slicing is straightforward but rather
* inefficient. If you do a lot of slicing it might be worth to review and
* rework the code.
*/
Strided& Strided::collapse(const Tdim& i, const Tsubscript& index)
{
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::collapse): illegal dimension");
AFF_assert(((Mfirst[i]<=index)&&(index<=Mlast[i])),
"ERROR (Strided::collapse): index range error");
this->shrink(i,index,index);
Tsubscript offset=this->first_offset();
Tdim j=i+1;
while (j<Mmax_dimen)
{
Mfirst[j-1]=Mfirst[j];
Mlast[j-1]=Mlast[j];
Mstride[j-1]=Mstride[j];
j++;
}
Mfirst[Mmax_dimen]=1;
Mlast[Mmax_dimen]=1;
Mstride[Mmax_dimen]=this->size(Mmax_dimen-2)*Mstride[Mmax_dimen-2];
this->calculate_base(offset);
return(*this);
}
#ifdef AFF_PREBUILT
} // namespace prebuilt
#endif
} // namespace aff
#endif // AFF_STRIDED_DEF_H_VERSION (includeguard)
/* ----- END OF strided_def.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.h,v 1.8 2002-12-13 23:48:29 forbrig Exp $
* $Id: strided.h,v 1.9 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -44,7 +44,7 @@
#define AFF_STRIDED_H_VERSION \
"AFF_STRIDED_H V1.3"
#define AFF_STRIDED_H_CVSID \
"$Id: strided.h,v 1.8 2002-12-13 23:48:29 forbrig Exp $"
"$Id: strided.h,v 1.9 2002-12-15 19:32:52 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/simplearray.h>
......@@ -210,17 +210,17 @@ namespace prebuilt {
*/
//@{
//! subarray
void shrink(const TIndexVec& last);
Strided& shrink(const TIndexVec& last);
//! subarray
void shrink(const TIndexVec& first, const TIndexVec& last);
Strided& shrink(const TIndexVec& first, const TIndexVec& last);
//! subarray
void shrink(const Tdim& i,
const Tsubscript& first, const Tsubscript& last);
Strided& shrink(const Tdim& i,
const Tsubscript& first, const Tsubscript& last);
//! subarray
void shrink(const Tdim& i,
const Tsubscript& last);
Strided& shrink(const Tdim& i,
const Tsubscript& last);
//! slice
void collapse(const Tdim& i, const Tsubscript& index);
Strided& collapse(const Tdim& i, const Tsubscript& index);
//@}
/*-----------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided_def.h,v 1.6 2002-12-13 23:48:30 forbrig Exp $
* $Id: strided_def.h,v 1.7 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -42,7 +42,7 @@
#define AFF_STRIDED_DEF_H_VERSION \
"AFF_STRIDED_DEF_H V1.3"
#define AFF_STRIDED_DEF_H_CVSID \
"$Id: strided_def.h,v 1.6 2002-12-13 23:48:30 forbrig Exp $"
"$Id: strided_def.h,v 1.7 2002-12-15 19:32:52 forbrig Exp $"
#include<aff/lib/error.h>
......@@ -128,38 +128,47 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
//! subarray
void Strided::shrink(const TIndexVec& last)
{ this->shrink(Mfirst, last); }
Strided& Strided::shrink(const TIndexVec& last)
{
AFF_assert((!inline_anysmaller(last,Mfirst)),
"ERROR (Strided::shrink): index must not be smaller than first");
AFF_assert((!inline_anylarger(last,Mlast)),
"ERROR (Strided::shrink): index must not be larger than last");
Mlast=last;
return(*this);
}
/*----------------------------------------------------------------------*/
//! subarray
void Strided::shrink(const TIndexVec& first, const TIndexVec& last)
Strided& Strided::shrink(const TIndexVec& first, const TIndexVec& last)
{
for (Tdim i=0; i<Mmax_dimen; i++)
{
this->shrink(i, first[i], last[i]);
}
AFF_assert((!(inline_anysmaller(last,Mfirst)
||inline_anylarger(last,Mlast))),
"ERROR (Strided::shrink): illegal last index vector");
AFF_assert((!(inline_anysmaller(first,Mfirst)
||inline_anylarger(first,Mlast))),
"ERROR (Strided::shrink): illegal first index vector");
AFF_assert((!inline_anysmaller(last,first)),
"ERROR (Strided::shrink): last must not be smaller than first");
Tsubscript offset=this->offset(first);
Mfirst=first;
Mlast=last;
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
/*! \brief subarray
* \todo
* This function is the actual implementation of calculating a subarray's
* shape. It is called \c Mmax_dimen times by the vector versions. The
* function uses a straightforward but rather inefficient implementation. If
* you use a lot of subarrays of small size, this may slow down your code
* significantly. It then might be worth to review and rework the code.
*/
void Strided::shrink(const Tdim& i,
const Tsubscript& first,
const Tsubscript& last)
//! subarray
Strided& Strided::shrink(const Tdim& i,
const Tsubscript& first,
const Tsubscript& last)
{
AFF_assert((i<Mmax_dimen),
"ERROR (shrink shape): illegal dimension");
"ERROR (Strided::shrink): illegal dimension");
AFF_assert(((Mfirst[i]<=first)&&(first<=last)&&(last<=Mlast[i])),
"ERROR (shrink shape): index range erres");
"ERROR (Strided::shrink): index range erres");
// take the long way home
TIndexVec newfirst(Mfirst);
newfirst[i]=first;
......@@ -167,17 +176,21 @@ namespace prebuilt {
Mfirst[i]=first;
Mlast[i]=last;
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
//! subarrays
void Strided::shrink(const Tdim& i,
const Tsubscript& last)
//! subarray
Strided& Strided::shrink(const Tdim& i,
const Tsubscript& last)
{
AFF_assert((i<Mmax_dimen),
"ERROR (shrink shape): illegal dimension");
this->shrink(i,Mfirst[i],last);
"ERROR (Strided::shrink): illegal dimension");
AFF_assert(((Mfirst[i]<=last)&&(last<=Mlast[i])),
"ERROR (Strided::shrink): illegal index value");
Mlast[i]=last;
return(*this);
}
/*----------------------------------------------------------------------*/
......@@ -188,12 +201,12 @@ namespace prebuilt {
* inefficient. If you do a lot of slicing it might be worth to review and
* rework the code.
*/
void Strided::collapse(const Tdim& i, const Tsubscript& index)
Strided& Strided::collapse(const Tdim& i, const Tsubscript& index)
{
AFF_assert((i<Mmax_dimen),
"ERROR (collapse shape): illegal dimension");
"ERROR (Strided::collapse): illegal dimension");
AFF_assert(((Mfirst[i]<=index)&&(index<=Mlast[i])),
"ERROR (collapse shape): index range erres");
"ERROR (Strided::collapse): index range error");
this->shrink(i,index,index);
Tsubscript offset=this->first_offset();
Tdim j=i+1;
......@@ -208,6 +221,7 @@ namespace prebuilt {
Mlast[Mmax_dimen]=1;
Mstride[Mmax_dimen]=this->size(Mmax_dimen-2)*Mstride[Mmax_dimen-2];
this->calculate_base(offset);
return(*this);
}
#ifdef AFF_PREBUILT
......
/*! \file stridedstepper_def.h
* \brief definition of strided stepper functions (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: stridedstepper.cc,v 1.1 2002-12-15 19:32:52 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
* definition of strided stepper functions (prototypes)
*
* \note
* Never include this header directly. Here you find code factored out from
* the aff::StridedStepper class. This code may be compiled into a binary
* library.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
*
* ============================================================================
*/
#ifndef AFF_STRIDED_H_VERSION
#error "include this only through strided.h"
#endif
// include guard
#ifndef AFF_STRIDEDSTEPPER_DEF_H_VERSION
#define AFF_STRIDEDSTEPPER_DEF_H_VERSION \
"AFF_STRIDEDSTEPPER_DEF_H V1.0 "
#define AFF_STRIDEDSTEPPER_DEF_H_CVSID \
"$Id: stridedstepper.cc,v 1.1 2002-12-15 19:32:52 forbrig Exp $"
namespace aff {
#ifdef AFF_PREBUILT
namespace prebuilt {
#endif
#ifdef AFF_PREBUILT
#ifndef AFF_COMPILING_LIBRARY
#error "definition read in prebuilt mode and not during library compilation"
#endif
#endif
#ifdef AFF_PREBUILT
using namespace aff::prebuilt::util;
#else
using namespace aff::util;
#endif
namespace util {
template<Tdim N, Tdim M>
class StepperInline {
public:
/*! \brief Index increment with range given by first, last, and stride
*
* \param I array of current index values to multidimensional array
* \param F array of smallest index values that are allowed
* \param L array of largest index values that are allowed
* \param S array of strides
* \return offset to previous linear offset position
* (\p I indicates next position on return)
*
* \sa Stepper
* \sa contxx::shape::Strided
* \sa contxx::shape::DenseStrided
*/
static inline Tsubscript increment(Tsubscript* I,
const Tsubscript* F, const Tsubscript* L, const Tsize* S)
{
if (I[N-M]<L[N-M])
{
I[N-M]++;
return(Tsubscript(S[N-M]));
}
else
{
Tsubscript R=-(I[N-M]-F[N-M])*S[N-M];
I[N-M]=F[N-M];
R+=StepperInline<N, M-1>::increment(I,F,L,S);
return(R);
}
return(0);
}
/*! \brief Index decrement with range given by first, last, and stride
*
* \param I array of current index values to multidimensional array
* \param F array of smallest index values that are allowed
* \param L array of largest index values that are allowed
* \param S array of strides
* \return offset to previous linear offset position
* (\p I indicates next position on return)
*
* \sa Stepper
* \sa contxx::shape::Strided
* \sa contxx::shape::DenseStrided
*/
static inline Tsubscript decrement(Tsubscript* I,
const Tsubscript* F, const Tsubscript* L, const Tsize* S)