Add "real" n-ary functions for `sum` and `product`.
Note that the HP50G does symbolic pre-computation for sums, with the
interesting side effect that it may give "strange" results for empty
sums. For example, `I 10 1 'I^3' Σ` gives `-2024`, which is a bit
suprising.
The rationale, I believe, is that `I A B 'I^3' Σ` is first simplified
as `'(B^2+2*B^3+B^4-A^2+2*A^3-A^4)/4'`, which gives the negative
result when `A>B`.
This behaviour is not replicated in DB48X, which follows the HP48
model, where a sum between 10 and 1 returns 0, not a negative value.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Render `comb` and `perm` using the traditional mathematical notation.
Note that this is different from the way the HP48 and HP50G do it:
- The HP48 gives an `Undefined name` error for `N M COMB`
- The HP50 expands this to a factorial-based expression.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Remove the `DataMenu`.
Replace `PrintMenu` with `ListMenu` as keyboard-accessible menu
(we can tuck the rarely used `PrintMenu` under `I/O`)
Add list product, sum, etc to `ListMenu`
Modify `ProgramMenu` to add special program entry characters.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
For some reason, I used the `Sum` (`Σ`) and `Product` (`∏`) commands
for list sums and products. This is not the way the HP48/HP50 do it,
so it's better to have dedicated `ΣList` and `∏List` commands.
Also implemented the missing `∆List` command and added the missing
related tests for all these commands.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Use a smaller font for the argument of these functions.
Also add tests for `sqrt`, `cbrt` and `xroot`
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release is mostly about bug fixes, improving the build on
simulator, and accelerating the test suite while keeping it stable.
** New features **
* simulator: Add F8 key to save state in the simulator
* errors: Add a beep when an error is shown
* linux: Add `-s` option for screen scaling (when Qt gets scaling wrong)
* equations: Get library equation value for plotter, solver and integrator
* characters: Add constant, equation and lib markers to RPL menu
* characters: Add music-related characters and character menu
* commands: Add missing stack commands (nip, pick3, ndupn, unrot, unpick)
** Bug fixes **
* variables: Clone purged objects on stack after `Purge`
* units: unit * symbolic is preserved as is (e.g. `'A'_m`)
* compare: Enforce the `NumericalResults` flag for comparisons
* constants: Fix parsing of constants, equations and library items
* sto: Repair `file exists` error storing to a source file
* simulator: Do not try to create directory if it exists
* Report file errors, e.g. permissions or I/O errors
* equations: Mark `c` and `R` as constants in equations
* simulator: Double clicks are now considered as virtual keyboard touches
* ui: Emit only one beep, not two, for a syntax error on the command line
* ui: Avoid rare null-dereference crash when menu label is not set
* complex: Report a syntax error if the second half is empty
* utf8: Do not accept constant/equation/library codepoint in names
* units: Multiplying by `1_m` is OK even with algebraic
* tests: Avoid case where CLEAR does not clear errors
* audio: Improve audio reliability on the simulator
* linux: Rewrite the audio-generation code to avoid crashes
* linux: Avoid infinite recursion in the tests
* linux: Fix warnings about unused variables
* linux: Avoid warnings about null pointer in strcmp
* linux: Avoid build error due to bad `ularge` overload in settings
* linux: Fix type issue for the Insert function (reported as a warning)
* linux: Remove warning about mixing enums and integers
* linux: Avoid error on printf format
* linux: Avoid warnings about type qualifiers
* linux: Remove warnings about incompatible function casts
* linux: Address warnings about missing initializers
* linux: Fix warning about prinf formats
* linux: Address warning about signed vs unsigned
* linux: Remove warning about fall-through switch statement
* linux: Remove warnings about unused arguments
* tests: Repair several tests that were unstable due to scrolling images
* tests: Increase memory size to avoid occasional out of memory failures
* object: Make `as_uint32` and `as_uint64` consistent for negative input
** Improvements **
* ui: Emulate HP48/HP50G behavior for errors (do not require key to continue)
* simulator: Add I/O wrapper around file state save/restore
* dmcp: Remove double return in the code
* simulator: Accept numeric keys in DMCP menus
* doc: Add Kjell Christenson to list of authors
* tests: Run command-line tests silently
* tests: Clear settings the fast way for quick tests
* dmcp: Do not treat the buzzer as a recorder error (avoid message noise)
* simulator: Ensure error messages show up in a recorder dump
* tests: Increase memory size to avoid failing tests
* tests: Increase delay waiting for function plots to appear
* tests: Refactor test suite interaction with RPL thread to accelerate it
* tests: Add a delay before launching the test thread to load initial state
* tests: Add missing reference picture for `char-menu`
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `as_uint32()` and `as_uint64()` functions were not consistent for
all kinds of negative input. Make them return default value or
`value_error()` in all cases.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `LastArg` stack was not correctly saved for the stack operations.
Note that the behaviour of these commands is not always very
consistent across commands. Some attempts were made to replicate the
HP behaviour for commands like `Pick` or `DropN` for compatibility.
Fixes: #859
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `nip` command is equivalent to `swap drop`
It's an HP-50G only command.
Fixes: #841
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
With the new test/RPL sync, we no longer need the explicit waits.
With this, we regularly go below 300s for the whole test suite.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
It is possible for that function to be called when there is no label.
In that case, we do a null-dereference trying to check if we have a
symbol instead of a text.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Boxes` menu is a replication of the `Blocks` menu.
Replace it with a `Music` menu.
Add four missing music glyphs to the font.
Also add the reference file for `chars-menu.png`, which was missing.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add a check for `LastArgs` returning the last equation and not the
last evaluation argument for the plot function.
This fixes the problem with `plot-pgm` mismatch.
Also replace explicit wait times with uses of `LENGTHY`.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The new sync between tests and RPL theads was not working correctly in
the case of `Wait` and `Show` commands because they were popping keys
without correctly updating `last_key`.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Lib` menu was added, which changes the default screen. This
explains the observed change in `help-exit.png`.
There was a minor change in clipping for the help that causes a
mismatch on `help-keyboard.png`.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Instead of actively waiting, increase the maximum default wait time
for the duration of the test. This makes it possible to run the
function plotting tests much faster, while not failing on the slower
ones like `gamma` and `lgamma`.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When running tests, the image check files for function plots often
fail due to the plot not having completed.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Split the recorders between `tests` and `tests_rpl`.
Separate the handling of commands into `process_test_commands` and
`process_test_key`, with the key handling happening before we actually
run the code.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Some keys, like `ENTER` or immediate keys, can be processed before we
get the key release. In that case, the release is actually consumed by
`program::interrupted` and not by the main runner thread, so that we
cannot rely on that to get the correct output key.
When reading the stack, cache what is being read so that we have a
consistent set of values.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This significantly improves the performance of tests by avoiding
delays waiting to process keys.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Use a separate channel for the communication of test commands with
the RPL thread, in order to make it simpler to deal with corner cases
such as an error being displayed.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This delay is necessary to avoid an occasional crash at startup when
running with `-Tall` and loading a large demo file.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Just make sure that we read the value only once, as it's possibly
written by another thread, so it's better to have a single value in
the instrumentation.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When recording the stack for the test suite, there is a sspecial case
for a depth of 0 that is dead code (we return earlier in that case)
and is actually not supported by the test suite if activated.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The error handling in the tests is now often failing due to the fact
that we no longer need to hit a BSP / ENTER key to clear it.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This is a shortcut to save the current state.
Note that you can also get that with RSHIFT-EXIT.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>