Minsky
MathDAG::LockDAG Struct Reference

#include <equations.h>

Inheritance diagram for MathDAG::LockDAG:
Inheritance graph
Collaboration diagram for MathDAG::LockDAG:
Collaboration graph

Public Member Functions

 LockDAG (const Lock &lock)
 
int BODMASlevel () const override
 algebraic heirarchy level, used for working out whether brackets are necessary. More...
 
ostream & latex (ostream &o) const override
 writes LaTeX representation of this DAG to the stream More...
 
ostream & matlab (ostream &o) const override
 writes a matlab representation of this DAG to the stream More...
 
void render (ecolab::cairo::Surface &surf) const override
 renders a visual representation of this node to surf graphic extends right from the current pen position (which needs to be defined), and pen is moved to the right edge of the graphic. The determine bounding box, render into a recording surface, and use width()/height() More...
 
VariableValuePtr addEvalOps (EvalOpVector &, const VariableValuePtr &result={}) override
 adds EvalOps to an EvalOpVector representing this node. More...
 
int order (unsigned maxOrder) const override
 returns evaluation order in sequence of variable defintions More...
 
bool tensorEval (std::set< const Node *> &) const override
 returns true if the evaluation of this involves tensor processing More...
 
std::shared_ptr< Nodederivative (SystemOfEquations &) const override
 support for the derivative operator. More...
 
- Public Member Functions inherited from MathDAG::Node
virtual ~Node ()
 
std::string latexStr () const
 
std::string matlabStr () const
 
bool tensorEval ()
 returns true if the evaluation of this involves tensor processing More...
 
LaTeXManip latex () const
 used within io streaming More...
 
MatlabManip matlab () const
 

Public Attributes

const Locklock
 
WeakNodePtr rhs
 
- Public Attributes inherited from MathDAG::Node
int cachedOrder =-1
 
VariableValuePtr result
 reference to where this node's value is stored More...
 

Detailed Description

Definition at line 276 of file equations.h.

Constructor & Destructor Documentation

◆ LockDAG()

MathDAG::LockDAG::LockDAG ( const Lock lock)
inline

Definition at line 280 of file equations.h.

280 : lock(lock) {}
const Lock & lock
Definition: equations.h:278

Member Function Documentation

◆ addEvalOps()

VariableValuePtr MathDAG::LockDAG::addEvalOps ( EvalOpVector ,
const VariableValuePtr result = {} 
)
overridevirtual

adds EvalOps to an EvalOpVector representing this node.

Returns
a variable where the result is stored. If a flowVariable has been provided in result, that may be used directly, otherwise a copy operation is added to ensure it receives the result.

Implements MathDAG::Node.

Definition at line 795 of file equations.cc.

References MathDAG::Node::addEvalOps(), civita::createRavelChain(), lock, minsky::Lock::locked(), minsky::Lock::lockedState, MathDAG::Node::result, rhs, minsky::VariableType::tempFlow, minsky::Item::throw_error(), and minsky::VariableType::undefined.

796  {
797  assert(result);
798  if (result->type()==VariableType::undefined)
799  {
800  if (r && r->isFlowVar())
801  result=r;
802  else
803  {
805  result->allocValue();
806  }
807  }
808 
809  if (!rhs) return result;
810  if (lock.locked())
811  try
812  {
813  auto chain=createRavelChain(lock.lockedState, rhs->addEvalOps(ev,{}));
814  if (chain.empty()) return {};
815  result->index(chain.back()->index());
816  result->hypercube(chain.back()->hypercube());
817  ev.emplace_back(EvalOpPtr(new TensorEval(result, make_shared<EvalCommon>(), chain.back())));
818  return result;
819  }
820  catch (const std::exception& ex)
821  {
822  lock.throw_error(ex.what());
823  }
824  return rhs->addEvalOps(ev,result);
825  }
virtual VariableValuePtr addEvalOps(EvalOpVector &, const VariableValuePtr &result={})=0
adds EvalOps to an EvalOpVector representing this node.
A helper to evaluate a variable value.
vector< TensorPtr > createRavelChain(const ravel::RavelState &state, const TensorPtr &arg)
creates a chain of tensor operations that represents a Ravel in state state, operating on arg ...
Definition: tensorOp.cc:497
VariableValuePtr result
reference to where this node&#39;s value is stored
Definition: equations.h:128
a shared_ptr that default constructs a default target, and is always valid
ravel::RavelState lockedState
Definition: lock.h:37
bool locked() const
Definition: lock.h:39
void throw_error(const std::string &) const
mark item on canvas, then throw
Definition: item.cc:86
const Lock & lock
Definition: equations.h:278
WeakNodePtr rhs
Definition: equations.h:279
Here is the call graph for this function:

◆ BODMASlevel()

int MathDAG::LockDAG::BODMASlevel ( ) const
inlineoverridevirtual

algebraic heirarchy level, used for working out whether brackets are necessary.

Implements MathDAG::Node.

Definition at line 281 of file equations.h.

281 {return 0;}

◆ derivative()

std::shared_ptr<Node> MathDAG::LockDAG::derivative ( SystemOfEquations ) const
inlineoverridevirtual

support for the derivative operator.

Implements MathDAG::Node.

Definition at line 288 of file equations.h.

References minsky::Item::throw_error().

289  {lock.throw_error("derivative not defined for locked objects");}
void throw_error(const std::string &) const
mark item on canvas, then throw
Definition: item.cc:86
const Lock & lock
Definition: equations.h:278
Here is the call graph for this function:

◆ latex()

ostream& MathDAG::LockDAG::latex ( ostream &  ) const
inlineoverridevirtual

writes LaTeX representation of this DAG to the stream

Implements MathDAG::Node.

Definition at line 282 of file equations.h.

282 {return o<<"locked";}

◆ matlab()

ostream& MathDAG::LockDAG::matlab ( ostream &  ) const
inlineoverridevirtual

writes a matlab representation of this DAG to the stream

Implements MathDAG::Node.

Definition at line 283 of file equations.h.

283 {return o<<"";}

◆ order()

int MathDAG::LockDAG::order ( unsigned  maxOrder) const
inlineoverridevirtual

returns evaluation order in sequence of variable defintions

Parameters
maxOrderis used to limit the recursion depth

Implements MathDAG::Node.

Definition at line 286 of file equations.h.

References MathDAG::Node::order().

286 {return rhs? rhs->order(maxOrder-1)+1:0;}
virtual int order(unsigned maxOrder) const =0
returns evaluation order in sequence of variable defintions
WeakNodePtr rhs
Definition: equations.h:279
Here is the call graph for this function:

◆ render()

void MathDAG::LockDAG::render ( ecolab::cairo::Surface &  surf) const
overridevirtual

renders a visual representation of this node to surf graphic extends right from the current pen position (which needs to be defined), and pen is moved to the right edge of the graphic. The determine bounding box, render into a recording surface, and use width()/height()

Implements MathDAG::Node.

Definition at line 224 of file equationDisplayRender.cc.

References MathDAG::anonymous_namespace{equationDisplayRender.cc}::print().

225  {
226  print(surf.cairo(), "locked", Anchor::nw);
227  }
double print(cairo_t *cairo, const string &text, Anchor anchor)
Here is the call graph for this function:

◆ tensorEval()

bool MathDAG::LockDAG::tensorEval ( std::set< const Node *> &  visited) const
inlineoverridevirtual

returns true if the evaluation of this involves tensor processing

Parameters
visitedset to break graph cycles

Implements MathDAG::Node.

Definition at line 287 of file equations.h.

287 {return true;}

Member Data Documentation

◆ lock

const Lock& MathDAG::LockDAG::lock

Definition at line 278 of file equations.h.

Referenced by addEvalOps().

◆ rhs

WeakNodePtr MathDAG::LockDAG::rhs

Definition at line 279 of file equations.h.

Referenced by addEvalOps().


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