Commit graph

1863 commits

Author SHA1 Message Date
Christophe de Dinechin
b2286718cf complex: Repair auto-simplificiation for i*i=-1
There was a regression on the i*i=-1 test from the work on constants.
Add it back and extend it to any case that produces real-only results
when auto-simplify is on.

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:10:51 +01:00
Christophe de Dinechin
e6845b1743 font: Make the white circle a bit thicker
This is to make the unselected flags look a bit better

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
beaaee23e4 constants: Evaluate constants from config/constants.csv
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
e1734d7579 cycle: Convert between angle units
This replaces the old "DRG" key on some calculators.

Fixes: #812

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
5cf4b7f4ef doc: Update some of the not-implemented features
Some have been implemented now...

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-21 00:40:45 +01:00
Christophe de Dinechin
bd6f32f8f3 menus: Draw a white circle for disabled flags
When we have a flag, show the disabled state with a white circle.
When clicked with a menu, toggle the flag.
Reorganize some settings menu to save a bit of space and add options.

Fixes: #821

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-21 00:40:45 +01:00
Christophe de Dinechin
aa99ca1489 angles: Add conversion functions
Add `R→D` and `D→R` as purely numerical functions, compatible with HP-48.

Add `→Deg`, `→Rad`, `→Grad`, `→πr` commands, which

- Convert a number to the target unit using current angle mode
- Convert an angle to the target angle unit

Fixes: #811

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-21 00:40:45 +01:00
Christophe de Dinechin
0bd0ee84f3 trig: Use units for angle markers
When the `SetAngleUnits` setting is enabled, `asin`, `acos` and `atan`
will return values with an angle unit that corresponds to the current
angle mode.

The evaluation of such values should be independent from the current
angle mode.

Fixes: #807

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-21 00:40:45 +01:00
Christophe de Dinechin
9a59df5928 dms: Allow convertion from DMS to HMS and HMS to DMS
Enable conversions from DMS values to HMS with `ToHMS`,
and from HMS values to DMS with `ToDMS`

Fixes: #813

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-18 14:44:35 +01:00
Christophe de Dinechin
72de969b89 dms: Accept entering minutes without third dot
Accept entering `1.2.3` to get `1°02′03″`

Fixes: #820

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-18 14:10:21 +01:00
Christophe de Dinechin
dbcb09f892 tests: Adjust tests to match bugs fixed in v0.6.5
There were some changes in v0.6.5 which impacted tests in a way that
was not correctly taken into account.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-12 23:02:37 +01:00
Christophe de Dinechin
54b228cb7d Release 0.6.5 "Testimony": Small bug fixes
This release does not contain much because FOSDEM took a lot of energy.

New features:

* menu: Connect `ceil` and `floor` functions
* Add real to polar conversions
* units: Add `dms` unit to angles menu

Bug fixes:

* decimal: Compute `ln(0.002)` correctly
* integer: Do not parse degree sign if in a complex
* units: Fix parsing of angle units
* font: Add radian glyph

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-12 00:17:09 +01:00
Christophe de Dinechin
4cffc39d3a units: Add dms unit to angles menu
Add the `dms` unit to angles menu, with value "one degree" so that we
can convert between DMS and decimal degrees using the normal units
menu.

Fixes: #818

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-12 00:05:25 +01:00
Christophe de Dinechin
06d042785e units: Fix parsing of angle units
After the introduction of `_dms` and the parsing of degrees symbols in
numbers, degrees could not be parsed correctly as a unit.

Fixes: #809
Fixes: #810

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-12 00:05:25 +01:00
Christophe de Dinechin
465c34443e font: Add radian glyph
Add an superscript `r` for radians, and superscript `π` for
pi-radians. This commit only adds the glyphs, but changes in parsing
of units is also necessary, see next commits.

Fixes: #809

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-11 23:51:43 +01:00
Christophe de Dinechin
2b18c7496b integer: Do not parse degree sign if in a complex
When parsing `2∡3°` we should not parse the `°` sign as in
`1°2` (i.e. a DMS number).

Fixes: #806

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-11 22:07:06 +01:00
Christophe de Dinechin
a39250f836 Add real to polar conversions
Add functions to convert real to polar and back.
Update the complex menu to match (and fixes a few other minor things)
Add tests for the complex to real conversion functions.

Fixes; #801

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-11 19:02:06 +01:00
Christophe de Dinechin
ecba5309fb menu: Connect ceil and floor functions
The functions were implemented but not connected to the corresponding
menu entries in the `RealMenu`.

Fixes: #802

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-11 18:08:49 +01:00
Christophe de Dinechin
23c1c2519d decimal: Compute ln(0.002) correctly
The loop adjusting the integer part may need to be repeated.

Fixes: #817

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-07 22:47:02 +01:00
Christophe de Dinechin
2dbbec4ad7 Release 0.6.4 "Healing": Testing and fixes
This release focuses on heavy testing of the new variable-precision
decimal stack. Adding tests also means finding bugs.

Another significant change is support for fixed-precision
hardware-accelerated floating point, using 32-bit and 64-bit IEEE754
binary floating-point representation. Since this uses a binary format,
some decimal values do not map to decimal correctly. For example,
displaying 1.2 with a large number of decimals will show residue,
because 1.2 does not have an exact (zero-terminated) representation in
binary.

New features:

* plotting: Make refresh rate configurable
* menu: Add `/` key to `FractionsMenu`
* hwfp: Add support for hardware-accelerated floating-point
* menus: Add hardware floating-point flag to `MathModesMenu`
* ui: Allow multiple uses of `.` to insert DMS separators
* HMS: Editing of HMS values in HMS format

Bug fixes:

* stats: Fix crash on `variance` with single-column statistics
* algebraic: Clear error before evaluating the function
* functions: Correctly emit a type error for non-algebraics
* ui: Make sure we save stack if closing the editor
* logical: Fix mask for rotate left with 64-bit size
* logical: Make sure we save args for single-argument logicals
* flags: Update flags on `FlipFlag`, consume them from `BinaryToFlags`
* stack: Show multi-line objects correctly
* lists: Returns `Bad argument value` for index with bad arguments
* lists: Return an empty list for tail of empty list
* arithmetic: `→Frac` should not error on integers
* power: Do not shut down during `WAIT` if on USB power

Improvements:

* menu: Shorten the labels `→QIter` and `→QPrec` to avoid scrolling
* stack: Avoid running same code twice on simulator
* ids: Add aliases for hardware floating point
* functions: Optimize abs and neg
* ui: Replace calls to `rt.insert` with calls to `insert`
* menu: Reorganize fractions menu
* dms: Do the DMS conversion using fractions
* list: Adjust multi-line rendering
* copyright: Update copyright to 2024
* text: Return null text when indexing past end of text

Testing:

* tests: Increase the delay for help to draw
* tests: Add tests for hardware-accelerated floating-point
* tests: Add shifts and rotate tests
* tests: Check flag functions
* tests: Test DMS and HMS operations
* tests: Add test for `integrate` using decimal values
* tests: Test multi-line stack display
* tests: Add tests for `GETI`
* tests: Min and max commands
* tests: Repair last regression test
* tests: Check behaviour of 0^0
* tests: Avoid string overflow in case of very long message

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 01:12:46 +01:00
Christophe de Dinechin
c7be6b14ec stats: Fix crash on variance with single-column statistics
When doing the sum, we were setting the result as a null pointer,
and collapsing all later results as a consequence.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
41ddcae6b6 tests: Increase the delay for help to draw
When running the tests under load, we frequently have issues with the
help tests failing. This is probably due to the time given to draw the
help file being a little too short.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
961b976d03 algebraic: Clear error before evaluating the function
Make sure we do not propagate errors when calling the function to
evaluate, so that the error does not block arithmetic evaluations.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
aed8e8da2e menu: Shorten the labels →QIter and →QPrec to avoid scrolling
Avoid scrolling when displaying the fractions menu by shortening the
labels for the `FractionIterations` and `FractionDigits` settings.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
421f3a3263 menu: Add / key to FractionsMenu
Add `/` to make it easy to enter values such as `1/4` from the
command-line, e.g. when entering complex numbers

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
b602b45314 plotting: Make refresh rate configurable
In order ot make it easier to see plotting as it happens, make refresh
rate for plotting reconfigurable with the `PlotRefreshRate` setting.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
30a30b1c42 stack: Avoid running same code twice on simulator
The creation of the output was done twice when running on simulator.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
70cf6c2fcb menus: Add hardware floating-point flag to MathModesMenu
Make it easier to find, without having to go through the catalog.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
d6ff91a05d ids: Add aliases for hardware floating point
This is simply to make testing easier.
The short aliases, `HFP` and `SFP`, are likely to be discarded.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
d580089be9 functions: Optimize abs and neg
Optimize `abs` and `neg` functions which can be simplified in almost
all cases without invoking the complex "function" mechanism.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
f7a7790294 functions: Correctly emit a type error for non-algebraics
Correctly emit a type error when running `sin` with a bad type.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
4794b3ca63 tests: Add tests for hardware-accelerated floating-point
Add tests checking functions using `float` and `double` formats.
Also add tests running variable-precision code at 120 digits.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
c12d27ac8b hwfp: Add support for hardware-accelerated floating-point
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.

See numbers recorded in `doc/6-Performance.md` for details.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
47766e79cf tests: Avoid string overflow in case of very long message
When we have a very long message, we were moving `pad` beyond the end
of the padding string. This actually happens for a few rare parsing
tests where the command name is very long, so the overflow check is
necessary.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
72b7526149 ui: Make sure we save stack if closing the editor
If we type `#1234` and then hit the `F1` key in the `BasesMenu`, the
editor is closed, and we need to save last arguments and undo stack.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
9aed0ebca7 logical: Fix mask for rotate left with 64-bit size
Rotating left with 64-bit size would return 0, because the bit mask
was incorrectly set to 0.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
d60f99a306 logical: Make sure we save args for single-argument logicals
Operations like `ShiftLeft` need to save the stack and last args.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
cb6fd40e5b tests: Add shifts and rotate tests
Add tests for shift and rotate with both small sizes (32, 64, 16 and
13 bits) and for larger sizes (72 and 128 bits).

Fixes: #759

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
f85bb0876a flags: Update flags on FlipFlag, consume them from BinaryToFlags
The `FlipFlag` command was not writing the flag state, in effect doing
nothing. Setting the `write` variable ensures that the state is
updated.

The `BinaryToFlags` command was leaving the flags value on the stack
instead of dropping it on success.

Fixes: #800

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
b94b667e1e tests: Check flag functions
Check the various flag functions

Fixes: #776

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
897f139239 ui: Replace calls to rt.insert with calls to insert
In order to correctly move the selection, it's important to call
`insert`, which knows how to update it, instead of `rt.insert`, which
does not. This also removes a number of explicit `cursor` updates.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
0fb39d1194 ui: Allow multiple uses of . to insert DMS separators
Hitting `.` on an existing decimal separator inserts `°`.
Hitting `.` again reverts to `.`.

Hitting `.` after entering a decimal part inserts `′`, and the next
one inserts `″`. This will replace `.` with `°` if necessary.

Fixes: #799

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
29f491a268 HMS: Editing of HMS values in HMS format
Parse degree/minutes/second values as fractions

We convert HMS to degrees/minutes/seconds for editing because `:` is
already reserved for tags, and would cause syntax ambiguities.

This is necessary for #799

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
d137a46ede tests: Test DMS and HMS operations
Add tests for basic DMS and HMS operations

Fixes: #793

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
431eb1b1cb menu: Reorganize fractions menu
Reorganize fraction menu to make common operations easier to access.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
2b82dd7c55 dms: Do the DMS conversion using fractions
Avoid rounding errors for DMS display using fractions for rendering.
Convert to fraction before attaching unit in →HMS.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
fc76ba4c5c tests: Add test for integrate using decimal values
The `integrate` test is very slow when given polynomials as integrand
and integers as bounds, because it computes everything using large
fractions, and this is quite expensive. Add a test that does it with
decimals and runs much faster.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
85fbdd84c9 tests: Test multi-line stack display
Check that multi-line stack display works as intended.

Fixes: #788

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
6d6e88f057 list: Adjust multi-line rendering
When using single-line rendering, the `wantCR()` calls would still
cause us to insert undesirable newlines.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
ca6614e4f2 stack: Show multi-line objects correctly
Multi-line text and multi-line objects (e.g. matrices) should show
correctly according to the multi-line settings.

Fixes: #479

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-23 12:02:46 +01:00