forked from johannesgerer/jburkardt-f
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cell.html
332 lines (296 loc) · 9.85 KB
/
cell.html
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
<html>
<head>
<title>
CELL - Manipulate Data in Cell Arrays
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
CELL <br> Manipulate Data in Cell Arrays
</h1>
<hr>
<p>
<b>CELL</b>
is a FORTRAN90 library which
defines a cell array, a generalization of an array which
can compactly store and retrieve vector or matrix data of
varying size, such as the rows of a triangular matrix.
</p>
<p>
In MATLAB, a cell array is a structure which generalizes a matrix.
It can be thought of as an object A, whose entries can be indexed
by expressions such as A(I,J). In a matrix, each entry is a numeric
scalar object. In a cell array, each entry A(I,J) is simply an object
of unspecified type, dimension, and range.
</p>
<p>
In the simplified version of a cell array presented here, the cell array
is a vector (one index) or matrix (two indices), each of whose entries
is, in turn, a vector or a matrix of standard numeric type. We still
allow the individual entries to have differing ranges. Thus, a lower
triangular matrix can be thought of as a cell array A that stores the
rows. Row 3 of the triangular matrix can be thought of as the third
entry in A. To retrieve a particular number in row 3, we have to
determine where the row is stored, and then where the desired item
is stored in the row.
</p>
<p>
The vectors or matrices which are the entries of a particular cell array
will all share a common numeric type, which we will designate as
<ul>
<li>
<b>C4</b>, 4 byte + 4 byte complex;
</li>
<li>
<b>C8</b>, 8 byte + 8 byte double precision complex;
</li>
<li>
<b>I4</b>, 4 byte integer;
</li>
<li>
<b>R4</b>, 4 byte real;
</li>
<li>
<b>R8</b>, 8 byte double precision real;
</li>
</ul>
</p>
<p>
We use a simple code to describe the numeric type, indexing scheme,
and entry type of a cell array. For example, an "R8CVM" would be
a cell array of numeric type double precision real (R8), which is
a single indexed vector (V) whose entries are matrices (M).
</p>
<p>
To see how cell arrays can be useful, we will concentrate on the
idea of efficient storage. Thus, suppose we simply want to store
rows 0 through 5 of Pascal's triangle. Since these quantities are integers,
we could use numeric type I4. Since we want to refer to items by row,
we only need a single index to access entries. Each entry is a row.
This means the code for the cell array would be I4CVV.
</p>
<p>
We could think of this cell array as having the following structure:
<pre>
A = { { 1 },
{ 1, 1 },
{ 1, 2, 1 },
{ 1, 3, 3, 1 },
{ 1, 4, 6, 4, 1 },
{ 1, 5, 10, 10, 5, 1 } }
</pre>
We can imagine that the cell array A is simply a vector of length 6,
and that the A(3), for example, is the vector {1,2,1}. On the other
hand, in this case it is very tempting to also consider the array
notation A(3,2), which now must be carefully interpreted, since the
3 is a cell array index (3rd row) which is easy to know is only
allowed to extend from 1 to 6, while the 2 is a row index (item
2 of the current row) whose validity is hard to know unless we know
the legal extent of that row.
</p>
<p>
Especially when we contemplate more
complicated structures, it might be better to replace the notation
A(3,2) by A(3)(2), meaning third entry of A, second item in that entry.
In this way, we can immediately understand that B(3,2)(4) means that
B is a matrix of entries, each of which is a vector, while C(3)(2,4)
means C is a vector whose entries are matrices.
</p>
<p>
To create a cell array, the user must provide information about the
dimension (1 for "V" and 2 for "M") of the cell array, and the range
of each entry (length of V entries or rows*columns for M entries).
This is used to determine the total size needed for the cell array,
and the offsets needed to quickly access individual items in the
entries.
</p>
<p>
Cell arrays of type **CVV are most commonly useful, given how often
triangular arrays and matrices occur, as well as lists, each of whose
entries is in turn a list of varying length.
</p>
<p>
Cell arrays of types I4CVV and R8CVV are implemented in this library.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this
web page are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>CELL</b> is available in
<a href = "../../c_src/cell/cell.html">a C version</a> and
<a href = "../../cpp_src/cell/cell.html">a C++ version</a> and
<a href = "../../f77_src/cell/cell.html">a FORTRAN77 version</a> and
<a href = "../../f_src/cell/cell.html">a FORTRAN90 version</a> and
<a href = "../../m_src/cell/cell.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../f_src/index/index.html">
INDEX</a>,
a FORTRAN90 library which
converts a multidimensional vector index to a one-dimensional vector index;
it can handle zero and one based indexing schemes, as well as column major
and row major conventions.
</p>
<p>
<a href = "../../f_src/subpak/subpak.html">
SUBPAK</a>,
a FORTRAN90 library which
contains many utility routines;
</p>
<p>
<a href = "../../f_src/vec_io/vec_io.html">
VEC_IO</a>,
a FORTRAN90 library which
reads and writes vectors
of fixed size, to and from a disk file, in any order;
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "cell.f90">cell.f90</a>, the source code.
</li>
<li>
<a href = "cell.sh">cell.sh</a>,
BASH commands to compile the source code.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "cell_prb.f90">cell_prb.f90</a>,
a sample calling program.
</li>
<li>
<a href = "cell_prb.sh">cell_prb.sh</a>,
BASH commands to compile and run the sample program.
</li>
<li>
<a href = "cell_prb_output.txt">cell_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>I4CVV_IGET</b> gets item J from row I in an I4CVV.
</li>
<li>
<b>I4CVV_IINC</b> increments item J from row I in an I4CVV.
</li>
<li>
<b>I4CVV_ISET</b> sets item J from row I in an I4CVV.
</li>
<li>
<b>I4CVV_NGET</b> gets N items JN(*) from row IN(*) in an I4CVV.
</li>
<li>
<b>I4CVV_NINC</b> increments items JN(*) from row IN(*) in an I4CVV.
</li>
<li>
<b>I4CVV_NSET</b> sets items JN(*) from row IN(*) in an I4CVV.
</li>
<li>
<b>I4CVV_OFFSET</b> determines the row offsets of an I4CVV.
</li>
<li>
<b>I4CVV_PRINT</b> prints an I4CVV.
</li>
<li>
<b>I4CVV_RGET</b> gets row I from an I4CVV.
</li>
<li>
<b>I4CVV_RINC</b> increments row I in an I4CVV.
</li>
<li>
<b>I4CVV_RSET</b> sets row I from an I4CVV.
</li>
<li>
<b>I4CVV_SIZE</b> determines the size of an I4CVV.
</li>
<li>
<b>I4VEC_PRINT</b> prints an I4VEC.
</li>
<li>
<b>I4VEC_TRANSPOSE_PRINT</b> prints an I4VEC "transposed".
</li>
<li>
<b>R8CVV_IGET</b> gets item J from row I in an R8CVV.
</li>
<li>
<b>R8CVV_IINC</b> increments item J from row I in an R8CVV.
</li>
<li>
<b>R8CVV_ISET</b> sets item J from row I in an R8CVV.
</li>
<li>
<b>R8CVV_NGET</b> gets N items JN(*) from row IN(*) in an R8CVV.
</li>
<li>
<b>R8CVV_NINC</b> increments items JN(*) from row IN(*) in an R8CVV.
</li>
<li>
<b>R8CVV_NSET</b> sets items JN(*) from row IN(*) in an R8CVV.
</li>
<li>
<b>R8CVV_OFFSET</b> determines the row offsets of an R8CVV.
</li>
<li>
<b>R8CVV_PRINT</b> prints an R8CVV.
</li>
<li>
<b>R8CVV_RGET</b> gets row I from an R8CVV.
</li>
<li>
<b>R8CVV_RINC</b> increments row I in an R8CVV.
</li>
<li>
<b>R8CVV_RSET</b> sets row I from an R8CVV.
</li>
<li>
<b>R8CVV_SIZE</b> determines the size of an R8CVV.
</li>
<li>
<b>R8VEC_PRINT</b> prints an R8VEC.
</li>
<li>
<b>R8VEC_TRANSPOSE_PRINT</b> prints an R8VEC "transposed".
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../f_src.html">
the FORTRAN90 source codes</a>.
</p>
<hr>
<i>
Last revised on 02 December 2012.
</i>
<!-- John Burkardt -->
</body>
<!-- Initial HTML skeleton created by HTMLINDEX. -->
</html>