Specify dimension list at beginning of data.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 4 Jan 2016 07:57:05 +0000 (23:57 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 4 Jan 2016 07:57:05 +0000 (23:57 -0800)
dump.c
spv-file-format.texi

diff --git a/dump.c b/dump.c
index 70ecab632058cf56a7146983f0da940f1e3c09d5..1cdb749f81fc714f09876a9701391cb48416e2bb 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -694,14 +694,21 @@ static void
 dump_data(void)
 {
   /* The first three numbers add to the number of dimensions. */
-  int t = get_u32();
-  t += get_u32();
-  match_u32_assert(n_dims - t);
+  int l = get_u32();
+  int r = get_u32();
+  int c = n_dims - l - r;
+  match_u32_assert(c);
 
   /* The next n_dims numbers are a permutation of the dimension numbers. */
   int a[n_dims];
   for (int i = 0; i < n_dims; i++)
-    a[i] = get_u32();
+    {
+      int dim = get_u32();
+      a[i] = dim;
+
+      const char *name = i < l ? "layer" : i < l + r ? "row" : "column";
+      printf ("<%s dimension=\"%d\"/>\n", name, dim);
+    }
   check_permutation(a, n_dims, "dimensions");
 
   int x = get_u32();
index c58723379517a7ddfd275184a96020313f147703..bb615a2384333bd3fd4166b21a38f04dceffeefd 100644 (file)
@@ -554,3 +554,20 @@ are terminal categories that directly represent data values for a
 variable (e.g. in a frequency table or crosstabulation, a group of
 values in a variable being tabulated) and i0 otherwise, but this might
 be naive.
+
+@example
+data := int[layers] int[rows] int[columns] int*[n-dimensions]
+@end example
+
+The values of @code{layers}, @code{rows}, and @code{columns} each
+specifies the number of dimensions represented in layers or rows or
+columns, respectively, and their values sum to the number of
+dimensions.
+
+The @code{n-dimensions} integers are a permutation of the 0-based
+dimension numbers.  The first @code{layers} of them specify each of
+the dimensions represented by layers, the next @code{rows} of them
+specify the dimensions represented by rows, and the final
+@code{columns} of them specify the dimensions represented by columns.
+When there is more than one dimension of a given kind, the inner
+dimensions are given first.