bpp-phyl3  3.0.0
HmmLikelihoodComputation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_HMMLIKELIHOODCOMPUTATION_H
6 #define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_HMMLIKELIHOODCOMPUTATION_H
7 
10 #include <Bpp/Numeric/NumTools.h>
11 
12 #include "../DataFlow/TransitionMatrix.h"
14 
15 // From the STL:
16 #include <vector>
17 #include <memory>
18 
19 namespace bpp
20 {
21 class CondLikelihood : public Value<Eigen::MatrixXd>
22 {
23 private:
30 
31 public:
33  {
34  // Check dependencies
36  checkDependencyVectorSize (typeid (CondLikelihood), deps, 2);
37 
38  // dependency on the name, to make objects different
39  checkNthDependencyIsValue<std::string>(typeid(CondLikelihood), deps, 1);
40 
41  return cachedAs<Value<Eigen::MatrixXd>>(c, std::make_shared<CondLikelihood>(std::move (deps), dim));
42  }
43 
45  : Value<Eigen::MatrixXd>(std::move (deps)), targetDimension_ (dim)
46  {
47  this->accessValueMutable().resize(dim.rows, dim.cols);
48  }
49 
50  std::string debugInfo () const override
51  {
52  using namespace numeric;
53  const auto name = accessValueConstCast<std::string>(*this->dependency (1));
54  return debug (this->accessValueConst ()) + " targetDim=" + to_string (targetDimension_) + ":name= " + name;
55  }
56 
57  // ForwardHmmLikelihood_DF additional arguments = ().
58  bool compareAdditionalArguments (const Node_DF& other) const final
59  {
60  return dynamic_cast<const CondLikelihood*>(&other) != nullptr;
61  }
62 
63  NodeRef derive (Context& c, const Node_DF& node) final
64  {
65  // NodeRef derivNode = this->dependency (3);
66  // const auto nDeriv = accessValueConstCast<size_t> (*derivNode);
67 
68  throw Exception("CondLikelihood::derive is done in dependency class.");
69  }
70 
71  NodeRef recreate (Context& c, NodeRefVec&& deps) final
72  {
73  return CondLikelihood::create (c, std::move (deps), targetDimension_);
74  }
75 
76  Eigen::MatrixXd& getCondLikelihood()
77  {
78  return this->accessValueMutable();
79  }
80 
81  const Eigen::MatrixXd& getCondLikelihood() const
82  {
83  return this->accessValueConst();
84  }
85 
86 private:
87  // Nothing happens here, computation is done in ForwardHmmLikelihood_DF class
88  void compute() override {}
89 
93 };
94 
95 /*
96  * Computation of Forward Likelihood Arrays
97  *
98  *
99  * Dependencies are:
100  * Value<VectorXd> : Starting vector of states probabililies
101  * Value<MatrixXd> : TransitionMatrix
102  * Value<MatrixLik> : Matrix of Emission likelihoods states X sites
103  *
104  * After computation, its value stores the conditional forward
105  * likelihoods of the sites, P(x_j|x_1,...,x_{j-1}), where the x are
106  * the observed states.
107  *
108  * The conditional matrix of the likelihoods per hidden state
109  * Pr(x_1...x_j, y_j=i)/Pr(x_1...x_j) (with y the hidden states), is
110  * stored, available through getForwardCondLikelihood.
111  *
112  */
113 
114 class ForwardHmmLikelihood_DF : public Value<RowLik>
115 {
116 private:
117  /*
118  * @brief conditional forward likelihoods : Will be used by
119  * backward likelihoods computation.
120  *
121  * condLik_(i,j) corresponds to @f$Pr(x_1...x_j, y_j=i)/Pr(x_1...x_j)@f$,
122  * where the x are the observed states, and y the hidden states.
123  *
124  * @f$ \sum_i \text{condLik\_(i,j)} = 1 @f$
125  */
126 
128 
129  /*
130  * @brief Conditional partial likelihood, used for computation.
131  *
132  * parCondLik_(i,j) corresponds to Pr(x_1...x_j, y_{j+1}=i)/Pr(x_1...x_j),
133  * where the x are the observed states, and y the hidden states.
134  *
135  * @f$ \sum_i \text{parCondLik\_(i,j)} = 1 @f$
136  */
137 
138  std::vector<Eigen::VectorXd> parCondLik_;
139 
140  /*
141  * @brief Dimension of the data : states X sites
142  *
143  */
144 
146 
147 public:
149 
151  {
152  // Check dependencies
153  checkDependenciesNotNull (typeid (Self), deps);
154  checkDependencyVectorSize (typeid (Self), deps, 3);
155 
156  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 0);
157  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 1);
158  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 2);
159 
160  auto sself = std::make_shared<Self>(std::move (deps), dim);
161  sself->build(c);
162 
163  return cachedAs<Value<RowLik>>(c, sself);
164  }
165 
167  : Value<RowLik>(std::move (deps)), condLik_(), parCondLik_((size_t)dim.cols), targetDimension_ (dim)
168  {
169  for (auto& v:parCondLik_)
170  {
171  v.resize(dim.rows);
172  }
173 
174  this->accessValueMutable().resize(targetDimension_.cols);
175  }
176 
177  void build(Context& c)
178  {
179  auto fname = NumericConstant<std::string>::create(c, "forwardCondLik");
180 
181  condLik_ = CondLikelihood::create(c, {this->shared_from_this(), fname}, targetDimension_);
182 
183  const auto& hmmEq = dynamic_pointer_cast<Value<Eigen::VectorXd>>(this->dependency(0))->targetValue();
184 
185  if (hmmEq.rows() != targetDimension_.rows)
186  throw BadSizeException("ForwardHmmLikelihood_DF: bad dimension for starting vector", size_t(hmmEq.rows()), size_t(targetDimension_.rows));
187 
188  const auto& hmmTrans = dynamic_pointer_cast<Value<Eigen::MatrixXd>>(this->dependency(1))->targetValue();
189 
190  if (hmmTrans.cols() != hmmTrans.rows())
191  throw BadSizeException("ForwardHmmLikelihood_DF: Transition matrix should be square", size_t(hmmTrans.cols()), size_t(hmmTrans.rows()));
192  if (hmmTrans.rows() != targetDimension_.rows)
193  throw BadSizeException("ForwardHmmLikelihood_DF: bad number of rows for transition matrix", size_t(hmmTrans.rows()), size_t(targetDimension_.rows));
194 
195  const auto& hmmEmis = dynamic_pointer_cast<Value<MatrixLik>>(this->dependency(2))->targetValue();
196 
197  if (hmmEmis.rows() != targetDimension_.rows)
198  throw BadSizeException("ForwardHmmLikelihood_DF: bad number of states for emission matrix", size_t(hmmEmis.rows()), size_t(targetDimension_.rows));
199  if (hmmEmis.cols() != targetDimension_.cols)
200  throw BadSizeException("ForwardHmmLikelihood_DF: bad number of sites for emission matrix", size_t(hmmEmis.cols()), size_t(targetDimension_.cols));
201  }
202 
203  std::string debugInfo () const override
204  {
205  using namespace numeric;
206  return debug (this->accessValueConst ()) + " targetDim=" + to_string (targetDimension_);
207  }
208 
209  // ForwardHmmLikelihood_DF additional arguments = ().
210  bool compareAdditionalArguments (const Node_DF& other) const final
211  {
212  return dynamic_cast<const Self*>(&other) != nullptr;
213  }
214 
215  NodeRef derive (Context& c, const Node_DF& node) final;
216 
217  NodeRef recreate (Context& c, NodeRefVec&& deps) final
218  {
219  return Self::create (c, std::move (deps), targetDimension_);
220  }
221 
223  {
224  return condLik_;
225  }
226 
227  const std::vector<Eigen::VectorXd>& getParCondLik() const
228  {
229  return parCondLik_;
230  }
231 
232 private:
233  void compute() override;
234 };
235 
236 
237 /*
238  * Computation of 1st order Derived Forward Likelihood Arrays
239  *
240  * Dependencies are:
241  * Value<VectorXd> : Starting vector of states probabililies
242  * Value<MatrixXd> : TransitionMatrix
243  * Value<MatrixLik> : Matrix of Emission likelihoods states X sites
244  *
245  * ForwardHmmLikelihood_DF : Forward Computations
246  *
247  * Value<VectorXd> : Derivatives of starting vector of states probabililies
248  * Value<MatrixXd> : Derivatives of TransitionMatrix
249  * Value<MatrixLik> : Derivatives Matrix of Emission likelihoods states X sites
250  *
251  * After computation, its value stores the derivates of the
252  * conditional forward likelihoods of the sites,
253  * dP(x_j|x_1,...,x_{j-1}), where the x are the observed states.
254  *
255  * The derivates of the conditional matrix of the likelihoods per hidden state
256  * d(Pr(x_1...x_j, y_j=i)/Pr(x_1...x_j)) (with y the hidden states), is
257  * stored, available through getForwardDCondLikelihood.
258  *
259  */
260 
261 
262 class ForwardHmmDLikelihood_DF : public Value<RowLik>
263 {
264 private:
275 
276  /*
277  * @brief Conditional partial likelihood derivatives, used for
278  * computation.
279  *
280  */
281 
282  std::vector<Eigen::VectorXd> dParCondLik_;
283 
290 
291 public:
293 
295  {
296  // Check dependencies
297  checkDependenciesNotNull (typeid (Self), deps);
298  checkDependencyVectorSize (typeid (Self), deps, 7);
299 
300  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 0);
301  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 1);
302  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 2);
303 
304  checkNthDependencyIs<ForwardHmmLikelihood_DF>(typeid (Self), deps, 3);
305 
306  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 4);
307  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 5);
308  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 6);
309 
310  auto sself = std::make_shared<Self>(std::move (deps), dim);
311  sself->build(c);
312 
313  return cachedAs<Value<RowLik>>(c, sself);
314  }
315 
317  : Value<RowLik>(std::move (deps)), dCondLik_(), dParCondLik_((size_t)dim.cols), targetDimension_ (dim)
318  {
319  for (auto& v:dParCondLik_)
320  {
321  v.resize(dim.rows);
322  }
323  this->accessValueMutable().resize(targetDimension_.cols);
324  }
325 
326  void build(Context& c)
327  {
328  auto fname = NumericConstant<std::string>::create(c, "forwardDcondLik");
329 
330  dCondLik_ = CondLikelihood::create(c, {this->shared_from_this(), fname}, targetDimension_);
331  }
332 
333  std::string debugInfo () const override
334  {
335  using namespace numeric;
336  return debug (this->accessValueConst ()) + " targetDim=" + to_string (targetDimension_);
337  }
338 
339  // ForwardHmmDLikelihood_DF additional arguments = ().
340  bool compareAdditionalArguments (const Node_DF& other) const final
341  {
342  return dynamic_cast<const Self*>(&other) != nullptr;
343  }
344 
345  NodeRef derive (Context& c, const Node_DF& node) final;
346 
347  NodeRef recreate (Context& c, NodeRefVec&& deps) final
348  {
349  return Self::create (c, std::move (deps), targetDimension_);
350  }
351 
353  {
354  return dCondLik_;
355  }
356 
357  const std::vector<Eigen::VectorXd>& getParDCondLik() const
358  {
359  return dParCondLik_;
360  }
361 
362 private:
363  void compute() override;
364 };
365 
366 /*
367  * Computation of 2nd order Derived Forward Likelihood Arrays
368  *
369  * Dependencies are:
370  * Value<VectorXd> : Starting vector of states probabililies
371  * Value<MatrixXd> : TransitionMatrix
372  * Value<MatrixLik> : Matrix of Emission likelihoods states X sites
373  *
374  * ForwardHmmLikelihood_DF : Forward Computations
375  *
376  * Value<VectorXd> : 1st Derivatives of starting vector of states probabililies
377  * Value<MatrixXd> : 1st Derivatives of TransitionMatrix
378  * Value<MatrixLik> : 1st Derivatives Matrix of Emission likelihoods states X sites
379  *
380  * ForwardHmmDLikelihood_DF : 1st order derivatives Forward Computations
381  *
382  * Value<VectorXd> : 2nd Derivatives of starting vector of states probabililies
383  * Value<MatrixXd> : 2nd Derivatives of TransitionMatrix
384  * Value<MatrixLik> : 2nd Derivatives Matrix of Emission likelihoods states X sites
385  *
386  * After computation, its value stores the 2nd derivates of the
387  * conditional forward likelihoods of the sites,
388  * d2P(x_j|x_1,...,x_{j-1}), where the x are the observed states.
389  *
390  * The derivates of the conditional matrix of the likelihoods per hidden state
391  * d(Pr(x_1...x_j, y_j=i)/Pr(x_1...x_j)) (with y the hidden states), is
392  * stored, available through getForwardCondLikelihood.
393  *
394  */
395 
396 
397 class ForwardHmmD2Likelihood_DF : public Value<RowLik>
398 {
399 private:
410 
417 
418 public:
420 
422  {
423  // Check dependencies
424  checkDependenciesNotNull (typeid (Self), deps);
425  checkDependencyVectorSize (typeid (Self), deps, 11);
426 
427  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 0);
428  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 1);
429  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 2);
430 
431  checkNthDependencyIs<ForwardHmmLikelihood_DF>(typeid (Self), deps, 3);
432 
433  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 4);
434  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 5);
435  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 6);
436 
437  checkNthDependencyIs<ForwardHmmDLikelihood_DF>(typeid (Self), deps, 7);
438 
439  checkNthDependencyIsValue<Eigen::VectorXd>(typeid (Self), deps, 8);
440  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 9);
441  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 10);
442 
443  auto sself = std::make_shared<Self>(std::move (deps), dim);
444  sself->build(c);
445 
446  return cachedAs<Value<RowLik>>(c, sself);
447  }
448 
450  : Value<RowLik>(std::move (deps)), d2CondLik_(), targetDimension_ (dim)
451  {
452  this->accessValueMutable().resize(targetDimension_.cols);
453  }
454 
455  void build(Context& c)
456  {
457  auto fname = NumericConstant<std::string>::create(c, "forwardD2condLik");
458 
459  d2CondLik_ = CondLikelihood::create(c, {this->shared_from_this(), fname}, targetDimension_);
460  }
461 
462  std::string debugInfo () const override
463  {
464  using namespace numeric;
465  return debug (this->accessValueConst ()) + " targetDim=" + to_string (targetDimension_);
466  }
467 
468  // ForwardHmmD2Likelihood_DF additional arguments = ().
469  bool compareAdditionalArguments (const Node_DF& other) const final
470  {
471  return dynamic_cast<const Self*>(&other) != nullptr;
472  }
473 
474  NodeRef derive (Context& c, const Node_DF& node) final
475  {
476  throw Exception("ForwardHmmD2Likelihood_DF::derive not implemented.");
477  }
478 
479  NodeRef recreate (Context& c, NodeRefVec&& deps) final
480  {
481  return Self::create (c, std::move (deps), targetDimension_);
482  }
483 
484 private:
485  void compute() override;
486 };
487 
488 
490 
491 /*
492  * Computation of Backward Likelihood Arrays
493  *
494  *
495  * Dependencies are:
496  * Value<RowLik> : Vector of conditional Forward Likelihoods
497  * Value<MatrixXd> : TransitionMatrix
498  * Value<MatrixLik> : Matrix of Emission likelihoods states X sites
499  * Value<size_t> : level of derivation
500  *
501  * After computation, stores the conditional likelihoods of the
502  * sites for all states.
503  */
504 
505 class BackwardHmmLikelihood_DF : public Value<Eigen::MatrixXd>
506 {
507 private:
525 
526 public:
528 
530  {
531  // Check dependencies
532  checkDependenciesNotNull (typeid (Self), deps);
533  checkDependencyVectorSize (typeid (Self), deps, 3);
534 
535  checkNthDependencyIsValue<RowLik>(typeid (Self), deps, 0);
536  checkNthDependencyIsValue<Eigen::MatrixXd>(typeid (Self), deps, 1);
537  checkNthDependencyIsValue<MatrixLik>(typeid (Self), deps, 2);
538 
539  return cachedAs<Value<Eigen::MatrixXd>>(c, std::make_shared<Self>(std::move (deps), dim));
540  }
541 
543  : Value<Eigen::MatrixXd>(std::move (deps)), targetDimension_ (dim)
544  {
545  this->accessValueMutable().resize(dim.rows, dim.cols);
546 
547  const auto& hmmScale = accessValueConstCast<RowLik>(*this->dependency(0));
548  if (hmmScale.cols() != dim.cols)
549  throw BadSizeException("BackwardHmmLikelihood_DF: bad dimension for forward likelihoods vector", size_t(hmmScale.cols()), size_t(dim.cols));
550 
551 
552  const auto& hmmTrans = accessValueConstCast<Eigen::MatrixXd>(*this->dependency(1));
553  if (hmmTrans.cols() != dim.rows)
554  throw BadSizeException("BackwardHmmLikelihood_DF: bad size for transition matrix", size_t(hmmTrans.cols()), size_t(dim.rows));
555 
556  const auto& hmmEmis = accessValueConstCast<MatrixLik>(*this->dependency(2));
557  if (hmmEmis.rows() != dim.rows)
558  throw BadSizeException("BackwardHmmLikelihood_DF: bad number of states for emission matrix", size_t(hmmEmis.rows()), size_t(dim.rows));
559  if (hmmEmis.cols() != dim.cols)
560  throw BadSizeException("BackwardHmmLikelihood_DF: bad number of sites for emission matrix", size_t(hmmEmis.cols()), size_t(dim.cols));
561  }
562 
563  std::string debugInfo () const override
564  {
565  using namespace numeric;
566  return debug (this->accessValueConst ()) + " targetDim=" + to_string (targetDimension_);
567  }
568 
569  // BackwardHmmLikelihood_DF additional arguments = ().
570  bool compareAdditionalArguments (const Node_DF& other) const final
571  {
572  return dynamic_cast<const Self*>(&other) != nullptr;
573  }
574 
575  NodeRef derive (Context& c, const Node_DF& node) final
576  {
577  // NodeRef derivNode = this->dependency (3);
578  // const auto nDeriv = accessValueConstCast<size_t> (*derivNode);
579 
580  throw Exception("BackwardHmmLikelihood_DF::derive To be finished.");
581 
582  return Self::create (c, {this->dependency(0)->derive (c, node)}, targetDimension_);
583  }
584 
585  NodeRef recreate (Context& c, NodeRefVec&& deps) final
586  {
587  return Self::create (c, std::move (deps), targetDimension_);
588  }
589 
590 private:
591  void compute() override;
592 };
593 }
594 #endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_HMMLIKELIHOODCOMPUTATION_H
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Dimension< Eigen::MatrixXd > targetDimension_
backward likelihood
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
static ValueRef< Eigen::MatrixXd > create(Context &c, NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
BackwardHmmLikelihood_DF(NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
Dimension< Eigen::MatrixXd > targetDimension_
Dimension of the data : states X sites.
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
static ValueRef< Eigen::MatrixXd > create(Context &c, NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
CondLikelihood(NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
Eigen::MatrixXd & getCondLikelihood()
void compute() override
Computation implementation.
friend class ForwardHmmD2Likelihood_DF
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
const Eigen::MatrixXd & getCondLikelihood() const
Context for dataflow node construction.
Definition: DataFlow.h:527
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
Dimension< Eigen::MatrixXd > targetDimension_
Dimension of the data : states X sites.
ValueRef< Eigen::MatrixXd > d2CondLik_
derivatives of the conditional forward likelihoods : Will be used by backward likelihoods computation...
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
static ValueRef< RowLik > create(Context &c, NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
ForwardHmmD2Likelihood_DF(NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
NodeRef derive(Context &c, const Node_DF &node) final
Returns a node computing d(this_node_expression)/d(node_expression).
Dimension< Eigen::MatrixXd > targetDimension_
Dimension of the data : states X sites.
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
const std::vector< Eigen::VectorXd > & getParDCondLik() const
std::vector< Eigen::VectorXd > dParCondLik_
ForwardHmmDLikelihood_DF(NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
ValueRef< Eigen::MatrixXd > getForwardDCondLikelihood() const
static ValueRef< RowLik > create(Context &c, NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
ValueRef< Eigen::MatrixXd > dCondLik_
derivatives of the conditional forward likelihoods : Will be used by likelihoods computation of 2nd o...
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
ValueRef< Eigen::MatrixXd > getForwardCondLikelihood() const
Dimension< Eigen::MatrixXd > targetDimension_
const std::vector< Eigen::VectorXd > & getParCondLik() const
std::string debugInfo() const override
Node debug info (default = ""): user defined detailed info for DF graph debug.
NodeRef recreate(Context &c, NodeRefVec &&deps) final
Recreate the node with different dependencies.
bool compareAdditionalArguments(const Node_DF &other) const final
Compare node-specific configuration to another.
std::vector< Eigen::VectorXd > parCondLik_
ValueRef< Eigen::MatrixXd > condLik_
static ValueRef< RowLik > create(Context &c, NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
ForwardHmmLikelihood_DF(NodeRefVec &&deps, const Dimension< Eigen::MatrixXd > &dim)
Base dataflow Node class.
Definition: DataFlow.h:152
const NodeRef & dependency(std::size_t i) const noexcept
Definition: DataFlow.h:185
static std::shared_ptr< Self > create(Context &c, Args &&... args)
Build a new NumericConstant node with T(args...) value.
Abstract Node storing a value of type T.
Definition: DataFlow.h:352
const Eigen::MatrixXd & accessValueConst() const noexcept
Raw value access (const).
Definition: DataFlow.h:385
const Eigen::MatrixXd & targetValue()
Access value, recompute if needed.
Definition: DataFlow.h:374
Eigen::MatrixXd & accessValueMutable() noexcept
Definition: DataFlow.h:416
std::string debug(const T &t, typename std::enable_if< std::is_arithmetic< T >::value >::type *=0)
Defines the basic types of data flow nodes.
std::shared_ptr< Value< T > > ValueRef
Shared pointer alias for Value<T>.
Definition: DataFlow.h:84
void checkDependenciesNotNull(const std::type_info &contextNodeType, const NodeRefVec &deps)
Checks that all dependencies are not null, throws if not.
Definition: DataFlow.cpp:103
std::string to_string(const NoDimension &)
std::vector< NodeRef > NodeRefVec
Alias for a dependency vector (of NodeRef).
Definition: DataFlow.h:81
void checkDependencyVectorSize(const std::type_info &contextNodeType, const NodeRefVec &deps, std::size_t expectedSize)
Definition: DataFlow.cpp:83
std::shared_ptr< Node_DF > NodeRef
Definition: DataFlow.h:78