digitalmars.D - Lazy concatenation and padding utilities
- Ilya Yaroshenko (27/27) Mar 09 2017 Hello
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/5) Mar 09 2017 Nice. Is this dependent on choosing either RC- or GC-based
- Ilya Yaroshenko (16/22) Mar 09 2017 No, they are completely generic.
- Ilya Yaroshenko (9/15) Mar 09 2017 ... continue prev. reply:
- Ilya Yaroshenko (3/4) Mar 09 2017 renamed:
- Ilya Yaroshenko (2/29) Mar 09 2017 `stack` was renamed to `concatenation` to much numpy and Matlab
- jmh530 (7/8) Mar 09 2017 Numpy does have stack, but this is more similar to the
Hello Ndslice got [1] lazy multidimensional concatenation and padding utilities: 1. stack 2. pad 2. padEdge 3. padSymmetric 4. padWrap `stack` can be used for ndslices instead of `chain`. --- import mir.ndslice.allocation: slice; import mir.ndslice.stack: stack; auto d = stack(a, b, c).slice; --- ndslice allocation and assign utilities are optimised to work with stacks. For example the code above is significantly faster then --- import std.array: array; import std.range: chain; auto d = chain(a, b, c).array; --- because `slice` uses external iteration for `Stack` data structure. [1] http://docs.algorithm.dlang.io/latest/mir_ndslice_stack.html Best regards, Ilya
Mar 09 2017
On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko wrote:Ndslice got [1] lazy multidimensional concatenation and padding utilities:Nice. Is this dependent on choosing either RC- or GC-based allocation?
Mar 09 2017
On Thursday, 9 March 2017 at 09:10:47 UTC, Nordlöw wrote:On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko wrote:No, they are completely generic. The new ndslice uses iterators under the hood. An iterator for manually allocated memory (with `makeSlice!T`) and GC allocated memory (with `slice!T`) is just a pointer type of T*. You can use `slicedField` [1] to create ndslice on top of a RC-array. slicedField will create iterator on top of the rc-array using FieldIterator [2], and return ndslice based on the iterator. This is quite simple RC arrays can be very simple: only `auto ref opIndex(size_t index)` and `length` are required. `front`, `opSlice` and other RAR primitives are not used by FieldIterator. [1] http://docs.algorithm.dlang.io/latest/mir_ndslice_slice.html#slicedField [2] http://docs.algorithm.dlang.io/latest/mir_ndslice_iterator.html#FieldIteratorNdslice got [1] lazy multidimensional concatenation and padding utilities:Nice. Is this dependent on choosing either RC- or GC-based allocation?
Mar 09 2017
On Thursday, 9 March 2017 at 09:10:47 UTC, Nordlöw wrote:On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko wrote:... continue prev. reply: stack and pad* functions are 100% lazy and do not allocate anything. If you have allocated slice of the same shape you can do the following: preallocated_slice[] = stack(a, b, c); where preallocated_slice was created on top of RC-array using `slicedField`.Ndslice got [1] lazy multidimensional concatenation and padding utilities:Nice. Is this dependent on choosing either RC- or GC-based allocation?
Mar 09 2017
On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko wrote:[1] http://docs.algorithm.dlang.io/latest/mir_ndslice_stack.htmlrenamed: http://docs.algorithm.dlang.io/latest/mir_ndslice_concatenation.html
Mar 09 2017
On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko wrote:Hello Ndslice got [1] lazy multidimensional concatenation and padding utilities: 1. stack 2. pad 2. padEdge 3. padSymmetric 4. padWrap `stack` can be used for ndslices instead of `chain`. --- import mir.ndslice.allocation: slice; import mir.ndslice.stack: stack; auto d = stack(a, b, c).slice; --- ndslice allocation and assign utilities are optimised to work with stacks. For example the code above is significantly faster then --- import std.array: array; import std.range: chain; auto d = chain(a, b, c).array; --- because `slice` uses external iteration for `Stack` data structure. [1] http://docs.algorithm.dlang.io/latest/mir_ndslice_stack.html Best regards, Ilya`stack` was renamed to `concatenation` to much numpy and Matlab
Mar 09 2017
On Thursday, 9 March 2017 at 13:46:57 UTC, Ilya Yaroshenko wrote:`stack` was renamed to `concatenation` to much numpy and MatlabNumpy does have stack, but this is more similar to the concatenate function (I'd prefer this to concatenation). Matlab just calls it cat, which is easier to type, but less informative. https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.stack.html https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.concatenate.html#numpy.concatenate https://www.mathworks.com/help/matlab/ref/cat.html
Mar 09 2017