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

provide new functions, changed interface

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: 1802
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent dba1cddc
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README,v 1.25 2005-07-04 13:58:13 tforb Exp $
* $Id: README,v 1.26 2005-07-04 15:27:28 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -72,7 +72,7 @@ namespace aff {
\since December 2002
\date December 2002
\version V1.0
$Id: README,v 1.25 2005-07-04 13:58:13 tforb Exp $
$Id: README,v 1.26 2005-07-04 15:27:28 tforb Exp $
Contents of this page:
- \ref sec_main_aims
......@@ -742,17 +742,18 @@ in the structure of header files and may be activated in the future.
\sa aff::ConstSeries
\par Restrictions for containers with const qualifier
In 7/2005 we changed the design decision of not allowing data modification
through containers that are declared const.
Strictly distinguishing between constness of the container and constness of
the contained data would allow to modify data through an object \c c that
the contained data allows to modify data through an object \c c that
was declared
\code const Array<int> c; \endcode
The containers in this library (aff::Array, etc.), however, provide only a
reduced set of access operators, when declared with \c const qualifier.
They do not allow direct modification of the data (only through assignment
to a non-const container instance).
Although the constness of the container object generally does not imply
constness of the contained data, we think that every user will expect the
classes to behave like this.
The containers in this library (aff::Array, etc.) allow data modification
through instances declared const. This may appear surprising to users of the
library. However, since it is possible to create a copy of a const container
at any place and modifying the data through this copy, we would regard a
different behaviour as a false promise.
To ensure true constness of the data, you have to assign to the base class
of the container.
Any container class (e.g. \c Cont) provides the type of container for const
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
* $Id: README.changelog,v 1.55 2005-07-04 15:27:29 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,7 +21,7 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
$Id: README.changelog,v 1.55 2005-07-04 15:27:29 tforb Exp $
\sa \ref page_project_status
......@@ -30,6 +30,9 @@
- \b 04/07/2005 (thof)
- \b !! removed lib/range.h, since the was no kind of array container.
Range classes already exist elsewhere (libtfxx, libpgplotxx).
- \b !! data modification is allowed through instances being declared
const (\ref sec_design_const_approach).
- aff::Series provides pointer access to underlying C-style array.
- \b 28/04/2005 (thof)
- added code for aff::func::histo()
......@@ -225,7 +228,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
$Id: README.changelog,v 1.55 2005-07-04 15:27:29 tforb Exp $
\sa \ref page_changelog
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: array_dec.h,v 1.25 2005-04-28 19:14:17 tforb Exp $
* $Id: array_dec.h,v 1.26 2005-07-04 15:27:29 tforb Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -61,6 +61,8 @@
* than an aff::ConstArray
* - aff::Array inherits copyout from aff::ConstArray
* - deepcopy is now in namespace aff
* - 04/07/2005 V1.11 (thof)
* - provide data modification through const Array
*
* ============================================================================
*/
......@@ -69,9 +71,9 @@
#ifndef AFF_ARRAY_DEC_H_VERSION
#define AFF_ARRAY_DEC_H_VERSION \
"AFF_ARRAY_DEC_H V1.10"
"AFF_ARRAY_DEC_H V1.11"
#define AFF_ARRAY_DEC_H_CVSID \
"$Id: array_dec.h,v 1.25 2005-04-28 19:14:17 tforb Exp $"
"$Id: array_dec.h,v 1.26 2005-07-04 15:27:29 tforb Exp $"
#include <aff/lib/sharedheap.h>
#include <aff/lib/strided.h>
......@@ -434,25 +436,25 @@ namespace prebuilt {
/*-----------------------------------------------------------------*/
//! full dimensionality access
T& operator()(const TIndexVec& index)
T& operator()(const TIndexVec& index) const
{ return(Mrepresentation[this->Tbase::offset(index)]); }
//! access from 1 index value
T& operator()(const Tsubscript& i0)
T& operator()(const Tsubscript& i0) const
{ return(Mrepresentation[this->Tbase::offset(i0)]); }
//! access from 2 index values
T& operator()(const Tsubscript& i0,
const Tsubscript& i1)
const Tsubscript& i1) const
{ return(Mrepresentation[this->Tbase::offset(i0, i1)]); }
//! access from 3 index values
T& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2)
const Tsubscript& i2) const
{ return(Mrepresentation[this->Tbase::offset(i0, i1, i2)]); }
//! access from 4 index values
T& operator()(const Tsubscript& i0,
const Tsubscript& i1,
const Tsubscript& i2,
const Tsubscript& i3)
const Tsubscript& i3) const
{ return(Mrepresentation[this->Tbase::offset(i0, i1, i2, i3)]); }
private:
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: linearshape.h,v 1.3 2004-01-13 19:51:55 tforb Exp $
* $Id: linearshape.h,v 1.4 2005-07-04 15:27:30 tforb Exp $
* \author Thomas Forbriger
* \date 23/12/2003
*
......@@ -28,7 +28,7 @@
#define AFF_LINEARSHAPE_H_VERSION \
"AFF_LINEARSHAPE_H V1.2 "
#define AFF_LINEARSHAPE_H_CVSID \
"$Id: linearshape.h,v 1.3 2004-01-13 19:51:55 tforb Exp $"
"$Id: linearshape.h,v 1.4 2005-07-04 15:27:30 tforb Exp $"
namespace aff {
......@@ -51,6 +51,10 @@ namespace aff {
* Thus the element \a k of the series will be found at index \a k-base
* in the representation.
*
* The shape guarantees that the memory layout is dense. This means that the
* elements of a series can be accessed like a C-style array through a
* pointer to the first element of the series.
*
* Since we do not need to handle multiple dimensions, we offer in-class
* reshaping functions.
*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sharedheap.h,v 1.16 2003-12-19 14:44:37 tforb Exp $
* $Id: sharedheap.h,v 1.17 2005-07-04 15:27:30 tforb Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -39,6 +39,9 @@
* ConstSharedHeap elements).
* - 19/12/2003 V1.7 (thof)
* - index check now should work
* - 04/07/2005 V1.8 (thof)
* - allows data modification through instances being
* declared const
*
* ============================================================================
*/
......@@ -47,9 +50,9 @@
#ifndef AFF_SHAREDHEAP_H_VERSION
#define AFF_SHAREDHEAP_H_VERSION \
"AFF_SHAREDHEAP_H V1.6"
"AFF_SHAREDHEAP_H V1.8"
#define AFF_SHAREDHEAP_H_CVSID \
"$Id: sharedheap.h,v 1.16 2003-12-19 14:44:37 tforb Exp $"
"$Id: sharedheap.h,v 1.17 2005-07-04 15:27:30 tforb Exp $"
#include<new>
#include<aff/lib/error.h>
......@@ -193,7 +196,7 @@ namespace util {
//! write access to data
inline
T& write_access(const Tsubscript& i)
T& write_access(const Tsubscript& i) const
{
#ifdef AFF_INDEXCHECK
AFF_assert(((i<Tsubscript(Mheapstruct->Msize)) && (i>=0)),
......@@ -277,13 +280,13 @@ namespace util {
//@}
//! delegate to base
T& operator[](const Tsubscript& i)
T& operator[](const Tsubscript& i) const
{ return(this->Tbase::write_access(i)); }
/*! Return array access.
* \return pointer to array on heap
*/
T* array()
T* array() const
{ return(this->Tbase::writable_array()); }
}; // class SharedHeap
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: series.h,v 1.16 2005-04-28 19:14:17 tforb Exp $
* $Id: series.h,v 1.17 2005-07-04 15:27:29 tforb Exp $
* \author Thomas Forbriger
* \date 17/12/2002
*
......@@ -47,6 +47,9 @@
* representation
* - 07/02/2004 V1.8 (thof)
* - provide index range manipulation access to user
* - 04/07/2005 V1.9 (thof)
* - provide pointer access
* - provide data modification through const Series
*
* ============================================================================
*/
......@@ -55,9 +58,9 @@
#ifndef AFF_SERIES_H_VERSION
#define AFF_SERIES_H_VERSION \
"AFF_SERIES_H V1.8"
"AFF_SERIES_H V1.9"
#define AFF_SERIES_H_CVSID \
"$Id: series.h,v 1.16 2005-04-28 19:14:17 tforb Exp $"
"$Id: series.h,v 1.17 2005-07-04 15:27:29 tforb Exp $"
#include <aff/lib/sharedheap.h>
#include <aff/lib/linearshape.h>
......@@ -152,6 +155,17 @@ namespace aff {
const T& operator()(const Tsubscript& i) const
{ return(Mrepresentation[this->Tshape::offset(i)]); }
/*! pointer to first element
*
* The shape guarantees that the memory layout is dense. This means
* that the elements of a series can be accessed like a C-style array
* through a pointer to the first element of the series. For this
* reason it is appropriate to provide direct access to the underlying
* memory block.
*/
const T* pointer() const
{ return &this->operator()(this->first()); }
/*-----------------------------------------------------------------*/
/*! \name Shape access
......@@ -319,8 +333,19 @@ namespace aff {
//@}
//! Data modification access
T& operator()(const Tsubscript& i)
T& operator()(const Tsubscript& i) const
{ return(Mrepresentation[this->Tbase::offset(i)]); }
/*! pointer to first element
*
* The shape guarantees that the memory layout is dense. This means
* that the elements of a series can be accessed like a C-style array
* through a pointer to the first element of the series. For this
* reason it is appropriate to provide direct access to the underlying
* memory block.
*/
T* pointer()
{ return &this->operator()(this->first()); }
//! set whole series to value
Tcontainer& operator=(const T& value);
......
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