@@ -28,24 +28,37 @@ import mir.math.common: optmath;
28
28
@optmath:
29
29
30
30
/+ +
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.
32
33
33
34
Params:
34
35
Dimensions = (optional) indexes of dimensions to be brought to the first position
35
36
Returns:
36
37
ndslice
37
38
+/
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);
42
54
// / 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... )
44
59
{
45
60
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))
49
62
/+ +
50
63
Params:
51
64
r = parallelotope (ndrange) with length/shape and input range primitives.
@@ -57,7 +70,10 @@ template fuseImpl(bool RC, Dimensions...)
57
70
import mir.algorithm.iteration: each;
58
71
import mir.ndslice.allocation;
59
72
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_ ;
61
77
alias UT = Unqual! T;
62
78
static if (RC )
63
79
{
@@ -137,6 +153,8 @@ template fuseImpl(bool RC, Dimensions...)
137
153
return * (() @trusted => cast (R* )&ret)();
138
154
}
139
155
}
156
+ else
157
+ alias fuseImpl = .fuseImpl! (RC , T_ , staticMap! (toSize_t, Dimensions));
140
158
}
141
159
142
160
// /
0 commit comments