Commit Graph

940 Commits

Author SHA1 Message Date
Gabriel Ozouf
d37540f032 [poincare/unit] Add Celsius and Fahrenheit
Temperatures can be converted to and from degree Celsius and Fahrenheit.
When used in non-trivial calculations, they are always reduced to undef,
as the rules for manipulating relative scales are not well defined.

Change-Id: If59e224a0e7f940b421bc894bbe2279c90f38d04
2020-11-04 15:33:00 +01:00
Gabriel Ozouf
6e9a5a010f [poincare/integer] Add tests on euclidean division
This commit also adds tests on mixed fractions.

Change-Id: I0fee88eb00febccaa9445230f8f2bbb92cd1ba98
2020-11-04 15:32:59 +01:00
Arthur Camouseigt
1995781a9f [Poincare/IEEE754] Changed methods to use std function
Implemented std::nextafter to replace hand made one.
Methods next and previous are no longer making the difference between -0
and +0

Change-Id: I42e1a073623b70656d9df954694803840cf3088c
2020-11-04 15:30:53 +01:00
Gabriel Ozouf
0ed0cc56e9 [poincare] Remove characteristicXHalfRange
Method characteristicXHalfRange was used to compute the range on which
to display cartesian function in Graph. With the new zoom algorithm,
this method is deprecated.

Change-Id: Ic681fab8d58d0f5628a94302a7b49dacaaa1a6a3
2020-11-04 15:30:53 +01:00
Gabriel Ozouf
db4a1b0265 [poincare/tests] Add tests on power layout
Change-Id: Ic7b0fbf87eec528221a4f836d34e1736e219ab96
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
ec6ee82b81 [poincare/multiplication] Imperial volume display
With the imperial system selected, volumes are expressed as volume in
Calculation's results, instead of cubic lengths.

Change-Id: Ib6c0a1a595dce8ae8db6371b41af818b3fdc6236
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
860ce558c2 [poincare/unit] Remove some additional results
Imperial additional results now only appear when the selected unit
system is Imperial.

Change-Id: Icc314d0148810bea67e4d729179393f1fceaf214
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
801c61549c [poincare/unit] Change units for volume split
In additional outputs, a volume is now splitted as :
  _gal+_qt+_pt+_cup
instead of :
  _gal+_cup+_floz

Change-Id: I5020afbab23be6331d8a8742fd6295db178f0b37
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
5e06f62ff6 [poincare/unit] Symbols for cup and tablespoon
_cp   -> _cup
_Tbsp -> _tbsp

Change-Id: Ied3e1624edc980f76c2f775cbb9e6028db8a83c5
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
52dcd8e749 [poincare/unit] Restructure Unit
1. Information about a unit's dimension now uses inheritance.
   _m is an instance of DistanceAlias, which is derived from Alias.
   A UnitNode now keeps a pointer to an Alias and one to a Prefix.
   All aliases are still defined as constexpr.
   This cleans up a lot of the code used namely for computing the
   additional outputs in Calculation.

2. Instead of being defined with a string, each unit is described by its
   ratio with the base SI unit (ex: _L is 0.001 instead of "0.001_m^3").
   This greatly speeds up the calculations using units, as the algorithm
   to find the best unit used to parse the definition.

Change-Id: I4d6ed6ad4cb967026a3f01a335aec270066e2b9f
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
e48e826536 [poincare/test] Updated tests on units
Change-Id: I7c146174bcedcccc3ed31a298c9720aa2a5ba3a9
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
fad375c11c [poincare] Add unitFormat to ReductionContext
Change-Id: I1d3fcd2f47c973c041e1be84e9a902dd58de3562
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
0a7833ec3d [poincare/test] Added 0*inf*π = undef test
Change-Id: Ie18e75c3cfd2a39f8436405f1061ba8fc5317b7f
2020-11-04 15:11:44 +01:00
Arthur Camouseigt
58b69c2779 [AbsoluteValue] Adding formal derivate to absolute value
This will prevent diff(|x|, x, 0) to be evaluated to 0 instead of undef
This fixes issue #1393
Change-Id: I73f40aa29f04c373cd3e9edbbd4fbe7be6d7a988
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
8d2af7e77f [poincare/test] Add VectorOperation tests, tidy rref tests
Change-Id: I4072bee6b2d3bf1ad17045149bff8dcdb6a2f238
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
cce1fa0c90 [poincare/test] Add tests for LCM and GCD
Change-Id: If91c1ef863c9810e1ab87525a5ed2b4c7ed45656
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
cafb1c1c05 [poincare] LCM and GCD accept set of numbers
Change-Id: I367ff5e48fa2856e976aa020ac0d172216f3a421
2020-11-04 15:11:43 +01:00
Arthur Camouseigt
f9a1f1a1b7 [Poincare/test/approximation.cpp] Fixed broken test
Change-Id: I6d851abf9626d282133f143afa2a16ca2d8bec7e
2020-11-04 15:07:20 +01:00
Arthur Camouseigt
b7bfc253eb [poincare/trigonometry] Modified shallowReduceInverseFunction
This fixes issues #1541. Formulas as asin(sin(X)) with X a large number
were failling to simplify themselves into the image interval of asin
ex : previous version asin(sin(6)) = 6
     new version asin(sin(6)) = -2pi+6

Change-Id: Ia6200b67914224cecd2cd943bcf9bc2ff6e0447a
2020-11-04 15:07:20 +01:00
Hugo Saint-Vignes
c4018d0648 [poincare] Update rowCanonize pivot selection for more consistent ref results
Change-Id: Id7e856f57ccd3d990077b0f6753089bc6edcc03b
2020-11-04 15:07:20 +01:00
Hugo Saint-Vignes
3bfc0c83d8 [poincare] Factorize Echelon Form classes
Change-Id: I7ec7290a4d94b9bd1224ad4c53be8b4662bd32d5
2020-11-04 15:07:20 +01:00
Hugo Saint-Vignes
007c38652f [poincare] Add ref and rref matrix functions
Change-Id: Id0e57a4f85d551ca5320c4b6e3c0baadae70946d
2020-11-04 15:07:20 +01:00
Arthur Camouseigt
997c103fba [Toolbox] Changed the required parameters for normal_distributions
Changed the parameter σ2 to σ. This is now consistant with the
probability app

Change-Id: I96101ba158cebef972e536cfa5cc1b2da71b543d
2020-11-04 15:07:19 +01:00
Hugo Saint-Vignes
a5a57c4076 [poincare] Improve prefixes for mass and inductance unities
Change-Id: Ic9eb7b5adff7b172452b4c73bd7ddc5c59761219
2020-11-04 14:45:35 +01:00
Hugo Saint-Vignes
11e41bb4dc [poincare] Add comments and alternative algorithm to beautify units
Change-Id: I4b1ce9528d9d6796fe08f8566ee5d1efafa1d87d
2020-11-04 14:45:35 +01:00
Hugo Saint-Vignes
51f1cdb076 [poincare] Handle rational unit exponents
Change-Id: Id710702dbed19d34992da90978d5823d68abb80a
2020-11-04 14:45:35 +01:00
Arthur Camouseigt
082f9819e9 [Poincare] Changed ConvertFloatToText to prevent conversion error
We now compute the value of the mantissa in double (instead of float)
to limit conversion error occuring for big numbers.

Change-Id: Ia61c052f0bc4a9196c53e2c7900eb48e3343d39c
2020-11-04 14:45:35 +01:00
Gabriel Ozouf
abb662b606 [poincare/test] Added tests on fraction layouts
Change-Id: I351d707c03b96c93e090e2e74c1841ebe9d7a691
2020-11-04 14:45:35 +01:00
Hugo Saint-Vignes
3db1cad18b [poincare] Move IsApproximatelyEqual to a better helper
Change-Id: I056a96b3721005e01c6ef3f166a80a08195ff338
2020-11-04 14:45:34 +01:00
Hugo Saint-Vignes
735fc6e1bb [poincare] Generalize Binomial Coefficient n to any real
Change-Id: I3cda882e67db4becfe232c6428e14905e922662b
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
78a1350f15 [poincare/test/derivative.cpp] Added context-aware tests.
New tests compute derivatives while replacing symbols with their definitions or undefined, as the device does.

Change-Id: I99179bf6540182ff929938fb96a00a1ed2fbcf49
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
a9c94236c2 [poincare] Implemented further derivation methods and updated tests.
Derivation now works on tangents and the three hyperbolic functions.

Change-Id: I62049e79c661c3c4a031be0a93c403fb936d611b
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
eab8167a56 [poicare/logarithm] Implemented didDerivate and unaryFunctionDifferential for Logarithm
Derivation now computes as expected on logarithms, as long as their base is not a function of the derivation variable.

Change-Id: Ia56da1c1151c0ddf3887be84ddb4bd02664c5188
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
407d4bce6e [poincare/cosine] Implemented didDerivate and unaryFunctionDifferential for Cosine
Derivation now propagates as expected on cosines.

Change-Id: I6f5af48ac7462c5b8e77ff1a6428a65bf6c0c7de
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
5cf85368ea [poincare] Added framework to derivate unary functions, and implemented it for Sine
Added a method unaryFunctionDifferential to ExpressionNode and Expression, to be implemented by subclasses representing unary functions.
Added a function derivateUnaryFunction to Derivative, to factor (f°g)' -> g' * f'°g.

Change-Id: Id1780f1082ccd001f1282fe4ddfff2b7055d3a27
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
648cdbaa29 [poincare] Implemented didDerivate method for Power
Derivation now propagates to powers as expected, whether the base, the exponent, or both are functions of the variable. This also makes division derive as intended.

Change-Id: I51cbd5f7ec9f6aaa1df068625bbda1437941fa08
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
6f378ef3ef [poincare] Implemented didDerivate for Multiplication
Derivation propagates as expected on multiplications (but not power). Some tests involving diff had to be updated to reflect that behaviour.

Change-Id: Ifa32031bc37a156c18d296757bcdd6ccdb0ea43e
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
c65687e9f6 [poincare] Implemented didDerivate methods for Number, Symbol and Addition
Number's subclasses, with the exception of Undefined and Unreal, derive as zero. Symbols derive as expected. Derivation propagates as expected on additions.

Change-Id: Icedbb1dfac8099347a19c14bf2537011b2e8b199
2020-11-04 14:45:34 +01:00
Gabriel Ozouf
051e608835 [poincare] Added method didDerivate to Expression and ExpressionNode
This method is to be implemented by derivable expression subclasses, for use in Derivative::shallowReduce. It performs the calculation for the derivative, and returns whether calculations happened.

Change-Id: I13cdb131e2044578392f5178a9f389314c1c4c8a
2020-11-04 14:45:34 +01:00
Léa Saviot
3a046f5bcb [poincare/multiplication] Fix Multiplication::removeUnit
Scenario:
f(x) = 0->_A
evaluate 0f(0)
2020-07-16 11:46:23 +02:00
Léa Saviot
36bc70aaee [poincare/power] Better Power::shallowReduce
Take care of an undefined index that arrived during the remove unit
2020-07-16 11:46:23 +02:00
Léa Saviot
9e94304db0 [poincre/test] Rename assert_simplify -> assert_reduce
And assert_expression_simplify -> assert_expression_reduce
2020-07-16 11:46:23 +02:00
Léa Saviot
43744bcae9 [poincare/power] Fix shallowReduce
Scenario: f(x) = 0->0
In graph, go to x = e^(f(0))
2020-07-15 13:07:17 +02:00
Charlotte THOMAS
7754693bdf fix: change IsIS => IsSI in test too 2020-07-15 10:28:15 +02:00
Léa Saviot
cf4eaa3d1f [apps/poincare] Use symbolicComputation in recursivelyMatches
This fixes a failed assertion for the scenario:
[3]->x then, in the Equation app, solve x+1->0
2020-06-15 16:20:09 +02:00
Émilie Feral
ad86378a5c [poincare] Unit: -_m should be beautified to -1x_m 2020-06-11 12:02:17 +02:00
Émilie Feral
2630d0dee2 [poincare] Change approximation test to work on the device
implementation of libm (hypotf is not as accurate on the device)
2020-06-04 14:58:20 +02:00
Émilie Feral
4b83da21b7 [poincare] Fix Multiplication between 0 and a unreduced matrix: it
should not be equal to 0 but to Matrix(0)
2020-06-04 14:50:10 +02:00
Léa Saviot
a9fbcf99b2 [poincare/test] Add failing test about multiplication simplification
The result should be 0*[[1,0][0,1]]^500, or, maybe later, [[0,0][0,0]]
2020-06-04 14:50:10 +02:00
Léa Saviot
55ae258653 [poincare/test] Add failing matrix/power simplification test 2020-06-04 14:50:10 +02:00