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

proceeding - but does not compile in this stage!

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: 1187
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 8106fdb5
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: shaper.h,v 1.2 2002-12-08 22:33:53 forbrig Exp $
* $Id: shaper.h,v 1.3 2002-12-11 20:57:54 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -13,6 +13,8 @@
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
* - 11/12/2002 V1.1 rework class (thof)
* - remove template parameters
*
* ============================================================================
*/
......@@ -21,11 +23,12 @@
#ifndef AFF_SHAPER_H_VERSION
#define AFF_SHAPER_H_VERSION \
"AFF_SHAPER_H V1.0 "
"AFF_SHAPER_H V1.1 "
#define AFF_SHAPER_H_CVSID \
"$Id: shaper.h,v 1.2 2002-12-08 22:33:53 forbrig Exp $"
"$Id: shaper.h,v 1.3 2002-12-11 20:57:54 forbrig Exp $"
#include<aff/lib/strided.h>
#include<aff/lib/error.h>
namespace aff {
......@@ -33,12 +36,6 @@ namespace aff {
namespace prebuilt {
#endif
#ifdef AFF_PREBUILT
using namespace aff::prebuilt::util;
#else
using namespace aff::util;
#endif
/*! \brief Shaper class for Fortran layout
*
* To create the equivalent to the Fortran declaration statement
......@@ -56,56 +53,73 @@ namespace prebuilt {
* contxx::Array<int, 3> a3(contxx::shaper::Fortran<3>(-10,10));
* \endcode
* will set all dimensions to index range [-10:10].
*
* \todo
* rework documentation of class Shaper
*/
template<Tdim N=1>
class Shaper
{
public:
//! Type of Shape class
typedef Strided<N> Tshape;
//! First dimension is defined by constructor
Shaper(const Tsubscript& last)
{
Mfirst=1;
Mlast=last;
Mdim=1;
}
//! First dimension is defined by constructor
Shaper(const Tsubscript& first, const Tsubscript& last)
{
Mfirst=first;
Mlast=last;
Mdim=1;
}
//! Other dimensions are defined by bracket operator
Shaper<N>& operator() (const Tsubscript& last)
{
Mfirst[Mdim]=1;
Mlast[Mdim]=last;
// foolproof
if (Mdim<(N-1)) Mdim++;
return(*this);
}
//! Other dimensions are defined by bracket operator
Shaper<N>& operator() (const Tsubscript& first, const Tsubscript& last)
{
Mfirst[Mdim]=first;
Mlast[Mdim]=last;
// foolproof
if (Mdim<(N-1)) Mdim++;
return(*this);
}
//! Return the shape class
operator Tshape () const
{
return(Tshape(Mfirst, Mlast));
}
private:
//! limits
Tshape::Tlimits Mfirst, Mlast;
//! next dimension to set
Tdim Mdim;
};
class Shaper
{
public:
//! Type of Shape class
typedef Strided Tshape;
//! First dimension is defined by constructor
Shaper(const Tsubscript& last):
Mfirst(1), Mlast(1), Minterval(1), Mdim(1)
{
AFF_assert((last>=1), "ERROR (shaper): invalid limit");
Mfirst[0]=1;
Mlast[0]=last;
}
//! First dimension is defined by constructor
Shaper(const Tsubscript& first, const Tsubscript& last,
const Tsize& interval=1):
Mfirst(1), Mlast(1), Minterval(1), Mdim(1)
{
This must not compile!
Of what use is the interval?
Is this helpful in constructing layout of external Fortram
arrays?
AFF_assert((last>=first), "ERROR (shaper): invalid index range");
AFF_assert((interval>0), "ERROR (shaper): invalid index interval");
Mfirst[0]=first;
Mlast[0]=last;
Minterval[0]=interval;
}
//! Other dimensions are defined by bracket operator
Shaper& operator() (const Tsubscript& last)
{
AFF_assert((last>=1), "ERROR (shaper): invalid limit");
Mfirst[Mdim]=1;
Mlast[Mdim]=last;
// foolproof
if (Mdim<(Tshape::Mmax_dimen-1)) Mdim++;
return(*this);
}
//! Other dimensions are defined by bracket operator
Shaper& operator() (const Tsubscript& first, const Tsubscript& last)
{
AFF_assert((last>=first), "ERROR (shaper): invalid index range");
AFF_assert((interval>0), "ERROR (shaper): invalid index interval");
Mfirst[Mdim]=first;
Mlast[Mdim]=last;
Minterval[Mdim]=interval;
// foolproof
if (Mdim<(Tshape::Mmax_dimen-1)) Mdim++;
return(*this);
}
//! Return the shape class
operator Tshape () const
{
return(Tshape(Mfirst, Mlast));
}
private:
//! limits
Tshape::TLimitVec Mfirst, Mlast;
//! strides
Tshape::TSizeVec Minterval;
//! next dimension to set
Tdim Mdim;
};
#ifdef AFF_PREBUILT
} // namespace prebuilt
......
Supports Markdown
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