@@ -23,10 +23,6 @@ import mir.qualifier;
23
23
import std.meta ;
24
24
import std.traits ;
25
25
26
- import mir.math.common: optmath;
27
-
28
- @optmath:
29
-
30
26
/+ +
31
27
Fuses ndrange `r` into GC-allocated ($(LREF fuse)) or RC-allocated ($(LREF rcfuse)) ndslice.
32
28
Can be used to join rows or columns into a matrix.
@@ -41,7 +37,7 @@ alias fuse(Dimensions...) = fuseImpl!(false, void, Dimensions);
41
37
alias rcfuse (Dimensions... ) = fuseImpl! (true , void , Dimensions);
42
38
43
39
// /
44
- @safe pure nothrow version(mir_test) unittest
40
+ @safe pure version(mir_test) unittest
45
41
{
46
42
import mir.ndslice.fuse;
47
43
import mir.ndslice.slice : Contiguous, Slice;
@@ -70,7 +66,7 @@ alias rcfuse(Dimensions...) = fuseImpl!(true, void, Dimensions);
70
66
}
71
67
72
68
// / Transposed
73
- @safe pure nothrow version(mir_test) unittest
69
+ @safe pure version(mir_test) unittest
74
70
{
75
71
import mir.ndslice.fuse;
76
72
import mir.ndslice.topology: iota;
@@ -99,7 +95,7 @@ alias rcfuse(Dimensions...) = fuseImpl!(true, void, Dimensions);
99
95
100
96
101
97
// / 3D
102
- @safe pure nothrow version(mir_test) unittest
98
+ @safe pure version(mir_test) unittest
103
99
{
104
100
import mir.ndslice.fuse;
105
101
import mir.ndslice.topology: iota;
@@ -120,7 +116,7 @@ alias rcfuse(Dimensions...) = fuseImpl!(true, void, Dimensions);
120
116
}
121
117
122
118
// / Work with RC Arrays of RC Arrays
123
- @safe pure nothrow version(mir_test) unittest
119
+ @safe pure version(mir_test) unittest
124
120
{
125
121
import mir.ndslice.fuse;
126
122
import mir.ndslice.slice;
@@ -148,7 +144,7 @@ alias fuseAs(T, Dimensions...) = fuseImpl!(false, T, Dimensions);
148
144
alias rcfuseAs (T, Dimensions... ) = fuseImpl! (true , T, Dimensions);
149
145
150
146
// /
151
- @safe pure nothrow version(mir_test) unittest
147
+ @safe pure version(mir_test) unittest
152
148
{
153
149
import mir.ndslice.fuse;
154
150
import mir.ndslice.slice : Contiguous, Slice;
@@ -185,7 +181,7 @@ template fuseImpl(bool RC, T_, Dimensions...)
185
181
Params:
186
182
r = parallelotope (ndrange) with length/shape and input range primitives.
187
183
+/
188
- @optmath auto fuseImpl(NDRange)(NDRange r)
184
+ auto fuseImpl (NDRange)(NDRange r)
189
185
if (hasShape! NDRange)
190
186
{
191
187
import mir.conv: emplaceRef;
@@ -290,6 +286,11 @@ private template fuseDimensionCount(R)
290
286
enum size_t fuseDimensionCount = 0 ;
291
287
}
292
288
289
+ private static immutable shapeExceptionMsg = " fuseShape Exception: elements have different shapes/lengths" ;
290
+
291
+ version (D_Exceptions)
292
+ static immutable shapeException = new Exception (shapeExceptionMsg);
293
+
293
294
/+
294
295
TODO docs
295
296
+/
@@ -298,7 +299,9 @@ size_t[fuseDimensionCount!Range] fuseShape(Range)(Range r)
298
299
{
299
300
// auto outerShape = r.shape;
300
301
enum N = r.shape.length;
301
- static if (N == typeof (return ).length)
302
+ enum RN = typeof (return ).length;
303
+ enum M = RN - N;
304
+ static if (M == 0 )
302
305
{
303
306
return r.shape;
304
307
}
@@ -310,6 +313,14 @@ size_t[fuseDimensionCount!Range] fuseShape(Range)(Range r)
310
313
if (! ret[0 .. N].anyEmptyShape)
311
314
{
312
315
ret[N .. $] = fuseShape(mixin (" r" ~ " .front" .repeat(N).fuseCells.field));
316
+ import mir.algorithm.iteration: all;
317
+ if (! all! ((a) => cast (size_t [M]) ret[N .. $] == .fuseShape(a))(r))
318
+ {
319
+ version (D_Exceptions)
320
+ throw shapeException;
321
+ else
322
+ assert (0 , shapeExceptionMsg);
323
+ }
313
324
}
314
325
return ret;
315
326
}
@@ -358,7 +369,7 @@ auto fuseCells(S)(S cells)
358
369
}
359
370
360
371
// / 1D
361
- @safe pure nothrow version(mir_test) unittest
372
+ @safe pure version(mir_test) unittest
362
373
{
363
374
import mir.ndslice.topology: iota;
364
375
enum ar = [[0 , 1 ], [], [2 , 3 , 4 , 5 ], [6 ], [7 , 8 , 9 ]];
@@ -367,7 +378,7 @@ auto fuseCells(S)(S cells)
367
378
}
368
379
369
380
// / 2D
370
- @safe pure nothrow version(mir_test) unittest
381
+ @safe pure version(mir_test) unittest
371
382
{
372
383
import mir.ndslice.topology: iota;
373
384
import mir.ndslice.chunks;
0 commit comments