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

new reshaper

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: 1142
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 80454b92
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: blitzutil.h,v 1.2 2002-11-28 09:06:07 forbrig Exp $
* $Id: blitzutil.h,v 1.3 2002-11-29 16:10:25 forbrig Exp $
* \author Thomas Forbriger
* \date 27/11/2002
*
......@@ -23,7 +23,7 @@
#define TF_BLITZUTIL_H_VERSION \
"TF_BLITZUTIL_H V1.0 "
#define TF_BLITZUTIL_H_CVSID \
"$Id: blitzutil.h,v 1.2 2002-11-28 09:06:07 forbrig Exp $"
"$Id: blitzutil.h,v 1.3 2002-11-29 16:10:25 forbrig Exp $"
#include<tfxx/error.h>
......@@ -63,6 +63,28 @@ namespace blitzutil {
{ return(blitz::areShapesConformable(a1.lbound(),a2.lbound())&&
blitz::areShapesConformable(a1.ubound(),a2.ubound())); }
/*! \brief create a second array spanning the same domain
*
* \ingroup group_blitzutil
* \param array A blitz array to be reshaped to \p domain.
* Upon return it references a new data area.
* \param domain Domain to apply to \p array. May by return value of
* Array member function domain().
* \param storage Blitz++ Array storage layout to be used for \p array.
*/
template<class T, int N>
void setToSameDomain(blitz::Array<T,N>& array,
const blitz::RectDomain<N>& domain,
const blitz::GeneralArrayStorage<N>&
storage=blitz::fortranArray)
{
blitz::TinyVector<int, N> extent;
for (int i=0; i<N; i++)
{ extent[i]=domain.ubound()[i]-domain.lbound()[i]+1; }
blitz::Array<T, N> result(domain.lbound(),extent,storage);
array.reference(result);
}
} // namespace blitzutil
} // namespace tfxx
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: blitztest.cc,v 1.1 2002-11-28 21:34:08 forbrig Exp $
* $Id: blitztest.cc,v 1.2 2002-11-29 16:10:25 forbrig Exp $
* \author Thomas Forbriger
* \date 28/11/2002
*
......@@ -19,11 +19,13 @@
#define BLITZTEST_VERSION \
"BLITZTEST V1.0 test all blitz support modules"
#define BLITZTEST_CVSID \
"$Id: blitztest.cc,v 1.1 2002-11-28 21:34:08 forbrig Exp $"
"$Id: blitztest.cc,v 1.2 2002-11-29 16:10:25 forbrig Exp $"
#include <iostream>
#include <blitz/array.h>
#include <tfxx/error.h>
#include <tfxx/commandline.h>
#include <tfxx/blitzutil.h>
#include <tfxx/blitzfortranio.h>
using std::cout;
......@@ -160,6 +162,36 @@ int main(int iargc, char* argv[])
<< "===========================" << endl << F << endl;
F.dumpStructureInformation();
/*----------------------------------------------------------------------*/
cout << endl << "Test shape copy function" << endl
<< "========================" << endl;
blitz::Array<int,3> G(blitz::Range(3,4),
blitz::Range(3,5),
blitz::Range(2,4),
blitz::fortranArray);
{
blitz::firstIndex i;
blitz::secondIndex j;
blitz::thirdIndex k;
G=i*100+j*10+k;
}
cout << endl << "Fortran array for type int:" << endl
<< "---------------------------" << endl << G << endl;
G.dumpStructureInformation();
blitz::Array<std::complex<double>,3> H;
tfxx::blitzutil::setToSameDomain(H,G.domain());
cout << endl << "Array of same domain and type complex<double>:" << endl
<< "----------------------------------------------"
<< endl << H << endl;
H.dumpStructureInformation();
TFXX_assert(tfxx::blitzutil::sameDomain(G,H),
"setToSameDomain failed!");
}
/* ----- END OF blitztest.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