Script Vector-multi.lua

Test-script for module ctables and class::Vector testing limits of dimensions

Arguments

  • How many dimensions
  • Resolve dimensions from test-matrix using method (optional).

Possible methods:

- ctables.dim
- ctables.tdim  (default)
- Vector.dim

Number of arguments N determines the numbers of dimensions. Each dimensions depth is implicit: D + N + 2, where D is the current dimension for each test.

Method tests usage of different functions. 2 C-API and one Lua, all with the same basic algorithm. ctables.dim returns a list which is convenient mut may have limitations. Number of C-API function return-values are said to be hard-limited in Lua. Documentation for Lua 5.3. Says 20, but empirically it's been shown dimensions can be much higher and seems limited rather by _GC and memory. Use this test to determine which.

Note:

  • Method can't be selected when invoked from shell as Lual will treat it as a string
  • multi-dimensional matrices can easily become ridiculously huge:
> \i;n3 11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3
19 958 400
> \i;n3 12 * 11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3
239 500 800
> \i;n3 13 * 12 * 11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3
3 113 510 400

I.e. theoretically (note the exponential consumption):

 Dimensions  Elements  Bytes
 ----------  --------  -----
 11D         19M       190MB
 12D         240M      2.4GB
 13D         3.1B      31GB

Tests however pass up to 37D (!) It's obvious that Lua use some pretty nifty mechanics for tables to avoid data-duplication (test uses same same data-leaf and sub-vectors are also identical for each level. I.e. data-duplication detect and cross-linking where possible.

Example from shell:

$ export PATH=$HOME/.lua/bin:$PATH
$ Vector-multi.lua 16

See also:

Usage:

    Create a 16-D Matrix of the following dimensions 18x17x16x15x14x13x12x11x10x9x8x7x6x5x4x3 and perform basic operations on it
    loadfile("Vector-multi.lua")(16)
    


generated by LDoc 1.5.0 Last updated 2024-09-16 20:16:45