Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: d
dist: trusty
sudo: false
sudo: required
packages:
- pkg-config
d:
Expand All @@ -15,28 +14,29 @@ branches:
env:
- ARCH="x86_64"
matrix:
# include:
# - {os: linux, d: ldc-beta, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
# - {os: linux, d: ldc, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
# - {os: linux, d: dmd-beta, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
# - {os: linux, d: dmd, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
include:
- {os: linux, d: ldc-beta, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
- {os: linux, d: ldc, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
- {os: linux, d: dmd-beta, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
- {os: linux, d: dmd, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
allow_failures:
- {d: dmd-nightly}
- {d: ldc-beta}
- {d: gdc}
install:
- pyenv global system 3.6
- pip3 install 'meson>=0.45'
- mkdir .ntmp
- curl -L https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -o .ntmp/ninja-linux.zip
- unzip .ntmp/ninja-linux.zip -d .ntmp
before_script:
- export PATH=$PATH:$PWD/.ntmp
- curl -L "https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip" -o ninja-linux.zip
- sudo unzip ninja-linux.zip -d /usr/local/bin
- sudo chmod 755 /usr/local/bin/ninja
- sudo add-apt-repository -y ppa:deadsnakes/ppa
- sudo apt-get -y update
- sudo apt-get -y install python3.6
- curl https://bootstrap.pypa.io/get-pip.py | sudo python3.6
- sudo pip3 install meson
script:
# - travis_wait 100 dub test --arch "$ARCH"
- travis_wait 100 dub test --arch "$ARCH" --build=unittest-cov
- ./test_examples.sh
- meson build && cd build && ninja -j4 && ninja -j4 test -v && cd .. # TODO: 32bit meson test
# - travis_wait 100 dub test --arch "$ARCH" --build=unittest-cov
# - travis_wait 100 dub test --arch "$ARCH" --build=unittest-release

after_success:
Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MIR_PACKAGES = mir mir/ndslice mir/ndslice/connect mir/internal mir/math mir/mat

PACKAGE_mir = bitmanip bitop conv functional primitives range series utility qualifier range

PACKAGE_mir_array = primitives
PACKAGE_mir_array = allocation primitives
PACKAGE_mir_combinatorics = package
PACKAGE_mir_algorithm = iteration setops
PACKAGE_mir_container = binaryheap
Expand Down
15 changes: 13 additions & 2 deletions source/mir/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ $(T2 cmp, Compares two slices.)
$(T2 count, Counts elements in a slices according to a predicate.)
$(T2 each, Iterates all elements.)
$(T2 eachLower, Iterates lower triangle of matrix.)
$(T2 eachUpper, Iterates upper triangle of matrix.)
$(T2 eachUploPair, Iterates upper and lower pairs of elements in square matrix.)
$(T2 eachUpper, Iterates upper triangle of matrix.)
$(T2 equal, Compares two slices for equality.)
$(T2 find, Finds backward index.)
$(T2 findIndex, Finds index.)
Expand All @@ -24,6 +24,7 @@ $(T2 minIndex, Finds index of the minimum.)
$(T2 minmaxIndex, Finds indexes of the minimum and the maximum.)
$(T2 minmaxPos, Finds backward indexes of the minimum and the maximum.)
$(T2 minPos, Finds backward index of the minimum.)
$(T2 nBitsToCount, Сount bits until set bit count is reached.)
$(T2 reduce, Accumulates all elements.)
$(T2 uniq, Iterates over the unique elements in a range, which is assumed sorted.)
)
Expand Down Expand Up @@ -498,6 +499,8 @@ const:
}

/++
Сount bits until set bit count is reached. Works with ndslices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
Returns: bit count if set bit count is reached or `-1` otherwise.
+/
sizediff_t nBitsToCount(Field, I)(Slice!(FieldIterator!(BitField!(Field, I))) bitSlice, size_t count)
{
Expand Down Expand Up @@ -1686,6 +1689,8 @@ Params:
See_also:
$(LREF find),
$(LREF any).
Optimization:
`findIndex!"a"` has accelerated specialization for slices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
+/
template findIndex(alias pred)
{
Expand Down Expand Up @@ -1774,6 +1779,9 @@ See_also:
$(LREF findIndex),
$(LREF any),
$(REF Slice.backward, mir,ndslice,slice).

Optimization:
`find!"a"` has accelerated specialization for slices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
+/
template find(alias pred)
{
Expand Down Expand Up @@ -1946,6 +1954,8 @@ Like $(LREF find), but only returns whether or not the search was successful.

Params:
pred = The predicate.
Optimization:
`any!"a"` has accelerated specialization for slices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
+/
template any(alias pred = "a")
{
Expand Down Expand Up @@ -2103,7 +2113,8 @@ Checks if all of the elements verify `pred`.

Params:
pred = The predicate.

Optimization:
`all!"a"` has accelerated specialization for slices created with $(REF bitwise, mir,ndslice,topology), $(REF bitSlice, mir,ndslice,allocation).
+/
template all(alias pred = "a")
{
Expand Down
2 changes: 1 addition & 1 deletion source/mir/ndslice/field.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ An ndslice can be created on top of a field using $(SUBREF slice, slicedField).

$(BOOKTABLE $(H2 Fields),
$(TR $(TH Field Name) $(TH Used By))
$(T2 BitpackField, $(SUBREF topology, bitpack))
$(T2 BitField, $(SUBREF topology, bitwise))
$(T2 BitpackField, $(SUBREF topology, bitpack))
$(T2 CycleField, $(SUBREF topology, cycle) (2 kinds))
$(T2 LinspaceField, $(SUBREF topology, linspace))
$(T2 MagicField, $(SUBREF topology, magic))
Expand Down
14 changes: 9 additions & 5 deletions source/mir/ndslice/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ $(TR $(TDNW $(SUBMODULE topology) $(BR)
$(SUBREF topology, assumeContiguous)
$(SUBREF topology, bitpack)
$(SUBREF topology, bitwise)
$(SUBREF topology, bytegroup)
$(SUBREF topology, blocks)
$(SUBREF topology, byDim)
$(SUBREF topology, canonical)
$(SUBREF topology, cartesian)
$(SUBREF topology, bytegroup)
$(SUBREF topology, cached)
$(SUBREF topology, cachedGC)
$(SUBREF topology, canonical)
$(SUBREF topology, cartesian)
$(SUBREF topology, cycle)
$(SUBREF topology, diagonal)
$(SUBREF topology, diff)
$(SUBREF topology, evertPack)
Expand All @@ -143,11 +144,12 @@ $(TR $(TDNW $(SUBMODULE topology) $(BR)
$(SUBREF topology, ipack)
$(SUBREF topology, kronecker)
$(SUBREF topology, linspace)
$(SUBREF topology, magic)
$(SUBREF topology, map)
$(SUBREF topology, mapSubSlices)
$(SUBREF topology, magic)
$(SUBREF topology, member)
$(SUBREF topology, ndiota)
$(SUBREF topology, orthogonalReduceField)
$(SUBREF topology, pack)
$(SUBREF topology, pairwise)
$(SUBREF topology, pairwiseMapSubSlices)
Expand Down Expand Up @@ -237,12 +239,14 @@ $(TR $(TDNW $(SUBMODULE iterator)
$(TR $(TDNW $(SUBMODULE field)
$(BR) $(SMALL Declarations))
$(TD
$(SUBREF field, BitpackField)
$(SUBREF field, BitField)
$(SUBREF field, BitpackField)
$(SUBREF field, CycleField)
$(SUBREF field, LinspaceField)
$(SUBREF field, MagicField)
$(SUBREF field, MapField)
$(SUBREF field, ndIotaField)
$(SUBREF field, OrthogonalReduceField)
$(SUBREF field, RepeatField)
)
)
Expand Down
9 changes: 6 additions & 3 deletions source/mir/ndslice/topology.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ $(T2 assumeContiguous, Converts a slice to contiguous $(SUBREF slice, SliceKind)
$(BOOKTABLE $(H2 Sequence Selectors),
$(TR $(TH Function Name) $(TH Description))

$(T2 repeat, Slice with identical values)
$(T2 cycle, Cycle repeates 1-dimensional field/range/array/slice in a fixed length 1-dimensional slice)
$(T2 iota, Contiguous Slice with initial flattened (contiguous) index.)
$(T2 ndiota, Contiguous Slice with initial multidimensional index.)
$(T2 linspace, Evenly spaced numbers over a specified interval.)
$(T2 magic, Magic square.)
$(T2 ndiota, Contiguous Slice with initial multidimensional index.)
$(T2 repeat, Slice with identical values)
)

.

$(BOOKTABLE $(H2 Products),
$(TR $(TH Function Name) $(TH Description))

Expand Down Expand Up @@ -1894,7 +1897,7 @@ version(mir_test) unittest
}

/++
Cycle creates 1-dimensional slice over the range.
Cycle repeates 1-dimensional field/range/array/slice in a fixed length 1-dimensional slice.
+/
auto cycle(Field)(Field field, size_t loopLength, size_t length)
if (!isSlice!Field && !is(Field : T[], T))
Expand Down
6 changes: 2 additions & 4 deletions test_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

set -euo pipefail

if [ ! -e test_extractor.d ] ; then
wget https://raw.githubusercontent.com/dlang/tools/6b7ef76d679563e6fccef2a6b437008d96459e95/tests_extractor.d
fi
dub fetch dtools

# extract examples
dub ./tests_extractor.d -i source -o out
dub run dtools:tests_extractor -- -i source -o out

# compile the examples
for file in $(find out -name "*.d") ; do
Expand Down