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

Carray.cc is not needed

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.
CArray and ConstCArray are implemented except the constructor of
ConstCArray


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libfourier
SVN Revision: 3941
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent eb13da75
/*! \file Carray.cc
* \brief classes to interface raw C arrays (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 14/05/2011
*
* classes to interface raw C arrays (implementation)
*
* Copyright (c) 2011 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 14/05/2011 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define AFF_CARRAY_CC_VERSION \
"AFF_CARRAY_CC V1.0 "
#define AFF_CARRAY_CC_CVSID \
"$Id$"
#include <aff/Carray.h>
namespace aff {
} // namespace aff
/* ----- END OF Carray.cc ----- */
......@@ -42,8 +42,225 @@
#define AFF_CARRAY_H_CVSID \
"$Id$"
#include<aff/array.h>
#include<aff/lib/checkedcast.h>
namespace aff {
/*! \brief Interface class to raw memory (C style array)
*
*/
template<class T>
class ConstCArray
{
public:
/*! \name Various types
*
* In particular due to our concept of const-correctness we need
* several typedefs to declare types derived from the element type of
* the array.
*
* \sa \ref sec_design_interface_typedef
* \sa \ref sec_design_const
*/
//@{
//! Type of array to be interfaced
typedef aff::ConstArray<T> Tarray;
//! Type of representation
typedef Tarray::Trepresentation Trepresentation;
//! Type of shape
typedef Tarray::Tshape Tshape;
//! we use this for one of the access operators
typedef Tshape::TSizeVec TSizeVec;
//! Element type
typedef Tarray::Tvalue Tvalue;
//! Type of pointer to element
typedef Tarray::Tpointer Tpointer;
//! Type of reference to element
typedef Tarray::Treference Treference;
//! const element type
typedef Tarray::Tconst_value Tconst_value;
//! Type of pointer to const element
typedef Tarray::Tconst_pointer Tconst_pointer;
//! Type of reference to const element
typedef Tarray::Tconst_reference Tconst_reference;
//! Type of this array
typedef ConstCArray<T> Tcontainer;
//! Type of the array of const values
typedef Tcontainer Tcontainer_of_const;
//! Short for Tcontainer_of_const
typedef Tcontainer Tcoc;
//@}
/*-----------------------------------------------------------------*/
/*! \name Constructors
*
* No copy constructors or copy operators are provided since this is
* provided as an interface class only.
*/
//@{
//! construct from shape and representation
ConstCArray(const Tarray& array)
: Mrepresentation(array.representation())
{
}
//@}
/*------------------------------------------------------------------*/
/*! \name Shape access
*/
//@{
//! size of dimension \par i
const Tsize& size(const Tsubscript& i) const
{ return (Msize[i]); }
//! stride of dimension \par i
const Tsize& stride(const Tsubscript& i) const
{ return Mstride[i]; }
//! size of dimensions
const TSizeVec& size() const
{ return (Msize); }
//! strides of dimensions
const TSizeVec& stride() const
{ return Mstride; }
//@}
/*-----------------------------------------------------------------*/
/*! \name Memory access
*
*/
//@{
//! return pointer to first element in Fortran layout
Tconst_pointer pointer() const
{ return(&Mrepresentation[this->offset()]); }
/*! \brief return type-casted pointer to first element in Fortran
* layout
*
* The cast checks for const-correctness and type-size. But you have
* to ensure that there is a meaningful relation between both types
* involved.
*
* \sa aff::util::SizeCheckedCast
*/
template<class TT>
TT* castedpointer() const
{ return(SizeCheckedCast<Tconst_value,TT>::cast(this->pointer())); }
//@}
protected:
//! pass offset to derived class
const TSizeVec::Tvalue& offset() const { return Moffset; }
private:
//! representation member
Trepresentation Mrepresentation;
//! sizes of dimensions
TSizeVec Msize;
//! strides of dimensions
TSizeVec Mstride;
//! offset to first index
TSizeVec::Tvalue Moffset;
}; // class ConstCArray
/*======================================================================*/
/*! \brief Interface class to raw memory (C style array)
*
* See aff::ConstCArray for the basic concepts used here.
*
* \sa aff::ConstCArray
*/
template<class T>
class CArray:
public ConstCArray<T>
{
public:
/*! \name Various types
*
* In particular due to our concept of const-correctness we need
* several typedefs to declare types derived from the element type of
* the array.
*
* \sa \ref sec_design_interface_typedef
* \sa \ref sec_design_const
*/
//@{
//! Type of array to be interfaced
typedef aff::Array<T> Tarray;
//! Base class
typedef aff::ConstCArray<T> Tbase;
//! Type of representation
typedef Tarray::Trepresentation Trepresentation;
//! Type of shape
typedef Tarray::Tshape Tshape;
//! we use this for one of the access operators
typedef Tshape::TSizeVec TSizeVec;
//! Element type
typedef Tarray::Tvalue Tvalue;
//! Type of pointer to element
typedef Tarray::Tpointer Tpointer;
//! Type of reference to element
typedef Tarray::Treference Treference;
//! const element type
typedef Tarray::Tconst_value Tconst_value;
//! Type of pointer to const element
typedef Tarray::Tconst_pointer Tconst_pointer;
//! Type of reference to const element
typedef Tarray::Tconst_reference Tconst_reference;
//! Type of this array
typedef CArray<T> Tcontainer;
//! Type of the array of const values
typedef Tbase Tcontainer_of_const;
//! Short for Tcontainer_of_const
typedef Tcontainer Tcoc;
//@}
/*-----------------------------------------------------------------*/
/*! \name Constructors
*
* No copy constructors or copy operators are provided since this is
* provided as an interface class only.
*/
//@{
//! construct from shape and representation
Array(const Tarray& array)
: Tbase(array), Mrepresentation(array.representation())
{ }
//@}
/*-----------------------------------------------------------------*/
/*! \name Memory access
*
*/
//@{
//! return pointer to first element in Fortran layout
Tpointer pointer() const
{ return(&Mrepresentation[this->offset()]); }
/*! \brief return type-casted pointer to first element in Fortran
* layout
*
* The cast checks for const-correctness and type-size. But you have
* to ensure that there is a meaningful relation between both types
* involved.
*
* \sa aff::util::SizeCheckedCast
*/
template<class TT>
TT* castedpointer() const
{ return(SizeCheckedCast<Tvalue,TT>::cast(this->pointer())); }
//@}
private:
//! my (mutable) data representation
Trepresentation Mrepresentation;
}; // class CArray
} // namespace aff
#endif // AFF_CARRAY_H_VERSION (includeguard)
......
......@@ -101,7 +101,7 @@ HEADERS=$(shell find . -name \*.h)
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \
lib/seriesstepper.cc fortranshape.cc Carray.cc
lib/seriesstepper.cc fortranshape.cc
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
......
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