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

proceeding - slowly

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: 1184
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f00896eb
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.2 2002-12-08 22:33:53 forbrig Exp $
* $Id: array_dec.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -29,7 +29,7 @@
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.0 "
#define AFF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.2 2002-12-08 22:33:53 forbrig Exp $"
"$Id: array_dec.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $"
#include <aff/sharedheap.h>
#include <aff/strided.h>
......@@ -70,6 +70,14 @@ namespace prebuilt {
* \sa \ref sec_main_modules
* \sa tests/arraytest.cc
*
* \note
* We may just use the default copy constructor and default copy operator.
*
* If you want to create an array for externally managed memory (e.g. arrays
* taken from Fortran code): First create a SharedHeap representation for the
* given memory pointer and size. Second create a shape, defining the memory
* layout and then create the array object from these both.
*
* \todo
* documentation of class Array must be reworked
*
......@@ -79,91 +87,64 @@ namespace prebuilt {
* \todo
* Explain the new concept of multidimensional array indexing
*/
template<class T,
Tdim N=1,
template<class TT>
class Representation=SharedHeap,
template<class TT, Tdim NN, template<class TTT> class RR>
class Subscriptor=StridedRepresentation>
template<class T>
class Array:
public Subscriptor<T, N, Representation>
public aff::Strided, public aff::SharedHeap<T>
{
public:
//! Type of representation
typedef Representation<T> Trepresentation;
//! Type of subscriptor
typedef Subscriptor<T, N, Representation> Tsubscriptor;
//! Type of shape
typedef typename Tsubscriptor::Tshape Tshape;
//! Element type
typedef typename Trepresentation::Tvalue Tvalue;
//! Type of pointer to element
typedef typename Trepresentation::Tpointer Tpointer;
//! Type of reference to element
typedef typename Trepresentation::Treference Treference;
//! Type of const reference to element
typedef typename Trepresentation::Tconst_reference Tconst_reference;
//! Type to be used as data representation
typedef typename Trepresentation::Tmutable_value Tmutable_value;
//! Type to be used as element for const version
typedef typename Trepresentation::Tconst_value Tconst_value;
//! Type of this array
typedef Array<T, N, Representation, Subscriptor> Tcontainer;
//! Type of the array of const values
typedef Array<Tconst_value, N, Representation, Subscriptor>
Tcontainer_of_const;
/*! \brief \b deprecated! Type of size array
* \deprecated
* This feature may be removed in future versions
*/
typedef SimpleRigidArray<Tsize, N> Tsizes;
/*! \brief \b deprecated! Type of range
* \deprecated
* This feature may be removed in future versions
*/
typedef Range<Tsubscript> Trange;
/*! \brief \b deprecated! Type of range array
* \deprecated
* This feature may be removed in future versions
*/
typedef SimpleRigidArray<Trange, N> Tranges;
//! construct from nothing (empty)
Array() { }
//! construct from shape and representation
Array(const Tshape& shape,
const Trepresentation& representation);
//! construct from shape
explicit Array(const Tshape& shape);
/*! \brief \b deprecated! construct from sizes
* \deprecated
* This constructor may be removed in future versions
* Use shapers instead.
*/
explicit Array(const Tsizes& size);
/*! \brief \b deprecated! construct from ranges
* \deprecated
* This constructor may be removed in future versions.
* Use shapers instead.
*/
explicit Array(const Tranges& ranges);
//! conversion to container of const values
operator Tcontainer_of_const() const
{
Tcontainer_of_const retval(*this, *this);
return(retval);
}
//! by size we mean the size defined by the shape
Tsize size(const Tsubscript& i) const
{ return(this->Tshape::size(i)); }
//! by size we mean the size defined by the shape
Tsize size() const
{ return(this->Tshape::size()); }
//! set value to whole array
Array& operator=(const T& value);
public:
//! Type of representation
typedef aff::SharedHeap<T> Trepresentation;
//! Type of subscriptor
typedef aff::Strided Tshape;
//! Element type
typedef typename Trepresentation::Tvalue Tvalue;
//! Type of pointer to element
typedef typename Trepresentation::Tpointer Tpointer;
//! Type of reference to element
typedef typename Trepresentation::Treference Treference;
//! Type of const reference to element
typedef typename Trepresentation::Tconst_reference Tconst_reference;
//! Type to be used as data representation
typedef typename Trepresentation::Tmutable_value Tmutable_value;
//! Type to be used as element for const version
typedef typename Trepresentation::Tconst_value Tconst_value;
//! Type of this array
typedef Array<T> Tcontainer;
//! Type of the array of const values
typedef Array<Tconst_value> Tcontainer_of_const;
//! construct from nothing (empty)
Array() { }
//! construct from shape and representation
Array(const Tshape& shape,
const Trepresentation& representation);
//! construct from shape (defines size and layout)
explicit Array(const Tshape& shape);
//! conversion to container of const values
operator Tcontainer_of_const() const
{
Tcontainer_of_const retval(*this, *this);
return(retval);
}
//! by size we mean the size defined by the shape
Tsize size(const Tsubscript& i) const
{ return(this->Tshape::size(i)); }
//! by size we mean the size defined by the shape
Tsize size() const
{ return(this->Tshape::size()); }
//! set whole array to value
Array& operator=(const T& value);
//! create an identical COPY (deep copy) of this array
Array copyout() const;
//! COPY values (deep copy) from other array of convertible type
//! (returns itself)
template<class TT>
Array& copyin(const Array<TT>& a);
}; // class Array
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_def.h,v 1.2 2002-12-08 22:33:53 forbrig Exp $
* $Id: array_def.h,v 1.3 2002-12-10 19:56:01 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.2 2002-12-08 22:33:53 forbrig Exp $"
"$Id: array_def.h,v 1.3 2002-12-10 19:56:01 forbrig Exp $"
namespace aff {
......@@ -60,62 +60,19 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tranges& ranges)
{
typename Tshape::Tlimits first, last;
for (int i=0; i<N; i++)
{
first[i]=ranges[i].first();
last[i]=ranges[i].last();
}
this->Tshape::operator=(Tshape(first,last));
this->Trepresentation::operator=(
Trepresentation(this->Tshape::size()));
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tsizes& sizes)
{
typename Tshape::Tlimits first, last;
for (int i=0; i<N; i++)
{
first[i]=0;
last[i]=sizes[i]-1;
}
this->Tshape::operator=(Tshape(first,last));
this->Trepresentation::operator=(
Trepresentation(this->Tshape::size()));
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tshape& shape,
const Trepresentation& representation)
template<class T>
Array<T>::Array(const Tshape& shape,
const Trepresentation& representation)
{
this->Tshape::operator=(shape);
this->Trepresentation::operator=(representation);
AFF_abort("check consitency (not yet implemented)");
}
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>::Array(const Tshape& shape)
template<class T>
Array<T>::Array(const Tshape& shape)
{
this->Tshape::operator=(shape);
this->Trepresentation::operator=(
......@@ -124,11 +81,8 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
template<class T,
Tdim N,
template<class TT> class R,
template<class TT, Tdim NN, template<class TTT> class RR> class S>
Array<T,N,R,S>& Array<T,N,R,S>::operator=(const T& value)
template<class T>
Array<T>& Array<T>::operator=(const T& value)
{
typename Tshape::Tstepper st(this->Tshape::stepper());
st.tofirst();
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap.h,v 1.3 2002-12-10 19:30:07 forbrig Exp $
* $Id: sharedheap.h,v 1.4 2002-12-10 19:56:02 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -26,9 +26,10 @@
#define AFF_SHAREDHEAP_H_VERSION \
"AFF_SHAREDHEAP_H V1.2 "
#define AFF_SHAREDHEAP_H_CVSID \
"$Id: sharedheap.h,v 1.3 2002-12-10 19:30:07 forbrig Exp $"
"$Id: sharedheap.h,v 1.4 2002-12-10 19:56:02 forbrig Exp $"
#include<new>
#include<aff/lib/error.h>
#include<aff/lib/types.h>
#include<aff/lib/qualified.h>
......@@ -46,6 +47,7 @@ namespace prebuilt {
/*! \brief Exception thrown in case of allocation error
*
* \ingroup group_error
* \sa aff::Exception
*/
class AllocException:
......@@ -63,7 +65,7 @@ namespace prebuilt {
/*----------------------------------------------------------------------*/
/*! A structure to be shared between different SharedHeap.
/*! \brief A structure to be shared between different SharedHeap instances.
*
* This is the core part of represented shared heap. Only objects of this
* class allocate and delete memory. The SharedHeap representation has holds
......@@ -76,6 +78,8 @@ namespace prebuilt {
* For arrays taken from Fortran code we use a flag \c Mextern. If it is
* true, this indicates that memory should neither be allocated be the
* constructor nor given free by the destructor.
*
* \sa aff::SharedHeap
*/
template<typename T>
struct SHeap
......@@ -104,9 +108,7 @@ namespace prebuilt {
* \todo
* Add usefull documentation to this class.
*
* \todo
* Add a parameter that switches reference counting off. This will be used
* to support the use of preexisting arrays (allocated by Fortran e.g.).
* \sa aff::SHeap
*/
template <typename T>
class SharedHeap
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.h,v 1.2 2002-12-08 22:33:54 forbrig Exp $
* $Id: strided.h,v 1.3 2002-12-10 19:56:02 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -13,6 +13,9 @@
* \note
* You usually will not include this directly. It is included through array.h
* and binarray.h
*
* \todo
* Needs a maximum dimensionality defining static member.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -28,7 +31,7 @@
#define AFF_STRIDED_H_VERSION \
"AFF_STRIDED_H V1.0 "
#define AFF_STRIDED_H_CVSID \
"$Id: strided.h,v 1.2 2002-12-08 22:33:54 forbrig Exp $"
"$Id: strided.h,v 1.3 2002-12-10 19:56:02 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/rawarfun.h>
......
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