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

added shift and setfirst

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: 1197
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5c7792ea
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.cc,v 1.2 2002-12-15 20:48:01 forbrig Exp $
* $Id: strided.cc,v 1.3 2002-12-16 18:17:30 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -28,14 +28,16 @@
* - this now is a compilable source file (no longer a
* header) the code contains not template parameter
* and fits well in the binary library
* - 16/12/2002 V1.5 (thof)
* - wolle asked for shift and setfirst functions...
*
* ============================================================================
*/
#define AFF_STRIDED_CC_VERSION \
"AFF_STRIDED_DEF_H V1.3"
"AFF_STRIDED_DEF_H V1.5"
#define AFF_STRIDED_CC_CVSID \
"$Id: strided.cc,v 1.2 2002-12-15 20:48:01 forbrig Exp $"
"$Id: strided.cc,v 1.3 2002-12-16 18:17:30 forbrig Exp $"
#include<aff/lib/strided.h>
#include<aff/lib/error.h>
......@@ -208,6 +210,59 @@ namespace aff {
return(*this);
}
/*----------------------------------------------------------------------*/
//! shift
Strided& Strided::shift(const Tdim& i, const Tsubscript& index)
{
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::shift): illegal dimension");
Tsubscript offset=this->first_offset();
Mfirst[i]+=index;
Mlast[i]+=index;
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
//! shift
Strided& Strided::shift(const TIndexVec& index)
{
Tsubscript offset=this->first_offset();
for (Tdim i=0; i<Mmax_dimen; i++)
{
Mfirst[i]+=index[i];
Mlast[i]+=index[i];
}
this->calculate_base(offset);
return(*this);
}
/*----------------------------------------------------------------------*/
//! setfirst
Strided& Strided::setfirst(const Tdim& i, const Tsubscript& index)
{
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::setfirst): illegal dimension");
Tsubscript ishift=index-Mfirst[i];
return(this->shift(i, ishift));
}
/*----------------------------------------------------------------------*/
//! setfirst
Strided& Strided::setfirst(const TIndexVec& index)
{
TIndexVec ishift(index);
for (Tdim i=0; i<Mmax_dimen; i++)
{
ishift[i]-=Mfirst[i];
}
return(this->shift(ishift));
}
} // namespace aff
/* ----- END OF strided.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.h,v 1.10 2002-12-15 20:48:01 forbrig Exp $
* $Id: strided.h,v 1.11 2002-12-16 18:17:30 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -34,6 +34,9 @@
* - 14/12/2002 V1.4 (thof)
* - template-free definition part will now always
* be placed in the binary library
* - 16/12/2002 V1.5 (thof)
* - renamed subarray and slice function
* - added shift and setfirst
*
* ============================================================================
*/
......@@ -42,9 +45,9 @@
#ifndef AFF_STRIDED_H_VERSION
#define AFF_STRIDED_H_VERSION \
"AFF_STRIDED_H V1.3"
"AFF_STRIDED_H V1.5"
#define AFF_STRIDED_H_CVSID \
"$Id: strided.h,v 1.10 2002-12-15 20:48:01 forbrig Exp $"
"$Id: strided.h,v 1.11 2002-12-16 18:17:30 forbrig Exp $"
#include<aff/lib/types.h>
#include<aff/lib/simplearray.h>
......@@ -200,6 +203,13 @@ namespace aff {
/*! \name Support for slices and subarrays
*
* \note
* We intentionally call the subarray and slice functions \c shrink and
* \c collapse (rather than \c subarray and \c slice), because they do
* not return another shape instance, which is a subarray or slice. They
* in fact manipulate the existing instance and return itself! To get a
* copy, you must first create a copy and then call shrink, collapse,
* shift or setfirst for this copy.
*/
//@{
//! subarray
......@@ -214,6 +224,14 @@ namespace aff {
const Tsubscript& last);
//! slice
Strided& collapse(const Tdim& i, const Tsubscript& index);
//! shift
Strided& shift(const Tdim& i, const Tsubscript& index);
//! shift
Strided& shift(const TIndexVec& index);
//! setfirst
Strided& setfirst(const Tdim& i, const Tsubscript& index);
//! setfirst
Strided& setfirst(const TIndexVec& index);
//@}
/*-----------------------------------------------------------------*/
......
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