Skip to content

Commit 6fe14f2

Browse files
authored
Merge pull request #4829 from 9il/ndslicechangelog
Ndslice changlog, tables update, note about Mir
2 parents e357050 + 7120a2f commit 6fe14f2

File tree

3 files changed

+113
-24
lines changed

3 files changed

+113
-24
lines changed

changelog.dd

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ $(BUGSTITLE Library Changes,
2020
$(LI $(RELATIVE_LINK2 optimization, `findLocalMin` was added to `std.numeric`.))
2121
$(LI $(RELATIVE_LINK2 slice_ptr, `ptr` property and public constructor were
2222
added to `std.experimental.ndslice.slice.Slice`.))
23+
$(LI $(RELATIVE_LINK2 slice_toHash, `toHash` method was
24+
added to `std.experimental.ndslice.slice.Slice`.))
2325
$(LI $(RELATIVE_LINK2 slice_alloc, `slice`, `shape`, `ndarray`, and other
2426
utilities were added to `std.experimental.ndslice.slice`.))
27+
$(LI $(RELATIVE_LINK2 slice_as, `as` lazy tensor was added to
28+
`std.experimental.ndslice.slice`.))
2529
$(LI $(RELATIVE_LINK2 slice_iota, `iotaSlice` lazy tensor was added to
2630
`std.experimental.ndslice.selection`.))
31+
$(LI $(RELATIVE_LINK2 slice_index, `indexSlice` lazy tensor was added to
32+
`std.experimental.ndslice.selection`.))
33+
$(LI $(RELATIVE_LINK2 slice_repeat, `repeatSlice` lazy tensor was added to
34+
`std.experimental.ndslice.selection`.))
35+
$(LI $(RELATIVE_LINK2 slice_map, `mapSlice` lazy tensor was added to
36+
`std.experimental.ndslice.selection`.))
2737
$(LI $(RELATIVE_LINK2 slice_mio, partial support for Math Index Order
2838
was added to `std.experimental.ndslice.slice.Slice`.))
2939
$(LI $(RELATIVE_LINK2 mutation, `std.algorithm.mutation.swapAt` was
@@ -183,16 +193,30 @@ $(LI $(LNAME2 slice_ptr, `ptr` property and public constructor were added to
183193
)
184194
)
185195

196+
$(LI $(LNAME2 slice_toHash, $(P $(REF .Slice.toHash, std,experimental,ndslice,slice) method was added.)
197+
---
198+
import std.experimental.ndslice;
199+
200+
// hash is the same for allocated data and generated data
201+
auto a = iotaSlice(3, 7);
202+
auto b = iotaSlice(3, 7).slice;
203+
204+
assert(a.toHash == b.toHash);
205+
---
206+
)
207+
186208
$(LI $(LNAME2 slice_alloc, `slice`, `shape`, `ndarray`, and other utilities
187209
were added to `std.experimental.ndslice.slice`.)
188210
$(P These utility functions have been added to
189211
$(MREF std,experimental,ndslice):)
190212
$(UL
213+
$(LI $(REF makeNdarray, std,experimental,ndslice,slice),)
214+
$(LI $(REF makeSlice, std,experimental,ndslice,slice),)
215+
$(LI $(REF makeUninitializedSlice, std,experimental,ndslice,slice),)
216+
$(LI $(REF ndarray, std,experimental,ndslice,slice),)
191217
$(LI $(REF shape, std,experimental,ndslice,slice),)
192218
$(LI $(REF slice, std,experimental,ndslice,slice),)
193-
$(LI $(REF makeSlice, std,experimental,ndslice,slice),)
194-
$(LI $(REF ndarray, std,experimental,ndslice,slice), and)
195-
$(LI $(REF makeNdarray, std,experimental,ndslice,slice).)
219+
$(LI $(REF uninitializedSlice, std,experimental,ndslice,slice).)
196220
)
197221
$(P Example: Transposing common 2D array using `ndslice`)
198222
-----
@@ -209,6 +233,24 @@ assert(ar == [[0, 3], [1, 4], [2, 5]]);
209233
-----
210234
)
211235

236+
$(LI $(LNAME2 slice_as, $(P $(REF as, std,experimental,ndslice,slice)
237+
lazy tensor was added.)
238+
---
239+
import std.experimental.ndslice;
240+
241+
auto matrix = slice!double([2, 2], 0);
242+
auto stringMatrixView = matrix.as!string;
243+
assert(stringMatrixView ==
244+
[["0", "0"],
245+
["0", "0"]]);
246+
247+
matrix.diagonal[] = 1;
248+
assert(stringMatrixView ==
249+
[["1", "0"],
250+
["0", "1"]]);
251+
---
252+
)
253+
212254
$(LI $(LNAME2 slice_iota, `iotaSlice` lazy tensor was added to `std.experimental.ndslice.selection`.)
213255
$(P $(REF iotaSlice, std,experimental,ndslice,selection) is the fastest possible `Slice`.)
214256
---
@@ -222,6 +264,46 @@ assert(sl.transposed == [[10, 13],
222264
---
223265
)
224266

267+
$(LI $(LNAME2 slice_index, $(P $(REF indexSlice, std,experimental,ndslice,selection)
268+
lazy tensor was added.)
269+
---
270+
import std.experimental.ndslice;
271+
272+
auto slice = indexSlice(2, 3);
273+
274+
assert(slice == [[[0, 0], [0, 1], [0, 2]],
275+
[[1, 0], [1, 1], [1, 2]]]);
276+
---
277+
)
278+
279+
$(LI $(LNAME2 slice_repeat, $(P $(REF repeatSlice, std,experimental,ndslice,selection)
280+
lazy tensor was added.)
281+
---
282+
import std.experimental.ndslice;
283+
284+
auto sl = iotaSlice(3).repeatSlice(4);
285+
assert(sl == [[0, 1, 2],
286+
[0, 1, 2],
287+
[0, 1, 2],
288+
[0, 1, 2]]);
289+
290+
auto m = 4.repeatSlice(2, 3);
291+
assert(m == [[4, 4, 4],
292+
[4, 4, 4]]);
293+
---
294+
)
295+
296+
$(LI $(LNAME2 slice_map, $(P $(REF mapSlice, std,experimental,ndslice,selection)
297+
lazy tensor was added.)
298+
---
299+
import std.experimental.ndslice;
300+
301+
auto s = iotaSlice(2, 3).mapSlice!(a => a * a);
302+
assert(s == [[ 0, 1, 4],
303+
[ 9, 16, 25]]);
304+
---
305+
)
306+
225307
$(LI $(LNAME2 slice_mio, partial support for Math Index Order was added to `std.experimental.ndslice.slice.Slice`.)
226308
---
227309
import std.experimental.ndslice;

std/experimental/ndslice/package.d

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ processing algorithms, but should also be general enough for use anywhere with
5050
homogeneously-typed multidimensional data.
5151
In addition, it includes various functions for iteration, accessing, and manipulation.
5252
53+
Advanced and fast iteration algorithms, matrix multiplication, and BLAS-like functions
54+
can be found in the $(LINK2 http://mir.dlang.io, Mir
55+
LLVM-Accelerated Generic Numerical Library for Science and Machine Learning).
56+
5357
Quick_Start:
5458
$(SUBREF slice, sliced) is a function designed to create
5559
a multidimensional view over a range.
@@ -80,30 +84,32 @@ $(TR $(TH Submodule) $(TH Declarations))
8084
$(TR $(TDNW $(SUBMODULE slice)
8185
$(BR) $(SMALL $(SUBREF slice, Slice), its properties, operator overloading))
8286
$(TD
83-
$(SUBREF slice, sliced)
84-
$(SUBREF slice, Slice)
85-
$(SUBREF slice, slice)
87+
$(SUBREF slice, as)
88+
$(SUBREF slice, assumeSameStructure)
89+
$(SUBREF slice, DeepElementType)
90+
$(SUBREF slice, makeNdarray)
8691
$(SUBREF slice, makeSlice)
92+
$(SUBREF slice, makeUninitializedSlice)
8793
$(SUBREF slice, ndarray)
88-
$(SUBREF slice, makeNdarray)
94+
$(SUBREF slice, ReplaceArrayWithPointer)
8995
$(SUBREF slice, shape)
9096
$(SUBREF slice, Slice)
91-
$(SUBREF slice, assumeSameStructure)
92-
$(SUBREF slice, ReplaceArrayWithPointer)
93-
$(SUBREF slice, DeepElementType)
97+
$(SUBREF slice, slice)
98+
$(SUBREF slice, sliced)
9499
$(SUBREF slice, SliceException)
100+
$(SUBREF slice, uninitializedSlice)
95101
)
96102
)
97103
$(TR $(TDNW $(SUBMODULE iteration)
98104
$(BR) $(SMALL Basic iteration operators))
99105
$(TD
100-
$(SUBREF iteration, transposed)
101-
$(SUBREF iteration, strided)
106+
$(SUBREF iteration, allReversed)
107+
$(SUBREF iteration, everted)
102108
$(SUBREF iteration, reversed)
103109
$(SUBREF iteration, rotated)
104-
$(SUBREF iteration, everted)
110+
$(SUBREF iteration, strided)
105111
$(SUBREF iteration, swapped)
106-
$(SUBREF iteration, allReversed)
112+
$(SUBREF iteration, transposed)
107113
$(SUBREF iteration, dropToHypercube) and other `drop` primitives
108114
)
109115
)
@@ -112,19 +118,19 @@ $(TR $(TDNW $(SUBMODULE selection)
112118
$(BR) $(SMALL Subspace manipulations $(BR) Operators for loop free programming))
113119
$(TD
114120
$(SUBREF selection, blocks)
115-
$(SUBREF selection, windows)
116-
$(SUBREF selection, diagonal)
117-
$(SUBREF selection, reshape)
118121
$(SUBREF selection, byElement)
119122
$(SUBREF selection, byElementInStandardSimplex)
120-
$(SUBREF selection, mapSlice)
123+
$(SUBREF selection, diagonal)
124+
$(SUBREF selection, evertPack)
121125
$(SUBREF selection, indexSlice)
122126
$(SUBREF selection, iotaSlice)
123-
$(SUBREF selection, repeatSlice)
127+
$(SUBREF selection, mapSlice)
124128
$(SUBREF selection, pack)
125-
$(SUBREF selection, evertPack)
126-
$(SUBREF selection, unpack)
129+
$(SUBREF selection, repeatSlice)
130+
$(SUBREF selection, reshape)
127131
$(SUBREF selection, ReshapeException)
132+
$(SUBREF selection, unpack)
133+
$(SUBREF selection, windows)
128134
)
129135
)
130136
))

std/experimental/ndslice/selection.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ $(T2 evertPack, reverses dimension packs)
2727
$(BOOKTABLE $(H2 Selectors),
2828
2929
$(TR $(TH Function Name) $(TH Description))
30+
$(T2 blocks, n-dimensional slice composed of n-dimensional non-overlapping blocks.
31+
If the slice has two dimensions, it is a block matrix.)
3032
$(T2 byElement, flat, random access range of all elements with `index` property)
3133
$(T2 byElementInStandardSimplex, an input range of all elements in standard simplex of hypercube with `index` property.
3234
If the slice has two dimensions, it is a range of all elements of upper left triangular matrix.)
35+
$(T2 diagonal, 1-dimensional slice composed of diagonal elements)
3336
$(T2 indexSlice, lazy slice with initial multidimensional index)
3437
$(T2 iotaSlice, lazy slice with initial flattened (continuous) index)
38+
$(T2 mapSlice, lazy multidimensional functional map)
3539
$(T2 repeatSlice, slice with identical values)
3640
$(T2 reshape, new slice with changed dimensions for the same data)
37-
$(T2 diagonal, 1-dimensional slice composed of diagonal elements)
38-
$(T2 blocks, n-dimensional slice composed of n-dimensional non-overlapping blocks.
39-
If the slice has two dimensions, it is a block matrix.)
4041
$(T2 windows, n-dimensional slice of n-dimensional overlapping windows.
4142
If the slice has two dimensions, it is a sliding window.)
4243
)

0 commit comments

Comments
 (0)