@@ -217,23 +217,31 @@ even when a Typed Array does not apply.
217
217
Multi-dimensional Array
218
218
-----------------------
219
219
220
+ A multi-dimensional array is represented as a tagged array that
221
+ contains two (one-dimensional) arrays. The first array defines the
222
+ dimensions of the
223
+ multi-dimensional array (in the sequence of outer dimensions towards
224
+ inner dimensions) while the second array represents the contents
225
+ of the multi-dimensional array. If the second array is itself tagged
226
+ as a Typed Array then the element type of the multi-dimensional array
227
+ is known to be the same type as that of the Typed Array.
228
+
229
+ Two tags are defined by this document, one for elements arranged in
230
+ row-major order, and one for column-major order.
231
+
232
+ # ## Row-major Order
233
+
220
234
Tag :
221
235
: 40
222
236
223
237
Data Item :
224
238
: array (major type 4) of two arrays, one array (major type 4) of
225
- dimensions, and one array (major type 4, a Typed Array, or a
239
+ dimensions, which are unsigned integers distinct from zero, and one
240
+ array (either a CBOR array of major type 4, or a Typed Array, or a
226
241
Homogeneous Array) of elements
227
242
228
- A multi-dimensional array is represented as a tagged array that
229
- contains two (one-dimensional) arrays. The first array defines the dimensions of the
230
- multi-dimensional array (in the sequence of outer dimensions towards
231
- inner dimensions) while the second array represents the contents
232
- of the multi-dimensional array. If the second array is itself tagged
233
- as a Typed Array then the element type of the multi-dimensional array
234
- is known to be the same type as that of the Typed Array. Data in
235
- the Typed Array byte string consists of consecutive values where the
236
- last dimension is considered contiguous (row-major order).
243
+ Data in the second array consists of consecutive values where the last
244
+ dimension is considered contiguous (row-major order).
237
245
238
246
{{ex-multidim}} shows a declaration of a two-dimensional array in the
239
247
C language, a representation of that in CBOR using both a
@@ -282,17 +290,21 @@ shorter).
282
290
~~~
283
291
{: # ex-multidim1 title="Multi-dimensional array using basic CBOR array"}
284
292
293
+ # ## Column-Major order
294
+
295
+ The multidimensional arrays specified in the previous
296
+ sub-subsection are in "row major" order, which is the preferred order
297
+ for the purposes of this specification. An analogous representation
298
+ that uses "column major" order arrays is provided in this subsection
299
+ under the tag 1040, as illustrated in {{ex-multidim2}}.
285
300
286
301
Tag :
287
302
: 1040
288
303
289
304
Data Item :
290
- : as with tag 40
291
-
292
- Note that above arrays are in "row major" order, which is the
293
- preferred order for the purposes of this specification. An analogous
294
- representation that uses "column major" order arrays is provided under
295
- the tag 1040, as illustrated in {{ex-multidim2}}.
305
+ : as with tag 40, except that the data in the second array consists of
306
+ consecutive values where the first dimension is considered contiguous
307
+ (column-major order).
296
308
297
309
~~~
298
310
<Tag 1040> # multi-dimensional array tag, column major order
0 commit comments