Commit Graph

3929 Commits

Author SHA1 Message Date
Émilie Feral
fe4e2e3e9d Misc. clang static analyzer fixes 2020-12-09 13:34:36 +01:00
Gabriel Ozouf
55f21f127c [poincare/zoom] Fix array overflow 2020-12-07 16:45:54 +01:00
Gabriel Ozouf
89979b4f50 [poincare/zoom] Comment on the RangeWithRatio method 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
71be09b4e7 [poincare, graph] Factor helper function 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
8726bbda3e [poincare/zoom] Update tests 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
072fdda6b8 [poincare/zoom] Redraft search of orthonormal range
To find the optimal range with a specified ratio, we compute the values
of the function on a default range, then center the Y axis to display
the maximum number of points of the function.
2020-12-07 15:58:56 +01:00
Gabriel Ozouf
7f63daa28e [poincare/zoom] Change weight function in RangeWithRatioForDisplay
Change-Id: I21520d8220083b40baa2e4928632632f2b73cb9b
2020-12-07 15:58:56 +01:00
Gabriel Ozouf
bd302bb67b [poincare/unreal] Type in derivate method
Unreal's derivate method returns true, to signify that it is unchanged
by the derivation operation. This implementation mostly exists for
documentation, as an Unreal derivand will be handled by the
defaultShallowReduce method.
2020-12-07 15:01:52 +01:00
Gabriel Ozouf
7ae03975cc [poincare/derivative] Derivate special numbers
Derivate the numbers Undefined, Unreal, Infinity symbolically :
  Undefined -> Undefined
  Unreal    -> Unreal
  Infinity  -> Undefined
2020-12-07 15:01:52 +01:00
Gabriel Ozouf
3f6e4444a5 [poincare/derivative] Reduce before replacing symbol
The general formula for deriving a power makes use of the logarithm,
which often disappears at simplification. However, replacing the symbol
before simplifying can lead to applying an invalid argument to the
logarithm, making the whole expression invalid.

e.g. diff(1/x,x,-2)
     If x is replaced by -2 before reducing the power derivative, ln(-2)
will reduce to Unreal, as will the rest of the expression.
2020-12-07 14:06:24 +01:00
Gabriel Ozouf
1a47207bee [poincare/trigonometry] Add comments 2020-12-04 11:59:12 +01:00
Gabriel Ozouf
1f0a18f94c [poincare/derivative] Update tests for trigonometric derivatives 2020-12-04 11:59:12 +01:00
Gabriel Ozouf
a113801ec2 [poincare/derivative] Fix derivative of trigonometric functions
The classic differentiation forumals for trigonometric functions assume
a variable in radians. A multiplicative constant must be added when
another unit is used.

Change-Id: Iec428acd7d93e415fddb184300437ae09d1d997c
2020-12-04 11:59:12 +01:00
Gabriel Ozouf
64208a7f3c [poincare/trigonometry] Method UnitConversionFactor
Change-Id: I4ef3e4404071a305354b572e15e5199040f9bf48
2020-12-04 11:59:12 +01:00
Gabriel Ozouf
f329ca825f [poincare] Add ReductionContext to unaryFunctionDifferential
Change-Id: I99ba90f8c38cab5d8fe2139f49e4f94c1d52d296
2020-12-04 11:59:12 +01:00
Hugo Saint-Vignes
636e863323 [escher] Moved repetition factor logic up in Escher from poincare
Change-Id: I7c8f932e3e7d04c928ca881113ba6b5df05b94e7
2020-12-02 17:20:32 +01:00
Gabriel Ozouf
b69f06b772 [poincare/logarithm] Comment clarity 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
1531f96bb8 [poincare/derivative] Update test on derivation 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
764d14fed1 [poincare/constant] Constants differentiate to 0 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
a178c88e54 [poincare/logarithm] Fix derivative domain of definition
The logarithm function is undefined for negative numbers, but its
derivative, the inverse function, is defined everywhere. We thus need to
virtually limit the domain of definition of the derivative.
2020-12-02 16:54:09 +01:00
Gabriel Ozouf
48bd7b6a77 [poincare/logarithm] Factor corner case log(x,0) and log(x,1) 2020-12-02 16:49:09 +01:00
Gabriel Ozouf
f09f06d7ac [poincare/logarithm] Update tests 2020-12-02 16:49:09 +01:00
Gabriel Ozouf
9775953142 [poincare/logarithm] ln(0) = undef
As a consequence, log(x,0) = ln(x)/ln(0) = undef
2020-12-02 16:49:09 +01:00
Gabriel Ozouf
2ba1941270 [poincare/zoom] Float litterals
Change-Id: Ifea5f356b9cee271c43b3d9b9168fd38db78d87a
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
ddfde60982 [poincare/zoom] Update tests for the device
Change-Id: Ied73829ff294dc243ca177c5c2acfb374a7446b9
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
746a781016 [poincare/zoom] Fix coding style
Change-Id: I263e1a95023f650376bf6a1c4bb45426d52d5e4c
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
fdcccde996 [poincare/zoom] Update unit tests
Change-Id: Ic108bfbacd54d43ef6c721589ada813ca648e88e
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
4869383263 [poincare/zoom] Better handling of single points of interest
Functions with a single point of inerest used to be drawn on a tiny
interval around this point.
Now, an orthonormal window is built around the point of interest, giving
a much nicer view.

Change-Id: I7793797aead2695532ddea44d93d62bb7ef870f4
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
229865aff8 [poincare/zoom] Rework unit tests
Change-Id: Id0ff36517d14710701f6a4c1cec8817442b6f946
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
291b400595 [poincare/zoom] Ignore imprecise float value
When looking for extrema in a function, we need to discard results where
the function growth rate is smaller than the precision of the float type
itself : these results are likely to be too noisy, and can cause false
positives.
e.g. : The sqrt(x^2+1)-x function

Change-Id: I6e2c002d7308b41a4c226d274cbb5d9efe4ea7db
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
adf28345b1 [poincare/zoom] Reduce zoom artifact
Do not use the bounds of the interval when computing a refined range.
As the bounds are often integers, the zoom would give strange result on
some non-continuous functions (e.g. f(x) = x!).

Change-Id: Ie127fe15191cb3951cff223adc8dc3172188c789
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
a418602763 [poincare/zoom] Remember points of interest when refining
Change-Id: I229cbffa2577d23bfa0a4c0632bc9ec32ae338e7
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
ca9cb63909 [poincare/zoom] Reduce the step for searching points of interest
The algorithm to search for points of interest will miss some. We reduce
the step to make it more precise, so that tan(x) and tan(x-90) have the
same profile.

Change-Id: Ia1bac1d4e7b98d2d6f36f8ce12ed9dac67d40198
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
540209f1a9 [poincare/zoom] Preserve standard bound when normalizing
Change-Id: I6d736e945eda6982ad26836763feded8a55134a0
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
e4162976e4 [poincare/zoom] Method NextUnit
Change-Id: I8200c38fd44b662dcffa8e9850fc272f3e2dc7e8
2020-11-26 17:51:40 +01:00
Hugo Saint-Vignes
3ac3fba468 [poincare] Prevent system parenthesis text insertion
Change-Id: I5963d2fda37ed9776059b29edced75f88b4ccb2b
2020-11-20 13:33:00 +01:00
Hugo Saint-Vignes
d8527b02ad [poincare] Add a vector type for matrix product and norm operations
Change-Id: I28b0956273f8c0a3a9bdc4389956caa106d6b8af
2020-11-19 11:41:29 +01:00
Hugo Saint-Vignes
522456677a [poincare] Add an Array class to factorize Matrix and Grid methods
Change-Id: Ia61caf0bf182c1111119740d43d957f203c0975c
2020-11-19 11:41:29 +01:00
Hugo Saint-Vignes
c0413709b7 [poincare] Require same vector orientation for dot and cross products
Change-Id: I4cf248cf564899314a1efb1c5e39a041395ba583
2020-11-19 11:41:29 +01:00
Hugo Saint-Vignes
cb54e22272 [poincare/test] Add tests on horizontal vectors
Change-Id: If2d6293ede044ffe71e632212eff155b80ad683f
2020-11-19 11:41:29 +01:00
Hugo Saint-Vignes
bee8d8531b [poincare] Handle horizontal vectors
Change-Id: I98088b2b9f2dbc0549795a5c3eed4787fea70068
2020-11-19 11:41:29 +01:00
Gabriel Ozouf
0c44deb35f [poincare/matrix_layout] Change comparison order
Change-Id: Iaa048d82005a7dfa380357e80bbac447c0976e55
2020-11-17 11:42:55 +01:00
Gabriel Ozouf
323e72a50c [poincare/matrix_layout] Remove columns with backspace
Allow removing empty columns with backspace, the same way one can remove
empty rows. This allows deleting the internal columns that are not
automatically deleted.

Change-Id: I52def7939257942a8396721d01c4d1531ef90361
2020-11-17 11:42:55 +01:00
Gabriel Ozouf
7184202a6e [poincare/matrix_layout] Keep median rows and columns
Empty columns and rows are only removed automatically when they are the
last row/column. This way, the user can edit a median row/column without
the matrix collapsing.

Change-Id: If611fa0133f270d785809d433ae879879b6b093f
2020-11-17 11:42:55 +01:00
Gabriel Ozouf
62e2a71da1 [poincare/matrix_layout] Remove empty rows
Empty columns are automatically removed ; the same is now done to empty
rows.

Change-Id: Ib66dfe83f1ea712d3f9a450eedd7ade709296413
2020-11-17 11:42:55 +01:00
Hugo Saint-Vignes
04b2683af2 [poincare] Replaced an escape case with an assert only
Change-Id: I5ea501beeb42577a25dd752f8b9492210abd38fc
2020-11-16 17:12:42 +01:00
Hugo Saint-Vignes
73b5b0775a [poincare] Avoid nullptr context on non-Numbers sign and nullStatus methods
Change-Id: I3361344c1e0b50cdbe999d6ea50025022a51f603
2020-11-16 17:12:42 +01:00
Hugo Saint-Vignes
a0497d3bd7 [poincare] Prevent Bad access on abstract symbol context
Change-Id: I3077db5fdc2430ee11ceb1c6eb651e4331fb2ba0
2020-11-16 17:12:42 +01:00
Léa Saviot
4df996cfd2 [poincare/expression_node] TODO: use ReductionContext via pointers 2020-11-09 15:50:27 +01:00
Léa Saviot
5df60e946a [poincare] shallowBeautify can modify the reduction context
UnitConvert must set UnitConversion to None, otherwise the unit asked
for in the conversion might get changed after being properly set in
UnitConvert::shallowBeautify.
2020-11-09 15:50:27 +01:00