mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 07:10:40 +01:00
[poincare] Fix evaluation
This commit is contained in:
@@ -13,11 +13,11 @@ public:
|
||||
typename EvaluationNode<T>::Type type() const override { return EvaluationNode<T>::Type::AllocationFailure; }
|
||||
bool isUndefined() const override { return true; }
|
||||
T toScalar() const override{ return NAN; }
|
||||
ExpressionReference complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const override;
|
||||
Expression complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const override;
|
||||
std::complex<T> trace() const override { return std::complex<T>(NAN); }
|
||||
std::complex<T> determinant() const override { return std::complex<T>(NAN); }
|
||||
EvaluationReference<T> inverse() const override { return ComplexReference<T>::Undefined(); }
|
||||
virtual EvaluationReference<T> transpose() const override { return ComplexReference<T>::Undefined(); }
|
||||
Evaluation<T> inverse() const override { return Complex<T>::Undefined(); }
|
||||
virtual Evaluation<T> transpose() const override { return Complex<T>::Undefined(); }
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(AllocationFailedEvaluationNode); }
|
||||
#if TREE_LOG
|
||||
@@ -26,13 +26,6 @@ public:
|
||||
bool isAllocationFailure() const override { return true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class AllocationFailedEvaluationReference : public EvaluationReference<T> {
|
||||
public:
|
||||
AllocationFailedEvaluationReference() : EvaluationReference<T>(TreePool::sharedPool()->createTreeNode<AllocationFailedEvaluationNode<T> >(), true) {}
|
||||
AllocationFailedEvaluationReference(TreeNode * n) : EvaluationReference<T>(n) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace Poincare {
|
||||
|
||||
template<typename T>
|
||||
class ComplexReference;
|
||||
class Complex;
|
||||
|
||||
template<typename T>
|
||||
class ComplexNode : public std::complex<T>, public EvaluationNode<T> {
|
||||
@@ -24,21 +24,20 @@ public:
|
||||
return (std::isnan(this->real()) && std::isnan(this->imag()));
|
||||
}
|
||||
T toScalar() const override;
|
||||
ExpressionReference complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const override;
|
||||
Expression complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const override;
|
||||
std::complex<T> trace() const override { return *this; }
|
||||
std::complex<T> determinant() const override { return *this; }
|
||||
EvaluationReference<T> inverse() const override;
|
||||
EvaluationReference<T> transpose() const override { return ComplexReference<T>(*this); }
|
||||
Evaluation<T> inverse() const override;
|
||||
Evaluation<T> transpose() const override { return Complex<T>(*this); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ComplexReference : public std::complex<T>, public EvaluationReference<T> {
|
||||
class Complex : public std::complex<T>, public Evaluation<T> {
|
||||
public:
|
||||
ComplexReference(TreeNode * t) : EvaluationReference<T>(t) {}
|
||||
ComplexReference(T a, T b = 0.0) : ComplexReference(std::complex<T>(a, b)) {}
|
||||
ComplexReference(std::complex<T> c);
|
||||
static ComplexReference<T> Undefined() {
|
||||
return ComplexReference<T>(NAN, NAN);
|
||||
Complex(T a, T b = 0.0) : Complex(std::complex<T>(a, b)) {}
|
||||
Complex(std::complex<T> c);
|
||||
static Complex<T> Undefined() {
|
||||
return Complex<T>(NAN, NAN);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
template<typename T>
|
||||
class Evaluation : public TreeByValue {
|
||||
public:
|
||||
//Evaluation(TreeNode * n, bool isCreatingNode = false) : TreeByValue(n, isCreatingNode) {}
|
||||
EvaluationNode<T> * node() const override {
|
||||
assert(!TreeByValue::node().isGhost());
|
||||
return static_cast<EvaluationNode<T> *>(TreeByValue::node());
|
||||
@@ -56,6 +55,7 @@ public:
|
||||
Evaluation inverse() const { return node()->inverse(); }
|
||||
Evaluation transpose() const { return node()->transpose(); }
|
||||
protected:
|
||||
//Evaluation(EvaluationNode * n) : TreeByValue(n) {}
|
||||
//Evaluation() : TreeByValue() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace Poincare {
|
||||
|
||||
class SerializableReference : virtual public TreeByReference {
|
||||
public:
|
||||
using TreeByReference::TreeByReference;
|
||||
|
||||
SerializableNode * node() const override { return static_cast<SerializableNode *>(TreeByReference::node()); }
|
||||
// Serialization
|
||||
bool needsParenthesisWithParent(SerializableReference parentRef) {
|
||||
@@ -25,7 +23,7 @@ public:
|
||||
// Tree
|
||||
SerializableReference serializableChildAtIndex(int i) {
|
||||
TreeByReference treeRefChild = TreeByReference::treeChildAtIndex(i);
|
||||
return SerializableReference(treeRefChild.node());
|
||||
return SerializableReference(static_cast<SerializableNode *>(treeRefChild.node()));
|
||||
}
|
||||
protected:
|
||||
SerializableReference(SerializableNode * n) : TreeByReference(n) {}
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
protected:
|
||||
/* Constructor */
|
||||
TreeByValue(TreeByReference t) : TreeByReference(node()) {}
|
||||
TreeByValue(TreeNode * n) : TreeByReference(n) {}
|
||||
|
||||
/* Hierarchy operations */
|
||||
// Add
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <poincare/allocation_failed_evaluation.h>
|
||||
#include <poincare/expression_reference.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/undefined.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<typename T>
|
||||
ExpressionReference AllocationFailedEvaluationNode<T>::complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const {
|
||||
return UndefinedReference();
|
||||
Expression AllocationFailedEvaluationNode<T>::complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const {
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/allocation_failed_evaluation.h>
|
||||
#include <poincare/expression_reference.h>
|
||||
#include <poincare/expression.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -12,7 +12,7 @@ TreeNode * EvaluationNode<T>::FailedAllocationStaticNode() {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ExpressionReference EvaluationReference<T>::complexToExpression(Preferences::ComplexFormat complexFormat) const {
|
||||
Expression Evaluation<T>::complexToExpression(Preferences::ComplexFormat complexFormat) const {
|
||||
return node()->complexToExpression(complexFormat);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user