'
- + '
'
- + '
'
- + ''
- + '
'
- + '
'
- + '
Application outputRunning...
'
- + '
'
- );
- });
-
- $('textarea[class=d_code]').each(function(index) {
- var parent = $(this).parent();
- var btnParent = parent.parent().children(".d_example_buttons");
- var outputDiv = parent.parent().children(".d_code_output");
- var editor = setupTextarea(this, {
- parent: btnParent,
- outputDiv: outputDiv,
- stdin: false,
- args: false,
- transformOutput: wrapIntoMain,
- defaultOutput: "All tests passed",
- keepCode: true,
- outputHeight: "auto",
- backend: "tour"
- });
- });
-});
diff --git a/dub.sdl b/dub.sdl
index 36bc1e81..e8085ba7 100644
--- a/dub.sdl
+++ b/dub.sdl
@@ -1,28 +1,85 @@
name "mir-algorithm"
-description "Mir Algorithm Collection"
+description "Dlang Core Library"
-authors "Ilya Yaroshenko" "Sebastian Wilzbach" "Andrei Alexandrescu and Phobos Team (original Phobos code)" "John Michael Hall"
-copyright "Copyright © 2016 - 2018, Ilya Yaroshenko; see also information per file."
-license "BSL-1.0"
+authors "Ilia Ki" "John Michael Hall" "Shigeki Karita" "Sebastian Wilzbach" "And others" "mir.date and a bit of other code is based on Phobos"
+copyright "2020 Ilia Ki, Kaleidic Associates Advisory Limited, Symmetry Investments"
+license "Apache-2.0"
-dependency "mir-core" version=">=0.3.5 <0.4.0"
+dependency "mir-core" version=">=1.6.0"
+
+// dflags "-version=MirNoSIMD"
+// dflags "-mtriple=aarch64-linux-gnu"
+
+// versions "TeslAlgoM"
buildType "unittest" {
- buildOptions "unittests" "debugMode" "debugInfo"
+ buildOptions "unittests" "debugMode" "debugInfo"
+ versions "mir_bignum_test" "mir_bignum_test_llv"
+ versions "mir_ndslice_test"
+ versions "mir_test"
+ dflags "-lowmem"
+}
+
+buildType "unittest-verbose" {
+ buildOptions "unittests" "debugMode" "debugInfo"
+ versions "mir_bignum_test" "mir_bignum_test_llv"
+ // versions "mir_ndslice_test"
versions "mir_test"
+ dflags "-lowmem" "-checkaction=context" "-allinst"
+}
+buildType "unittest-dip1008" {
+ buildOptions "unittests" "debugMode" "debugInfo"
+ versions "mir_bignum_test" "mir_ndslice_test" "mir_test" "mir_bignum_test_llv"
+ dflags "-lowmem" "-preview=dip1008"
+}
+buildType "unittest-dip1000" {
+ buildOptions "unittests" "debugMode" "debugInfo"
+ versions "mir_bignum_test" "mir_ndslice_test" "mir_test"
+ dflags "-lowmem" "-preview=dip1000"
}
buildType "unittest-cov" {
- buildOptions "unittests" "coverage" "debugMode" "debugInfo"
- versions "mir_test"
+ buildOptions "unittests" "coverage" "debugMode" "debugInfo"
+ versions "mir_bignum_test" "mir_bignum_test_llv" "mir_ndslice_test" "mir_test"
+ dflags "-lowmem"
+}
+buildType "unittest-ci" {
+ buildOptions "unittests" "coverage" "debugMode" "debugInfo"
+ dflags "-lowmem"
}
buildType "unittest-release" {
- buildOptions "unittests" "releaseMode" "optimize" "inline" "noBoundsCheck"
- versions "mir_test"
+ buildOptions "unittests" "releaseMode" "optimize" "inline" "noBoundsCheck"
+ versions "mir_bignum_test" "mir_ndslice_test" "mir_test"
+ dflags "-lowmem"
}
configuration "default" {
}
+configuration "silly" {
+ dependency "silly" version="~>1.1.1"
+}
+
+configuration "dip1008" {
+ dflags "-preview=dip1008"
+}
+
configuration "dips" {
- dflags "-dip25" "-dip1000" "-dip1008"
+ dflags "-preview=dip1000" "-preview=dip1008"
+}
+
+configuration "ci-bignum-test" {
+ versions "mir_bignum_test" "mir_bignum_test_llv"
+ dflags "-lowmem" "-preview=dip1000"
+}
+
+configuration "ci-core-test" {
+ versions "mir_core_test"
+}
+
+configuration "ci-ndslice-test" {
+ versions "mir_ndslice_test"
+}
+
+configuration "ci-test" {
+ versions "mir_test"
}
diff --git a/images/symmetry.png b/images/symmetry.png
deleted file mode 100644
index 4dcca0f3..00000000
Binary files a/images/symmetry.png and /dev/null differ
diff --git a/include/mir/interpolate.h b/include/mir/interpolate.h
new file mode 100644
index 00000000..ddb39011
--- /dev/null
+++ b/include/mir/interpolate.h
@@ -0,0 +1,35 @@
+#pragma once
+
+namespace mir {
+ namespace interpolate
+ {
+ enum class SplineType
+ {
+ c2,
+ cardinal,
+ monotone,
+ doubleQuadratic,
+ akima,
+ makima
+ };
+
+ enum class SplineBoundaryType
+ {
+ periodic = -1,
+ notAKnot,
+ firstDerivative,
+ secondDerivative,
+ parabolic,
+ monotone,
+ akima,
+ makima
+ };
+
+ template
+ struct SplineBoundaryCondition
+ {
+ SplineBoundaryType type = SplineBoundaryType::notAKnot;
+ T value = 0;
+ };
+ }
+}
diff --git a/include/mir/ndslice.h b/include/mir/ndslice.h
index 62ec07f5..c5f23713 100644
--- a/include/mir/ndslice.h
+++ b/include/mir/ndslice.h
@@ -1,21 +1,21 @@
+#ifndef MIR_NDSLICE
+
+#define MIR_NDSLICE
+
/**
************ Mir-Algorithm ************
The module provides wrappers for $(SUBREF slice, Slice) that
can be used as arguments for C++ functions.
-License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
-Copyright: Copyright © 2017-, Ilya Yaroshenko
-Authors: Ilya Yaroshenko
+License: $(HTTP www.apache.org/licenses/LICENSE-2.0, Apache-2.0)
+Copyright: 2020 Ilia Ki, Kaleidic Associates Advisory Limited, Symmetry Investments
+Authors: Ilia Ki
*/
-
-#ifndef MIR_NDSLICE
-
-#define MIR_NDSLICE
-
#include
#include
#include
+#include
#if INTPTR_MAX == INT32_MAX
#define mir_size_t unsigned int
@@ -40,6 +40,21 @@ enum class mir_slice_kind : int
contiguous = 2
};
+template
+struct mir_rci;
+
+namespace mir {
+ template <
+ typename T
+ >
+ const T* light_const(const T* ptr) { return ptr; }
+
+ template <
+ typename T
+ >
+ mir_rci light_const(const mir_rci& s);
+}
+
template <
typename Iterator,
mir_size_t N = 1,
@@ -172,12 +187,12 @@ struct mir_slice
auto begin() const noexcept
{
- return _iterator;
+ return mir::light_const(_iterator);
}
auto cbegin() const noexcept
{
- return _iterator;
+ return begin();
}
Iterator end() noexcept
@@ -187,12 +202,12 @@ struct mir_slice
auto end() const noexcept
{
- return _iterator + _lengths[0] * _lengths[1];
+ return mir::light_const(_iterator) + _lengths[0] * _lengths[1];
}
auto cend() const noexcept
{
- return _iterator + _lengths[0] * _lengths[1];
+ return end();
}
};
@@ -205,6 +220,11 @@ struct mir_slice
static const mir_ptrdiff_t _strides[0];
Iterator _iterator = nullptr;
+ using iterator = Iterator;
+ using const_iterator = Iterator;
+ using reverse_iterator = std::reverse_iterator;
+ using const_reverse_iterator = std::reverse_iterator;
+
template
size_t size() const noexcept
{
@@ -232,6 +252,16 @@ struct mir_slice
return _iterator[index];
}
+ auto&& backward(mir_size_t index)
+ {
+ return at(size() - 1 - index);
+ }
+
+ auto&& backward(mir_size_t index) const
+ {
+ return at(size() - 1 - index);
+ }
+
auto&& operator[](mir_size_t index)
{
return at(index);
@@ -247,6 +277,11 @@ struct mir_slice
return _iterator;
}
+ auto begin() const noexcept
+ {
+ return mir::light_const(_iterator);
+ }
+
auto cbegin() const noexcept
{
return _iterator;
@@ -257,10 +292,22 @@ struct mir_slice
return _iterator + _lengths[0];
}
+ auto end() const noexcept
+ {
+ return mir::light_const(_iterator) + _lengths[0];
+ }
+
auto cend() const noexcept
{
- return _iterator + _lengths[0];
+ return end();
}
+
+ reverse_iterator rbegin() noexcept { return reverse_iterator(this->begin()); }
+ const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->begin()); }
+ const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->begin()); }
+ reverse_iterator rend() noexcept { return reverse_iterator(this->end()); }
+ const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->end()); }
+ const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->end()); }
};
template <
@@ -312,11 +359,6 @@ struct mir_slice
namespace mir
{
- template <
- typename T
- >
- const T* light_const(const T* ptr) { return ptr; }
-
template <
typename T,
mir_size_t N,
diff --git a/include/mir/rcarray.h b/include/mir/rcarray.h
index 69f8ed8f..78c5f5de 100644
--- a/include/mir/rcarray.h
+++ b/include/mir/rcarray.h
@@ -24,9 +24,7 @@ struct mir_rcarray
private:
T* _payload = nullptr;
- using U = typename std::remove_all_extents::type;
- static constexpr void (*destr)(U&) = std::is_destructible::value ? &mir::Destructor::destroy : nullptr;
- static constexpr mir::type_info_g typeInfoT = {destr, sizeof(T)};
+ using U = typename std::remove_const::type;
void _cpp_copy_constructor(const mir_rcarray& rhs) noexcept;
mir_rcarray& _cpp_assign(const mir_rcarray& rhs) noexcept;
@@ -38,7 +36,7 @@ struct mir_rcarray
{
if (length == 0)
return;
- auto context = mir_rc_create((const mir_type_info*)&typeInfoT, length, nullptr, false, deallocate);
+ auto context = mir_rc_create(mir::typeInfoT_(), length, nullptr, false, deallocate);
if (context == nullptr)
throw std::bad_alloc();
_payload = (T*)(context + 1);
@@ -159,6 +157,8 @@ struct mir_rcarray
size_t empty() const noexcept { return size() == 0; }
T& at(size_t index) { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[index]; }
const T& at(size_t index) const { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[index]; }
+ T& backward(size_t index) { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[size() - 1 - index]; }
+ const T& backward(size_t index) const { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[size() - 1 - index]; }
T& operator[](size_t index) { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[index]; }
const T& operator[](size_t index) const { if (index >= this->size()) throw std::out_of_range("mir_rcarray: out of range"); return _payload[index]; }
T* data() noexcept { return _payload; }
@@ -185,6 +185,12 @@ struct mir_rci
using Iterator = T*;
using Array = mir_rcarray;
+ using difference_type = ptrdiff_t;
+ using value_type = T;
+ using pointer = T*;
+ using reference = T&;
+ using iterator_category = std::random_access_iterator_tag;
+
Iterator _iterator = nullptr;
mir_rcarray _array;
@@ -235,13 +241,13 @@ struct mir_rci
return *this;
}
- mir_rci& operator+=(mir_ptrdiff_t shift)
+ mir_rci& operator+=(ptrdiff_t shift)
{
_iterator += shift;
return *this;
}
- mir_rci& operator-=(mir_ptrdiff_t shift)
+ mir_rci& operator-=(ptrdiff_t shift)
{
_iterator -= shift;
return *this;
@@ -261,6 +267,11 @@ struct mir_rci
return ret;
}
+ ptrdiff_t operator-(const mir_rci& shift) const
+ {
+ return _iterator - shift._iterator;
+ }
+
T& operator[](size_t index)
{
auto ptr = _iterator + index;
@@ -275,26 +286,16 @@ struct mir_rci
return _iterator[index];
}
- mir_rci operator+(ptrdiff_t index)
+ mir_rci operator+(ptrdiff_t index) const
{
return mir_rci(_iterator + index, _array);
}
- mir_rci operator-(ptrdiff_t index)
+ mir_rci operator-(ptrdiff_t index) const
{
return mir_rci(_iterator - index, _array);
}
- mir_rci operator+(ptrdiff_t index) const
- {
- return mir_rci(_iterator + index, _array);
- }
-
- mir_rci operator-(ptrdiff_t index) const
- {
- return mir_rci(_iterator - index, _array);
- }
-
bool operator==(const mir_rci& rhs) const { return _iterator == rhs._iterator; }
bool operator!=(const mir_rci& rhs) const { return _iterator != rhs._iterator; }
bool operator<(const mir_rci& rhs) const { return _iterator < rhs._iterator; }
diff --git a/include/mir/rcptr.h b/include/mir/rcptr.h
index e5a18e0f..9959eceb 100644
--- a/include/mir/rcptr.h
+++ b/include/mir/rcptr.h
@@ -33,7 +33,7 @@ extern "C"
const mir_type_info* typeInfo,
size_t length,
const void* payload = nullptr,
- bool initialise = true,
+ bool initialize = true,
bool deallocate = true
);
}
@@ -72,6 +72,13 @@ namespace mir
// template::value>::type>
+ template
+ static const mir_type_info* typeInfoT_()
+ {
+ static constexpr void (*destr)(U&) = std::is_destructible::value ? &Destructor::destroy : nullptr;
+ static constexpr type_info_g value = {destr, sizeof(U)};
+ return (const mir_type_info*)&value;
+ }
}
// Does not support allocators for now
@@ -82,9 +89,7 @@ struct mir_rcptr
T* _payload = nullptr;
mir_rc_context* _context = nullptr;
- using U = typename std::remove_all_extents::type;
- static constexpr void (*destr)(U&) = std::is_destructible::value ? &mir::Destructor::destroy : nullptr;
- static constexpr mir::type_info_g typeInfoT = {destr, sizeof(T)};
+ using U = typename std::remove_const::type;
public:
@@ -114,7 +119,7 @@ struct mir_rcptr
using U = typename std::remove_const::type;
static_assert( std::is_constructible::value, "Can't construct object in mir_rcptr constructor" );
mir_rcptr ret;
- ret._context = mir_rc_create((const mir_type_info*)&typeInfoT, 1);
+ ret._context = mir_rc_create(mir::typeInfoT_(), 1);
if (ret._context == nullptr)
throw std::bad_alloc();
ret._payload = (T*)(ret._context + 1);
@@ -200,7 +205,7 @@ struct mir_rcptr
T* _payload = nullptr;
mir_rc_context* _context = nullptr;
- using U = typename std::remove_all_extents::type;
+ using U = typename std::remove_const::type;
static constexpr void (*destr)(U&) = std::is_destructible::value ? &mir::Destructor::destroy : nullptr;
static constexpr mir::type_info_g typeInfoT = {destr, sizeof(T)};
@@ -317,7 +322,7 @@ struct mir_rcptr
T* _payload = nullptr;
mir_rc_context* _context = nullptr;
- using U = typename std::remove_all_extents::type;
+ using U = typename std::remove_const::type;
static constexpr void (*destr)(U&) = std::is_destructible::value ? &mir::Destructor::destroy : nullptr;
static constexpr mir::type_info_g typeInfoT = {destr, sizeof(T)};
diff --git a/include/mir/series.h b/include/mir/series.h
index 77cbfbd2..c7e39ddf 100644
--- a/include/mir/series.h
+++ b/include/mir/series.h
@@ -2,6 +2,7 @@
#define MIR_SERIES
+#include
#include