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

a lot of corrections

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: 1192
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 9345a7af
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.5 2002-12-13 22:38:24 forbrig Exp $
* $Id: array_dec.h,v 1.6 2002-12-13 23:48:28 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -29,11 +29,11 @@
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.0 "
#define AFF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.5 2002-12-13 22:38:24 forbrig Exp $"
"$Id: array_dec.h,v 1.6 2002-12-13 23:48:28 forbrig Exp $"
#include <aff/sharedheap.h>
#include <aff/strided.h>
#include <aff/range.h>
#include <aff/lib/sharedheap.h>
#include <aff/lib/strided.h>
// #include <aff/lib/range.h>
namespace aff {
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_def.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $
* $Id: array_def.h,v 1.4 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -38,7 +38,7 @@
#define AFF_ARRAY_DEF_H_VERSION \
"AFF_ARRAY_DEF_H V1.0 "
#define AFF_ARRAY_DEF_H_CVSID \
"$Id: array_def.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $"
"$Id: array_def.h,v 1.4 2002-12-13 23:48:29 forbrig Exp $"
namespace aff {
......@@ -46,11 +46,11 @@ namespace aff {
namespace prebuilt {
#endif
#ifdef AFF_PREBUILT
using namespace aff::prebuilt::shape;
#else
using namespace aff::shape;
#endif
//#ifdef AFF_PREBUILT
// using namespace aff::prebuilt::shape;
//#else
// using namespace aff::shape;
//#endif
#ifdef AFF_PREBUILT
#ifndef FF_COMPILING_LIBRARY
......@@ -84,12 +84,14 @@ namespace prebuilt {
template<class T>
Array<T>& Array<T>::operator=(const T& value)
{
/*
typename Tshape::Tstepper st(this->Tshape::stepper());
st.tofirst();
for (st.tofirst(); st.more(); st.incr())
{
this->Trepresentation::operator[](st.current())=value;
}
*/
return(*this);
}
......
......@@ -3,11 +3,15 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.1 2002-12-12 22:08:20 forbrig Exp $
* $Id: dump.h,v 1.2 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
* debug helpers (prototypes)
*
* \note
* You should include aff/array.h or aff/binarray.h just before including this
* file.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -23,7 +27,7 @@
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.0 "
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.1 2002-12-12 22:08:20 forbrig Exp $"
"$Id: dump.h,v 1.2 2002-12-13 23:48:29 forbrig Exp $"
#include<iostream>
......@@ -33,15 +37,53 @@ namespace aff {
namespace prebuilt {
#endif
using std::endl;
/*! \defgroup group_helpers Debug functions
*/
/*----------------------------------------------------------------------*/
/*! \brief Dump heap contents
*
* \ingroup group_helpers
*/
template<class T>
void dump(const SharedHeap<T>::Tcoc& sharedheap, std::ostream& os=std::cout);
void dump(const SharedHeap<T>::Tcoc& sharedheap, std::ostream& os=std::cout)
{
os << "dump of a SharedHeap object:" << endl;
os << " size: " << sharedheap.size() << endl;
os << " elements:" << endl;
int i=0;
for (int k=0; k<sharedheap.size(); k++)
{
if (!i) { os << " "; }
os.width(9);
os << sharedheap[k] << " ";
if (++i>7) { i=0; os << endl; }
}
}
/*----------------------------------------------------------------------*/
/*! \brief Dump aff::SimpleRigidArray
*
* \ingroup group_helpers
*/
template<class T, int N>
void dump(const SimpleRigidArray<T,N>& array, std::ostream& os=std::cout)
{
int i=0;
for (int k=0; k<int(N); k++)
{
if (!i) { os << " "; }
os.width(9);
os << array[k] << " ";
if (++i>7) { i=0; os << endl; }
}
}
/*----------------------------------------------------------------------*/
/*! \brief Dump array values
*
......@@ -50,24 +92,36 @@ void dump(const SharedHeap<T>::Tcoc& sharedheap, std::ostream& os=std::cout);
template<class T>
void dump(const Array<T>::Tcoc& array, std::ostream& os=std::cout);
/*----------------------------------------------------------------------*/
/*! \brief Dump array shape information
*
* \ingroup group_helpers
*/
void dump(const Strided& shape, std::ostream& os=std::cout);
/*----------------------------------------------------------------------*/
/*! \brief Dump array shape mapping
*
* \ingroup group_helpers
*/
void dump_map(const Strided& shape, std::ostream& os=std::cout);
/*----------------------------------------------------------------------*/
#ifdef AFF_PREBUILT
} // namespace prebuilt
#endif
} // namespace aff
/*! \brief Dump any
*
* \ingroup group_helpers
*/
#define DUMP( A ) std::cout << #A << ":" << endl; aff::dump(A)
#endif // AFF_DUMP_H_VERSION (includeguard)
/* ----- END OF dump.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: error.h,v 1.2 2002-12-13 22:38:24 forbrig Exp $
* $Id: error.h,v 1.3 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \date 27/11/2002
*
......@@ -28,7 +28,7 @@
#define AFF_ERROR_H_VERSION \
"AFF_ERROR_H V1.0 "
#define AFF_ERROR_H_CVSID \
"$Id: error.h,v 1.2 2002-12-13 22:38:24 forbrig Exp $"
"$Id: error.h,v 1.3 2002-12-13 23:48:29 forbrig Exp $"
namespace aff {
......@@ -75,9 +75,10 @@ namespace aff {
static void report_on_construct();
//! Issue NO screen report on construction of exception
static void dont_report_on_construct();
private:
protected:
//! Screen report
void base_report() const;
private:
//! Shall we print to cerr at construction time?
static bool Mreport_on_construct;
//! pointer to message string
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: rawarfun.h,v 1.3 2002-12-11 20:58:10 forbrig Exp $
* $Id: rawarfun.h,v 1.4 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -30,7 +30,7 @@
#define AFF_RAWARFUN_H_VERSION \
"AFF_RAWARFUN_H V1.1 "
#define AFF_RAWARFUN_H_CVSID \
"$Id: rawarfun.h,v 1.3 2002-12-11 20:58:10 forbrig Exp $"
"$Id: rawarfun.h,v 1.4 2002-12-13 23:48:29 forbrig Exp $"
#include<aff/lib/types.h>
......@@ -150,24 +150,24 @@ namespace util {
static inline void copy(const T1* source, T2* target)
{
target[I-1]=source[I-1];
Inline<T1, T2,I-1>::copy(source, target);
Inline2<T1, T2, I-1>::copy(source, target);
}
//! set all elements to value
static inline void set(T1* array, const T2& value)
{
array[I-1]=value; Inline<T1, T2 ,I-1>::set(array, value);
array[I-1]=value; Inline2<T1, T2 ,I-1>::set(array, value);
}
//! true if ony of A is smaller than corresponding B
static inline bool anysmaller(const T1* A, const T2* B)
{
return (((*A) < (*B))
|| Inline<T1, T2, I-1>::anysmaller(&(A[1]), &(B[1])));
|| Inline2<T1, T2, I-1>::anysmaller(&(A[1]), &(B[1])));
}
//! true if ony of A is larger than corresponding B
static inline bool anylarger(const T1* A, const T2* B)
{
return (((*A) > (*B))
|| Inline<T1, T2,I-1>::anylarger(&(A[1]), &(B[1])));
|| Inline2<T1, T2,I-1>::anylarger(&(A[1]), &(B[1])));
}
/*! \brief calculate inner product
*
......@@ -177,7 +177,7 @@ namespace util {
*/
static inline T1 innerproduct(const T1* A, const T2* B)
{
return(A[I-1]*B[I-1]+Inline<T1, T2, I-1>::innerproduct(A,B));
return(A[I-1]*B[I-1]+Inline2<T1, T2, I-1>::innerproduct(A,B));
}
/*! \brief calculate stride product
*
......@@ -196,7 +196,7 @@ namespace util {
*/
static inline T1 strideproduct(const T1* A, const T2* B)
{
return((*A)+(*B)*Inline<T1, T2, I-1>::strideproduct(&(A[1]),&(B[1])));
return((*A)+(*B)*Inline2<T1, T2, I-1>::strideproduct(&(A[1]),&(B[1])));
}
};
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap.h,v 1.6 2002-12-13 22:38:24 forbrig Exp $
* $Id: sharedheap.h,v 1.7 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -26,7 +26,7 @@
#define AFF_SHAREDHEAP_H_VERSION \
"AFF_SHAREDHEAP_H V1.2 "
#define AFF_SHAREDHEAP_H_CVSID \
"$Id: sharedheap.h,v 1.6 2002-12-13 22:38:24 forbrig Exp $"
"$Id: sharedheap.h,v 1.7 2002-12-13 23:48:29 forbrig Exp $"
#include<new>
#include<aff/lib/error.h>
......@@ -39,11 +39,11 @@ namespace aff {
namespace prebuilt {
#endif
//#ifdef AFF_PREBUILT
// using namespace aff::prebuilt::util;
//#else
// using namespace aff::util;
//#endif
#ifdef AFF_PREBUILT
using namespace aff::prebuilt::util;
#else
using namespace aff::util;
#endif
/*! \brief Exception thrown in case of allocation error
*
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap_def.h,v 1.4 2002-12-13 22:38:24 forbrig Exp $
* $Id: sharedheap_def.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -31,7 +31,7 @@
#define AFF_SHAREDHEAP_DEF_H_VERSION \
"AFF_SHAREDHEAP_DEF_H V1.0 "
#define AFF_SHAREDHEAP_DEF_H_CVSID \
"$Id: sharedheap_def.h,v 1.4 2002-12-13 22:38:24 forbrig Exp $"
"$Id: sharedheap_def.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $"
namespace aff {
......@@ -47,14 +47,14 @@ namespace prebuilt {
//! instantiate AllocException
AllocException::AllocException(const Tsize& n, const Tsize& size):
Mn(n), Msize(size), Exception("ERROR: memory allocation failed!") { }
Exception("ERROR: memory allocation failed!"), Mn(n), Msize(size) { }
//! report AllocException
void AllocException::report() const
{
basereport();
std::cout << " You requested " << n << " memory locations of "
<< size << " Bytes size." << endl;
base_report();
std::cout << " You requested " << Mn << " memory locations of "
<< Msize << " Bytes size." << std::endl;
}
/*----------------------------------------------------------------------*/
......@@ -117,7 +117,7 @@ namespace prebuilt {
*/
template <typename T>
inline
SharedHeap<T>::SharedHeap(Tpointer* pointer, const Tsize& size);
SharedHeap<T>::SharedHeap(Tpointer* pointer, const Tsize& size)
: Mheapstruct(new Theapstruct(static_cast<Tmutable_pointer>(pointer),
size)) { }
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: simplearray.h,v 1.4 2002-12-13 22:38:24 forbrig Exp $
* $Id: simplearray.h,v 1.5 2002-12-13 23:48:29 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.4 2002-12-13 22:38:24 forbrig Exp $"
"$Id: simplearray.h,v 1.5 2002-12-13 23:48:29 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/rawarfun.h>
......@@ -102,13 +102,13 @@ namespace prebuilt {
template<class TT>
explicit SimpleRigidArray(const TT& value)
{
aff::util::Inline2<T, TT, N>::inline_set(Marray, 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>::inline_copy(array.Marray, Marray);
aff::util::Inline2<TT, T, N>::copy(array.pointer(), Marray);
}
//@}
......@@ -121,14 +121,14 @@ namespace prebuilt {
template<class TT>
SimpleRigidArray& operator=(const SimpleRigidArray<TT, N>& array)
{
aff::util::Inline2<TT, T, N>::inline_copy(array.Marray, Marray);
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)
{
aff::util::Inline2<T, TT, N>::inline_set(Marray, value);
aff::util::Inline2<T, TT, N>::set(Marray, value);
return(*this);
}
//@}
......@@ -181,6 +181,12 @@ namespace prebuilt {
const SimpleRigidArray<T, N>& B)
{ return Inline<T, N>::anylarger(A.pointer(), B.pointer()); }
//! Returns true if any of A is larger than corresponding B
template<typename T1, typename T2, Tsize N>
inline bool inline_anylarger(const SimpleRigidArray<T1, N>& A,
const SimpleRigidArray<T2, N>& B)
{ return Inline2<T1, T2, N>::anylarger(A.pointer(), B.pointer()); }
//! Returns inner product
template<typename T, Tsize N>
inline T inline_innerproduct(const SimpleRigidArray<T, N>& A,
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.h,v 1.7 2002-12-13 22:38:24 forbrig Exp $
* $Id: strided.h,v 1.8 2002-12-13 23:48:29 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.7 2002-12-13 22:38:24 forbrig Exp $"
"$Id: strided.h,v 1.8 2002-12-13 23:48:29 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/simplearray.h>
......@@ -115,7 +115,7 @@ namespace prebuilt {
*/
//@{
//! construct and initialize to zero
Strided(): Mstride(0), Mfirst(0), Msize(0), Mbase(0), Moffset(0) { }
Strided(): Mstride(0), Mfirst(0), Mlast(0), Mbase(0) { }
/*! \brief construct do given size and first index
*
* \param sizes vector defining index range size for each dimension
......@@ -148,10 +148,10 @@ namespace prebuilt {
//! total number of mapped elements
Tsize size() const;
//! first mapped position
const Tsubscript& first_offset() const
Tsubscript first_offset() const
{ return offset(Mfirst[0]); }
//! last mapped position
const Tsubscript& last_offset() const
Tsubscript last_offset() const
{ return offset(Mlast); }
//! first index of dimension \par i
const Tsubscript& first(const Tsubscript& i) const
......@@ -160,7 +160,7 @@ namespace prebuilt {
Tsubscript last(const Tsubscript& i) const
{ return (Mlast[i]); }
//! size of dimension \par i
const Tsize& size(const Tsubscript& i) const
Tsize size(const Tsubscript& i) const
{ return (static_cast<Tsize>(Mlast[i]-Mfirst[i]+1)); }
//! stride of dimension \par i
const Tsize& stride(const Tsubscript& i) const
......@@ -180,25 +180,25 @@ namespace prebuilt {
*/
//@{
//! full dimensionality access
Tsubscript offset()(const TIndexVec& index) const
{ return(inner_product(index,Mstride)+Mbase[Mmax_dimen-1]); }
Tsubscript offset(const TIndexVec& index) const
{ return(inline_innerproduct(index,Mstride)+Mbase[Mmax_dimen-1]); }
//! offset from 1 index value
Tsubscript offset()(const Tsubscript& i0) const
Tsubscript offset(const Tsubscript& i0) const
{ return(i0*Mstride[0]+Mbase[0]); }
//! offset from 2 index values
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1) const
Tsubscript offset(const Tsubscript& i0,
const Tsubscript& i1) const
{ return(i0*Mstride[0]+i1*Mstride[1]+Mbase[1]); }
//! offset from 3 index values
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
Tsubscript offset(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+Mbase[2]); }
//! offset from 4 index values
Tsubscript offset()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
Tsubscript offset(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3) const
{ return(i0*Mstride[0]+i1*Mstride[1]+i2*Mstride[2]+
i3*Mstride[3]+Mbase[3]); }
//@}
......@@ -226,7 +226,7 @@ namespace prebuilt {
/*-----------------------------------------------------------------*/
private:
void calculate_base(const Tsubscript& offset) const;
void calculate_base(const Tsubscript& offset);
TSizeVec Mstride; //<! strides for each dimension
TIndexVec Mfirst; //<! first index of each dimension
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided_def.h,v 1.5 2002-12-13 22:38:24 forbrig Exp $
* $Id: strided_def.h,v 1.6 2002-12-13 23:48:30 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.5 2002-12-13 22:38:24 forbrig Exp $"
"$Id: strided_def.h,v 1.6 2002-12-13 23:48:30 forbrig Exp $"
#include<aff/lib/error.h>
......@@ -66,7 +66,7 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
//! construct do given size and first index
Strided::Strided(const TSizeVec& sizes,
Strided::Strided(const TSizeVec& size,
const Tsubscript& first,
const Tsubscript& shift)
{
......@@ -75,11 +75,11 @@ namespace prebuilt {
"ERROR (Strided): size must be at least one");
Mfirst=first;
Mstride[0]=1;
Mlast[0]=Mfirst[0]+Msize[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]+Msize[i]-1;
Mlast[i]=Mfirst[i]+size[i]-1;
}
calculate_base(shift);
}
......@@ -97,7 +97,7 @@ namespace prebuilt {
Mstride[0]=1;
for(Tdim i=1; i<Mmax_dimen; i++)
{
Mstride[i]=Mstride[i-1]*(1+Mlast[i-1]-Mfirst(i-1));
Mstride[i]=Mstride[i-1]*(1+Mlast[i-1]-Mfirst[i-1]);
}
calculate_base(shift);
}
......@@ -105,7 +105,7 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
//! construct do given first and last index
void Strided::calculate_base(const Tsubscript& offset) const
void Strided::calculate_base(const Tsubscript& offset)
{
Mbase[0]=offset-Mfirst[0]*Mstride[0];
for (Tdim i=1; i<Mmax_dimen; i++)
......@@ -156,7 +156,7 @@ namespace prebuilt {
const Tsubscript& first,
const Tsubscript& last)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
AFF_assert((i<Mmax_dimen),
"ERROR (shrink shape): illegal dimension");
AFF_assert(((Mfirst[i]<=first)&&(first<=last)&&(last<=Mlast[i])),
"ERROR (shrink shape): index range erres");
......@@ -175,7 +175,7 @@ namespace prebuilt {
void Strided::shrink(const Tdim& i,
const Tsubscript& last)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
AFF_assert((i<Mmax_dimen),
"ERROR (shrink shape): illegal dimension");
this->shrink(i,Mfirst[i],last);
}
......@@ -190,12 +190,12 @@ namespace prebuilt {
*/
void Strided::collapse(const Tdim& i, const Tsubscript& index)
{
AFF_assert(((0<=i)&&(i<Mmax_dimen)),
AFF_assert((i<Mmax_dimen),
"ERROR (collapse shape): illegal dimension");
AFF_assert(((Mfirst[i]<=index)&&(index<=Mlast[i])),
"ERROR (collapse shape): index range erres");
this->shrink(i,index,index);
Tsubscript offset=this->offset(newfirst);
Tsubscript offset=this->first_offset();
Tdim j=i+1;
while (j<Mmax_dimen)
{
......
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.2 2002-12-06 19:21:08 forbrig Exp $
# $Id: Makefile,v 1.3 2002-12-13 23:48:30 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -17,7 +17,7 @@ CPPFLAGS=-I$(LOCINCLUDEDIR) -I$(SERVERINCLUDEDIR)
LDFLAGS=-L$(SERVERLIBDIR) -L$(LOCLIBDIR)