From 2d3ab06298a449f5e68b7e3b4fc16f4af940cc8e Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 3 Jul 2020 20:50:00 +0100 Subject: [PATCH 01/17] Fixed a couple of typos and minor issues --- libRDE/dyadic_interval.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libRDE/dyadic_interval.h b/libRDE/dyadic_interval.h index 3d2a881..5913dfa 100644 --- a/libRDE/dyadic_interval.h +++ b/libRDE/dyadic_interval.h @@ -28,7 +28,7 @@ enum IntervalType : int16_t { /// a comparison operator that always has the contained element as the least element in the interval /// for a clopen interval this is the standard less operator, for opencl it is reversed template -struct compare +struct Compare { template bool operator() (T lhs, T rhs)const @@ -93,7 +93,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious private: typedef typename dyadic_t::k_t k_t; typedef typename dyadic_t::n_t n_t; - typedef compare compare; + typedef Compare compare; const compare cmp; public: @@ -127,7 +127,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious public: basic_dyadic_interval(dyadic_t s) - : dyadic_t(s) + : dyadic_t(s), cmp{} { } basic_dyadic_interval(k_t k1, n_t n1) @@ -136,7 +136,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious } /// the dyadic interval of length 2^-(resolution) containing the dyadic value arg - basic_dyadic_interval(dyadic_t arg, n_t resolution) + basic_dyadic_interval(dyadic_t arg, n_t resolution) : cmp{} { bool isint = arg.rebase(resolution); // set in greatest denominator so k is integer and denom <= 2^resolution if (!isint) @@ -154,13 +154,13 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// will overflow if 2^(resolution) * arg cannot be represented as a k_t integer basic_dyadic_interval(double arg, n_t resolution) { - basic_dyadic out; + dyadic_t out; auto rescaled_arg = ldexp(arg, resolution); assert(double(std::numeric_limits::max()) > abs(rescaled_arg)); switch (interval_t) { - case opencl: out = basic_dyadic{ (k_t)ceil(rescaled_arg), resolution }; break; - case clopen: out = basic_dyadic{ (k_t)floor(rescaled_arg), resolution }; break; + case opencl: out = dyadic_t{ (k_t)ceil(rescaled_arg), resolution }; break; + case clopen: out = dyadic_t{ (k_t)floor(rescaled_arg), resolution }; break; } dyadic_t::operator = (out); } @@ -270,7 +270,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// interval at that level to contain the current interval. basic_dyadic_interval & expand_interval(k_t Arg = 1) { - return operator = (typename basic_dyadic_interval(included_end(), n - Arg)); + return operator = (basic_dyadic_interval(included_end(), n - Arg)); } /// total comparison operator for dyadic intervals @@ -333,7 +333,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious return temp; } private: - +/* /// Explicit constructors that when given a dyadic or double and an interval type returns the closest dyadic with n = tolerance /// whose value is just larger ( (] case) or smaller ( [) case) or equal to that of the dyadic or double and so that the relevant /// interval containing the new dyadic contains the numerical value of the constructing number; @@ -391,7 +391,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious n = tolerance; } } - +*/ /// Outputs a dyadic interval in the form [double, double) to an std::ostream. friend inline std::ostream& operator << (std::ostream & os, const basic_dyadic_interval & rhs) { @@ -426,7 +426,7 @@ to_dyadic_intervals(double inf, double sup, int tolerance, IntervalType unused) begin.k += di::unit; }; - auto store_ = [](std::list &intervals, std::list::iterator p, di end) -> std::list::iterator + auto store_ = [](std::list &intervals, typename std::list::iterator p, di end) -> typename std::list::iterator { p = intervals.insert(p, end.shrink_to_contained_end()); return p; @@ -465,12 +465,12 @@ typedef basic_dyadic_interval dyadic_inter /// clopen or opencl. Individual intervals are represented internally by their sup, inf, /// and this tag. The template generates different types for clopen and opencl intervals /// and they do not communicate. -template +template class basic_interval { public: typedef SCALAR scalar_t; - static const IntervalType intervaltype{ intervaltype }; - typedef compare compare; + static const IntervalType intervaltype{ Intervaltype }; + typedef Compare compare; const compare cmp; scalar_t excluded_end() const { return (intervaltype == clopen) ? m_sup : m_inf; } @@ -496,7 +496,8 @@ class basic_interval { // constructors basic_interval(std::pair < scalar_t, scalar_t > arg) : m_inf{ std::min(arg.first, arg.second) }, - m_sup{ std::max(arg.first, arg.second) } + m_sup{ std::max(arg.first, arg.second) }, + cmp {} {} basic_interval(scalar_t first, scalar_t second) : basic_interval{ std::make_pair(first, second) } From a1f07afb9d8764dd85dd90bbf108879bce134ed1 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Mon, 6 Jul 2020 08:45:24 +0100 Subject: [PATCH 02/17] Added one more instantiation of constant cmp object --- libRDE/dyadic_interval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libRDE/dyadic_interval.h b/libRDE/dyadic_interval.h index 5913dfa..fbc5d25 100644 --- a/libRDE/dyadic_interval.h +++ b/libRDE/dyadic_interval.h @@ -152,7 +152,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// the dyadic interval of length 2^-(resolution) containing the numerical value arg /// will overflow if 2^(resolution) * arg cannot be represented as a k_t integer - basic_dyadic_interval(double arg, n_t resolution) + basic_dyadic_interval(double arg, n_t resolution) : cmp{} { dyadic_t out; auto rescaled_arg = ldexp(arg, resolution); From 6740477004f780c892c8f8bd96b9e76f4a10069e Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 21:54:33 +0100 Subject: [PATCH 03/17] Removed pure virtual marker and added const --- libRDE/BasePath.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libRDE/BasePath.h b/libRDE/BasePath.h index fa77b5c..22b5c6b 100644 --- a/libRDE/BasePath.h +++ b/libRDE/BasePath.h @@ -15,6 +15,8 @@ Version 3. (See accompanying file License.txt) #include "dyadic_interval.h" #include +#include + /// A common ancestor for all given paths. @@ -43,7 +45,7 @@ class BasePath /// The description of the path /// Describe the path over a dyadic interval by a Lie element - LIE virtual DescribePath(const dyadic_interval &increment, const int accuracy) const = 0 + virtual LIE DescribePath(const dyadic_interval &increment, const int accuracy) const { return LIE(); }; @@ -62,7 +64,7 @@ class BasePath { std::deque stack = to_dyadic_intervals(inf, sup, tolerance, dyadic_interval::intervaltype); std::vector incs; - std::vector pincs; + std::vector pincs; for (std::deque::iterator it = stack.begin(); it != stack.end(); ++it) { LIE temp = DescribePath(*it, tolerance); From 376194a6a1aa4cca2d7e0b400580a5cf8d1cbdaa Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 21:59:20 +0100 Subject: [PATCH 04/17] Added typedefs to Brownian path class --- libRDE/BrownianPath.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libRDE/BrownianPath.h b/libRDE/BrownianPath.h index 7a4ccfe..af3c887 100644 --- a/libRDE/BrownianPath.h +++ b/libRDE/BrownianPath.h @@ -29,6 +29,21 @@ class BrownianPath : public DynamicallyConstructedPath { + typedef typename my_alg_type::TENSOR TENSOR; + typedef typename my_alg_type::LIE LIE; + typedef typename my_alg_type::MAPS MAPS; + typedef typename my_alg_type::CBH CBH; + typedef typename my_alg_type::SCA SCA; + typedef typename my_alg_type::S S; + typedef typename my_alg_type::LET LET; + typedef typename my_alg_type::DEG DEG; + + typedef std::map < dyadic_interval, Increment > DataTree; + typedef typename DataTree::iterator Iterator; + typedef typename DataTree::const_iterator ConstIterator; + + static const unsigned myDIM = my_alg_type::myDIM; + /// Default NormalRandomNumberGenerator - used if another is not specified in the constructor. static NormalRandomNumberGenerator vgCommonNormal; From caa0b97e8a11e41bb036aec4babbb6dce7a0721d Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:01:20 +0100 Subject: [PATCH 05/17] Added typedef of DataTree to Increment class --- libRDE/DataTree.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libRDE/DataTree.h b/libRDE/DataTree.h index 9a4cc96..f32e59c 100644 --- a/libRDE/DataTree.h +++ b/libRDE/DataTree.h @@ -71,6 +71,7 @@ class Increment : public FamilyConnections static const unsigned myDIM = my_alg_type::myDIM; static const unsigned ALPHABET_SIZE = my_alg_type::ALPHABET_SIZE; + typedef std::map < dyadic_interval, Increment > DataTree; protected: /// The increment. LIE _LieValue; From c4fe60ac0308cd807d79530314d76688d3cb0514 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:17:57 +0100 Subject: [PATCH 06/17] Added Lie typedef to class --- libRDE/DefaultPath.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libRDE/DefaultPath.h b/libRDE/DefaultPath.h index 3a40921..d44cb51 100644 --- a/libRDE/DefaultPath.h +++ b/libRDE/DefaultPath.h @@ -24,8 +24,10 @@ template class DefaultPath : public BasePath { - public: + + typedef typename my_alg_type::LIE LIE; + DefaultPath(void) { }; From 790e4073e9fda29f74fb284fe67d481644975c96 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:19:30 +0100 Subject: [PATCH 07/17] Added instantiation of const compare object --- libRDE/dyadic_interval.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libRDE/dyadic_interval.h b/libRDE/dyadic_interval.h index 5913dfa..90b803b 100644 --- a/libRDE/dyadic_interval.h +++ b/libRDE/dyadic_interval.h @@ -152,7 +152,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// the dyadic interval of length 2^-(resolution) containing the numerical value arg /// will overflow if 2^(resolution) * arg cannot be represented as a k_t integer - basic_dyadic_interval(double arg, n_t resolution) + basic_dyadic_interval(double arg, n_t resolution) : cmp{} { dyadic_t out; auto rescaled_arg = ldexp(arg, resolution); @@ -167,7 +167,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// the dyadic interval of length 2^-(resolution) containing the numerical value arg /// with the largest resolution so that 2^(resolution) * arg can be represented as a k_t integer - explicit basic_dyadic_interval(double arg) + explicit basic_dyadic_interval(double arg) : cmp{} { double temp = abs(arg) / double(std::numeric_limits::max()); if (temp == 0) From f7672bce5bc8d6f715369391b1145e8759184c40 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:20:53 +0100 Subject: [PATCH 08/17] Added typedefs and typenames --- libRDE/DynamicallyConstructedPath.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libRDE/DynamicallyConstructedPath.h b/libRDE/DynamicallyConstructedPath.h index 6d14577..ad1d723 100644 --- a/libRDE/DynamicallyConstructedPath.h +++ b/libRDE/DynamicallyConstructedPath.h @@ -29,6 +29,14 @@ class DynamicallyConstructedPath : public BasePath { typedef std::map < dyadic_interval, Increment > DataTree; + typedef typename my_alg_type::MAPS MAPS; + typedef typename my_alg_type::CBH CBH; + typedef typename my_alg_type::LIE LIE; + typedef typename my_alg_type::S S; + typedef typename my_alg_type::TENSOR TENSOR; + typedef typename my_alg_type::SCA SCA; + typedef typename my_alg_type::LET LET; + typedef typename my_alg_type::DEG DEG; private: @@ -138,11 +146,11 @@ class DynamicallyConstructedPath : Iterator itLeft = mPathData.insert( itLeafAbove, //hint to position - DataTree::value_type(diLeft,nvLeft) // the interval and its data + typename DataTree::value_type(diLeft,nvLeft) // the interval and its data ); Iterator itRight = mPathData.insert( itLeft, //hint to position - DataTree::value_type(diRight,nvRight) // the interval and its data + typename DataTree::value_type(diRight,nvRight) // the interval and its data ); itLeft->second.mitSibling=itRight; @@ -192,8 +200,8 @@ class DynamicallyConstructedPath : int iAccuracyAvailable = std::min(nvBelow.Accuracy(), nvSibling.Accuracy()); if ( nvParent.Accuracy() < iAccuracyAvailable ) { - std::vector - pincs(std::vector::size_type(2)); + std::vector + pincs(typename std::vector::size_type(2)); if (diBelow.aligned()) { pincs[0]= & nvBelow.LieValue(); @@ -300,9 +308,9 @@ class DynamicallyConstructedPath : ?diNeighbour.shrink_interval_right() :diNeighbour.shrink_interval_left(); - Iterator itNeighbour = mPathData.insert( itRoot, DataTree::value_type(diNeighbour, Increment(diNeighbour,mPathData.end(),mPathData.end()) ) ); + Iterator itNeighbour = mPathData.insert( itRoot, typename DataTree::value_type(diNeighbour, Increment(diNeighbour,mPathData.end(),mPathData.end()) ) ); Increment & nvNeighbour = itNeighbour->second; - Iterator itNewRoot = mPathData.insert( itRoot, DataTree::value_type(diNewRoot, Increment(diNewRoot,mPathData.end(),mPathData.end()) ) ); + Iterator itNewRoot = mPathData.insert( itRoot, typename DataTree::value_type(diNewRoot, Increment(diNewRoot,mPathData.end(),mPathData.end()) ) ); Increment & nvNewRoot = itNewRoot->second; nvOldRoot.mitSibling = itNeighbour; nvOldRoot.mitParent = itNewRoot; @@ -325,7 +333,7 @@ class DynamicallyConstructedPath : Increment nvData(increment,mPathData.end(),mPathData.end()); Iterator itRoot = mPathData.insert( - DataTree::value_type (increment,nvData) + typename DataTree::value_type (increment,nvData) ).first; // update the Lie Value using the model specific helper function itRoot->second.LieValue(MakeRootLieIncrement(increment)); From b9635db509d63dc01ef7092f9bb88495f46f84c4 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:23:18 +0100 Subject: [PATCH 09/17] added typedefs of interger and double real that are required in lapack_defns.h --- libRDE/FractBrownianPath.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libRDE/FractBrownianPath.h b/libRDE/FractBrownianPath.h index 37b487c..0a8d940 100644 --- a/libRDE/FractBrownianPath.h +++ b/libRDE/FractBrownianPath.h @@ -15,6 +15,9 @@ Version 3. (See accompanying file License.txt) #ifndef __FRACTBROWNIANPATH__ #define __FRACTBROWNIANPATH__ +typedef int integer; +typedef double doublereal; + // Check windows #include "lapack_defns.h" From bb30cb497e640b1bca10c6427fc755430e126504 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:26:59 +0100 Subject: [PATCH 10/17] Removed tr1 namespace from shared ptr --- libRDE/MakeBrownianPath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libRDE/MakeBrownianPath.h b/libRDE/MakeBrownianPath.h index 7f5d5d5..5d9ef21 100644 --- a/libRDE/MakeBrownianPath.h +++ b/libRDE/MakeBrownianPath.h @@ -24,14 +24,14 @@ Version 3. (See accompanying file License.txt) template Path MakeBrownianPath() { - std::tr1::shared_ptr< const BrownianPath > p(new BrownianPath()); + std::shared_ptr< const BrownianPath > p(new BrownianPath()); return Path(p); }; template Path MakeBrownianPath( NormalRandomNumberGenerator & rand, unsigned int d = my_alg_type::myDIM ) { - std::tr1::shared_ptr< const BrownianPath > p(new BrownianPath(rand,d)); + std::shared_ptr< const BrownianPath > p(new BrownianPath(rand,d)); return Path(p); }; From f908f56fe4df67d6baa324810d95b968397b8eae Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:28:34 +0100 Subject: [PATCH 11/17] Uncommented import of SFMT.h --- libRDE/NormalRandomNumberGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libRDE/NormalRandomNumberGenerator.cpp b/libRDE/NormalRandomNumberGenerator.cpp index 606408d..7c083a5 100644 --- a/libRDE/NormalRandomNumberGenerator.cpp +++ b/libRDE/NormalRandomNumberGenerator.cpp @@ -13,7 +13,7 @@ Version 3. (See accompanying file License.txt) #include "NormalRandomNumberGenerator.h" extern "C" { -//#include "SFMT.h" +#include "SFMT.h" } #include From ccec3566e31998eb3595957e462f4a59690e12fb Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:29:51 +0100 Subject: [PATCH 12/17] Removed tr1 namespace and added LIE typedef --- libRDE/Path.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libRDE/Path.h b/libRDE/Path.h index 7a8f0f0..2e9c099 100644 --- a/libRDE/Path.h +++ b/libRDE/Path.h @@ -31,13 +31,16 @@ class Path : public BasePath { public: + + typedef typename my_alg_type::LIE LIE; + /// Trivial constructor. - Path(void) : pImpl(std::tr1::shared_ptr< const DefaultPath > (new DefaultPath)) + Path(void) : pImpl(std::shared_ptr< const DefaultPath > (new DefaultPath)) { }; /// Constructor from pointer to implementation. - Path(std::tr1::shared_ptr < const BasePath > pimpl1) : pImpl(pimpl1) + Path(std::shared_ptr < const BasePath > pimpl1) : pImpl(pimpl1) { }; @@ -66,7 +69,7 @@ class Path : private: /// The pointer to the implementation. - std::tr1::shared_ptr < const BasePath > pImpl; + std::shared_ptr < const BasePath > pImpl; }; //END CLASS DEFINITION Path From 8bd4d0074a3b825f691c14dc71ed09995d06e97a Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 24 Jul 2020 13:59:35 +0100 Subject: [PATCH 13/17] Fixed typo in categorical tick data path class --- libRDE/CategoricalTickDataPath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libRDE/CategoricalTickDataPath.h b/libRDE/CategoricalTickDataPath.h index de7a598..e5c3b18 100644 --- a/libRDE/CategoricalTickDataPath.h +++ b/libRDE/CategoricalTickDataPath.h @@ -186,8 +186,8 @@ class CategoricalTickDataPath : void add_event(double time_stamp, alg::LET letter) { std::vector time_stamps; - time_stamps.push_back(timestamp); - delete_shadow(timestamps); + time_stamps.push_back(time_stamp); + delete_shadow(time_stamps); TickData.insert(make_pair(time_stamp, letter)); } From c650ff4641fc66e0d841d866a59d402eefddae44 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 24 Jul 2020 14:01:46 +0100 Subject: [PATCH 14/17] Made typedefs public --- libRDE/DynamicallyConstructedPath.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libRDE/DynamicallyConstructedPath.h b/libRDE/DynamicallyConstructedPath.h index ad1d723..2545414 100644 --- a/libRDE/DynamicallyConstructedPath.h +++ b/libRDE/DynamicallyConstructedPath.h @@ -28,6 +28,7 @@ template class DynamicallyConstructedPath : public BasePath { +public: typedef std::map < dyadic_interval, Increment > DataTree; typedef typename my_alg_type::MAPS MAPS; typedef typename my_alg_type::CBH CBH; From 930f32d9de1d77fe2e56581d3e66fb6056327f7a Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 24 Jul 2020 14:05:13 +0100 Subject: [PATCH 15/17] Made type definitions for n and k public --- libRDE/dyadic_interval.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libRDE/dyadic_interval.h b/libRDE/dyadic_interval.h index 90b803b..a61e725 100644 --- a/libRDE/dyadic_interval.h +++ b/libRDE/dyadic_interval.h @@ -89,10 +89,10 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious static const IntervalType intervaltype{ interval_t }; static const IntervalType reverseintervaltype{ (interval_t == opencl) ? clopen : opencl }; typedef DYADIC dyadic_t; - -private: typedef typename dyadic_t::k_t k_t; typedef typename dyadic_t::n_t n_t; +private: + typedef Compare compare; const compare cmp; @@ -395,7 +395,7 @@ class basic_dyadic_interval : DYADIC // use private derivation to avoid spurious /// Outputs a dyadic interval in the form [double, double) to an std::ostream. friend inline std::ostream& operator << (std::ostream & os, const basic_dyadic_interval & rhs) { - switch (rhs.interval_t) + switch (rhs.intervaltype) { case clopen: os << "[" << (double)rhs.inf() << ", " << (double)rhs.sup() << ")"; break; case opencl: os << "(" << (double)rhs.inf() << ", " << (double)rhs.sup() << "]"; break; From 811f2323cfe78616831444775750c0e9d4619f36 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Sun, 26 Jul 2020 22:35:39 +0100 Subject: [PATCH 16/17] Fixed various typos --- libRDE/DynamicallyConstructedPath.h | 4 ++-- libRDE/my_map_trap.h | 10 +++++----- libRDE/trap_alloc.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libRDE/DynamicallyConstructedPath.h b/libRDE/DynamicallyConstructedPath.h index 2545414..2d6183b 100644 --- a/libRDE/DynamicallyConstructedPath.h +++ b/libRDE/DynamicallyConstructedPath.h @@ -233,7 +233,7 @@ class DynamicallyConstructedPath : if (itPair.first != itPair.second) { - // increment already in mPathData to low accuracy + // increment already in mPathData to low accuracy const Iterator & itCurrent = itPair.first; @@ -298,7 +298,7 @@ class DynamicallyConstructedPath : while (!((itRoot->first).contains(increment))) { // move root up - + const dyadic_interval & diOldRoot = itRoot->first; Increment & nvOldRoot = itRoot->second; diff --git a/libRDE/my_map_trap.h b/libRDE/my_map_trap.h index f29882f..c974404 100644 --- a/libRDE/my_map_trap.h +++ b/libRDE/my_map_trap.h @@ -8,12 +8,12 @@ namespace tjl { //NOTE THAT THIS NEEDS MODIFICATION FOR CLANG COMPILER which does not construct or destroy items of type value_type - template + template class my_map_trap { public: - typedef typename MIRROR MIRROR; - typedef typename MAP MAP; + typedef MIRROR_T MIRROR; + typedef MAP_T MAP; typedef my_map_trap TRAP; typedef typename MAP::key_type key_type; typedef typename MAP::mapped_type mapped_type; @@ -38,10 +38,10 @@ namespace tjl template friend struct trap_alloc; // the value types of MAP and MIRROR must be convertible - typename typename MIRROR::value_type convert(const value_type& arg) const { + typename MIRROR::value_type convert(const value_type& arg) const { return arg.first; } - typename typename MIRROR::value_type convert(value_type&& arg) const { + typename MIRROR::value_type convert(value_type&& arg) const { return arg.first; } diff --git a/libRDE/trap_alloc.h b/libRDE/trap_alloc.h index d21c05a..09c4ee7 100644 --- a/libRDE/trap_alloc.h +++ b/libRDE/trap_alloc.h @@ -22,7 +22,7 @@ namespace tjl template struct trap_alloc : private std::allocator { - template friend struct trap_alloc; + template friend struct trap_alloc; typedef std::allocator base; From feb5a644253360da501d4674276cdc680dcac7b4 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 28 Aug 2020 14:20:52 +0100 Subject: [PATCH 17/17] Added support for concantenating and restricting paths --- libRDE/Path.h | 10 +++ libRDE/TransformedPath.h | 138 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 libRDE/TransformedPath.h diff --git a/libRDE/Path.h b/libRDE/Path.h index 2e9c099..22aa8ad 100644 --- a/libRDE/Path.h +++ b/libRDE/Path.h @@ -67,6 +67,16 @@ class Path : return pImpl->DescribePath(inf, sup, tolerance); }; + Path RestrictPath(const interval& interval) const + { + return Path(new RestrictedPath(pImpl, interval)); + } + + Path Concatenate(const Path& other) const + { + return Path(new ConcatenatedPath(pImpl, other.pImpl)); + } + private: /// The pointer to the implementation. std::shared_ptr < const BasePath > pImpl; diff --git a/libRDE/TransformedPath.h b/libRDE/TransformedPath.h new file mode 100644 index 0000000..b40fbb5 --- /dev/null +++ b/libRDE/TransformedPath.h @@ -0,0 +1,138 @@ +/** + * + * + * + * + * + */ + + +#pragma once + +#ifndef TRANSFORMED_PATH__H__ +#define TRANSFORMED_PATH__H__ + +#include "BasePath.h" + + +template +class RestrictedPath : BasePath +{ +public: + typedef BasePath BPATH; + typedef typename my_alg_type::LIE LIE; + typedef typename my_alg_type::S S; + + RestrictedPath(std::shared_ptr base, const interval& interval) + : pImpl{base}, _restriction{interval} + {} + + ~RestrictedPath() {} + + LIE DescribePath(const dyadic_interval & di, const int accuracy) const + { + if (di.sup() < _restriction.inf() || di.inf() > _restriction.sup()) + return LIE(); + + interval intersection { + std::max(double(di.inf()), _restriction.inf()), + std::min(double(di.sup()), _restriction.sup()) + }; + + return pImpl->DescribePath(intersection, accuracy); + } + + LIE DescribePath(double inf, double sup, int tolerance) const + { + if (sup < _restriction.inf() || inf > _restriction.sup()) + return LIE(); + + interval intersection { + std::max(inf, _restriction.inf()), + std::min(sup, _restriction.sup()) + }; + + return pImpl->DescribePath(intersection, accuracy); + } + + LIE DescribePath(const interval& interval, const int accuracy) const + { + return DescribePath(interval.inf(), interval.sup(), accuracy); + } + +private: + const interval _restriction; + std::shared_ptr pImpl; +}; + + + + + +template +class ConcatenatedPath : BasePath +{ +public: + typedef BasePath BPATH; + typedef std::shared_ptr PIMPL_T; + typedef typename my_alg_type::LIE LIE; + typedef typename my_alg_type::TENSOR TENSOR; + typedef typename my_alg_type::MAPS MAPS; + + ConcatenatedPath(PIMPL_T lpath, PIMPL_T rpath) + : _lpath{lpath}, _rpath{rpath} + {} + + ~ConcatenatedPath() {} + + TENSOR Signature(const dyadic_interval& increment, const int accuracy) const + { + return _lpath->Signature(increment, accuracy) * _rpath->Signature(increment, accuracy); + } + + TENSOR Signature(const dyadic_interval &increment) const + { + return _lpath->Signature(increment) * _rpath->Signature(increment); + }; + + /// Describe the path signature over a real interval with specified time accuracy 2^-(tolerance) + TENSOR Signature(double inf, double sup, int tolerance) const + { + return _lpath->Signature(inf, sup, tolerance) + * _rpath->Signature(inf, sup, tolerance); + }; + + LIE DescribePath(const dyadic_interval &increment, const int accuracy) const + { + MAPS maps; + return maps.t2l(log(Signature(increment, accuracy))); + } + + LIE DescribePath(const dyadic_interval &increment) const + { + MAPS maps; + return maps.t2l(log(Signature(increment, increment.n))); + }; + + LIE DescribePath(double inf, double sup, int tolerance) const + { + MAPS maps; + return maps.t2l(log(Signature(inf, sup, tolerance))); + } + +private: + std::shared_ptr _lpath; + std::shared_ptr _rpath; +}; + + + + + + + + + + + +#endif \ No newline at end of file