The OpenD Programming Language

rcfuseAs

Fuses ndrange r into GC-allocated (fuseAs) or RC-allocated (rcfuseAs) ndslice. Can be used to join rows or columns into a matrix.

import mir.ndslice.fuse;
alias rcfuseAs(T, Dimensions...) = fuseImpl!(true, T, Dimensions)

Parameters

T

output type of ndslice elements

Dimensions

(optional) indices of dimensions to be brought to the first position

Return Value

ndslice

Examples

import mir.ndslice.fuse;
import mir.ndslice.slice : Contiguous, Slice;
import mir.ndslice.topology: iota;
import mir.rc.array: RCI;

enum ror = [
        [0, 1, 2, 3],
        [4, 5, 6, 7],
        [8, 9,10,11]];

//  0  1  2  3
//  4  5  6  7
//  8  9 10 11
auto matrix = ror.fuseAs!double;

auto rcmatrix = ror.rcfuseAs!double; // nogc version

assert(matrix == [3, 4].iota);
assert(rcmatrix == [3, 4].iota);
static assert(ror.fuseAs!double == [3, 4].iota); // CTFE-able

// matrix is contiguos
static assert(is(typeof(matrix) == Slice!(double*, 2)));
static assert(is(typeof(rcmatrix) == Slice!(RCI!double, 2)));

Meta