~ubuntu-branches/ubuntu/raring/blitz++/raring

« back to all changes in this revision

Viewing changes to testsuite/matthias-troyer-2.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2005-02-28 20:25:01 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050228202501-3i4f2sknnprsqfhz
Tags: 1:0.8-4
Added missing build-depends (Closes: #297323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <blitz/array.h>
 
2
 
 
3
BZ_USING_NAMESPACE(blitz)
 
4
 
 
5
//declaration of the stencil kinEnergy
 
6
BZ_DECLARE_STENCIL2(kinEnergy,A,B)
 
7
B=Laplacian3D(A);
 
8
BZ_END_STENCIL_WITH_SHAPE(shape(-1,-1,-1),shape(+1,+1,+1))
 
9
 
 
10
typedef Array<complex<double>,3> array3d;
 
11
 
 
12
int main()
 
13
{
 
14
const int N=5;
 
15
array3d A(N,N,N);
 
16
array3d B(N,N,N);
 
17
// Fill a three-dimensional array with a Gaussian function
 
18
firstIndex i;
 
19
secondIndex j;
 
20
thirdIndex k;
 
21
float midpoint = 3.;
 
22
float c = - 1.;
 
23
//A = exp(c * (sqr(i-midpoint) + sqr(j-midpoint)
 
24
//    + sqr(k-midpoint)));
 
25
A = zip( exp(c * (sqr(i-midpoint) + sqr(j-midpoint)
 
26
    + sqr(k-midpoint))), 0.0, complex<double>());
 
27
 
 
28
applyStencil(kinEnergy(),A,B);
 
29
 
 
30
Array<complex<double>,1> a_view(A.data(),shape(N*N*N));
 
31
cout << a_view;
 
32
Array<complex<double>,1> out_view(B.data(),shape(N*N*N));
 
33
cout << out_view<<endl;
 
34
}
 
35