Commit Graph

4054 Commits

Author SHA1 Message Date
Émilie Feral
5afdec00b8 [poincare] Avoid reading "garbage" value: result variable can be
read in the while condition without being set to an initial value
(if the first ridderApproximation was undefined for instance)

Found by clang-analyzer
2020-11-05 10:28:24 +01:00
Émilie Feral
c7711b74c2 [poincare] Sequence: reorder condition (optimization) 2020-11-04 15:58:43 +01:00
Émilie Feral
4cc3542a99 [poincare] Sequence: when approximating within a reduce routine, escape to avoid
infinite loop
2020-11-04 15:58:41 +01:00
Émilie Feral
7142f9545e [poincare] Finish replacing approximateContext 2020-11-04 15:58:41 +01:00
Léa Saviot
f8b3156f19 [poincare] Start replacing approximateContext 2020-11-04 15:58:41 +01:00
Léa Saviot
644cf4dcf3 [poincare] Step II: create ApproximateContext 2020-11-04 15:58:40 +01:00
Émilie Feral
75dc415e27 [poincare] Step I: add a parameter to approximation routines to indicate
if we're within a reduction routine
2020-11-04 15:58:40 +01:00
Hugo Saint-Vignes
42f20fb58d [poincare] Add NullStatus and sign for more complex expressions
Change-Id: Ic593517bf7a983985fe3c521e10c19ab0bca4191
2020-11-04 15:58:34 +01:00
Hugo Saint-Vignes
61d33be2a7 [poincare] Add NullStatus and sign for more expressions
Change-Id: I4443a28532f5b728afe169a3d2a70d9026bc1909
2020-11-04 15:58:34 +01:00
Hugo Saint-Vignes
4a3f749cc6 [poincare] Add NullStatus for expressions
Change-Id: Ibaba72e3e3589ba259c7b22d402e2b27937f27c1
2020-11-04 15:58:34 +01:00
Hugo Saint-Vignes
b2945c3f8b [poincare] Add isNumberZero tests
Change-Id: Ia8906e27c5c28f96c87ed39f522f4b1028ad80b8
2020-11-04 15:58:33 +01:00
Hugo Saint-Vignes
98499f6c9f [poincare] Rename isRationalZero to isNumberZero
Change-Id: I554dd5e9b9ab3af4364ca23cde590f9e0a458ef8
2020-11-04 15:58:33 +01:00
Hugo Saint-Vignes
58114255e5 [poincare] implement isRationalZero for other numbers
Change-Id: I40f61958f9e51adb376407b2a512097962979417
2020-11-04 15:58:33 +01:00
Hugo Saint-Vignes
9d077c672d [poincare/test] Add tests for multiplication reduction
Change-Id: I54186c0a7c12f7fb0122c0a67f4a6d0d462feb82
2020-11-04 15:58:32 +01:00
Hugo Saint-Vignes
0d883bfb19 [poincare] Handle division by 0 when combining powers
Change-Id: I108ba8131ef2f8d3d210a769322a815121311f6b
2020-11-04 15:58:32 +01:00
Hugo Saint-Vignes
aba09e1a1f [poincare] Fix multiplication.cpp comment typos
Change-Id: I1553144fb45f45cbdb4e021b14ef20cb319984cc
2020-11-04 15:58:32 +01:00
Gabriel Ozouf
65156c8e5a [poincare/zoom] Add test for x*ln(x)
Change-Id: Ia28a7ffb826a9b6e3618b222b6ed9d0d43de308a
2020-11-04 15:58:28 +01:00
Hugo Saint-Vignes
93b5a3f63a [poincare] Handle equal negative numbers in GCD LCM
Change-Id: Ia46966270418a339f8a37e8a1971a7f7dd046034
2020-11-04 15:58:28 +01:00
Gabriel Ozouf
82c4fe2190 [poincare/zoom] Limit explosion detection
Do not take strong variations into account if they would erase more
interesting variations.

Change-Id: I6299a64bed449a611f90eda4234af10a183958d1
2020-11-04 15:58:28 +01:00
Gabriel Ozouf
a76e54642c [poincare/zoom] Change struct to class
Change-Id: I06d1850074b266a694d74e4db4c754ff156c8098
2020-11-04 15:58:25 +01:00
Gabriel Ozouf
29f47124b1 [poincare/zoom] Use std::min & max
Change-Id: If3983c16d3bfa0de31aefe8a3f5c650e1858f822
2020-11-04 15:58:25 +01:00
Gabriel Ozouf
f491be2db5 [poincare/zoom] Accelerate normal range search
Change-Id: I4a7f2e024ca82a3996ad3e395c8f62ca4170ec9e
2020-11-04 15:58:24 +01:00
Gabriel Ozouf
31e694f41a [poincare/zoom] Add tests
Change-Id: Ia7229d790ef1d2039071e35accb102804c94cb01
2020-11-04 15:58:23 +01:00
Gabriel Ozouf
9c320185dd [poincare/zoom] Return value for boring curve
Change-Id: Iad983da0aa3066f5be0c75c5b8e38e62a907d5a1
2020-11-04 15:58:23 +01:00
Gabriel Ozouf
c647bfe566 [poincare/zoom] Clean up and comment API
Change-Id: I58347d7188551471817fb334bcb54d5c5b398f72
2020-11-04 15:58:23 +01:00
Gabriel Ozouf
c4cd3ecffa [poincare/zoom] Factor range sanitation
Checking wether the range that has been computed is suitable is now
done in Poincare::Zoom by SanitizeRange.

Change-Id: Ib7ff73a3beae29996b1a773744021ad85c6ba946
2020-11-04 15:58:22 +01:00
Gabriel Ozouf
b10be2c60c [poincare/zoom] Method SanitizeRange
Create a method to clean up an ill-formed range, ie a range whose bounds
are not finite, or where max <= min.

Change-Id: If4525e65f95385cfa970be72bbcc21ad84286bfa
2020-11-04 15:58:22 +01:00
Gabriel Ozouf
958b172d08 [poincare/zoom] Handle undefined functions
Rework the logic so that :
  - an undefined function will be displayed with a clealry defined
    null range.
  - display both an undefined function and a correct function at the
    same time will not affect the correct range.

Change-Id: Ife9dc0d2ace667cab5a6b8826347078fca33e4d5
2020-11-04 15:58:21 +01:00
Gabriel Ozouf
1bfeeb5842 [poincare/zoom] Detect explosions
Add a clause in InterestingRangesForDisplay to detect strong variations.
This improve the graph for x^x or x^2+x+1 for instance.

Change-Id: I74214c2382cfe4b0e2603556dd8c6cbd450effc0
2020-11-04 15:58:20 +01:00
Gabriel Ozouf
482ca10363 [poincare/zoom] Improve null range
When displaying f(x) = undef, the range now defaults to an orthonormal
range, centered on the origin, with axis unit 1.

Change-Id: Ie3515be0572af4849b8ebd113449f4444755b34f
2020-11-04 15:58:19 +01:00
Gabriel Ozouf
16707aa518 [poincare/zoom] Tweak orthonormal range
Change some parameters to improve the output of
RangeWithRatioForDisplay. Notably, change how the size of the range is
weighed.

Change-Id: I7695c61c3f93482f3fed9c7d2183642573b02cff
2020-11-04 15:58:18 +01:00
Gabriel Ozouf
6be5e7d62c [apps/shared] Change Zoom API
Moved some code around to decrease redundancy and put more of the logic
into Poincare::Zoom

Change-Id: I4804cf39493ac7f2f0b3c4eb554e5c15c3cef1c9
2020-11-04 15:58:18 +01:00
Gabriel Ozouf
8572f4953c [poincare/zoom] Method CombineRanges
The logic behind combining several ranges will be handled by the Zoom
class directly.

Change-Id: I4de3f020d94b9bc1a21953b0c416158c65beb606
2020-11-04 15:58:18 +01:00
Gabriel Ozouf
81e425eb04 [poincare/zoom] Method FullRange
Change-Id: Ibfaa0b694afecab312199b20b102a57901f34ae7
2020-11-04 15:58:17 +01:00
Gabriel Ozouf
09c061e871 [poincare/zoom] Method RangeFromSingleValue
This method adds margins to a range whose bounds are equal.

Change-Id: I2b2fe26fe431deda112389060d401f738a75b1ae
2020-11-04 15:58:17 +01:00
Gabriel Ozouf
a525c35ebb [poincare/zoom] Factor constants
The mantissas {1, 2, 5} used in CurveViewRange to compute the grid units
can be factored in Zoom.

Change-Id: I2bcc9b9df1ff6b6df82092a5d78ed3db132bf63a
2020-11-04 15:58:17 +01:00
Gabriel Ozouf
88ea32bd0d [poincare/zoom] Change range forms for fixed ratio
When looking for a range with a certain ratio using
RangeWithRatioForDisplay, instead of looking for ranges of the form
0.01*1.1^n, search for ranges of the form a*10^k, with a being either 1,
  2, or 5.

Change-Id: I2eaa229574a9a6aa4afa6eb1a3d57365d3d52801
2020-11-04 15:58:17 +01:00
Gabriel Ozouf
403315f6ac [poincare/zoom] Find range with specific ratio
Change-Id: Id0c816c42e3fa93519241bf53f920c333e204af1
2020-11-04 15:58:15 +01:00
Gabriel Ozouf
08c96c5107 [poincare/zoom] Method SetToRatio
Added a method to Zoom to set a range to a specific ratio. This method
is used by InteractiveCurveViewRange::normalize.

Change-Id: Id3029439294ece02ea19fb6c6de90b9edc85d771
2020-11-04 15:58:14 +01:00
Gabriel Ozouf
c4aad1641e [poincare/zoom] Rename k_defaultMaxInterval
Bring it in line with k_minimalDistance which as a similar role.

Change-Id: Ifc3ad793e8b5ff1e7f2598d0665abdd5c954e61f
2020-11-04 15:58:14 +01:00
Gabriel Ozouf
0465cec924 [poincare/zoom] Remove rounding of abscissa
As margins are added later in InteractiveCurveViewRange::setDefault,
rounding abscissa at this point is premature.

Change-Id: I411dd014b712649efd55cb995ed7a9c5c14a7f43
2020-11-04 15:58:14 +01:00
Gabriel Ozouf
ad6edffc07 [poincare/zoom] Remove tuneXRange argument
The ability to perform a range search without changing the X range was
only there to accomodate the Yauto feature.

Change-Id: I8c2b61b447fbd3dc1f4e303dff06d1a8d6e7a4f2
2020-11-04 15:58:14 +01:00
Gabriel Ozouf
d2b36be846 [poincare/zoom] Move automatic zoom to Poincare
Change-Id: I7a70ab54b33b9150682cc4f999ff4999a8288b7f
2020-11-04 15:58:07 +01:00
Arthur Camouseigt
bf95b460c3 [Sequence] Fixed computation error and asan fails
Change-Id: Ib3a619d29bee5cc6f10b939ee066459a5b135c5d
2020-11-04 15:33:04 +01:00
Hugo Saint-Vignes
b051242f2b [test] Avoid high precision number approximation
Change-Id: I88537653cea2a399581e9686bd027c9d20953667
2020-11-04 15:33:03 +01:00
Hugo Saint-Vignes
a326a1f9ff [poincare] Fix approximation test
Change-Id: I0951e01acf7266e33d05f40de3119b73c656b9a2
2020-11-04 15:33:03 +01:00
Hugo Saint-Vignes
3f43504398 [poincare] Check for nan values when inverting matrix
Change-Id: Idb542682003348da151975e635958cf909010d16
2020-11-04 15:33:03 +01:00
Gabriel Ozouf
0c1d0195cd [poincare/unit] Check uninitialized expressions
In Calculation, keeping the BACK key pressed can lead to iffy
simplifications and uninitialized expressions beign passed to
ShouldDisplayAdditionalOutputs and SetAdditionalExpressions methods.

Change-Id: If248ab193c471ff433828fc841e01a391e0c052d
2020-11-04 15:33:02 +01:00
Gabriel Ozouf
bc7ca057a0 [apps/calculation] Add Joules to results on energy
Change-Id: Ib775b1bd2bac1fd3bf755a9a4d3d5b3739a67cfa
2020-11-04 15:33:02 +01:00
Gabriel Ozouf
10f8e2f507 [poicare/unit] Rename method
hasAdditionalExpressions -> hasSpecialAdditionalExpressions

Change-Id: Ia5200402b23ab5adf0f94dabe027955a86d1174d
2020-11-04 15:33:02 +01:00