@@ -28,24 +28,37 @@ import mir.math.common: optmath;
2828@optmath:
2929
3030/+ +
31- Fuses ndrange `r` into GC-allocated (`fuse`) or RC-allocated (`rcfuse`) ndslice. Can be used to join rows or columns into a matrix.
31+ Fuses ndrange `r` into GC-allocated ($(LREF fuse)) or RC-allocated ($(LREF rcfuse)) ndslice.
32+ Can be used to join rows or columns into a matrix.
3233
3334Params:
3435 Dimensions = (optional) indexes of dimensions to be brought to the first position
3536Returns:
3637 ndslice
3738+/
38- // /
39- alias fuse (Dimensions... ) = fuseImpl! (false , Dimensions);
40- // /
41- alias rcfuse (Dimensions... ) = fuseImpl! (true , Dimensions);
39+ alias fuse (Dimensions... ) = fuseImpl! (false , void , Dimensions);
40+ // / ditto
41+ alias rcfuse (Dimensions... ) = fuseImpl! (true , void , Dimensions);
42+
43+ /+ +
44+ Fuses ndrange `r` into GC-allocated ($(LREF fuseAs)) or RC-allocated ($(LREF rcfuseAs)) ndslice.
45+ Can be used to join rows or columns into a matrix.
46+
47+ Params:
48+ T = output type of ndslice elements
49+ Dimensions = (optional) indexes of dimensions to be brought to the first position
50+ Returns:
51+ ndslice
52+ +/
53+ alias fuseAs (T, Dimensions... ) = fuseImpl! (false , T, Dimensions);
4254// / ditto
43- template fuseImpl (bool RC , Dimensions... )
55+ alias rcfuseAs (T, Dimensions... ) = fuseImpl! (true , T, Dimensions);
56+
57+ // /
58+ template fuseImpl (bool RC , T_ , Dimensions... )
4459{
4560 import mir.ndslice.internal: isSize_t, toSize_t;
46- static if (! allSatisfy! (isSize_t, Dimensions))
47- alias fuseImpl = .fuseImpl! (RC , staticMap! (toSize_t, Dimensions));
48- else
61+ static if (allSatisfy! (isSize_t, Dimensions))
4962 /+ +
5063 Params:
5164 r = parallelotope (ndrange) with length/shape and input range primitives.
@@ -57,7 +70,10 @@ template fuseImpl(bool RC, Dimensions...)
5770 import mir.algorithm.iteration: each;
5871 import mir.ndslice.allocation;
5972 auto shape = fuseShape(r);
60- alias T = FuseElementType! NDRange;
73+ static if (is (T_ == void ))
74+ alias T = FuseElementType! NDRange;
75+ else
76+ alias T = T_ ;
6177 alias UT = Unqual! T;
6278 static if (RC )
6379 {
@@ -137,6 +153,8 @@ template fuseImpl(bool RC, Dimensions...)
137153 return * (() @trusted => cast (R* )&ret)();
138154 }
139155 }
156+ else
157+ alias fuseImpl = .fuseImpl! (RC , T_ , staticMap! (toSize_t, Dimensions));
140158}
141159
142160// /
0 commit comments