Minsky
MathDAG::Expr Struct Reference

#include <expr.h>

Inheritance diagram for MathDAG::Expr:
Inheritance graph
Collaboration diagram for MathDAG::Expr:
Collaboration graph

Public Member Functions

 Expr (SubexpressionCache &cache, const NodePtr &x)
 
 Expr (SubexpressionCache &cache, const shared_ptr< OperationDAGBase > &x)
 
 Expr (SubexpressionCache &cache, const Node &x)
 
 Expr (SubexpressionCache &cache, const WeakNodePtr &x)
 
shared_ptr< OperationDAGBasenewNode (OperationType::Type type) const
 
Expr operator+ (const NodePtr &x) const
 
Expr operator- (const NodePtr &x) const
 
Expr operator* (const NodePtr &x) const
 
Expr operator/ (const NodePtr &x) const
 

Public Attributes

SubexpressionCachecache
 

Detailed Description

Definition at line 29 of file expr.h.

Constructor & Destructor Documentation

◆ Expr() [1/4]

MathDAG::Expr::Expr ( SubexpressionCache cache,
const NodePtr x 
)
inline

Definition at line 32 of file expr.h.

References cache, and MathDAG::SubexpressionCache::insertAnonymous().

Referenced by operator*(), operator+(), operator-(), and operator/().

32  :
SubexpressionCache & cache
Definition: expr.h:31
std::shared_ptr< Node > NodePtr
Definition: equations.h:131
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expr() [2/4]

MathDAG::Expr::Expr ( SubexpressionCache cache,
const shared_ptr< OperationDAGBase > &  x 
)
inline

Definition at line 34 of file expr.h.

References cache, and MathDAG::SubexpressionCache::insertAnonymous().

34  :
SubexpressionCache & cache
Definition: expr.h:31
std::shared_ptr< Node > NodePtr
Definition: equations.h:131
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Here is the call graph for this function:

◆ Expr() [3/4]

MathDAG::Expr::Expr ( SubexpressionCache cache,
const Node x 
)
inline

Definition at line 36 of file expr.h.

36  :
37  NodePtr(cache.reverseLookup(x)), cache(cache) {assert(*this);}
SubexpressionCache & cache
Definition: expr.h:31
std::shared_ptr< Node > NodePtr
Definition: equations.h:131
NodePtr reverseLookup(const Node &x) const
returns NodePtr corresponding to object , if it exists in cache, nullptr otherwise ...
Definition: equations.h:342

◆ Expr() [4/4]

MathDAG::Expr::Expr ( SubexpressionCache cache,
const WeakNodePtr x 
)
inline

Definition at line 38 of file expr.h.

38  :
39  NodePtr(cache.reverseLookup(*x)), cache(cache) {assert(*this);}
SubexpressionCache & cache
Definition: expr.h:31
std::shared_ptr< Node > NodePtr
Definition: equations.h:131
NodePtr reverseLookup(const Node &x) const
returns NodePtr corresponding to object , if it exists in cache, nullptr otherwise ...
Definition: equations.h:342

Member Function Documentation

◆ newNode()

shared_ptr<OperationDAGBase> MathDAG::Expr::newNode ( OperationType::Type  type) const
inline

Definition at line 41 of file expr.h.

References cache, MathDAG::OperationDAGBase::create(), and MathDAG::SubexpressionCache::insertAnonymous().

Referenced by MathDAG::cos(), MathDAG::cosh(), MathDAG::exp(), MathDAG::fact(), MathDAG::Gamma(), MathDAG::log(), operator*(), operator+(), operator-(), operator/(), MathDAG::operator<(), MathDAG::operator<=(), MathDAG::polygamma(), MathDAG::sin(), MathDAG::sinh(), and MathDAG::sqrt().

41  {
42  shared_ptr<OperationDAGBase> r(OperationDAGBase::create(type));
44  return r;
45  }
SubexpressionCache & cache
Definition: expr.h:31
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
static OperationDAGBase * create(Type type, const string &name="")
factory method
Definition: equations.cc:176
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*()

Expr MathDAG::Expr::operator* ( const NodePtr x) const
inline

Definition at line 61 of file expr.h.

References cache, Expr(), MathDAG::SubexpressionCache::insertAnonymous(), minsky::OperationType::multiply, and newNode().

61  {
63  shared_ptr<OperationDAGBase> r=newNode(OperationType::multiply);
64  r->arguments[0].push_back(*this);
65  r->arguments[1].push_back(x);
66  return Expr(cache,r);
67  }
shared_ptr< OperationDAGBase > newNode(OperationType::Type type) const
Definition: expr.h:41
SubexpressionCache & cache
Definition: expr.h:31
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Expr(SubexpressionCache &cache, const NodePtr &x)
Definition: expr.h:32
Here is the call graph for this function:

◆ operator+()

Expr MathDAG::Expr::operator+ ( const NodePtr x) const
inline

Definition at line 47 of file expr.h.

References minsky::OperationType::add, cache, Expr(), MathDAG::SubexpressionCache::insertAnonymous(), and newNode().

47  {
49  shared_ptr<OperationDAGBase> r=newNode(OperationType::add);
50  r->arguments[0].push_back(*this);
51  r->arguments[1].push_back(x);
52  return Expr(cache,r);
53  }
shared_ptr< OperationDAGBase > newNode(OperationType::Type type) const
Definition: expr.h:41
SubexpressionCache & cache
Definition: expr.h:31
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Expr(SubexpressionCache &cache, const NodePtr &x)
Definition: expr.h:32
Here is the call graph for this function:

◆ operator-()

Expr MathDAG::Expr::operator- ( const NodePtr x) const
inline

Definition at line 54 of file expr.h.

References cache, Expr(), MathDAG::SubexpressionCache::insertAnonymous(), newNode(), and minsky::OperationType::subtract.

54  {
56  shared_ptr<OperationDAGBase> r=newNode(OperationType::subtract);
57  r->arguments[0].push_back(*this);
58  r->arguments[1].push_back(x);
59  return Expr(cache,r);
60  }
shared_ptr< OperationDAGBase > newNode(OperationType::Type type) const
Definition: expr.h:41
SubexpressionCache & cache
Definition: expr.h:31
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Expr(SubexpressionCache &cache, const NodePtr &x)
Definition: expr.h:32
Here is the call graph for this function:

◆ operator/()

Expr MathDAG::Expr::operator/ ( const NodePtr x) const
inline

Definition at line 68 of file expr.h.

References cache, minsky::OperationType::divide, Expr(), MathDAG::SubexpressionCache::insertAnonymous(), and newNode().

68  {
70  shared_ptr<OperationDAGBase> r=newNode(OperationType::divide);
71  r->arguments[0].push_back(*this);
72  r->arguments[1].push_back(x);
73  return Expr(cache,r);
74  }
shared_ptr< OperationDAGBase > newNode(OperationType::Type type) const
Definition: expr.h:41
SubexpressionCache & cache
Definition: expr.h:31
NodePtr insertAnonymous(NodePtr x)
Definition: equations.h:351
Expr(SubexpressionCache &cache, const NodePtr &x)
Definition: expr.h:32
Here is the call graph for this function:

Member Data Documentation

◆ cache


The documentation for this struct was generated from the following file: