Minsky: 3.17.0
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 28 of file expr.h.

Constructor & Destructor Documentation

◆ Expr() [1/4]

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

Definition at line 31 of file expr.h.

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

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

31  :
SubexpressionCache & cache
Definition: expr.h:30
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 33 of file expr.h.

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

33  :
SubexpressionCache & cache
Definition: expr.h:30
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 35 of file expr.h.

35  :
36  NodePtr(cache.reverseLookup(x)), cache(cache) {assert(*this);}
SubexpressionCache & cache
Definition: expr.h:30
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 37 of file expr.h.

37  :
38  NodePtr(cache.reverseLookup(*x)), cache(cache) {assert(*this);}
SubexpressionCache & cache
Definition: expr.h:30
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 40 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().

40  {
41  shared_ptr<OperationDAGBase> r(OperationDAGBase::create(type));
43  return r;
44  }
SubexpressionCache & cache
Definition: expr.h:30
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 60 of file expr.h.

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

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

◆ operator+()

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

Definition at line 46 of file expr.h.

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

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

◆ operator-()

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

Definition at line 53 of file expr.h.

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

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

◆ operator/()

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

Definition at line 67 of file expr.h.

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

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

Member Data Documentation

◆ cache


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