Minsky
MathDAG::ConstantDAG Struct Reference

#include <equations.h>

Inheritance diagram for MathDAG::ConstantDAG:
Inheritance graph
Collaboration diagram for MathDAG::ConstantDAG:
Collaboration graph

Public Member Functions

 ConstantDAG (const string &value="0")
 
 ConstantDAG (double value)
 
int BODMASlevel () const override
 algebraic heirarchy level, used for working out whether brackets are necessary. 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...
 
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 &) override
 adds EvalOps to an EvalOpVector representing this node. More...
 
NodePtr derivative (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

string value
 
- 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 156 of file equations.h.

Constructor & Destructor Documentation

◆ ConstantDAG() [1/2]

MathDAG::ConstantDAG::ConstantDAG ( const string &  value = "0")
inline

Definition at line 159 of file equations.h.

159 : value(value.length()? value: "0") {}

◆ ConstantDAG() [2/2]

MathDAG::ConstantDAG::ConstantDAG ( double  value)
inline

Definition at line 160 of file equations.h.

160 : value(str(value)) {}
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33

Member Function Documentation

◆ addEvalOps()

VariableValuePtr MathDAG::ConstantDAG::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 58 of file equations.cc.

References minsky::doOneEvent(), minsky::minsky(), minsky::VariableValues::resetValue(), minsky::VariableType::tempFlow, minsky::VariableType::undefined, and minsky::Minsky::variableValues.

59  {
60  if (result->idx()<0)
61  {
63  if (r->type()!=VariableType::undefined && r->isFlowVar())
64  {
65  result=r;
66  // set the initial value of the actual variableValue (if it exists)
67  auto v=values.find(result->valueId());
68  if (v!=values.end())
69  v->second->init(value);
70  }
71  else
72  {
74  result->allocValue();
75  }
76  result->init(value);
77  values.resetValue(*result);
78  }
79  if (r->type()!=VariableType::undefined && r->isFlowVar() && r!=result)
80  ev.emplace_back(EvalOpPtr(new TensorEval(r,result)));
81  assert(result->idx()>=0);
82  doOneEvent(true);
83  return result;
84  }
void doOneEvent(bool idletasksOnly)
checks if any GUI events are waiting, and proces an event if so
Definition: tclmain.cc:161
A helper to evaluate a variable value.
void resetValue(VariableValue &) const
reset a give variable value to it&#39;s initial condition, in this context
VariableValues variableValues
Definition: minsky.h:200
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
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
Here is the call graph for this function:

◆ BODMASlevel()

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

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

Implements MathDAG::Node.

Definition at line 161 of file equations.h.

161 {return 0;}

◆ derivative()

NodePtr MathDAG::ConstantDAG::derivative ( SystemOfEquations ) const
overridevirtual

support for the derivative operator.

Implements MathDAG::Node.

Definition at line 36 of file derivative.cc.

◆ latex()

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

writes LaTeX representation of this DAG to the stream

Implements MathDAG::Node.

Definition at line 164 of file equations.h.

164 {return o<<value;}

◆ matlab()

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

writes a matlab representation of this DAG to the stream

Implements MathDAG::Node.

Definition at line 165 of file equations.h.

165 {return o<<value;}

◆ order()

int MathDAG::ConstantDAG::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 162 of file equations.h.

162 {return 0;}

◆ render()

void MathDAG::ConstantDAG::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 214 of file equationDisplayRender.cc.

References minsky::latexToPango(), and MathDAG::anonymous_namespace{equationDisplayRender.cc}::print().

215  {
216  print(surf.cairo(), latexToPango(value),Anchor::nw);
217  }
std::string latexToPango(const char *s)
Definition: latexMarkup.h:30
double print(cairo_t *cairo, const string &text, Anchor anchor)
Here is the call graph for this function:

◆ tensorEval()

bool MathDAG::ConstantDAG::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 163 of file equations.h.

163 {return false;}

Member Data Documentation

◆ value

string MathDAG::ConstantDAG::value

Definition at line 158 of file equations.h.


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