~ubuntu-branches/ubuntu/utopic/blitz++/utopic

« back to all changes in this revision

Viewing changes to examples/curldiv.cpp

  • Committer: Package Import Robot
  • Author(s): Christophe Trophime
  • Date: 2012-07-06 09:15:30 UTC
  • mfrom: (11.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120706091530-vzrb8zf0vpbf8tp9
Tags: 1:0.10-1
* New upstream release
  Closes: #679407
* debian/rules:
  - update for new release
  - add override_dh_auto_test target
  - regenerate configure and Makefile.am
* debian/control:
  - add libtool, automake to BuildDepends
* debian/libblitz-doc.install
  - modify path for html files
* remove uneeded patches
* add examples.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Div, grad, curl and all that
2
 
 
3
 
#include <blitz/array.h>
4
 
#include <blitz/tinyvec.h>
5
 
 
6
 
BZ_USING_NAMESPACE(blitz)
7
 
BZ_USING_NAMESPACE(blitz::tensor)
8
 
 
9
 
BZ_DECLARE_STENCIL8(test,Ax,Ay,Az,curlA,divA,gradAx,gradAy,gradAz)
10
 
    curlA = curl(Ax,Ay,Az);
11
 
    divA = div(Ax,Ay,Az);
12
 
    gradAx = grad3D(Ax);
13
 
    gradAy = grad3D(Ay);
14
 
    gradAz = grad3D(Az);
15
 
BZ_STENCIL_END
16
 
 
17
 
int main()
18
 
{
19
 
    Array<float,3> Ax, Ay, Az, divA;
20
 
    Array<TinyVector<float,3>,3> gradAx, gradAy, gradAz, curlA;
21
 
    const int N = 40;
22
 
    allocateArrays(shape(N,N,N), Ax, Ay, Az, divA);
23
 
    allocateArrays(shape(N,N,N), gradAx, gradAy, gradAz, curlA);
24
 
 
25
 
    Array<float,1> cx(N), cy(N), cz(N);
26
 
    float h = 1.0 / (N-1);
27
 
 
28
 
    cx = h * i;
29
 
    cy = h * i;
30
 
    cz = h * i;
31
 
 
32
 
    Ax = cos(cx(i)) + cos(cy(j)) + cos(cz(k));
33
 
    Ay = sin(cx(i)) + sin(cy(j)) + sin(cz(k));
34
 
    Az = exp(cx(i)) + exp(cy(j)) + exp(cz(k));
35
 
 
36
 
    applyStencil(test(), Ax, Ay, Az, curlA, divA, gradAx, gradAy, gradAz);
37
 
}
38