mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 23:30:37 +01:00
[poincare] Remove old files
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
#ifndef POINCARE_BOUNDED_STATIC_HIERARCHY_H
|
||||
#define POINCARE_BOUNDED_STATIC_HIERARCHY_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<int T>
|
||||
class BoundedStaticHierarchy : public StaticHierarchy<T> {
|
||||
public:
|
||||
BoundedStaticHierarchy();
|
||||
BoundedStaticHierarchy(const Expression * expression, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2>
|
||||
BoundedStaticHierarchy(const Expression * expression1, const Expression * expression2, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2>
|
||||
BoundedStaticHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands = true);
|
||||
void setArgument(ListData * listData, int numberOfEntries, bool clone) override;
|
||||
int numberOfChildren() const override { return m_numberOfChildren; }
|
||||
bool hasValidNumberOfOperands(int numberOfChildren) const override;
|
||||
private:
|
||||
int m_numberOfChildren;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef POINCARE_BOUNDED_STATIC_LAYOUT_HIERARCHY_H
|
||||
#define POINCARE_BOUNDED_STATIC_LAYOUT_HIERARCHY_H
|
||||
|
||||
#include <poincare/static_layout_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<int T>
|
||||
class BoundedStaticLayoutHierarchy : public StaticLayoutHierarchy<T> {
|
||||
public:
|
||||
BoundedStaticLayoutHierarchy();
|
||||
BoundedStaticLayoutHierarchy(const ExpressionLayout * expressionLayout, bool cloneOperands); // Specialized constructor for StaticLayoutHierarchy<2>
|
||||
BoundedStaticLayoutHierarchy(const ExpressionLayout * expressionLayout1, const ExpressionLayout * expressionLayout2, bool cloneOperands); // Specialized constructor for StaticLayoutHierarchy<2>
|
||||
BoundedStaticLayoutHierarchy(const ExpressionLayout * const * operands, int numberOfChildren, bool cloneOperands);
|
||||
int numberOfChildren() const override { return m_numberOfChildren; }
|
||||
private:
|
||||
int m_numberOfChildren;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef POINCARE_DYNAMIC_HIERARCHY_H
|
||||
#define POINCARE_DYNAMIC_HIERARCHY_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/expression_array.h>
|
||||
#include <poincare/rational.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class DynamicHierarchy : public Expression {
|
||||
public:
|
||||
DynamicHierarchy();
|
||||
DynamicHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands);
|
||||
DynamicHierarchy(const Expression * operand1, const Expression * operand2, bool cloneOperands) :
|
||||
DynamicHierarchy(ExpressionArray(operand1, operand2).array(), 2, cloneOperands) {}
|
||||
~DynamicHierarchy();
|
||||
DynamicHierarchy(const DynamicHierarchy & other) = delete;
|
||||
DynamicHierarchy(DynamicHierarchy && other) = delete;
|
||||
DynamicHierarchy& operator=(const DynamicHierarchy & other) = delete;
|
||||
DynamicHierarchy& operator=(DynamicHierarchy && other) = delete;
|
||||
|
||||
int numberOfChildren() const override { return m_numberOfChildren; }
|
||||
const Expression * const * operands() const override { return m_operands; };
|
||||
|
||||
void removeOperand(const Expression * e, bool deleteAfterRemoval = true);
|
||||
void addOperands(const Expression * const * operands, int numberOfChildren);
|
||||
void addOperand(Expression * operand);
|
||||
void addOperandAtIndex(Expression * operand, int index);
|
||||
void mergeOperands(DynamicHierarchy * d);
|
||||
typedef int (*ExpressionOrder)(const Expression * e1, const Expression * e2, bool canBeInterrupted);
|
||||
void sortOperands(ExpressionOrder order, bool canBeInterrupted);
|
||||
Expression * squashUnaryHierarchy();
|
||||
protected:
|
||||
const Expression ** m_operands;
|
||||
int m_numberOfChildren;
|
||||
private:
|
||||
void removeOperandAtIndex(int i, bool deleteAfterRemoval);
|
||||
int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override;
|
||||
int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef POINCARE_STATIC_HIERARCHY_H
|
||||
#define POINCARE_STATIC_HIERARCHY_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/list_data.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<int T>
|
||||
class StaticHierarchy : public Expression {
|
||||
public:
|
||||
StaticHierarchy();
|
||||
StaticHierarchy(const Expression * const * operands, bool cloneOperands);
|
||||
StaticHierarchy(const Expression * expression, bool cloneOperands); // Specialized constructor for StaticHierarchy<1>
|
||||
StaticHierarchy(const Expression * expression1, const Expression * expression2, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2>
|
||||
~StaticHierarchy();
|
||||
StaticHierarchy(const StaticHierarchy & other) = delete;
|
||||
StaticHierarchy(StaticHierarchy && other) = delete;
|
||||
StaticHierarchy& operator=(const StaticHierarchy & other) = delete;
|
||||
StaticHierarchy& operator=(StaticHierarchy && other) = delete;
|
||||
|
||||
virtual void setArgument(ListData * listData, int numberOfEntries, bool clone);
|
||||
int numberOfChildren() const override { return T; }
|
||||
const Expression * const * operands() const override { return m_operands; }
|
||||
virtual bool hasValidNumberOfOperands(int numberOfChildren) const;
|
||||
protected:
|
||||
void build(const Expression * const * operands, int numberOfChildren, bool cloneOperands);
|
||||
int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override;
|
||||
const Expression * m_operands[T];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,48 +0,0 @@
|
||||
#include <poincare/bounded_static_hierarchy.h>
|
||||
#include <poincare/expression_array.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<int T>
|
||||
BoundedStaticHierarchy<T>::BoundedStaticHierarchy() :
|
||||
StaticHierarchy<T>(),
|
||||
m_numberOfChildren(0)
|
||||
{
|
||||
}
|
||||
|
||||
template<int T>
|
||||
BoundedStaticHierarchy<T>::BoundedStaticHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands) :
|
||||
m_numberOfChildren(numberOfChildren)
|
||||
{
|
||||
StaticHierarchy<T>::build(operands, numberOfChildren, cloneOperands);
|
||||
}
|
||||
|
||||
template<>
|
||||
BoundedStaticHierarchy<2>::BoundedStaticHierarchy(const Expression * e1, const Expression * e2, bool cloneOperands) :
|
||||
BoundedStaticHierarchy(ExpressionArray(e1, e2).array(), 2, cloneOperands)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
BoundedStaticHierarchy<2>::BoundedStaticHierarchy(const Expression * e, bool cloneOperands) :
|
||||
BoundedStaticHierarchy((Expression **)&e, 1, cloneOperands)
|
||||
{
|
||||
}
|
||||
|
||||
template<int T>
|
||||
void BoundedStaticHierarchy<T>::setArgument(ListData * listData, int numberOfChildren, bool clone) {
|
||||
StaticHierarchy<T>::setArgument(listData, numberOfChildren, clone);
|
||||
m_numberOfChildren = listData->numberOfChildren();
|
||||
}
|
||||
|
||||
template<int T>
|
||||
bool BoundedStaticHierarchy<T>::hasValidNumberOfOperands(int numberOfChildren) const {
|
||||
return numberOfChildren >= 1 && numberOfChildren <= T;
|
||||
}
|
||||
|
||||
template class Poincare::BoundedStaticHierarchy<2>;
|
||||
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
#include <poincare/dynamic_hierarchy.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
DynamicHierarchy::DynamicHierarchy() :
|
||||
Expression(),
|
||||
m_operands(nullptr),
|
||||
m_numberOfChildren(0)
|
||||
{
|
||||
}
|
||||
|
||||
DynamicHierarchy::DynamicHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands) :
|
||||
Expression(),
|
||||
m_numberOfChildren(numberOfChildren)
|
||||
{
|
||||
assert(operands != nullptr);
|
||||
m_operands = new const Expression * [numberOfChildren];
|
||||
for (int i=0; i<numberOfChildren; i++) {
|
||||
assert(operands[i] != nullptr);
|
||||
if (cloneOperands) {
|
||||
m_operands[i] = operands[i]->clone();
|
||||
} else {
|
||||
m_operands[i] = operands[i];
|
||||
}
|
||||
const_cast<Expression *>(m_operands[i])->setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicHierarchy::~DynamicHierarchy() {
|
||||
if (m_operands != nullptr) {
|
||||
for (int i = 0; i < m_numberOfChildren; i++) {
|
||||
if (m_operands[i] != nullptr) {
|
||||
delete m_operands[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] m_operands;
|
||||
}
|
||||
|
||||
void DynamicHierarchy::addOperands(const Expression * const * operands, int numberOfChildren) {
|
||||
assert(numberOfChildren > 0);
|
||||
const Expression ** newOperands = new const Expression * [m_numberOfChildren+numberOfChildren];
|
||||
for (int i=0; i<m_numberOfChildren; i++) {
|
||||
newOperands[i] = m_operands[i];
|
||||
}
|
||||
for (int i=0; i<numberOfChildren; i++) {
|
||||
const_cast<Expression *>(operands[i])->setParent(this);
|
||||
newOperands[i+m_numberOfChildren] = operands[i];
|
||||
}
|
||||
delete[] m_operands;
|
||||
m_operands = newOperands;
|
||||
m_numberOfChildren += numberOfChildren;
|
||||
}
|
||||
|
||||
void DynamicHierarchy::mergeOperands(DynamicHierarchy * d) {
|
||||
removeOperand(d, false);
|
||||
addOperands(d->operands(), d->numberOfChildren());
|
||||
d->detachOperands();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void DynamicHierarchy::addOperand(Expression * operand) {
|
||||
addOperandAtIndex(operand, m_numberOfChildren);
|
||||
}
|
||||
|
||||
void DynamicHierarchy::addOperandAtIndex(Expression * operand, int index) {
|
||||
assert(index >= 0 && index <= m_numberOfChildren);
|
||||
const Expression ** newOperands = new const Expression * [m_numberOfChildren+1];
|
||||
int j = 0;
|
||||
for (int i=0; i<=m_numberOfChildren; i++) {
|
||||
if (i == index) {
|
||||
operand->setParent(this);
|
||||
newOperands[i] = operand;
|
||||
} else {
|
||||
newOperands[i] = m_operands[j++];
|
||||
}
|
||||
}
|
||||
delete[] m_operands;
|
||||
m_operands = newOperands;
|
||||
m_numberOfChildren += 1;
|
||||
}
|
||||
|
||||
void DynamicHierarchy::removeOperand(const Expression * e, bool deleteAfterRemoval) {
|
||||
for (int i=0; i<numberOfChildren(); i++) {
|
||||
if (operand(i) == e) {
|
||||
removeOperandAtIndex(i, deleteAfterRemoval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void DynamicHierarchy::sortOperands(ExpressionOrder order, bool canBeInterrupted) {
|
||||
for (int i = numberOfChildren()-1; i > 0; i--) {
|
||||
bool isSorted = true;
|
||||
for (int j = 0; j < numberOfChildren()-1; j++) {
|
||||
/* Warning: Matrix operations are not always commutative (ie,
|
||||
* multiplication) so we never swap 2 matrices. */
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (order(operand(j), operand(j+1), canBeInterrupted) > 0 && (!operand(j)->recursivelyMatches(Expression::IsMatrix) || !operand(j+1)->recursivelyMatches(Expression::IsMatrix))) {
|
||||
#else
|
||||
if (order(operand(j), operand(j+1), canBeInterrupted) > 0) {
|
||||
#endif
|
||||
swapOperands(j, j+1);
|
||||
isSorted = false;
|
||||
}
|
||||
}
|
||||
if (isSorted) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Expression * DynamicHierarchy::squashUnaryHierarchy() {
|
||||
if (numberOfChildren() == 1) {
|
||||
assert(parent() != nullptr);
|
||||
Expression * o = editableOperand(0);
|
||||
replaceWith(o, true);
|
||||
return o;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
void DynamicHierarchy::removeOperandAtIndex(int i, bool deleteAfterRemoval) {
|
||||
if (deleteAfterRemoval) {
|
||||
delete m_operands[i];
|
||||
} else {
|
||||
const_cast<Expression *>(m_operands[i])->setParent(nullptr);
|
||||
}
|
||||
m_numberOfChildren--;
|
||||
for (int j=i; j<m_numberOfChildren; j++) {
|
||||
m_operands[j] = m_operands[j+1];
|
||||
}
|
||||
}
|
||||
|
||||
int DynamicHierarchy::simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const {
|
||||
int m = this->numberOfChildren();
|
||||
int n = e->numberOfChildren();
|
||||
for (int i = 1; i <= m; i++) {
|
||||
// The NULL node is the least node type.
|
||||
if (n < i) {
|
||||
return 1;
|
||||
}
|
||||
int order = SimplificationOrder(this->operand(m-i), e->operand(n-i), canBeInterrupted);
|
||||
if (order != 0) {
|
||||
return order;
|
||||
}
|
||||
}
|
||||
// The NULL node is the least node type.
|
||||
if (n > m) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DynamicHierarchy::simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const {
|
||||
int m = numberOfChildren();
|
||||
if (m == 0) {
|
||||
return -1;
|
||||
}
|
||||
/* Compare e to last term of hierarchy. */
|
||||
int order = SimplificationOrder(operand(m-1), e, canBeInterrupted);
|
||||
if (order != 0) {
|
||||
return order;
|
||||
}
|
||||
if (m > 1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/expression_array.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template<int T>
|
||||
StaticHierarchy<T>::StaticHierarchy() :
|
||||
Expression(),
|
||||
m_operands{}
|
||||
{
|
||||
}
|
||||
|
||||
template<int T>
|
||||
StaticHierarchy<T>::StaticHierarchy(const Expression * const * operands, bool cloneOperands) :
|
||||
Expression()
|
||||
{
|
||||
build(operands, T, cloneOperands);
|
||||
}
|
||||
|
||||
template<>
|
||||
StaticHierarchy<1>::StaticHierarchy(const Expression * e, bool cloneOperands) :
|
||||
StaticHierarchy((Expression **)&e, cloneOperands)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
StaticHierarchy<2>::StaticHierarchy(const Expression * e1, const Expression * e2, bool cloneOperands) :
|
||||
StaticHierarchy(ExpressionArray(e1, e2).array(), cloneOperands)
|
||||
{
|
||||
}
|
||||
|
||||
template<int T>
|
||||
StaticHierarchy<T>::~StaticHierarchy() {
|
||||
for (int i = 0; i < T; i++) {
|
||||
if (m_operands[i] != nullptr) {
|
||||
delete m_operands[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<int T>
|
||||
void StaticHierarchy<T>::setArgument(ListData * listData, int numberOfChildren, bool clone) {
|
||||
build(listData->operands(), listData->numberOfChildren(), clone);
|
||||
}
|
||||
|
||||
template<int T>
|
||||
bool StaticHierarchy<T>::hasValidNumberOfOperands(int numberOfChildren) const {
|
||||
return numberOfChildren == T;
|
||||
}
|
||||
|
||||
template<int T>
|
||||
void StaticHierarchy<T>::build(const Expression * const * operands, int numberOfChildren, bool cloneOperands) {
|
||||
assert(operands != nullptr);
|
||||
assert(numberOfChildren <= T);
|
||||
for (int i=0; i < numberOfChildren; i++) {
|
||||
assert(operands[i] != nullptr);
|
||||
if (cloneOperands) {
|
||||
m_operands[i] = operands[i]->clone();
|
||||
} else {
|
||||
m_operands[i] = operands[i];
|
||||
}
|
||||
const_cast<Expression *>(m_operands[i])->setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<int T>
|
||||
int StaticHierarchy<T>::simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const {
|
||||
for (int i = 0; i < this->numberOfChildren(); i++) {
|
||||
// The NULL node is the least node type.
|
||||
if (e->numberOfChildren() <= i) {
|
||||
return 1;
|
||||
}
|
||||
if (SimplificationOrder(this->operand(i), e->operand(i), canBeInterrupted) != 0) {
|
||||
return SimplificationOrder(this->operand(i), e->operand(i), canBeInterrupted);
|
||||
}
|
||||
}
|
||||
// The NULL node is the least node type.
|
||||
if (e->numberOfChildren() > numberOfChildren()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template class Poincare::StaticHierarchy<0>;
|
||||
template class Poincare::StaticHierarchy<1>;
|
||||
template class Poincare::StaticHierarchy<2>;
|
||||
template class Poincare::StaticHierarchy<3>;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user