mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
Use proper english name for sine.
Change-Id: I44c1bed203b126e0bd36be1efe00b7f5df9cff06
This commit is contained in:
@@ -4,7 +4,7 @@ objs += $(addprefix poincare/src/,\
|
||||
binary_operation.o\
|
||||
commutative_operation.o\
|
||||
context.o\
|
||||
cosinus.o\
|
||||
cosine.o\
|
||||
expression.o\
|
||||
expression_lexer.o\
|
||||
expression_parser.o\
|
||||
@@ -15,7 +15,7 @@ objs += $(addprefix poincare/src/,\
|
||||
leaf_expression.o\
|
||||
power.o\
|
||||
product.o\
|
||||
sinus.o\
|
||||
sine.o\
|
||||
subtraction.o\
|
||||
symbol.o\
|
||||
tangent.o\
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <poincare/addition.h>
|
||||
#include <poincare/context.h>
|
||||
#include <poincare/cosinus.h>
|
||||
#include <poincare/cosine.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/float.h>
|
||||
#include <poincare/fraction.h>
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <poincare/integer.h>
|
||||
#include <poincare/power.h>
|
||||
#include <poincare/product.h>
|
||||
#include <poincare/sinus.h>
|
||||
#include <poincare/sine.h>
|
||||
#include <poincare/subtraction.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/tangent.h>
|
||||
|
||||
14
poincare/include/poincare/cosine.h
Normal file
14
poincare/include/poincare/cosine.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef POINCARE_COSINE_H
|
||||
#define POINCARE_COSINE_H
|
||||
|
||||
#include <poincare/function.h>
|
||||
|
||||
class Cosine : public Function {
|
||||
public:
|
||||
Cosine(Expression * arg, bool clone_arg=true): Function(arg, (char*) "cos", clone_arg) {}
|
||||
float approximate(Context& context) override;
|
||||
Type type() override;
|
||||
Expression * clone() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef POINCARE_COSINUS_H
|
||||
#define POINCARE_COSINUS_H
|
||||
|
||||
#include <poincare/function.h>
|
||||
|
||||
class Cosinus : public Function {
|
||||
public:
|
||||
Cosinus(Expression * arg, bool clone_arg=true): Function(arg, (char*) "cos", clone_arg) {}
|
||||
float approximate(Context& context) override;
|
||||
Type type() override;
|
||||
Expression * clone() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -10,13 +10,13 @@ class Expression {
|
||||
public:
|
||||
enum class Type : uint8_t {
|
||||
Addition,
|
||||
Cosinus,
|
||||
Cosine,
|
||||
Float,
|
||||
Fraction,
|
||||
Integer,
|
||||
Power,
|
||||
Product,
|
||||
Sinus,
|
||||
Sine,
|
||||
Subtraction,
|
||||
Symbol,
|
||||
Tangent,
|
||||
|
||||
14
poincare/include/poincare/sine.h
Normal file
14
poincare/include/poincare/sine.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef POINCARE_SINE_H
|
||||
#define POINCARE_SINE_H
|
||||
|
||||
#include <poincare/function.h>
|
||||
|
||||
class Sine : public Function {
|
||||
public:
|
||||
Sine(Expression * arg, bool clone_arg=true): Function(arg, (char*) "sin", clone_arg) {}
|
||||
float approximate(Context& context) override;
|
||||
Type type() override;
|
||||
Expression * clone() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef POINCARE_SINUS_H
|
||||
#define POINCARE_SINUS_H
|
||||
|
||||
#include <poincare/function.h>
|
||||
|
||||
class Sinus : public Function {
|
||||
public:
|
||||
Sinus(Expression * arg, bool clone_arg=true): Function(arg, (char*) "sin", clone_arg) {}
|
||||
float approximate(Context& context) override;
|
||||
Type type() override;
|
||||
Expression * clone() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
15
poincare/src/cosine.cpp
Normal file
15
poincare/src/cosine.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <poincare/cosine.h>
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Expression * Cosine::clone() {
|
||||
return new Cosine(m_arg, true);
|
||||
}
|
||||
|
||||
Expression::Type Cosine::type() {
|
||||
return Expression::Type::Cosine;
|
||||
}
|
||||
|
||||
float Cosine::approximate(Context& context) {
|
||||
// FIXME: use cosine obviously.
|
||||
return m_arg->approximate(context);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <poincare/cosinus.h>
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Expression * Cosinus::clone() {
|
||||
return new Cosinus(m_arg, true);
|
||||
}
|
||||
|
||||
Expression::Type Cosinus::type() {
|
||||
return Expression::Type::Cosinus;
|
||||
}
|
||||
|
||||
float Cosinus::approximate(Context& context) {
|
||||
// FIXME: use cosinus obviously.
|
||||
return m_arg->approximate(context);
|
||||
}
|
||||
@@ -42,8 +42,8 @@ class Expression;
|
||||
%%
|
||||
|
||||
[0-9]+ { yylval->string = yytext; return(INTEGER); }
|
||||
sin {return(SINUS);}
|
||||
cos {return(COSINUS);}
|
||||
sin {return(SINE);}
|
||||
cos {return(COSINE);}
|
||||
tan {return(TANGENT);}
|
||||
[A-Za-z]+ { yylval->string = yytext; return(SYMBOL); }
|
||||
\+ { return(PLUS); }
|
||||
|
||||
@@ -54,8 +54,8 @@ void poincare_expression_yyerror(void * scanner, Expression ** expressionOutput,
|
||||
%token MULTIPLY
|
||||
%token DIVIDE
|
||||
%token POW
|
||||
%token SINUS
|
||||
%token COSINUS
|
||||
%token SINE
|
||||
%token COSINE
|
||||
%token TANGENT
|
||||
%token LEFT_PARENTHESIS
|
||||
%token RIGHT_PARENTHESIS
|
||||
@@ -88,8 +88,8 @@ exp:
|
||||
| exp DIVIDE exp { Expression * terms[2] = {$1,$3}; $$ = new Fraction(terms, false); }
|
||||
| exp POW exp { Expression * terms[2] = {$1,$3}; $$ = new Power(terms, false); }
|
||||
| LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = $2; }
|
||||
| SINUS LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = new Sinus($3); }
|
||||
| COSINUS LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = new Cosinus($3); }
|
||||
| SINE LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = new Sine($3); }
|
||||
| COSINE LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = new Cosine($3); }
|
||||
| TANGENT LEFT_PARENTHESIS exp RIGHT_PARENTHESIS { $$ = new Tangent($3); }
|
||||
;
|
||||
|
||||
|
||||
15
poincare/src/sine.cpp
Normal file
15
poincare/src/sine.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <poincare/sine.h>
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Expression * Sine::clone() {
|
||||
return new Sine(m_arg, true);
|
||||
}
|
||||
|
||||
Expression::Type Sine::type() {
|
||||
return Expression::Type::Sine;
|
||||
}
|
||||
|
||||
float Sine::approximate(Context& context) {
|
||||
// FIXME: use sine obviously.
|
||||
return m_arg->approximate(context);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <poincare/sinus.h>
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Expression * Sinus::clone() {
|
||||
return new Sinus(m_arg, true);
|
||||
}
|
||||
|
||||
Expression::Type Sinus::type() {
|
||||
return Expression::Type::Sinus;
|
||||
}
|
||||
|
||||
float Sinus::approximate(Context& context) {
|
||||
// FIXME: use sinus obviously.
|
||||
return m_arg->approximate(context);
|
||||
}
|
||||
@@ -6,12 +6,12 @@ QUIZ_CASE(poincare_parse_trigo) {
|
||||
{
|
||||
Expression * e = Expression::parse("sin(0)");
|
||||
Expression * e2 = e->simplify();
|
||||
assert(e2->type() == Expression::Type::Sinus);
|
||||
assert(e2->type() == Expression::Type::Sine);
|
||||
}
|
||||
{
|
||||
Expression * e = Expression::parse("cos(0)");
|
||||
Expression * e2 = e->simplify();
|
||||
assert(e2->type() == Expression::Type::Cosinus);
|
||||
assert(e2->type() == Expression::Type::Cosine);
|
||||
}
|
||||
{
|
||||
Expression * e = Expression::parse("tan(0)");
|
||||
|
||||
Reference in New Issue
Block a user