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

« back to all changes in this revision

Viewing changes to doc/blitz_4.html

  • 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
<HTML>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
3
<!-- Created on November, 4  2004 by texi2html 1.64 -->
 
4
<!-- 
 
5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
 
6
            Karl Berry  <karl@freefriends.org>
 
7
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
 
8
            and many others.
 
9
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
 
10
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
 
11
 
 
12
-->
 
13
<HEAD>
 
14
<TITLE>Blitz++: Stencils</TITLE>
 
15
 
 
16
<META NAME="description" CONTENT="Blitz++: Stencils">
 
17
<META NAME="keywords" CONTENT="Blitz++: Stencils">
 
18
<META NAME="resource-type" CONTENT="document">
 
19
<META NAME="distribution" CONTENT="global">
 
20
<META NAME="Generator" CONTENT="texi2html 1.64">
 
21
 
 
22
</HEAD>
 
23
 
 
24
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
 
25
 
 
26
<A NAME="SEC98"></A>
 
27
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
28
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_3.html#SEC97"> &lt; </A>]</TD>
 
29
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC99"> &gt; </A>]</TD>
 
30
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &lt;&lt; </A>]</TD>
 
31
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top"> Up </A>]</TD>
 
32
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
33
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
34
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
35
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
36
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
37
</TR></TABLE>
 
38
<H1> 4. Stencils </H1>
 
39
<!--docid::SEC98::-->
 
40
<P>
 
41
 
 
42
<A NAME="IDX307"></A>
 
43
<A NAME="IDX308"></A>
 
44
</P><P>
 
45
 
 
46
Blitz++ provides an implementation of stencil objects which is currently
 
47
<STRONG>experimental</STRONG>.  This means that the exact details of how they are
 
48
declared and used may change in future releases.  Use at your own risk.
 
49
</P><P>
 
50
 
 
51
<HR SIZE="6">
 
52
<A NAME="SEC99"></A>
 
53
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
54
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> &lt; </A>]</TD>
 
55
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC100"> &gt; </A>]</TD>
 
56
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> &lt;&lt; </A>]</TD>
 
57
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
58
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
59
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
60
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
61
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
62
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
63
</TR></TABLE>
 
64
<H2> 4.1 Motivation: a nicer notation for stencils </H2>
 
65
<!--docid::SEC99::-->
 
66
<P>
 
67
 
 
68
Suppose we wanted to implement the 3-D acoustic wave equation using finite
 
69
differencing.  Here is how a single iteration would look using subarray
 
70
syntax:
 
71
</P><P>
 
72
 
 
73
<TABLE><tr><td>&nbsp;</td><td class=example><pre>Range I(1,N-2), J(1,N-2), K(1,N-2);
 
74
 
 
75
P3(I,J,K) = (2-6*c(I,J,K)) * P2(I,J,K)
 
76
            + c(I,J,K)*(P2(I-1,J,K) + P2(I+1,J,K) + P2(I,J-1,K) + P2(I,J+1,K)
 
77
            + P2(I,J,K-1) + P2(I,J,K+1)) - P1(I,J,K);
 
78
</pre></td></tr></table></P><P>
 
79
 
 
80
This syntax is a bit klunky.  With stencil objects, the implementation
 
81
becomes:
 
82
</P><P>
 
83
 
 
84
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL4(acoustic3D_stencil,P1,P2,P3,c)
 
85
  P3 = 2 * P2 + c * Laplacian3D(P2) - P1;
 
86
BZ_END_STENCIL
 
87
 
 
88
  .
 
89
  .
 
90
 
 
91
applyStencil(acoustic3D_stencil(), P1, P2, P3, c);
 
92
</pre></td></tr></table></P><P>
 
93
 
 
94
<HR SIZE="6">
 
95
<A NAME="SEC100"></A>
 
96
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
97
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC99"> &lt; </A>]</TD>
 
98
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC101"> &gt; </A>]</TD>
 
99
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC101"> &lt;&lt; </A>]</TD>
 
100
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
101
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
102
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
103
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
104
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
105
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
106
</TR></TABLE>
 
107
<H2> 4.2 Declaring stencil objects </H2>
 
108
<!--docid::SEC100::-->
 
109
<P>
 
110
 
 
111
A stencil declaration may not be inside a function.  It can appear inside a
 
112
class declaration (in which case the stencil object is a nested type).
 
113
</P><P>
 
114
 
 
115
Stencil objects are declared using the macros <CODE>BZ_DECLARE_STENCIL1</CODE>,
 
116
<CODE>BZ_DECLARE_STENCIL2</CODE>, etc.  The number suffix is how many arrays are
 
117
involved in the stencil (in the above example, 4 arrays-- P1, P2, P3, c -- are
 
118
used, so the macro <CODE>BZ_DECLARE_STENCIL4</CODE> is invoked).
 
119
</P><P>
 
120
 
 
121
The first argument is a name for the stencil object.  Subsequent arguments
 
122
are names for the arrays on which the stencil operates.
 
123
</P><P>
 
124
 
 
125
After the stencil declaration, the macro <CODE>BZ_END_STENCIL</CODE> must appear
 
126
(or the macro <CODE>BZ_END_STENCIL_WITH_SHAPE</CODE>, described in the next
 
127
section).
 
128
</P><P>
 
129
 
 
130
In between the two macros, you can have multiple assignment statements,
 
131
if/else/elseif constructs, function calls, loops, etc.
 
132
</P><P>
 
133
 
 
134
Here are some simple examples:
 
135
</P><P>
 
136
 
 
137
<A NAME="IDX309"></A>
 
138
</P><P>
 
139
 
 
140
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL2(smooth2D,A,B)
 
141
  A = (B(0,0) + B(0,1) + B(0,-1) + B(1,0) + B(-1,0)) / 5.0;
 
142
BZ_END_STENCIL
 
143
 
 
144
BZ_DECLARE_STENCIL4(acoustic2D,P1,P2,P3,c)
 
145
  A = 2 * P2 + c * (-4 * P2(0,0) + P2(0,1) + P2(0,-1) + P2(1,0) + P2(-1,0))
 
146
      - P1;
 
147
BZ_END_STENCIL
 
148
 
 
149
BZ_DECLARE_STENCIL8(prop2D,E1,E2,E3,M1,M2,M3,cE,cM)
 
150
  E3 = 2 * E2 + cE * Laplacian2D(E2) - E1;
 
151
  M3 = 2 * M2 + cM * Laplacian2D(M2) - M1;
 
152
BZ_END_STENCIL
 
153
 
 
154
BZ_DECLARE_STENCIL3(smooth2Db,A,B,c)
 
155
  if ((c &#62; 0.0) &#38;&#38; (c &#60; 1.0))
 
156
    A = c * (B(0,0) + B(0,1) + B(0,-1) + B(1,0) + B(-1,0)) / 5.0
 
157
      + (1-c)*B;
 
158
  else
 
159
    A = 0;
 
160
BZ_END_STENCIL
 
161
</pre></td></tr></table></P><P>
 
162
 
 
163
Currently, a stencil can take up to 11 array parameters.
 
164
</P><P>
 
165
 
 
166
You can use the notation <CODE>A(i,j,k)</CODE> to read the element at an offset
 
167
<CODE>(i,j,k)</CODE> from the current element.  If you omit the parentheses
 
168
(i.e. as in "<CODE>A</CODE>" then the current element is read.
 
169
</P><P>
 
170
 
 
171
You can invoke <EM>stencil operators</EM> which calculate finite differences
 
172
and laplacians.
 
173
</P><P>
 
174
 
 
175
<HR SIZE="6">
 
176
<A NAME="SEC101"></A>
 
177
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
178
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC100"> &lt; </A>]</TD>
 
179
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> &gt; </A>]</TD>
 
180
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> &lt;&lt; </A>]</TD>
 
181
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
182
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
183
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
184
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
185
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
186
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
187
</TR></TABLE>
 
188
<H2> 4.3 Automatic determination of stencil extent </H2>
 
189
<!--docid::SEC101::-->
 
190
<P>
 
191
 
 
192
In stencil declarations such as
 
193
</P><P>
 
194
 
 
195
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL2(smooth2D,A,B)
 
196
  A = (B(0,0) + B(0,1) + B(0,-1) + B(1,0) + B(-1,0)) / 5.0;
 
197
BZ_END_STENCIL
 
198
</pre></td></tr></table></P><P>
 
199
 
 
200
Blitz++ will try to automatically determine the spatial extent of the
 
201
stencil.  This will usually work for stencils defined on integer or float
 
202
arrays.  However, the mechanism does not work well for complex-valued
 
203
arrays, or arrays of user-defined types.  If you get a peculiar error when
 
204
you try to use a stencil, you probably need to tell Blitz++ the special
 
205
extent of the stencil manually.
 
206
</P><P>
 
207
 
 
208
You do this by ending a stencil declaration with
 
209
<CODE>BZ_END_STENCIL_WITH_SHAPE</CODE>:
 
210
</P><P>
 
211
 
 
212
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL2(smooth2D,A,B)
 
213
  A = (B(0,0) + B(0,1) + B(0,-1) + B(1,0) + B(-1,0)) / 5.0;
 
214
BZ_END_STENCIL_WITH_SHAPE(shape(-1,-1),shape(+1,+1))
 
215
</pre></td></tr></table></P><P>
 
216
 
 
217
The parameters of this macro are: a <CODE>TinyVector</CODE> (constructed by the
 
218
<CODE>shape()</CODE> function) containing the lower bounds of the stencil offsets,
 
219
and a <CODE>TinyVector</CODE> containing the upper bounds.  You can determine this
 
220
by looking at the the terms in the stencil and finding the minimum and
 
221
maximum value of each index:
 
222
</P><P>
 
223
 
 
224
<TABLE><tr><td>&nbsp;</td><td class=example><pre>      A = (B(0,  0) 
 
225
         + B(0, +1)
 
226
         + B(0, -1)
 
227
         + B(+1, 0)
 
228
         + B(-1, 0)) / 5.0;
 
229
           --------
 
230
min indices  -1, -1
 
231
max indices  +1, +1
 
232
</pre></td></tr></table></P><P>
 
233
 
 
234
<HR SIZE="6">
 
235
<A NAME="SEC102"></A>
 
236
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
237
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC101"> &lt; </A>]</TD>
 
238
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC103"> &gt; </A>]</TD>
 
239
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &lt;&lt; </A>]</TD>
 
240
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
241
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
242
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
243
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
244
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
245
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
246
</TR></TABLE>
 
247
<H2> 4.4 Stencil operators </H2>
 
248
<!--docid::SEC102::-->
 
249
<P>
 
250
 
 
251
This section lists all the stencil operators provided by Blitz++.  They
 
252
assume that an array represents evenly spaced data points separated by a
 
253
distance of <CODE>h</CODE>.  A 2nd-order accurate operator has error term 
 
254
<EM>O(h^2)</EM>; a 4th-order accurate operator has error term <EM>O(h^4)</EM>.
 
255
</P><P>
 
256
 
 
257
All of the stencils have factors associated with them.  For example, the
 
258
<CODE>central12</CODE> operator is a discrete first derivative which is 2nd-order
 
259
accurate.  Its factor is 2h; this means that to get the first derivative of
 
260
an array A, you need to use <CODE>central12(A,firstDim)</CODE><EM>/(2h)</EM>.
 
261
Typically when designing stencils, one factors out all of the <EM>h</EM> terms
 
262
for efficiency.
 
263
</P><P>
 
264
 
 
265
The factor terms always consist of an integer multiplier (often 1) and a
 
266
power of <EM>h</EM>.  For ease of use, all of the operators listed below are
 
267
provided in a second "normalized" version in which the integer multiplier
 
268
is 1.  The normalized versions have an <CODE>n</CODE> appended to the name, for
 
269
example <CODE>central12n</CODE> is the normalized version of <CODE>central12</CODE>, and
 
270
has factor <EM>h</EM> instead of <EM>2h</EM>.
 
271
</P><P>
 
272
 
 
273
These operators are defined in <CODE>blitz/array/stencilops.h</CODE> if you wish
 
274
to see the implementation.
 
275
</P><P>
 
276
 
 
277
<HR SIZE="6">
 
278
<A NAME="SEC103"></A>
 
279
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
280
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> &lt; </A>]</TD>
 
281
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC104"> &gt; </A>]</TD>
 
282
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &lt;&lt; </A>]</TD>
 
283
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
284
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
285
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
286
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
287
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
288
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
289
</TR></TABLE>
 
290
<H3> 4.4.1 Central differences </H3>
 
291
<!--docid::SEC103::-->
 
292
<P>
 
293
 
 
294
<DL COMPACT>
 
295
<DT><CODE>central12(A,dimension)</CODE>
 
296
<DD>1st derivative, 2nd order accurate.  Factor: <EM>2h</EM>
 
297
<table cellpadding=2 rules=all>
 
298
<tr align=right><td></td><td>-1</td><td>0</td><td>1</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
299
</table>
 
300
<P>
 
301
 
 
302
<DT><CODE>central22(A,dimension)</CODE>
 
303
<DD>2nd derivative, 2nd order accurate.  Factor: <EM>h^2</EM>
 
304
<table cellpadding=2 rules=all>
 
305
<tr align=right><td></td><td>-1</td><td>0</td><td>1</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000060"><font color="#ffffff">-2</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
306
</table>
 
307
<P>
 
308
 
 
309
<DT><CODE>central32(A,dimension)</CODE>
 
310
<DD>3rd derivative, 2nd order accurate.  Factor: <EM>2h^3</EM>
 
311
<table cellpadding=2 rules=all>
 
312
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">2</font></td><td></td><td bgcolor="#000000"><font color="#ffffff">-2</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
313
</table>
 
314
<P>
 
315
 
 
316
<DT><CODE>central42(A,dimension)</CODE>
 
317
<DD>4th derivative, 2nd order accurate.  Factor: <EM>h^4</EM>
 
318
<table cellpadding=2 rules=all>
 
319
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000060"><font color="#ffffff">6</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
320
</table>
 
321
<P>
 
322
 
 
323
<DT><CODE>central14(A,dimension)</CODE>
 
324
<DD>1st derivative, 4th order accurate.  Factor: <EM>12h</EM>
 
325
<table cellpadding=2 rules=all>
 
326
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-8</font></td><td></td><td bgcolor="#000000"><font color="#ffffff">8</font></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td></tr>
 
327
</table>
 
328
<P>
 
329
 
 
330
<DT><CODE>central24(A,dimension)</CODE>
 
331
<DD>2nd derivative, 4th order accurate.  Factor: <EM>12h^2</EM>
 
332
<table cellpadding=2 rules=all>
 
333
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td bgcolor="#000060"><font color="#ffffff">-30</font></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td></tr>
 
334
</table>
 
335
<P>
 
336
 
 
337
<DT><CODE>central34(A,dimension)</CODE>
 
338
<DD>3rd derivative, 4th order accurate.  Factor: <EM>8h^3</EM>
 
339
<table cellpadding=2 rules=all>
 
340
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-8</font></td><td bgcolor="#000000"><font color="#ffffff">13</font></td><td></td><td bgcolor="#000000"><font color="#ffffff">-13</font></td><td bgcolor="#000000"><font color="#ffffff">8</font></td></tr>
 
341
</table>
 
342
<P>
 
343
 
 
344
<DT><CODE>central44(A,dimension)</CODE>
 
345
<DD>4th derivative, 4th order accurate.  Factor: <EM>6h^4</EM>
 
346
<table cellpadding=2 rules=all>
 
347
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">12</font></td><td bgcolor="#000000"><font color="#ffffff">-39</font></td><td bgcolor="#000060"><font color="#ffffff">56</font></td><td bgcolor="#000000"><font color="#ffffff">-39</font></td><td bgcolor="#000000"><font color="#ffffff">12</font></td></tr>
 
348
</table>
 
349
</DL>
 
350
<P>
 
351
 
 
352
Note that the above are available in normalized versions <CODE>central12n</CODE>,
 
353
<CODE>central22n</CODE>, ..., <CODE>central44n</CODE> which have factors of <EM>h</EM>,
 
354
<EM>h^2</EM>, <EM>h^3</EM>, or <EM>h^4</EM> as appropriate.  
 
355
</P><P>
 
356
 
 
357
These are available in multicomponent versions: for example,
 
358
<CODE>central12(A,component,dimension)</CODE> gives the central12 operator for the
 
359
specified component (Components are numbered 0, 1, ... N-1).  
 
360
</P><P>
 
361
 
 
362
<HR SIZE="6">
 
363
<A NAME="SEC104"></A>
 
364
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
365
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC103"> &lt; </A>]</TD>
 
366
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC105"> &gt; </A>]</TD>
 
367
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC105"> &lt;&lt; </A>]</TD>
 
368
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
369
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
370
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
371
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
372
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
373
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
374
</TR></TABLE>
 
375
<H3> 4.4.2 Forward differences </H3>
 
376
<!--docid::SEC104::-->
 
377
<P>
 
378
 
 
379
<DL COMPACT>
 
380
<DT><CODE>forward11(A,dimension)</CODE>
 
381
<DD>1st derivative, 1st order accurate.  Factor: <EM>h</EM>
 
382
<table cellpadding=2 rules=all>
 
383
<tr align=right><td></td><td>0</td><td>1</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
384
</table>
 
385
<P>
 
386
 
 
387
<DT><CODE>forward21(A,dimension)</CODE>
 
388
<DD>2nd derivative, 1st order accurate.  Factor: <EM>h^2</EM>
 
389
<table cellpadding=2 rules=all>
 
390
<tr align=right><td></td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-2</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
391
</table>
 
392
<P>
 
393
 
 
394
<DT><CODE>forward31(A,dimension)</CODE>
 
395
<DD>3rd derivative, 1st order accurate.  Factor: <EM>h^3</EM>
 
396
<table cellpadding=2 rules=all>
 
397
<tr align=right><td></td><td>0</td><td>1</td><td>2</td><td>3</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">3</font></td><td bgcolor="#000000"><font color="#ffffff">-3</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
398
</table>
 
399
<P>
 
400
 
 
401
<DT><CODE>forward41(A,dimension)</CODE>
 
402
<DD>4th derivative, 1st order accurate.  Factor: <EM>h^4</EM>
 
403
<table cellpadding=2 rules=all>
 
404
<tr align=right><td></td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000000"><font color="#ffffff">6</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
405
</table>
 
406
<P>
 
407
 
 
408
<DT><CODE>forward12(A,dimension)</CODE>
 
409
<DD>1st derivative, 2nd order accurate.  Factor: <EM>2h</EM>
 
410
<table cellpadding=2 rules=all>
 
411
<tr align=right><td></td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">-3</font></td><td bgcolor="#000000"><font color="#ffffff">4</font></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td></tr>
 
412
</table>
 
413
<P>
 
414
 
 
415
<DT><CODE>forward22(A,dimension)</CODE>
 
416
<DD>2nd derivative, 2nd order accurate.  Factor: <EM>h^2</EM>
 
417
<table cellpadding=2 rules=all>
 
418
<tr align=right><td></td><td>0</td><td>1</td><td>2</td><td>3</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">2</font></td><td bgcolor="#000000"><font color="#ffffff">-5</font></td><td bgcolor="#000000"><font color="#ffffff">4</font></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td></tr>
 
419
</table>
 
420
<P>
 
421
 
 
422
<DT><CODE>forward32(A,dimension)</CODE>
 
423
<DD>3rd derivative, 2nd order accurate.  Factor: <EM>2h^3</EM>
 
424
<table cellpadding=2 rules=all>
 
425
<tr align=right><td></td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">-5</font></td><td bgcolor="#000000"><font color="#ffffff">18</font></td><td bgcolor="#000000"><font color="#ffffff">-24</font></td><td bgcolor="#000000"><font color="#ffffff">14</font></td><td bgcolor="#000000"><font color="#ffffff">-3</font></td></tr>
 
426
</table>
 
427
<P>
 
428
 
 
429
<DT><CODE>forward42(A,dimension)</CODE>
 
430
<DD>4th derivative, 2nd order accurate.  Factor: <EM>h^4</EM>
 
431
<table cellpadding=2 rules=all>
 
432
<tr align=right><td></td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr align=right><td></td><td bgcolor="#000060"><font color="#ffffff">3</font></td><td bgcolor="#000000"><font color="#ffffff">-14</font></td><td bgcolor="#000000"><font color="#ffffff">26</font></td><td bgcolor="#000000"><font color="#ffffff">-24</font></td><td bgcolor="#000000"><font color="#ffffff">11</font></td><td bgcolor="#000000"><font color="#ffffff">-2</font></td></tr>
 
433
</table>
 
434
</DL>
 
435
<P>
 
436
 
 
437
Note that the above are available in normalized versions <CODE>forward11n</CODE>,
 
438
<CODE>forward21n</CODE>, ..., <CODE>forward42n</CODE> which have factors of <EM>h</EM>,
 
439
<EM>h^2</EM>, <EM>h^3</EM>, or <EM>h^4</EM> as appropriate.  
 
440
</P><P>
 
441
 
 
442
These are available in multicomponent versions: for example,
 
443
<CODE>forward11(A,component,dimension)</CODE> gives the forward11 operator for the
 
444
specified component (Components are numbered 0, 1, ... N-1).
 
445
</P><P>
 
446
 
 
447
<HR SIZE="6">
 
448
<A NAME="SEC105"></A>
 
449
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
450
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC104"> &lt; </A>]</TD>
 
451
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC106"> &gt; </A>]</TD>
 
452
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC106"> &lt;&lt; </A>]</TD>
 
453
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
454
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
455
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
456
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
457
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
458
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
459
</TR></TABLE>
 
460
<H3> 4.4.3 Backward differences </H3>
 
461
<!--docid::SEC105::-->
 
462
<P>
 
463
 
 
464
<DL COMPACT>
 
465
<DT><CODE>backward11(A,dimension)</CODE>
 
466
<DD>1st derivative, 1st order accurate.  Factor: <EM>h</EM>
 
467
<table cellpadding=2 rules=all>
 
468
<tr align=right><td></td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000060"><font color="#ffffff">1</font></td></tr>
 
469
</table>
 
470
<P>
 
471
 
 
472
<DT><CODE>backward21(A,dimension)</CODE>
 
473
<DD>2nd derivative, 1st order accurate.  Factor: <EM>h^2</EM>
 
474
<table cellpadding=2 rules=all>
 
475
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-2</font></td><td bgcolor="#000060"><font color="#ffffff">1</font></td></tr>
 
476
</table>
 
477
<P>
 
478
 
 
479
<DT><CODE>backward31(A,dimension)</CODE>
 
480
<DD>3rd derivative, 1st order accurate.  Factor: <EM>h^3</EM>
 
481
<table cellpadding=2 rules=all>
 
482
<tr align=right><td></td><td>-3</td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">3</font></td><td bgcolor="#000000"><font color="#ffffff">-3</font></td><td bgcolor="#000060"><font color="#ffffff">1</font></td></tr>
 
483
</table>
 
484
<P>
 
485
 
 
486
<DT><CODE>backward41(A,dimension)</CODE>
 
487
<DD>4th derivative, 1st order accurate.  Factor: <EM>h^4</EM>
 
488
<table cellpadding=2 rules=all>
 
489
<tr align=right><td></td><td>-4</td><td>-3</td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000000"><font color="#ffffff">6</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000060"><font color="#ffffff">1</font></td></tr>
 
490
</table>
 
491
<P>
 
492
 
 
493
<DT><CODE>backward12(A,dimension)</CODE>
 
494
<DD>1st derivative, 2nd order accurate.  Factor: <EM>2h</EM>
 
495
<table cellpadding=2 rules=all>
 
496
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000000"><font color="#ffffff">-4</font></td><td bgcolor="#000060"><font color="#ffffff">3</font></td></tr>
 
497
</table>
 
498
<P>
 
499
 
 
500
<DT><CODE>backward22(A,dimension)</CODE>
 
501
<DD>2nd derivative, 2nd order accurate.  Factor: <EM>h^2</EM>
 
502
<table cellpadding=2 rules=all>
 
503
<tr align=right><td></td><td>-3</td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">4</font></td><td bgcolor="#000000"><font color="#ffffff">-5</font></td><td bgcolor="#000060"><font color="#ffffff">2</font></td></tr>
 
504
</table>
 
505
<P>
 
506
 
 
507
<DT><CODE>backward32(A,dimension)</CODE>
 
508
<DD>3rd derivative, 2nd order accurate.  Factor: <EM>2h^3</EM>
 
509
<table cellpadding=2 rules=all>
 
510
<tr align=right><td></td><td>-4</td><td>-3</td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">3</font></td><td bgcolor="#000000"><font color="#ffffff">-14</font></td><td bgcolor="#000000"><font color="#ffffff">24</font></td><td bgcolor="#000000"><font color="#ffffff">-18</font></td><td bgcolor="#000060"><font color="#ffffff">5</font></td></tr>
 
511
</table>
 
512
<P>
 
513
 
 
514
<DT><CODE>backward42(A,dimension)</CODE>
 
515
<DD>4th derivative, 2nd order accurate.  Factor: <EM>h^4</EM>
 
516
<table cellpadding=2 rules=all>
 
517
<tr align=right><td></td><td>-5</td><td>-4</td><td>-3</td><td>-2</td><td>-1</td><td>0</td></tr><tr align=right><td></td><td bgcolor="#000000"><font color="#ffffff">-2</font></td><td bgcolor="#000000"><font color="#ffffff">11</font></td><td bgcolor="#000000"><font color="#ffffff">-24</font></td><td bgcolor="#000000"><font color="#ffffff">26</font></td><td bgcolor="#000000"><font color="#ffffff">-14</font></td><td bgcolor="#000060"><font color="#ffffff">3</font></td></tr>
 
518
</table>
 
519
</DL>
 
520
<P>
 
521
 
 
522
Note that the above are available in normalized versions <CODE>backward11n</CODE>,
 
523
<CODE>backward21n</CODE>, ..., <CODE>backward42n</CODE> which have factors of <EM>h</EM>,
 
524
<EM>h^2</EM>, <EM>h^3</EM>, or <EM>h^4</EM> as appropriate.  
 
525
</P><P>
 
526
 
 
527
These are available in multicomponent versions: for example,
 
528
<CODE>backward42(A,component,dimension)</CODE> gives the backward42 operator for
 
529
the specified component (Components are numbered 0, 1, ... N-1).
 
530
</P><P>
 
531
 
 
532
<HR SIZE="6">
 
533
<A NAME="SEC106"></A>
 
534
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
535
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC105"> &lt; </A>]</TD>
 
536
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC107"> &gt; </A>]</TD>
 
537
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC107"> &lt;&lt; </A>]</TD>
 
538
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
539
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
540
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
541
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
542
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
543
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
544
</TR></TABLE>
 
545
<H3> 4.4.4 Laplacian (<EM>nabla ^2</EM>) operators </H3>
 
546
<!--docid::SEC106::-->
 
547
<P>
 
548
 
 
549
<DL COMPACT>
 
550
<DT><CODE>Laplacian2D(A)</CODE>
 
551
<DD>2nd order accurate, 2-dimensional laplacian.  Factor: <EM>h^2</EM>
 
552
<table cellpadding=2 rules=all>
 
553
<tr align=right><td></td><td>-1</td><td>0</td><td>1</td></tr><tr align=right><td>-1</td><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td></td></tr>
 
554
<tr align=right><td>0</td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td bgcolor="#000060"><font color="#ffffff">-4</font></td><td bgcolor="#000000"><font color="#ffffff">1</font></td></tr>
 
555
<tr align=right><td>1</td><td></td><td bgcolor="#000000"><font color="#ffffff">1</font></td><td></td></tr>
 
556
</table>
 
557
<P>
 
558
 
 
559
<DT><CODE>Laplacian3D(A)</CODE>
 
560
<DD>2nd order accurate, 3-dimensional laplacian.  Factor: <EM>h^2</EM>
 
561
<P>
 
562
 
 
563
<DT><CODE>Laplacian2D4(A)</CODE>
 
564
<DD>4th order accurate, 2-dimensional laplacian.  Factor: <EM>12h^2</EM>
 
565
<table cellpadding=2 rules=all>
 
566
<tr align=right><td></td><td>-2</td><td>-1</td><td>0</td><td>1</td><td>2</td></tr><tr align=right><td>-2</td><td></td><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td></td><td></td></tr>
 
567
<tr align=right><td>-1</td><td></td><td></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td></td><td></td></tr>
 
568
<tr align=right><td>0</td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td bgcolor="#000060"><font color="#ffffff">-60</font></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td></tr>
 
569
<tr align=right><td>1</td><td></td><td></td><td bgcolor="#000000"><font color="#ffffff">16</font></td><td></td><td></td></tr>
 
570
<tr align=right><td>2</td><td></td><td></td><td bgcolor="#000000"><font color="#ffffff">-1</font></td><td></td><td></td></tr>
 
571
</table>
 
572
<P>
 
573
 
 
574
<DT><CODE>Laplacian3D4(A)</CODE>
 
575
<DD>4th order accurate, 3-dimensional laplacian.  Factor: <EM>12h^2</EM>
 
576
</DL>
 
577
<P>
 
578
 
 
579
Note that the above are available in normalized versions
 
580
<CODE>Laplacian2D4n</CODE>, <CODE>Laplacian3D4n</CODE> which have factors <EM>h^2</EM>.
 
581
</P><P>
 
582
 
 
583
<HR SIZE="6">
 
584
<A NAME="SEC107"></A>
 
585
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
586
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC106"> &lt; </A>]</TD>
 
587
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC108"> &gt; </A>]</TD>
 
588
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC108"> &lt;&lt; </A>]</TD>
 
589
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
590
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
591
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
592
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
593
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
594
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
595
</TR></TABLE>
 
596
<H3> 4.4.5 Gradient (<EM>nabla</EM>) operators </H3>
 
597
<!--docid::SEC107::-->
 
598
<P>
 
599
 
 
600
These return <CODE>TinyVector</CODE>s of the appropriate numeric type and length:
 
601
</P><P>
 
602
 
 
603
<DL COMPACT>
 
604
 
 
605
<DT><CODE>grad2D(A)</CODE>
 
606
<DD>2nd order, 2-dimensional gradient (vector of first derivatives), generated
 
607
using the central12 operator.  Factor: <EM>2h</EM>
 
608
<P>
 
609
 
 
610
<DT><CODE>grad2D4(A)</CODE>
 
611
<DD>4th order, 2-dimensional gradient, using central14 operator.  Factor: <EM>12h</EM>
 
612
<P>
 
613
 
 
614
<DT><CODE>grad3D(A)</CODE>
 
615
<DD>2nd order, 3-dimensional gradient, using central12 operator.  Factor: <EM>2h</EM>
 
616
<P>
 
617
 
 
618
<DT><CODE>grad3D4(A)</CODE>
 
619
<DD>4th order, 3-dimensional gradient, using central14 operator.  Factor: <EM>12h</EM>
 
620
</DL>
 
621
<P>
 
622
 
 
623
These are available in normalized versions <CODE>grad2Dn</CODE>, <CODE>grad2D4n</CODE>,
 
624
<CODE>grad3Dn</CODE> and <CODE>grad3D4n</CODE> which have factors <EM>h</EM>.
 
625
</P><P>
 
626
 
 
627
<HR SIZE="6">
 
628
<A NAME="SEC108"></A>
 
629
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
630
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC107"> &lt; </A>]</TD>
 
631
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC109"> &gt; </A>]</TD>
 
632
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC109"> &lt;&lt; </A>]</TD>
 
633
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
634
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
635
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
636
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
637
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
638
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
639
</TR></TABLE>
 
640
<H3> 4.4.6 Jacobian operators </H3>
 
641
<!--docid::SEC108::-->
 
642
<P>
 
643
 
 
644
The Jacobian operators are defined over 3D vector fields only (e.g.
 
645
<CODE>Array&#60;TinyVector&#60;double,3&#62;,3&#62;</CODE>).  They return a
 
646
<CODE>TinyMatrix&#60;T,3,3&#62;</CODE> where T is the numeric type of the vector field.
 
647
</P><P>
 
648
 
 
649
<DL COMPACT>
 
650
<DT><CODE>Jacobian3D(A)</CODE>
 
651
<DD>2nd order, 3-dimensional Jacobian using the central12 operator.  Factor:
 
652
<EM>2h</EM>.
 
653
<P>
 
654
 
 
655
<DT><CODE>Jacobian3D4(A)</CODE>
 
656
<DD>4th order, 3-dimensional Jacobian using the central14 operator.  Factor:
 
657
<EM>12h</EM>.
 
658
</DL>
 
659
<P>
 
660
 
 
661
These are also available in normalized versions <CODE>Jacobian3Dn</CODE> and
 
662
<CODE>Jacobain3D4n</CODE> which have factors <EM>h</EM>.
 
663
</P><P>
 
664
 
 
665
<HR SIZE="6">
 
666
<A NAME="SEC109"></A>
 
667
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
668
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC108"> &lt; </A>]</TD>
 
669
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC110"> &gt; </A>]</TD>
 
670
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC110"> &lt;&lt; </A>]</TD>
 
671
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
672
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
673
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
674
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
675
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
676
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
677
</TR></TABLE>
 
678
<H3> 4.4.7 Grad-squared operators </H3>
 
679
<!--docid::SEC109::-->
 
680
<P>
 
681
 
 
682
There are also grad-squared operators, which return <CODE>TinyVector</CODE>s of
 
683
second derivatives:
 
684
</P><P>
 
685
 
 
686
<DL COMPACT>
 
687
<DT><CODE>gradSqr2D(A)</CODE>
 
688
<DD>2nd order, 2-dimensional grad-squared (vector of second derivatives),
 
689
generated using the central22 operator.  Factor: <EM>h^2</EM>
 
690
<P>
 
691
 
 
692
<DT><CODE>gradSqr2D4(A)</CODE>
 
693
<DD>4th order, 2-dimensional grad-squared, using central24 operator.  Factor:
 
694
<EM>12h^2</EM>
 
695
<P>
 
696
 
 
697
<DT><CODE>gradSqr3D(A)</CODE>
 
698
<DD>2nd order, 3-dimensional grad-squared, using the central22 operator.
 
699
Factor: <EM>h^2</EM>
 
700
<P>
 
701
 
 
702
<DT><CODE>gradSqr3D4(A)</CODE>
 
703
<DD>4th order, 3-dimensional grad-squared, using central24 operator.  Factor:
 
704
<EM>12h^2</EM>
 
705
</DL>
 
706
<P>
 
707
 
 
708
Note that the above are available in normalized versions <CODE>gradSqr2Dn</CODE>,
 
709
<CODE>gradSqr2D4n</CODE>, <CODE>gradSqr3Dn</CODE>, <CODE>gradSqr3D4n</CODE> which have factors
 
710
<EM>h^2</EM>.
 
711
</P><P>
 
712
 
 
713
<HR SIZE="6">
 
714
<A NAME="SEC110"></A>
 
715
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
716
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC109"> &lt; </A>]</TD>
 
717
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC111"> &gt; </A>]</TD>
 
718
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC111"> &lt;&lt; </A>]</TD>
 
719
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
720
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
721
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
722
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
723
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
724
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
725
</TR></TABLE>
 
726
<H3> 4.4.8 Curl (<EM>nabla times</EM>) operators </H3>
 
727
<!--docid::SEC110::-->
 
728
<P>
 
729
 
 
730
These curl operators return scalar values:
 
731
</P><P>
 
732
 
 
733
<DL COMPACT>
 
734
<DT><CODE>curl(Vx,Vy)</CODE>
 
735
<DD>2nd order curl operator using the central12 operator.  Factor: <EM>2h</EM>
 
736
<P>
 
737
 
 
738
<DT><CODE>curl4(Vx,Vy)</CODE>
 
739
<DD>4th order curl operator using the central14 operator.  Factor: <EM>12h</EM>
 
740
<P>
 
741
 
 
742
<DT><CODE>curl2D(V)</CODE>
 
743
<DD>2nd order curl operator on a 2D vector field (e.g.
 
744
<CODE>Array&#60;TinyVector&#60;float,2&#62;,2&#62;</CODE>), using the central12 operator.  Factor:
 
745
<EM>2h</EM>
 
746
<P>
 
747
 
 
748
<DT><CODE>curl2D4(V)</CODE>
 
749
<DD>4th order curl operator on a 2D vector field, using the central12 operator.
 
750
Factor: <EM>12h</EM>
 
751
</DL>
 
752
<P>
 
753
 
 
754
Available in normalized forms <CODE>curln</CODE>, <CODE>curl4n</CODE>, <CODE>curl2Dn</CODE>,
 
755
<CODE>curl2D4n</CODE>.
 
756
</P><P>
 
757
 
 
758
These curl operators return three-dimensional <CODE>TinyVector</CODE>s of the 
 
759
appropriate numeric type:
 
760
</P><P>
 
761
 
 
762
<DL COMPACT>
 
763
<DT><CODE>curl(Vx,Vy,Vz)</CODE>
 
764
<DD>2nd order curl operator using the central12 operator.  Factor: <EM>2h</EM>
 
765
<P>
 
766
 
 
767
<DT><CODE>curl4(Vx,Vy,Vz)</CODE>
 
768
<DD>4th order curl operator using the central14 operator.  Factor: <EM>12h</EM>
 
769
<P>
 
770
 
 
771
<DT><CODE>curl(V)</CODE>
 
772
<DD>2nd order curl operator on a 3D vector field (e.g.
 
773
<CODE>Array&#60;TinyVector&#60;double,3&#62;,3&#62;</CODE>, using the central12 operator.  Factor:
 
774
<EM>2h</EM>
 
775
<P>
 
776
 
 
777
<DT><CODE>curl4(V)</CODE>
 
778
<DD>4th order curl operator on a 3D vector field, using the central14 operator.
 
779
Factor: <EM>12h</EM>
 
780
</DL>
 
781
<P>
 
782
 
 
783
Note that the above are available in normalized versions <CODE>curln</CODE> and
 
784
<CODE>curl4n</CODE>, which have factors of <CODE>h</CODE>.
 
785
</P><P>
 
786
 
 
787
<HR SIZE="6">
 
788
<A NAME="SEC111"></A>
 
789
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
790
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC110"> &lt; </A>]</TD>
 
791
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC112"> &gt; </A>]</TD>
 
792
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &lt;&lt; </A>]</TD>
 
793
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
794
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
795
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
796
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
797
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
798
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
799
</TR></TABLE>
 
800
<H3> 4.4.9 Divergence (<EM>nabla cdot</EM>) operators </H3>
 
801
<!--docid::SEC111::-->
 
802
<P>
 
803
 
 
804
The divergence operators return a scalar value.
 
805
</P><P>
 
806
 
 
807
<DL COMPACT>
 
808
<DT><CODE>div(Vx,Vy)</CODE>
 
809
<DD>2nd order div operator using the central12 operator.  Factor: <EM>2h</EM>
 
810
<P>
 
811
 
 
812
<DT><CODE>div4(Vx,Vy)</CODE>
 
813
<DD>4th order div operator using the central14 operator.  Factor: <EM>12h</EM>
 
814
<P>
 
815
 
 
816
<DT><CODE>div(Vx,Vy,Vz)</CODE>
 
817
<DD>2nd order div operator using the central12 operator.  Factor: <EM>2h</EM>
 
818
<P>
 
819
 
 
820
<DT><CODE>div4(Vx,Vy,Vz)</CODE>
 
821
<DD>4th order div operator using the central14 operator.  Factor: <EM>12h</EM>
 
822
<P>
 
823
 
 
824
<DT><CODE>div2D(V)</CODE>
 
825
<DD>2nd order div operator on a 2D vector field, using the central12 operator.
 
826
Factor: <EM>2h</EM>
 
827
<P>
 
828
 
 
829
<DT><CODE>div2D4(V)</CODE>
 
830
<DD>2nd order div operator on a 2D vector field, using the central14 operator.
 
831
Factor: <EM>12h</EM>
 
832
<P>
 
833
 
 
834
<DT><CODE>div3D(V)</CODE>
 
835
<DD>2nd order div operator on a 3D vector field, using the central12 operator.
 
836
Factor: <EM>2h</EM>
 
837
<P>
 
838
 
 
839
<DT><CODE>div3D4(V)</CODE>
 
840
<DD>2nd order div operator on a 3D vector field using the central14 operator.
 
841
Factor: <EM>12h</EM>
 
842
</DL>
 
843
<P>
 
844
 
 
845
These are available in normalized versions
 
846
<CODE>divn</CODE>, <CODE>div4n</CODE>, <CODE>div2Dn</CODE>, <CODE>div2D4n</CODE>, <CODE>div3Dn</CODE>, and
 
847
<CODE>div3D4n</CODE> which have factors of <EM>h</EM>.
 
848
</P><P>
 
849
 
 
850
<HR SIZE="6">
 
851
<A NAME="SEC112"></A>
 
852
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
853
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC111"> &lt; </A>]</TD>
 
854
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt; </A>]</TD>
 
855
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC104"> &lt;&lt; </A>]</TD>
 
856
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC102"> Up </A>]</TD>
 
857
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &gt;&gt; </A>]</TD>
 
858
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
859
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
860
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
861
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
862
</TR></TABLE>
 
863
<H3> 4.4.10 Mixed partial derivatives </H3>
 
864
<!--docid::SEC112::-->
 
865
<P>
 
866
 
 
867
<DL COMPACT>
 
868
<DT><CODE>mixed22(A,dim1,dim2)</CODE>
 
869
<DD>2nd order accurate, 2nd mixed partial derivative.  Factor: <EM>4h^2</EM>
 
870
<P>
 
871
 
 
872
<DT><CODE>mixed24(A,dim1,dim2)</CODE>
 
873
<DD>4th order accurate, 2nd mixed partial derivative.  Factor: <EM>144h^2</EM>
 
874
</DL>
 
875
<P>
 
876
 
 
877
There are also normalized versions of the above, <CODE>mixed22n</CODE> and
 
878
<CODE>mixed24n</CODE> which have factors <EM>h^2</EM>.
 
879
</P><P>
 
880
 
 
881
<HR SIZE="6">
 
882
<A NAME="SEC113"></A>
 
883
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
884
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC112"> &lt; </A>]</TD>
 
885
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC114"> &gt; </A>]</TD>
 
886
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC114"> &lt;&lt; </A>]</TD>
 
887
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
888
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
889
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
890
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
891
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
892
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
893
</TR></TABLE>
 
894
<H2> 4.5 Declaring your own stencil operators </H2>
 
895
<!--docid::SEC113::-->
 
896
<P>
 
897
 
 
898
You can declare your own stencil operators using the macro
 
899
<CODE>BZ_DECLARE_STENCIL_OPERATOR1</CODE>.  For example, here is the declaration
 
900
of <CODE>Laplacian2D</CODE>:
 
901
</P><P>
 
902
 
 
903
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL_OPERATOR1(Laplacian2D, A)
 
904
    return -4*A(0,0) + A(-1,0) + A(1,0) + A(0,-1) + A(0,1);
 
905
BZ_END_STENCIL_OPERATOR
 
906
</pre></td></tr></table></P><P>
 
907
 
 
908
To declare a stencil operator on 3 operands, use the macro
 
909
<CODE>BZ_DECLARE_STENCIL_OPERATOR3</CODE>.  Here is the declaration of <CODE>div</CODE>:
 
910
</P><P>
 
911
 
 
912
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_STENCIL_OPERATOR3(div,vx,vy,vz)
 
913
  return central12(vx,firstDim) + central12(vy,secondDim)
 
914
    + central12(vz,thirdDim);
 
915
BZ_END_STENCIL_OPERATOR
 
916
</pre></td></tr></table></P><P>
 
917
 
 
918
The macros aren't magical; they just declare an inline template function
 
919
with the names and arguments you specify.  For example, the declaration of
 
920
<CODE>div</CODE> could also be written
 
921
</P><P>
 
922
 
 
923
<TABLE><tr><td>&nbsp;</td><td class=example><pre>template&#60;class T&#62;                              
 
924
inline typename T::T_numtype div(T&#38; vx, T&#38; vy, T&#38; vz)   
 
925
{
 
926
  return central12(vx,firstDim) + central12(vy,secondDim)
 
927
                                + central12(vz,thirdDim);
 
928
}
 
929
</pre></td></tr></table></P><P>
 
930
 
 
931
The template parameter <CODE>T</CODE> is an iterator type for arrays.
 
932
</P><P>
 
933
 
 
934
You are encouraged to use the macros when possible, because it is possible
 
935
the implementation could be changed in the future.
 
936
</P><P>
 
937
 
 
938
To declare a difference operator, use this syntax:
 
939
</P><P>
 
940
 
 
941
<TABLE><tr><td>&nbsp;</td><td class=example><pre>BZ_DECLARE_DIFF(central12,A) {
 
942
  return A.shift(1,dim) - A.shift(-1,dim);
 
943
}
 
944
</pre></td></tr></table></P><P>
 
945
 
 
946
The method <CODE>shift(offset,dim)</CODE> retrieves the element at
 
947
<CODE>offset</CODE> in dimension <CODE>dim</CODE>.
 
948
</P><P>
 
949
 
 
950
Stencil operator declarations cannot occur inside a function.  If
 
951
declared inside a class, they are scoped by the class.
 
952
</P><P>
 
953
 
 
954
<HR SIZE="6">
 
955
<A NAME="SEC114"></A>
 
956
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
957
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC113"> &lt; </A>]</TD>
 
958
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt; </A>]</TD>
 
959
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> &lt;&lt; </A>]</TD>
 
960
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> Up </A>]</TD>
 
961
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
962
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
963
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
964
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
965
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
966
</TR></TABLE>
 
967
<H2> 4.6 Applying a stencil </H2>
 
968
<!--docid::SEC114::-->
 
969
<P>
 
970
 
 
971
The syntax for applying a stencil is:
 
972
</P><P>
 
973
 
 
974
<TABLE><tr><td>&nbsp;</td><td class=example><pre>applyStencil(stencilname(),A,B,C...,F);
 
975
</pre></td></tr></table></P><P>
 
976
 
 
977
Where <CODE>stencilname</CODE> is the name of the stencil, and <CODE>A,B,C,...,F</CODE>
 
978
are the arrays on which the stencil operates.
 
979
</P><P>
 
980
 
 
981
For examples, see <TT>`examples/stencil.cpp'</TT> and <TT>`examples/stencil2.cpp'</TT>.
 
982
</P><P>
 
983
 
 
984
Blitz++ interrogates the stencil object to find out how large its footprint
 
985
is.  It only applies the stencil over the region of the arrays where it
 
986
won't overrun the boundaries.
 
987
</P><P>
 
988
 
 
989
<A NAME="Customised Arrays"></A>
 
990
<HR SIZE="6">
 
991
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
 
992
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_4.html#SEC98"> &lt;&lt; </A>]</TD>
 
993
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_5.html#SEC115"> &gt;&gt; </A>]</TD>
 
994
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD>
 
995
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD>
 
996
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
 
997
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD>
 
998
</TR></TABLE>
 
999
<BR>  
 
1000
<FONT SIZE="-1">
 
1001
This document was generated
 
1002
by <I>Julian Cummings</I> on <I>November, 4  2004</I>
 
1003
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
 
1004
"><I>texi2html</I></A>
 
1005
 
 
1006
</BODY>
 
1007
</HTML>