Skip to content
Open
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
6 changes: 4 additions & 2 deletions libRDE/BasePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Version 3. (See accompanying file License.txt)

#include "dyadic_interval.h"
#include <deque>
#include <vector>


/// A common ancestor for all given paths.

Expand Down Expand Up @@ -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();
};
Expand All @@ -62,7 +64,7 @@ class BasePath
{
std::deque<dyadic_interval> stack = to_dyadic_intervals<dyadic_interval::intervaltype, dyadic>(inf, sup, tolerance, dyadic_interval::intervaltype);
std::vector <LIE > incs;
std::vector <LIE* > pincs;
std::vector <const LIE* > pincs;
for (std::deque<dyadic_interval>::iterator it = stack.begin(); it != stack.end(); ++it)
{
LIE temp = DescribePath(*it, tolerance);
Expand Down
15 changes: 15 additions & 0 deletions libRDE/BrownianPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ class BrownianPath :
public DynamicallyConstructedPath<my_alg_type>
{

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<my_alg_type> > 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;

Expand Down
4 changes: 2 additions & 2 deletions libRDE/CategoricalTickDataPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class CategoricalTickDataPath :
void add_event(double time_stamp, alg::LET letter)
{
std::vector<double> 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));
}

Expand Down
1 change: 1 addition & 0 deletions libRDE/DataTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Increment : public FamilyConnections<my_alg_type>
static const unsigned myDIM = my_alg_type::myDIM;
static const unsigned ALPHABET_SIZE = my_alg_type::ALPHABET_SIZE;

typedef std::map < dyadic_interval, Increment<my_alg_type> > DataTree;
protected:
/// The increment.
LIE _LieValue;
Expand Down
4 changes: 3 additions & 1 deletion libRDE/DefaultPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ template <typename my_alg_type>
class DefaultPath :
public BasePath<my_alg_type>
{

public:

typedef typename my_alg_type::LIE LIE;

DefaultPath(void)
{
};
Expand Down
27 changes: 18 additions & 9 deletions libRDE/DynamicallyConstructedPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ template <typename my_alg_type>
class DynamicallyConstructedPath :
public BasePath<my_alg_type>
{
public:
typedef std::map < dyadic_interval, Increment<my_alg_type> > 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:

Expand Down Expand Up @@ -138,11 +147,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;
Expand Down Expand Up @@ -192,8 +201,8 @@ class DynamicallyConstructedPath :
int iAccuracyAvailable = std::min(nvBelow.Accuracy(), nvSibling.Accuracy());
if ( nvParent.Accuracy() < iAccuracyAvailable )
{
std::vector <LIE*>
pincs(std::vector<LIE*>::size_type(2));
std::vector <const LIE*>
pincs(typename std::vector<LIE*>::size_type(2));
if (diBelow.aligned())
{
pincs[0]= & nvBelow.LieValue();
Expand Down Expand Up @@ -224,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;
Expand Down Expand Up @@ -289,7 +298,7 @@ class DynamicallyConstructedPath :
while (!((itRoot->first).contains(increment)))
{
// move root up

const dyadic_interval & diOldRoot = itRoot->first;
Increment<my_alg_type> & nvOldRoot = itRoot->second;

Expand All @@ -300,9 +309,9 @@ class DynamicallyConstructedPath :
?diNeighbour.shrink_interval_right()
:diNeighbour.shrink_interval_left();

Iterator itNeighbour = mPathData.insert( itRoot, DataTree::value_type(diNeighbour, Increment<my_alg_type>(diNeighbour,mPathData.end(),mPathData.end()) ) );
Iterator itNeighbour = mPathData.insert( itRoot, typename DataTree::value_type(diNeighbour, Increment<my_alg_type>(diNeighbour,mPathData.end(),mPathData.end()) ) );
Increment<my_alg_type> & nvNeighbour = itNeighbour->second;
Iterator itNewRoot = mPathData.insert( itRoot, DataTree::value_type(diNewRoot, Increment<my_alg_type>(diNewRoot,mPathData.end(),mPathData.end()) ) );
Iterator itNewRoot = mPathData.insert( itRoot, typename DataTree::value_type(diNewRoot, Increment<my_alg_type>(diNewRoot,mPathData.end(),mPathData.end()) ) );
Increment<my_alg_type> & nvNewRoot = itNewRoot->second;
nvOldRoot.mitSibling = itNeighbour;
nvOldRoot.mitParent = itNewRoot;
Expand All @@ -325,7 +334,7 @@ class DynamicallyConstructedPath :
Increment<my_alg_type> 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));
Expand Down
3 changes: 3 additions & 0 deletions libRDE/FractBrownianPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions libRDE/MakeBrownianPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Version 3. (See accompanying file License.txt)
template <typename my_alg_type>
Path<my_alg_type> MakeBrownianPath()
{
std::tr1::shared_ptr< const BrownianPath<my_alg_type> > p(new BrownianPath<my_alg_type>());
std::shared_ptr< const BrownianPath<my_alg_type> > p(new BrownianPath<my_alg_type>());
return Path<my_alg_type>(p);
};

template <typename my_alg_type>
Path<my_alg_type> MakeBrownianPath( NormalRandomNumberGenerator & rand, unsigned int d = my_alg_type::myDIM )
{
std::tr1::shared_ptr< const BrownianPath<my_alg_type> > p(new BrownianPath<my_alg_type>(rand,d));
std::shared_ptr< const BrownianPath<my_alg_type> > p(new BrownianPath<my_alg_type>(rand,d));
return Path<my_alg_type>(p);
};

Expand Down
2 changes: 1 addition & 1 deletion libRDE/NormalRandomNumberGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Version 3. (See accompanying file License.txt)
#include "NormalRandomNumberGenerator.h"

extern "C" {
//#include "SFMT.h"
#include "SFMT.h"
}

#include <cmath>
Expand Down
19 changes: 16 additions & 3 deletions libRDE/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ class Path :
public BasePath<my_alg_type>
{
public:

typedef typename my_alg_type::LIE LIE;

/// Trivial constructor.
Path(void) : pImpl(std::tr1::shared_ptr< const DefaultPath<my_alg_type> > (new DefaultPath<my_alg_type>))
Path(void) : pImpl(std::shared_ptr< const DefaultPath<my_alg_type> > (new DefaultPath<my_alg_type>))
{
};

/// Constructor from pointer to implementation.
Path(std::tr1::shared_ptr < const BasePath<my_alg_type> > pimpl1) : pImpl(pimpl1)
Path(std::shared_ptr < const BasePath<my_alg_type> > pimpl1) : pImpl(pimpl1)
{
};

Expand All @@ -64,9 +67,19 @@ 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::tr1::shared_ptr < const BasePath<my_alg_type> > pImpl;
std::shared_ptr < const BasePath<my_alg_type> > pImpl;

}; //END CLASS DEFINITION Path

Expand Down
138 changes: 138 additions & 0 deletions libRDE/TransformedPath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
*
*
*
*
*
*/


#pragma once

#ifndef TRANSFORMED_PATH__H__
#define TRANSFORMED_PATH__H__

#include "BasePath.h"


template <typename my_alg_type>
class RestrictedPath : BasePath<my_alg_type>
{
public:
typedef BasePath<my_alg_type> BPATH;
typedef typename my_alg_type::LIE LIE;
typedef typename my_alg_type::S S;

RestrictedPath(std::shared_ptr<const BPATH> 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<const BPATH> pImpl;
};





template <typename my_alg_type>
class ConcatenatedPath : BasePath<my_alg_type>
{
public:
typedef BasePath<my_alg_type> BPATH;
typedef std::shared_ptr<const BPATH> 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<const BPATH> _lpath;
std::shared_ptr<const BPATH> _rpath;
};











#endif
Loading