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

Shape class and utilities passed basic tests

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: 1214
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5710fe83
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.4 2002-12-18 17:41:32 forbrig Exp $
* $Id: README.changelog,v 1.5 2002-12-18 18:43:43 uid1201 Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -26,6 +26,11 @@
- defined dump function for Strided
- started with tests/shapetest.cc
- reworked stridedstepper to fit into new concept
- essential correction in aff::Strided::collapse()
- aff::Strided, aff::Shaper, and aff::util::StridedStepper
passed basic tests
- additionally aff::SharedHeap and aff::SimpleRigidArray passed their
basic tests
- \b 17/12/2002 (thof)
- introduced class Series
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.cc,v 1.4 2002-12-18 09:58:50 forbrig Exp $
* $Id: dump.cc,v 1.5 2002-12-18 18:43:43 uid1201 Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
......@@ -21,7 +21,7 @@
#define AFF_DUMP_CC_VERSION \
"AFF_DUMP_CC V1.1"
#define AFF_DUMP_CC_CVSID \
"$Id: dump.cc,v 1.4 2002-12-18 09:58:50 forbrig Exp $"
"$Id: dump.cc,v 1.5 2002-12-18 18:43:43 uid1201 Exp $"
#include <aff/dump.h>
......@@ -53,11 +53,82 @@ void dump(const Strided& shape, std::ostream& os)
/*----------------------------------------------------------------------*/
namespace {
//! recursive usage tests all offset functions
void dump_map_helper(const Strided& shape, const Tdim& i, const Tdim& j,
Strided::TIndexVec& index, std::ostream& os)
{
if (i>1)
{
for (index[i]=shape.first(i); index[i]<=shape.last(i); index[i]++)
{
os << " dimension ";
os << i << ": [" << index[i] << "]";
dump_map_helper(shape, i-1, j, index, os);
}
}
else if (i>0)
{
if (i<j) os << endl;
os.width(6); os << " ";
for (int k=shape.first(1); k<=shape.last(1); k++)
{
os.width(5); os << k;
}
os << endl;
for (index[0]=shape.first(0); index[0]<=shape.last(0); index[0]++)
{
os.width(5); os << index[0];
for (index[1]=shape.first(1); index[1]<=shape.last(1); index[1]++)
{
os.width(5);
if (j==0)
{ os << shape.offset(index[0]); }
else if (j==1)
{ os << shape.offset(index[0], index[1]); }
else if (j==2)
{ os << shape.offset(index[0], index[1], index[2]); }
else if (j==3)
{ os << shape.offset(index[0], index[1], index[2], index[3]); }
else
{ os << shape.offset(index); }
os << "#";
}
os << endl;
}
}
else
{
for (index[0]=shape.first(0); index[0]<=shape.last(0); index[0]++)
{
os.width(5); os << index[0];
os.width(5);
if (j==0)
{ os << shape.offset(index[0]); }
else if (j==1)
{ os << shape.offset(index[0], index[1]); }
else if (j==2)
{ os << shape.offset(index[0], index[1], index[2]); }
else if (j==3)
{ os << shape.offset(index[0], index[1], index[2], index[3]); }
else
{ os << shape.offset(index); }
os << "#" << endl;
}
}
}
};
//! dump index mapping of shape
void dump_map(const Strided& shape, std::ostream& os)
void dump_map(const Strided& shape, const Tdim& i, std::ostream& os)
{
AFF_assert((i<Strided::Mmax_dimen),
"ERROR (dump_map): illegal dimensionality");
dump(shape);
os << " index mapping:" << endl;
os << " index mapping for " << i+1 << "dimensional access:" << endl;
Strided::TIndexVec index(shape.first());
dump_map_helper(shape, i, i, index, os);
}
} // namespace aff
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dump.h,v 1.7 2002-12-18 09:58:50 forbrig Exp $
* $Id: dump.h,v 1.8 2002-12-18 18:43:43 uid1201 Exp $
* \author Thomas Forbriger
* \date 12/12/2002
*
......@@ -31,7 +31,7 @@
#define AFF_DUMP_H_VERSION \
"AFF_DUMP_H V1.1"
#define TF_DUMP_H_CVSID \
"$Id: dump.h,v 1.7 2002-12-18 09:58:50 forbrig Exp $"
"$Id: dump.h,v 1.8 2002-12-18 18:43:43 uid1201 Exp $"
#include<iostream>
#include<aff/lib/simplearray.h>
......@@ -139,7 +139,8 @@ void dump(const Strided& shape, std::ostream& os=std::cout);
*
* \ingroup group_helpers
*/
void dump_map(const Strided& shape, std::ostream& os=std::cout);
void dump_map(const Strided& shape, const Tdim& i=(Strided::Mmax_dimen-1),
std::ostream& os=std::cout);
/*----------------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.cc,v 1.3 2002-12-16 18:17:30 forbrig Exp $
* $Id: strided.cc,v 1.4 2002-12-18 18:43:44 uid1201 Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -30,14 +30,16 @@
* and fits well in the binary library
* - 16/12/2002 V1.5 (thof)
* - wolle asked for shift and setfirst functions...
* - 18/12/2002 V1.6 (thof)
* - essential correction in collapse
*
* ============================================================================
*/
#define AFF_STRIDED_CC_VERSION \
"AFF_STRIDED_DEF_H V1.5"
"AFF_STRIDED_DEF_H V1.6"
#define AFF_STRIDED_CC_CVSID \
"$Id: strided.cc,v 1.3 2002-12-16 18:17:30 forbrig Exp $"
"$Id: strided.cc,v 1.4 2002-12-18 18:43:44 uid1201 Exp $"
#include<aff/lib/strided.h>
#include<aff/lib/error.h>
......@@ -203,9 +205,9 @@ namespace aff {
Mstride[j-1]=Mstride[j];
j++;
}
Mfirst[Mmax_dimen]=1;
Mlast[Mmax_dimen]=1;
Mstride[Mmax_dimen]=this->size(Mmax_dimen-2)*Mstride[Mmax_dimen-2];
Mfirst[Mmax_dimen-1]=1;
Mlast[Mmax_dimen-1]=1;
Mstride[Mmax_dimen-1]=this->size(Mmax_dimen-2)*Mstride[Mmax_dimen-2];
this->calculate_base(offset);
return(*this);
}
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: shapetest.cc,v 1.3 2002-12-18 17:41:34 forbrig Exp $
* $Id: shapetest.cc,v 1.4 2002-12-18 18:43:45 uid1201 Exp $
* \author Thomas Forbriger
* \date 25/05/2002
*
......@@ -13,14 +13,16 @@
*
* REVISIONS and CHANGES
* - 25/05/2002 V1.0 Thomas Forbriger
* - 18/12/2002 V1.1 started test of Strided (aff)
* - 18/12/2002 V1.1 (thof)
* - started test of Strided (aff)
* - test works
*
* ============================================================================
*/
#define AFF_SHAPETEST_CC_VERSION \
"AFF_SHAPETEST_CC V1.1"
#define AFF_SHAPETEST_CC_CVSID \
"$Id: shapetest.cc,v 1.3 2002-12-18 17:41:34 forbrig Exp $"
"$Id: shapetest.cc,v 1.4 2002-12-18 18:43:45 uid1201 Exp $"
#include<iostream>
#include<aff/dump.h>
......@@ -65,22 +67,28 @@ void steppers(const Strided& shape, const int& nmax=30)
s2.tolast();
for (int i=0; i<nmax; i++)
{
cout.width(5); cout << i+1;
cout.width(3); cout << i+1;
cout << " ";
cout.width(5); cout << s1.current() << "=[";
for (int j=0; j<Strided::Mmax_dimen; j++)
{
if (j) cout << ", ";
cout.width(3); cout << s1.index(j);
cout.width(2); cout << s1.index(j);
}
cout << "] ";
cout << "] ";
cout.width(5);
cout << bvalue(s1.more());
cout << " ";
cout.width(5); cout << s2.current() << "=[";
for (int j=0; j<Strided::Mmax_dimen; j++)
{
if (j) cout << ", ";
cout.width(3); cout << s2.index(j);
cout.width(2); cout << s2.index(j);
}
cout << "]" << endl;
cout << "] ";
cout.width(5);
cout << bvalue(s2.less());
cout << endl;
s1.incr();
s2.decr();
}
......@@ -146,6 +154,23 @@ int main()
DUMP( shape );
CODE( steppers(shape, shape.size()+10); )
}
section("Test offset functions");
{
CODE( Strided shape(Shaper(5)(10)(10)(10)); )
CODE( shape.shrink(0,2,4).shrink(1,3,7).shrink(2,5,6).shrink(3,2,3); )
CODE( dump_map(shape, 3); )
CODE( dump_map(shape, 2); )
CODE( dump_map(shape, 1); )
CODE( dump_map(shape, 0); )
CODE( steppers(shape, shape.size()); )
CODE( Strided copy(shape); )
CODE( copy.collapse(2,6).collapse(2,3).shift(0,1000).setfirst(1,50); )
CODE( dump_map(copy); )
CODE( copy=shape; )
CODE( copy.collapse(1,7).collapse(2,3).shift(0,1000).setfirst(1,50); )
CODE( dump_map(copy); )
}
}
/* ----- END OF shapetest.cc ----- */
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