Thread overview
Example of append & rectangualar arrays?
May 25, 2019
Robert M. Münch
May 27, 2019
9il
May 28, 2019
Robert M. Münch
May 25, 2019
Does anyone has an example using Appender with a rectangual array?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

May 27, 2019
On Saturday, 25 May 2019 at 14:17:43 UTC, Robert M. Münch wrote:
> Does anyone has an example using Appender with a rectangual array?

Appender!(T[][]) can append rows of type T[]. It does not check their lengths, the T[][] is an array of arrays, not a matrix.

To append columns one needs an array of Appenders, Appenders!(T[])[].

T[][] can be converted to Slice!(T*, 2) (ndslice matrix) using the mir.ndslice.fuse module [1].

Then the matrix can be transposed. Zero cost transposition can be found in the second example at [1].

`ndarray` function can be used [2] to convert matrix back to an array of array.

http://mir-algorithm.libmir.org/mir_ndslice_fuse.html#.fuse
http://mir-algorithm.libmir.org/mir_ndslice_allocation.html#ndarray

May 28, 2019
On 2019-05-27 13:14:47 +0000, 9il said:

> Appender!(T[][]) can append rows of type T[]. It does not check their lengths, the T[][] is an array of arrays, not a matrix.
> 
> To append columns one needs an array of Appenders, Appenders!(T[])[].

And to have appenders on both dimensions?

Appenders!(T[])Appenders!(T[])  --- not tested.

I'm using dynamic arrays at the moment which works. As the amount of data is not very high, the overhead shouldn't be critical. My idea to use an appender instead of dynamic arrays was efficency.


> T[][] can be converted to Slice!(T*, 2) (ndslice matrix) using the mir.ndslice.fuse module [1].

I took a look at mir, but as I understands it, it needs known dimension sizes (matrix). I don't have these, it's all dynamic.

> Then the matrix can be transposed. Zero cost transposition can be found in the second example at [1].
> `ndarray` function can be used [2] to convert matrix back to an array of array.

Yes, as said I don't have a matrix more a collection of differently sized dynamic arrays.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster