mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Merge "[poincare] Change name: product->multiplication"
This commit is contained in:
@@ -23,12 +23,12 @@ objs += $(addprefix poincare/src/,\
|
||||
logarithm.o\
|
||||
matrix.o\
|
||||
matrix_data.o\
|
||||
multiplication.o\
|
||||
n_context.o\
|
||||
nth_root.o\
|
||||
opposite.o\
|
||||
parenthesis.o\
|
||||
power.o\
|
||||
product.o\
|
||||
sine.o\
|
||||
subtraction.o\
|
||||
sum.o\
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
#include <poincare/logarithm.h>
|
||||
#include <poincare/matrix.h>
|
||||
#include <poincare/matrix_data.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/n_context.h>
|
||||
#include <poincare/nth_root.h>
|
||||
#include <poincare/opposite.h>
|
||||
#include <poincare/parenthesis.h>
|
||||
#include <poincare/power.h>
|
||||
#include <poincare/product.h>
|
||||
#include <poincare/sine.h>
|
||||
#include <poincare/subtraction.h>
|
||||
#include <poincare/sum.h>
|
||||
|
||||
@@ -19,12 +19,12 @@ class Expression {
|
||||
Integral,
|
||||
Logarithm,
|
||||
Matrix,
|
||||
Multiplication,
|
||||
NthRoot,
|
||||
Opposite,
|
||||
Fraction,
|
||||
Parenthesis,
|
||||
Power,
|
||||
Product,
|
||||
Sine,
|
||||
Sum,
|
||||
Subtraction,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef POINCARE_PRODUCT_H
|
||||
#define POINCARE_PRODUCT_H
|
||||
#ifndef POINCARE_MULTIPLICATION_H
|
||||
#define POINCARE_MULTIPLICATION_H
|
||||
|
||||
#include <poincare/binary_operation.h>
|
||||
#include <poincare/float.h>
|
||||
#include <poincare/matrix.h>
|
||||
|
||||
class Product : public BinaryOperation {
|
||||
class Multiplication : public BinaryOperation {
|
||||
using BinaryOperation::BinaryOperation;
|
||||
public:
|
||||
Type type() const override;
|
||||
@@ -121,7 +121,7 @@ exp:
|
||||
| SYMBOL { $$ = new Symbol($1); }
|
||||
| exp PLUS exp { Expression * terms[2] = {$1,$3}; $$ = new Addition(terms, 2, false); }
|
||||
| exp MINUS exp { Expression * terms[2] = {$1,$3}; $$ = new Subtraction(terms, false); }
|
||||
| exp MULTIPLY exp { Expression * terms[2] = {$1,$3}; $$ = new Product(terms, false); }
|
||||
| exp MULTIPLY exp { Expression * terms[2] = {$1,$3}; $$ = new Multiplication(terms, false); }
|
||||
| exp DIVIDE exp { Expression * terms[2] = {$1,$3}; $$ = new Fraction(terms, false); }
|
||||
| exp POW exp { Expression * terms[2] = {$1,$3}; $$ = new Power(terms, false); }
|
||||
| MINUS exp { $$ = new Opposite($2, false); }
|
||||
|
||||
@@ -3,15 +3,15 @@ extern "C" {
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
#include <poincare/product.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include "layout/string_layout.h"
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Expression::Type Product::type() const {
|
||||
return Expression::Type::Product;
|
||||
Expression::Type Multiplication::type() const {
|
||||
return Expression::Type::Multiplication;
|
||||
}
|
||||
|
||||
ExpressionLayout * Product::createLayout() const {
|
||||
ExpressionLayout * Multiplication::createLayout() const {
|
||||
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(3*sizeof(ExpressionLayout *));
|
||||
children_layouts[0] = m_operands[0]->createLayout();
|
||||
children_layouts[1] = new StringLayout("*", 1);
|
||||
@@ -19,18 +19,18 @@ ExpressionLayout * Product::createLayout() const {
|
||||
return new HorizontalLayout(children_layouts, 3);
|
||||
}
|
||||
|
||||
float Product::approximate(Context& context) const {
|
||||
float Multiplication::approximate(Context& context) const {
|
||||
return m_operands[0]->approximate(context)*m_operands[1]->approximate(context);;
|
||||
}
|
||||
|
||||
Expression * Product::cloneWithDifferentOperands(Expression** newOperands,
|
||||
Expression * Multiplication::cloneWithDifferentOperands(Expression** newOperands,
|
||||
int numberOfOperands, bool cloneOperands) const {
|
||||
assert(numberOfOperands == 2);
|
||||
assert(newOperands != nullptr);
|
||||
return new Product(newOperands, cloneOperands);
|
||||
return new Multiplication(newOperands, cloneOperands);
|
||||
}
|
||||
|
||||
Expression * Product::evaluateOnMatrixAndFloat(Matrix * m, Float * a, Context& context) const {
|
||||
Expression * Multiplication::evaluateOnMatrixAndFloat(Matrix * m, Float * a, Context& context) const {
|
||||
Expression * operands[m->numberOfRows() * m->numberOfColumns()];
|
||||
for (int i = 0; i < m->numberOfRows() * m->numberOfColumns(); i++) {
|
||||
operands[i] = new Float(m->operand(i)->approximate(context)*a->approximate(context));
|
||||
@@ -38,11 +38,11 @@ Expression * Product::evaluateOnMatrixAndFloat(Matrix * m, Float * a, Context& c
|
||||
return new Matrix(operands, m->numberOfRows() * m->numberOfColumns(), m->numberOfColumns(), m->numberOfRows(), false);
|
||||
}
|
||||
|
||||
Expression * Product::evaluateOnFloatAndMatrix(Float * a, Matrix * m, Context& context) const {
|
||||
Expression * Multiplication::evaluateOnFloatAndMatrix(Float * a, Matrix * m, Context& context) const {
|
||||
return evaluateOnMatrixAndFloat(m, a, context);
|
||||
}
|
||||
|
||||
Expression * Product::evaluateOnMatrices(Matrix * m, Matrix * n, Context& context) const {
|
||||
Expression * Multiplication::evaluateOnMatrices(Matrix * m, Matrix * n, Context& context) const {
|
||||
if (m->numberOfColumns() != n->numberOfRows()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ extern "C" {
|
||||
#include <math.h>
|
||||
}
|
||||
#include <poincare/power.h>
|
||||
#include <poincare/product.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include "layout/exponent_layout.h"
|
||||
|
||||
float Power::approximate(Context& context) const {
|
||||
@@ -24,11 +24,11 @@ Expression * Power::evaluateOnMatrixAndFloat(Matrix * m, Float * a, Context& con
|
||||
Expression * operands[2];
|
||||
operands[0] = result;
|
||||
operands[1] = m;
|
||||
Expression * product = new Product(operands, true);
|
||||
Expression * newResult = product->evaluate(context);
|
||||
Expression * multiplication = new Multiplication(operands, true);
|
||||
Expression * newResult = multiplication->evaluate(context);
|
||||
delete result;
|
||||
result = newResult;
|
||||
delete product;
|
||||
delete multiplication;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "expression_builder.h"
|
||||
#include <poincare/addition.h>
|
||||
#include <poincare/integer.h>
|
||||
#include <poincare/product.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/symbol.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -36,10 +36,10 @@ Expression * ExpressionBuilder::build(ExpressionMatch matches[]) {
|
||||
* before. */
|
||||
result = new Addition(children_expressions, numberOfChildrenExpressions, false);
|
||||
break;
|
||||
case Expression::Type::Product:
|
||||
case Expression::Type::Multiplication:
|
||||
/* The children do not need to be cloned as they already have been
|
||||
* before. */
|
||||
result = new Product(children_expressions, false);
|
||||
result = new Multiplication(children_expressions, false);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
||||
@@ -2,19 +2,19 @@ Addition(Addition(a*),b*)->Addition(a*,b*);
|
||||
Addition(Integer.a,Integer.b)->$AddIntegers(a,b);
|
||||
Addition(Integer.a,Integer.b,c*)->Addition($AddIntegers(a,b),c*);
|
||||
|
||||
Subtraction(a,b)->Addition(a,Product(b,Integer[-1]));
|
||||
Addition(a, Product(a,Integer[-1]))->Integer[0];
|
||||
Addition(a, Product(a,Integer[-1]), b)->b;
|
||||
Addition(a, Product(a,Integer[-1]), b, c*)->Addition(b,c*);
|
||||
Subtraction(a,b)->Addition(a,Multiplication(b,Integer[-1]));
|
||||
Addition(a, Multiplication(a,Integer[-1]))->Integer[0];
|
||||
Addition(a, Multiplication(a,Integer[-1]), b)->b;
|
||||
Addition(a, Multiplication(a,Integer[-1]), b, c*)->Addition(b,c*);
|
||||
|
||||
Addition(a,a,b*)->Addition(Product(a,Integer[2]),b*);
|
||||
Addition(a,Product(a,b),c*)->Addition(Product(a,Addition(b,Integer[1])),c*);
|
||||
Addition(Product(a,b),Product(a,c),d*)->Addition(Product(a,Addition(b,c)),d*);
|
||||
Addition(a,a)->Product(a,Integer[2]);
|
||||
Addition(a,Product(a,b))->Product(a,Addition(b,Integer[1]));
|
||||
Addition(Product(a,b),Product(a,c))->Product(a,Addition(b,c));
|
||||
Addition(a,a,b*)->Addition(Multiplication(a,Integer[2]),b*);
|
||||
Addition(a,Multiplication(a,b),c*)->Addition(Multiplication(a,Addition(b,Integer[1])),c*);
|
||||
Addition(Multiplication(a,b),Multiplication(a,c),d*)->Addition(Multiplication(a,Addition(b,c)),d*);
|
||||
Addition(a,a)->Multiplication(a,Integer[2]);
|
||||
Addition(a,Multiplication(a,b))->Multiplication(a,Addition(b,Integer[1]));
|
||||
Addition(Multiplication(a,b),Multiplication(a,c))->Multiplication(a,Addition(b,c));
|
||||
|
||||
Product(Product(a*),b*)->Product(a*,b*);
|
||||
Product(Integer[0],a*)->Integer[0];
|
||||
Product(Integer.a,Integer.b)->$MultiplyIntegers(a,b);
|
||||
Product(Integer.a,Integer.b,c*)->Product($MultiplyIntegers(a,b),c*);
|
||||
Multiplication(Multiplication(a*),b*)->Multiplication(a*,b*);
|
||||
Multiplication(Integer[0],a*)->Integer[0];
|
||||
Multiplication(Integer.a,Integer.b)->$MultiplyIntegers(a,b);
|
||||
Multiplication(Integer.a,Integer.b,c*)->Multiplication($MultiplyIntegers(a,b),c*);
|
||||
|
||||
Reference in New Issue
Block a user