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

aff::CArray interface is implemented; remains to be tested

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/branches/libfourier
SVN Revision: 3942
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent db762ac7
......@@ -49,6 +49,46 @@ namespace aff {
/*! \brief Interface class to raw memory (C style array)
*
* This class together with aff::CArray is provided as an interface for
* users which have to provide the contents of an array through raw memory
* pointers in C style.
* Both classes take an aff::ConstArray or aff::Array instance respectively
* as an argument for their constructor.
* They provide a pointer to raw memory through their member functions
* pointer() and castedpointer().
* If a pointer \c p to the raw memeory behind \c array is defined by
* \code
* aff::Array<T> array;
* aff::CArray<T> carray(array);
* T* p=carray.pointer();
* \endcode
* then the array element \c array(i0,i1,i2,i3) is addressed by
* \code
* p[i0*s0+i1*s1+i2*s2+i3*s3]
* \endcode
* where the index value ranges are
* - \c i0=0,1,... \c n0-1
* - \c i1=0,1,... \c n1-1
* - \c i2=0,1,... \c n2-1
* - \c i3=0,1,... \c n3-1
*
* and
* - \c n0=carray.size(0)
* - \c n1=carray.size(1)
* - \c n2=carray.size(2)
* - \c n3=carray.size(3)
*
* and
* - \c s0=carray.stride(0)
* - \c s1=carray.stride(1)
* - \c s2=carray.stride(2)
* - \c s3=carray.stride(3)
*
* \note
* The pointers passed by the access functions of this class are (certainly)
* not reference counted.
* Make sure to keep an instance of one of the arrays maintining the
* underlying memory allocation as long as these pointers are in use.
*/
template<class T>
class ConstCArray
......@@ -104,6 +144,19 @@ namespace aff {
ConstCArray(const Tarray& array)
: Mrepresentation(array.representation())
{
Tshape shape=array.shape();
// index range is zero based
shape.setfirst(Tshape::TIndexVec(0));
// offset to first element in represented memory
Moffset=shape.first_offset();
// strides
Mstride=shape.stride();
// sizes
Msize=shape.last();
for (int i=0; i<Msize.size(); ++i)
{
++Msize[i];
}
}
//@}
......
......@@ -290,10 +290,7 @@
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/Carray.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/Carray.cc</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD>14/05/2011 </TD><TD>14/05/2011 </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/dump.cc</TD>
<TD>18/12/2002</TD><TD>20/12/2002</TD><TD>18/12/2002</TD><TD> </TD>
......
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