This file is indexed.

/usr/share/doc/libblitz-doc/html/Array-ctors.html is in libblitz-doc 1:0.10-3.3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.0, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Blitz++: Array ctors</title>

<meta name="description" content="Blitz++: Array ctors">
<meta name="keywords" content="Blitz++: Array ctors">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Keyword-Index.html#Keyword-Index" rel="index" title="Keyword Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Arrays.html#Arrays" rel="up" title="Arrays">
<link href="Array-slicing.html#Array-slicing" rel="next" title="Array slicing">
<link href="Array-types.html#Array-types" rel="prev" title="Array types">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space: nowrap}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: serif; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<a name="Array-ctors"></a>
<div class="header">
<p>
Next: <a href="Array-slicing.html#Array-slicing" accesskey="n" rel="next">Array slicing</a>, Previous: <a href="Array-types.html#Array-types" accesskey="p" rel="prev">Array types</a>, Up: <a href="Arrays.html#Arrays" accesskey="u" rel="up">Arrays</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Keyword-Index.html#Keyword-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Constructors"></a>
<h3 class="section">2.3 Constructors</h3>

<a name="Default-constructor"></a>
<h4 class="subsection">2.3.1 Default constructor</h4>
<a name="index-Array-default-ctor"></a>

<div class="example">
<pre class="example">Array();
Array(GeneralArrayStorage&lt;N_rank&gt; storage)
</pre></div>

<p>The default constructor creates a C-style array of zero size.  Any attempt
to access data in the array may result in a run-time error, because there
isn&rsquo;t any data to access!
</p>
<p>An optional argument specifies a storage order for the array.
</p>
<p>Arrays created using the default constructor can subsequently be given data
by the <code>resize()</code>, <code>resizeAndPreserve()</code>, or <code>reference()</code>
member functions.
</p>
<a name="Creating-an-array-from-an-expression"></a>
<h4 class="subsection">2.3.2 Creating an array from an expression</h4>

<div class="example">
<pre class="example">Array(expression...)
</pre></div>

<p>You may create an array from an array expression.  For example,
</p>
<div class="example">
<pre class="example">Array&lt;float,2&gt; A(4,3), B(4,3);   // ...
Array&lt;float,2&gt; C(A*2.0+B);
</pre></div>

<p>This is an explicit constructor (it will not be used to perform implicit
type conversions).  The newly constructed array will have the same storage
format as the arrays in the expression.  If arrays with different storage
formats appear in the expression, an error will result.  (In this case, you
must first construct the array, then assign the expression to it).
</p>
<a name="Constructors-which-take-extent-parameters"></a>
<h4 class="subsection">2.3.3 Constructors which take extent parameters</h4>
<a name="index-Array-ctors-with-extent-parameters"></a>

<div class="example">
<pre class="example">Array(int extent1);
Array(int extent1, int extent2);
Array(int extent1, int extent2, int extent3);
...
Array(int extent1, int extent2, int extent3, ..., int extent11)
</pre></div>

<p>These constructors take arguments which specify the size of the array to be
constructed.  You should provide as many arguments as there are dimensions
in the array.<a name="DOCF1" href="#FOOT1"><sup>1</sup></a>
</p>
<p>An optional last parameter specifies a storage format:
</p>
<div class="example">
<pre class="example">Array(int extent1, GeneralArrayStorage&lt;N_rank&gt; storage);
Array(int extent1, int extent2, GeneralArrayStorage&lt;N_rank&gt; storage);
...
</pre></div>

<p>For high-rank arrays, it may be convenient to use this constructor:
<a name="index-Array-high_002drank"></a>
</p>
<div class="example">
<pre class="example">Array(const TinyVector&lt;int, N_rank&gt;&amp; extent);
Array(const TinyVector&lt;int, N_rank&gt;&amp; extent, 
      GeneralArrayStorage&lt;N_rank&gt; storage);
</pre></div>

<p>The argument <code>extent</code> is a vector containing the extent (length) of the
array in each dimension.  The optional second parameter indicates a storage
format.  Note that you can construct <code>TinyVector&lt;int,N&gt;</code> objects on the
fly with the <code>shape(i1,i2,...)</code> global function.  For example,
<code>Array&lt;int,2&gt; A(shape(3,5))</code> will create a 3x5 array.
</p>
<p>A similar constructor lets you provide both a vector of base index values
(lbounds) and extents:
</p>
<div class="example">
<pre class="example">Array(const TinyVector&lt;int, N_rank&gt;&amp; lbound, 
      const TinyVector&lt;int, N_rank&gt;&amp; extent);
Array(const TinyVector&lt;int, N_rank&gt;&amp; lbound,
      const TinyVector&lt;int, N_rank&gt;&amp; extent,
      GeneralArrayStorage&lt;N_rank&gt; storage);
</pre></div>

<p>The argument <code>lbound</code> is a vector containing the base index value (or
lbound) of the array in each dimension.  The argument <code>extent</code> is a
vector containing the extent (length) of the array in each dimension.  The
optional third parameter indicates a storage format.  As with the above
constructor, you can use the <code>shape(i1,i2,...)</code> global function to
create the <code>lbound</code> and <code>extent</code> parameters.
</p>
<a name="Constructors-with-Range-arguments"></a>
<h4 class="subsection">2.3.4 Constructors with Range arguments</h4>
<a name="index-Array-ctor-with-Range-args"></a>

<p>These constructors allow arbitrary bases (starting indices) to be set:
</p>
<div class="example">
<pre class="example">Array(Range r1);
Array(Range r1, Range r2);
Array(Range r1, Range r2, Range r3);
...
Array(Range r1, Range r2, Range r3, ..., Range r11);
</pre></div>

<p>For example, this code:
</p>
<div class="example">
<pre class="example">Array&lt;int,2&gt; A(Range(10,20), Range(20,30));
</pre></div>

<p>will create an 11x11 array whose indices are 10..20 and 20..30.  An optional
last parameter provides a storage order:
</p>
<div class="example">
<pre class="example">Array(Range r1, GeneralArrayStorage&lt;N_rank&gt; storage);
Array(Range r1, Range r2, GeneralArrayStorage&lt;N_rank&gt; storage);
...
</pre></div>

<a name="Referencing-another-array"></a>
<h4 class="subsection">2.3.5 Referencing another array</h4>
<a name="index-Array-referencing-another-array"></a>

<p>This constructor makes a shared view of another array&rsquo;s data:
<a name="index-Array-creating-a-reference-of-another-array"></a>
</p>
<div class="example">
<pre class="example">Array(Array&lt;T_numtype, N_rank&gt;&amp; array);
</pre></div>

<p>After this constructor is used, both <code>Array</code> objects refer to the
<em>same data</em>.  Any changes made to one array will appear in the other
array.  If you want to make a duplicate copy of an array, use the
<code>copy()</code> member function.
</p>
<a name="Constructing-an-array-from-an-expression"></a>
<h4 class="subsection">2.3.6 Constructing an array from an expression</h4>

<p>Arrays may be constructed from expressions, which are described in
<a href="Array-Expressions.html#Array-Expressions">Array Expressions</a>.  The syntax is:
</p>
<div class="example">
<pre class="example">Array(...array expression...);
</pre></div>

<p>For example, this code creates an array B which contains the square roots of
the elements in A:
</p>
<div class="example">
<pre class="example">Array&lt;float,2&gt; A(N,N);   // ...
Array&lt;float,2&gt; B(sqrt(A));
</pre></div>

<a name="Creating-an-array-from-pre_002dexisting-data"></a>
<h4 class="subsection">2.3.7 Creating an array from pre-existing data</h4>
<a name="index-Array-creating-from-pre_002dexisting-data"></a>

<p>When creating an array using a pointer to already existing data, you have
three choices for how Blitz++ will handle the data.  These choices are
enumerated by the enum type <code>preexistingMemoryPolicy</code>:
<a name="index-Array-creating-a-reference-of-another-array-1"></a>
</p>
<div class="example">
<pre class="example">enum preexistingMemoryPolicy { 
  duplicateData, 
  deleteDataWhenDone, 
  neverDeleteData 
};
</pre></div>
<a name="index-preexistingMemoryPolicy"></a>
<a name="index-duplicateData"></a>
<a name="index-deleteDataWhenDone"></a>
<a name="index-neverDeleteData"></a>

<p>If you choose <code>duplicateData</code>, Blitz++ will create an array object
using a copy of the data you provide.  If you choose
<code>deleteDataWhenDone</code>, Blitz++ will not create a copy of the data; and
when no array objects refer to the data anymore, it will deallocate the data
using <code>delete []</code>.  Note that to use <code>deleteDataWhenDone</code>, your
array data must have been allocated using the C++ <code>new</code> operator &ndash; for
example, you cannot allocate array data using Fortran or <code>malloc</code>, then
create a Blitz++ array from it using the <code>deleteDataWhenDone</code> flag.
The third option is <code>neverDeleteData</code>, which means that Blitz++ will
not never deallocate the array data.  This means it is your responsibility
to determine when the array data is no longer needed, and deallocate it.
You should use this option for memory which has not been allocated using the
C++ <code>new</code> operator.
</p>
<p>These constructors create array objects from pre-existing data:
</p>
<div class="example">
<pre class="example">Array(T_numtype* dataFirst, TinyVector&lt;int, N_rank&gt; shape,
      preexistingMemoryPolicy deletePolicy);
Array(T_numtype* dataFirst, TinyVector&lt;int, N_rank&gt; shape,
      preexistingMemoryPolicy deletePolicy, 
      GeneralArrayStorage&lt;N_rank&gt; storage);
</pre></div>

<p>The first argument is a pointer to the array data.  It should point to the
element of the array which is stored first in memory.  The second argument
indicates the shape of the array.  You can create this argument using the
<code>shape()</code> function.  For example:
</p>
<div class="example">
<pre class="example">double data[] = { 1, 2, 3, 4 };
Array&lt;double,2&gt; A(data, shape(2,2), neverDeleteData);   // Make a 2x2 array
</pre></div>

<a name="index-shape_0028_0029"></a>

<p>The <code>shape()</code> function takes N integer arguments and returns a
<code>TinyVector&lt;int,N&gt;</code>.
</p>
<p>By default, Blitz++ arrays are row-major.  If you want to work with data
which is stored in column-major order (e.g. a Fortran array), use the second
version of the constructor: 
</p>
<a name="index-Array-creating-from-Fortran-arrays"></a>

<div class="example">
<pre class="example">Array&lt;double,2&gt; B(data, shape(2,2), neverDeleteData,
                  FortranArray&lt;2&gt;());
</pre></div>

<p>This is a tad awkward, so Blitz++ provides the global object
<code>fortranArray</code> which will convert to an instance of
<code>GeneralArrayStorage&lt;N_rank&gt;</code>:
</p>
<div class="example">
<pre class="example">Array&lt;double,2&gt; B(data, shape(2,2), neverDeleteData, fortranArray);
</pre></div>

<p>Another version of this constructor allows you to pass an arbitrary
vector of strides:
</p>
<div class="example">
<pre class="example">Array(T_numtype* _bz_restrict dataFirst, TinyVector&lt;int, N_rank&gt; shape,
      TinyVector&lt;int, N_rank&gt; stride, 
      preexistingMemoryPolicy deletePolicy,
      GeneralArrayStorage&lt;N_rank&gt; storage = GeneralArrayStorage&lt;N_rank&gt;())
</pre></div>

<a name="Interlacing-arrays"></a>
<h4 class="subsection">2.3.8 Interlacing arrays</h4>
<a name="index-Array-interlacing"></a>
<a name="index-interlaceArrays_0028_0029"></a>
<a name="index-allocateArrays_0028_0029"></a>

<p>For some platforms, it can be advantageous to store a set of arrays
interlaced together in memory.  Blitz++ provides support for this through
the routines <code>interlaceArrays()</code> and <code>allocateArrays()</code>.  An
example:
</p>
<div class="example">
<pre class="example">Array&lt;int,2&gt; A, B;
interlaceArrays(shape(10,10), A, B);
</pre></div>

<p>The first parameter of <code>interlaceArrays()</code> is the shape for the arrays
(10x10).  The subsequent arguments are the set of arrays to be interlaced
together.  Up to 11 arrays may be interlaced.  All arrays must store the
same data type and be of the same rank.  In the above example, storage is
allocated so that <code>A(0,0)</code> is followed immediately by <code>B(0,0)</code> in
memory, which is folloed by <code>A(0,1)</code> and <code>B(0,1)</code>, and so on.
</p>
<p>A related routine is <code>allocateArrays()</code>, which has identical syntax:
</p>
<div class="example">
<pre class="example">Array&lt;int,2&gt; A, B;
allocateArrays(shape(10,10), A, B);
</pre></div>

<p>Unlike <code>interlaceArrays()</code>, which always interlaces the arrays, the
routine <code>allocateArrays()</code> may or may not interlace them, depending on
whether interlacing is considered advantageous for your platform.  If the
tuning flag <code>BZ_INTERLACE_ARRAYS</code> is defined in
<code>&lt;blitz/tuning.h&gt;</code>, then the arrays are interlaced.
</p>
<p>Note that the performance effects of interlacing are unpredictable: in some
situations it can be a benefit, and in most others it can slow your code
down substantially.  You should only use <code>interlaceArrays()</code> after
running some benchmarks to determine whether interlacing is beneficial for
your particular algorithm and architecture.
</p>
<a name="A-note-about-reference-counting"></a>
<h4 class="subsection">2.3.9 A note about reference counting</h4>
<a name="index-Array-reference-counting"></a>
<a name="index-reference-counting"></a>

<p>Blitz++ arrays use reference counting.  When you create a new array, a
memory block is allocated.  The <code>Array</code> object acts like a handle for
this memory block.  A memory block can be shared among multiple <code>Array</code>
objects &ndash; for example, when you take subarrays and slices.  The memory
block keeps track of how many <code>Array</code> objects are referring to it.
When a memory block is orphaned &ndash; when no <code>Array</code> objects are
referring to it &ndash; it automatically deletes itself and frees the allocated
memory.
</p>

<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>

<h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
<p>If you provide fewer than <code>N_rank</code> arguments,
the missing arguments will be filled in using the last provided argument.
However, for code clarity, it makes sense to provide all <code>N_rank</code>
parameters.</p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Array-slicing.html#Array-slicing" accesskey="n" rel="next">Array slicing</a>, Previous: <a href="Array-types.html#Array-types" accesskey="p" rel="prev">Array types</a>, Up: <a href="Arrays.html#Arrays" accesskey="u" rel="up">Arrays</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Keyword-Index.html#Keyword-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>