Skip to content

Commit 75f78a2

Browse files
committed
move unittest
1 parent ce17951 commit 75f78a2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

source/mir/ndslice/filling.d

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ do {
4141
}
4242
}
4343
}
44+
45+
///
46+
@safe pure nothrow version(mir_test) unittest
47+
{
48+
import mir.ndslice.filling: fillVandermonde;
49+
import mir.ndslice.allocation: uninitSlice;
50+
auto x = [1.0, 2, 3, 4, 5].sliced;
51+
auto v = uninitSlice!double(x.length, x.length);
52+
v.fillVandermonde(x);
53+
assert(v ==
54+
[[ 1.0, 1, 1, 1, 1],
55+
[ 1.0, 2, 4, 8, 16],
56+
[ 1.0, 3, 9, 27, 81],
57+
[ 1.0, 4, 16, 64, 256],
58+
[ 1.0, 5, 25, 125, 625]]);
59+
}

source/mir/ndslice/slice.d

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,22 +268,6 @@ auto sliced(size_t N, Iterator)(Iterator iterator, size_t[N] lengths...)
268268
}
269269
}
270270

271-
/// $(LINK2 https://en.wikipedia.org/wiki/Vandermonde_matrix, Vandermonde matrix)
272-
@safe pure nothrow version(mir_test) unittest
273-
{
274-
import mir.ndslice.filling: fillVandermonde;
275-
import mir.ndslice.allocation: uninitSlice;
276-
auto x = [1.0, 2, 3, 4, 5].sliced;
277-
auto v = uninitSlice!double(x.length, x.length);
278-
v.fillVandermonde(x);
279-
assert(v ==
280-
[[ 1.0, 1, 1, 1, 1],
281-
[ 1.0, 2, 4, 8, 16],
282-
[ 1.0, 3, 9, 27, 81],
283-
[ 1.0, 4, 16, 64, 256],
284-
[ 1.0, 5, 25, 125, 625]]);
285-
}
286-
287271
/// Random access range primitives for slices over user defined types
288272
@safe pure nothrow @nogc version(mir_test) unittest
289273
{
@@ -298,6 +282,7 @@ auto sliced(size_t N, Iterator)(Iterator iterator, size_t[N] lengths...)
298282
auto lightConst()() const @property { return MyIota(); }
299283
auto lightImmutable()() immutable @property { return MyIota(); }
300284
}
285+
301286
import mir.ndslice.iterator: FieldIterator;
302287
alias Iterator = FieldIterator!MyIota;
303288
alias S = Slice!(Iterator, 2);

0 commit comments

Comments
 (0)