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

test helpers in converters.h

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: 3952
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 94afa745
......@@ -301,7 +301,7 @@
<TD>14/05/2011 </TD><TD>14/05/2011 </TD><TD>15/05/2011 </TD><TD> </TD>
</TR>
<TR><TD>libaff/converters.h</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD>15/05/2011 </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/dump.cc</TD>
......
......@@ -44,7 +44,7 @@
#include<aff/array.h>
#include<aff/series.h>
#include<aff/error.h>
#include<aff/lib/error.h>
namespace aff {
......
......@@ -42,6 +42,7 @@
* - scanning a const array requires a Browser
* - 15/05/2011 V1.4 (thof)
* - test aff::CArray
* - test helpers in converters.h
*
* ============================================================================
*/
......@@ -56,6 +57,8 @@
*
* This test program gives an example of the usage of the following classes,
* functions, and preprocessor macros:
* - \ref group_array_extensions
* - \ref group_series_extensions
* - aff::CArray
* - aff::Iterator
* - aff::util::Subarray
......@@ -80,6 +83,7 @@
#include <aff/subarray.h>
#include <aff/slice.h>
#include <aff/Carray.h>
#include <aff/converters.h>
using std::cout;
using std::endl;
......@@ -283,6 +287,53 @@ int main()
CODE( printarray(B) );
CODE( printarray(A) );
}
/*----------------------------------------------------------------------*/
section("Test interface to raw memory array: aff::CSeries");
{
CODE( aff::Series<int> A(-3,4); )
CODE( for (int i=A.f(); i<=A.l(); ++i) { A(i)=i; })
CODE( dump(A); )
CODE( aff::CSeries<int> CS(A); )
CODE( int* p=CS.pointer(); )
CODE( for (int i=0; i<CS.size(); ++i) { p[i]=i; })
CODE( dump(A); )
CODE( Series<int> S=series_from_raw_memory(p, CS.size()); )
CODE( dump(S); )
}
/*----------------------------------------------------------------------*/
section("Test converters", '=');
section("Test conversion from Array to Series");
{
CODE( Array<int> A(Shaper(2,9)(10,12)(0,2)(2,4)); );
section("fill array");
for(int i=A.f(0); i<=A.l(0); i++)
{
for(int j=A.f(1); j<=A.l(1); j++)
{
for(int k=A.f(2); k<=A.l(2); k++)
{
for(int l=A.f(3); l<=A.l(3); l++)
{
A(i,j,k,l)=(i-A.f(0)+1)+(j-A.f(1)+1)*10
+(k-A.f(2)+1)*100+(l-A.f(3)+1)*1000;
}
}
}
}
CODE( dump_array(A,3); );
CODE( Array<int> B=aff::slice(A)(1,11)(1,1)(1,3); )
CODE( printarray(B) );
CODE( Series<int> C=series_from_array(B); )
CODE( dump(C); )
CODE( ConstArray<int> D=B; )
CODE( ConstSeries<int> E=series_from_array(D); )
CODE( dump(E); )
}
}
/* ----- END OF helpertest.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