Commit Graph

105 Commits

Author SHA1 Message Date
Léa Saviot
620ef3f570 [poincare] Use SymbolAbstract::hasSameNameAs 2020-03-31 13:42:42 +02:00
Léa Saviot
94fb5815f9 [poincare] Fix replaceReplaceableSymbols for parametered expressions
Scenario: ans*int(0,x,0,0)->x then cos(x) crashed because replaceReplaceableSymbols
would not care if it was replacing parameters in a parametered
expression
2020-03-31 13:42:42 +02:00
Léa Saviot
80c03220dd [poincare/function] Fix getVariables
Faulty scenario:
Equation x+y=f(0) without defining any variable
2020-02-20 11:58:56 +01:00
Léa Saviot
94d71634b6 [poincare/unit_convert] In shallowReduce, fix units testing on the right
First reduce the right member by replacing the units to make sure there
is a unit, then reduce without replacing to keep "complex units" such as
L, N, ...
2020-02-12 15:13:25 +01:00
Émilie Feral
3df80ed780 [poincare] ParameteredExpression: overrides getVariables to avoid
considering parameter as a variable
2020-02-12 15:13:25 +01:00
Léa Saviot
cb119b796a [poincare/symbol] Use flag RplceAllSymbolsWithUndefAndDoNotRplceUnits 2020-02-12 15:13:24 +01:00
Léa Saviot
9102ba1381 [poincare/function] Fix shallowReduce to take into account symbComp 2020-02-12 15:13:24 +01:00
Léa Saviot
424ee9fa15 [poincare] Add SymbolicComputation parameter to the reduction context
This way, in solver, we can reduce expression without expanding symbols
2020-02-12 15:13:24 +01:00
Léa Saviot
0e64e89496 [apps/solver] Do not use symbol context if no solution found
Still replace the functions
2020-02-12 15:13:23 +01:00
Léa Saviot
f0ca8296bf [poincare/function] f(1/0) = undef when f(x) = 3 2020-02-12 15:13:21 +01:00
Émilie Feral
227a52940d [poincare] Fix Function::deepReplaceReplaceableSymbols, replace
replaceable symbols in the child first

This fixes the following bug: when checking whether 'blop(g(0))' is
circularly defined with g(x) = blop(g(0)), g(0) was not checked which
triggers a crash.
2020-02-12 15:13:21 +01:00
Émilie Feral
f6dcc35bce [poincare] Standardize the convention of 'deepReplaceReplaceableSymbols'
and 'ExpressionWithoutSymbols': they return an uninitialized expression
when the expression is circularly defined
2020-02-12 15:13:21 +01:00
Ruben Dashyan
95c7235831 [poincare] Align implementation of shallowReduce in Symbol and Function 2020-02-12 15:13:16 +01:00
Ruben Dashyan
b728fb8a1b [poincare/symbol_abstract] No need to clone the expression for a Function
Already cloned in the global context.
2020-02-12 15:13:15 +01:00
Ruben Dashyan
fc392d4e81 [poincare/function] Remove old TODO 2020-02-12 15:13:15 +01:00
Ruben Dashyan
3183ca7d7e Replace Poincare::Function unknown earlier (in Context) 2020-02-12 15:13:15 +01:00
Ruben Dashyan
dd80be026d [poincare] Rename shallowReplaceReplaceableSymbols to deep... 2020-02-12 15:13:15 +01:00
Ruben Dashyan
47ed5814a2 [poincare] Remove hasReplaceableSymbols 2020-02-12 15:13:15 +01:00
Léa Saviot
93832549f1 [poincare] childNeedsUserParentheses takes childIndex param
Scenario:
0+exp^0 i->b
0+exp b^0 i->b
Go to VariableBox/expression -> Parentheses were not properly added when
b was replaced
2019-09-20 10:20:48 +02:00
Léa Saviot
e09e36a57f [poincare] When replacing symbols, if it contains itsef return undef
Circularly defined functions/symbols are detected more quickly, which
prevents some tree pool exhaustions.
For instance, with f(t) = [[f(t)][f(2t)]]
2019-09-12 11:04:12 +02:00
Léa Saviot
dcb5a061e9 [apps/poincare] Clearer method names 2019-08-27 17:24:57 +02:00
Léa Saviot
faca423a82 [poincare/symbol_abstract] Remove unused method 2019-08-27 17:24:57 +02:00
Émilie Feral
6c203a545a [poincare] Fix Expression::isReal method with Matrix reducing 2019-08-14 09:38:28 +02:00
Émilie Feral
5900dcae0e [poincare] Clean the use of System parentheses from normal parentheses:
System parentheses are used when serializing a tree to keep the
structure information in the serialization. For example, we serialize
 2+1
----- to [2+3]/3
  3

User parentheses can be added after parsing or when beautifying a
reduced expression to make a mathematically correct expression or more
conventionnal expression. For example, parsing "1+-2" will give
Addition(One, Opposite(2)) that we will transform into Addition(One,
Parenthesis(Opposite(2))) (1+-2 --> 1+(-2)).
2019-08-08 17:22:02 +02:00
Léa Saviot
956cfc2bc4 [poincare] Expression:replaceWithUndefinedInPlace 2019-08-08 16:29:37 +02:00
Léa Saviot
61cf762eef [poincare] Expression::ReductionContext 2019-08-08 16:29:37 +02:00
Léa Saviot
de2d9f7c57 [poincare] SerializationHelper::Map -> Expression::mapOnMatrixChild 2019-08-08 16:24:51 +02:00
Léa Saviot
3554f441c1 [poincare] Remove symbolic computation 2019-04-12 15:16:53 +02:00
Léa Saviot
82d5ff7799 [ion/unicode] Clean special code points 2019-04-12 15:16:53 +02:00
Émilie Feral
8ca4094e13 [poincare] Un-inline Symbol and Function UntypedBuilder 2019-02-21 11:29:35 +01:00
Émilie Feral
d29885028b [poincare] Factorize Builders of SymbolAbstract classes 2019-02-21 11:29:35 +01:00
Émilie Feral
fad3ad958d [poincare] SymbolAbstract: the node alignment is handled by the TreePool
and the TreeNode classes. SymbolAbstract and its children class don't
need to watch the alignment.
2019-02-21 11:29:35 +01:00
Émilie Feral
7b5f3c570d [poincare] Change the way Expression are built 2019-02-21 11:29:35 +01:00
Émilie Feral
ac6f23684d [poincare] Clean Expression and Layout builders
Before: Opposite(Opposite(Rational(1))) misleadingly created the
expression "-1"; now, Opposite::Builder(Opposite::Builder(Rational(1)))
creates "--1"
2019-02-21 11:29:35 +01:00
Émilie Feral
4841542750 [poincare] Add ComplexFormat argument to the approximation routine 2019-01-10 11:42:05 +01:00
Émilie Feral
ecf3f2ea0f [poincare] Create a a flag on Expression that is set when the
approximation encouters a complex value

All approximation methods take the complex format into account.
2019-01-10 11:42:04 +01:00
Émilie Feral
26e2e9be0d [poincare] Add complex format as an argument of simplification 2019-01-10 11:42:04 +01:00
Émilie Feral
1f247b731d [poincare] Discard useless parameters of sign and isReal methods 2019-01-10 11:42:04 +01:00
Émilie Feral
8a00aa16cc [poincare] Clean: remove complexCartesian and complexPolar methods 2019-01-10 11:42:03 +01:00
Émilie Feral
cbef3dadb9 [poincare] Implement real and shallowReduce of ComplexCartesian on nodes: conjugate, function, symbol 2019-01-10 11:42:03 +01:00
Émilie Feral
c62922ec5c [poincare] Change complex getters design: extract real and imaginary
parts at the same time in complexCartesian and norm and arg in
complexPolar
2019-01-10 11:42:03 +01:00
Émilie Feral
d95585956c [poincare] Implement Expression::realPart, Expression::imaginaryPart,
Expression::complexNorm, Expression::complexArgument
2019-01-10 11:42:03 +01:00
Émilie Feral
58eab04c5f [poincare] Expression: add an argument to reduce routine.
Reduction can be done for:
- the user
- a top-down computation
- a bottom-up computation
2018-11-30 09:53:31 +01:00
Émilie Feral
cf92eb8506 [poincare] Discard useless argument 'replaceSymbols' from simplification
routine
2018-11-30 09:53:31 +01:00
Émilie Feral
19b3a8a479 [poincare] Factorize 'expand' and 'matches' methods between Symbol and
Function
2018-11-23 12:04:08 +01:00
Émilie Feral
c01d66c77b [poincare] Change name: replaceReplaceableSymbols -->
shallowReplaceReplaceableSymbols
2018-11-23 12:04:08 +01:00
Émilie Feral
e80512f362 [poincare] Context::expressionForSymbol takes a boolean notifying that
we want a copy or not
2018-11-23 12:04:08 +01:00
Émilie Feral
ac6f7346e0 [poincare] Fix Function: expand and replace child before getting
properties
2018-11-23 12:04:08 +01:00
Émilie Feral
a6ad7484a0 [poincare] FunctionNode: pay attention to parent context with UnknownX value to
avoid overriding it.

For example, when evaluating the expression 'f(x)' in a context where x =
2 and f: x-->x^2.
2018-11-23 12:04:08 +01:00
Émilie Feral
e042279471 [poincare] Function: fix replaceReplaceableSymbols 2018-11-23 12:04:08 +01:00