Commit graph

17 commits

Author SHA1 Message Date
Christophe de Dinechin
85b9be68c8 solver: Add support for multiple equation solving
Add the possibility for the solver to contain a list of equations.
The `NextEq` command rotates the equation list.

Add the `EvalEq` command to evaluate the equation.

Add `EvalEq` and `NextEq` to the solving menu.

Fixes: #1050

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-28 16:31:57 +02:00
Christophe de Dinechin
edb3cf1e9f functions: Very basic random number generator
A very basic set of random-generation functions.

This implementation only generates 32-bit worth of randomness.
A later iteration will follow the `Precision` setting for decimals.

Fixes: #1019

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-15 00:57:53 +02:00
Christophe de Dinechin
3473ca0284 demo: Add CountPrimes example
The `CountPrimes` example is a simple program that is inspired by a
[speed test YouTube video](https://www.youtube.com/watch?v=vwI5xbqIM7g).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-11 19:36:14 +02:00
Christophe de Dinechin
bdd8e53987 demo: Modernize the code a little
We can now take advantage of:
* The `Gray` command to set patterns
* Redrawing text with a different foreground color

Also change the lines demo to have a progressive fade-out

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
ea326ae38f demo: Modify performance benchmarks to use TEval
Use `TEval` to benchmark the code, remove the benchmark helper.
Also rename the two sum benchmarks to add clarity in the name

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
552740e53b demo: Add HP-48 style slow walk to Walk demo
Make the program mimic the HP48 program behavior

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
8c9858b84e demo: Replace imaginary unit constant
The `ImaginaryUnit` and `Pi` commands no longer exist.
Replace them with the constants from the constant library.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
013304b1cf command: Factor out arity for all commands
For all commands, put the arity check in the top-level evaluator.
This factors out all that code in a single (source-code) location.

This also makes it possible to use arity reliably during parsing of
expressions, and fixes a number of cases where it wqas set wrong, like
for the `det` command and many others.

Finally, it fixes missing calls to `rt.args` for a number of commands,
while explicitly removing it (`nargs < 0`) for a few cases where it
was harful, like `LastArgs` or `Undo`.

Fixes: #865

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:14 +02:00
Christophe de Dinechin
df472471ef Release 0.7.2 "Light" - Libraries, Characters menu
This release introduces four relatively significant features:

1. An Equation Library
2. A more general Library
3. Character menus
4. A character modification catalog

There are also a number of bug fixes and improvements.

=== Features ===

* The *Equation Library* is similar in principle to what is found in the HP50G.
  It is intended to store equations covering a variety of topics.
  The Equation Library is accessible using the _EQS_ key (🟦 _'()'_).
  It is presently only very sparsely populated, but a future release should
  add the equations listed in Chapter 5 of the *HP50G Advanced User's Reference
  Manual*. Elements of the Equation Library appear as named *Equation Objects*.
  The Equation Library is configured by file `config/equations.csv`.

* The *Library* is similar to the Equation Library, but for all kinds of objects
  such as programs or code snippets. The Library is accessible using the _LIB_
  key (🟦 _VAR_). It can be used to customize your calculator, and is intended
  to play the roles of the `CST` variable (quick access to common features)
  and Library Objects / XLIB (external extensions to RPL). Elements of the
  Library appear as named *Library Objects*.
  The Library is configured by file `config/library.csv`.

* The *Characters Menu* lets you enter Unicode characters easily, by presenting
  various classes of characters, such as `RPL`, `Greek` or `Punct`.
  The Characters Menus is accessible using the _CHAR_ key (🟦 _2_).
  It can be used to enter international characters (e.g. Greek or Cyrillic), as
  well as special characters such as arrows or blocks.
  The Characters Menu is configured by file `config/characters.csv`.

* The *Characters Catalog* appears when the `Catalog` is active and the cursor
  is inside some text object. It gives you access to characters that are
  visually close to the character on the left of the cursor. For example, after
  typing `A`, the presented choices include `À`, `a` or `α`.
  The Characters Catalog is configured by file `config/characters.csv`.

* compare: Add comparisons for `true` and `false` values

* Add `TEVAL` command (timed evaluation)

=== Bug fixes ===

* Do not add unnecessary parentheses in ratios, e.g. `(A+B)/(X-Y)`
* Make sure we can save back the configuration files correctly
* Improve access path checks to accept `config:constants.csv`.
* Avoid syntax error in `1/(1+x)` due to `1/` being seen as a fraction
* unitfile: Remove slight risk of bad menu display after garbage collection
* date/time: Make sure we save the stack and last args for `Date`, `Time`, ...
* parser: Skip spacing when parsing numbers (to parse back `→Text` result)
* time: Fix rendering of DMS time in lists, matrices, vectors
* catalog: Fix a subtle bug on DM32 leading to a crash using the catalog

=== Improvements ===

* constants: Get values of special `π` and `e` by name
* constants: Add prefix in editor to identify constants, equations and xlib
* constants: Represent constants with an index for memory and performance
* constants: Parse units containing text
* constants: Allow `RCL` to recall a constant value
* units: Direct insertion of units after numbers
* menu: Update `Roll` and `RollDown` menu entries
* show: Show all decimals for decimal values
* help: Display the correct on-line help topic for constants
* catalog: Use less memory for the sorted IDs
* integrate: Use numerical computations for faster convergence
* locals: Improve error message for bad locals
* graph: Improve graphical rendering of constants (bold) and equations
* graph: Do not add unnecessary parentheses in ratios
* tests: Add tests for characters menu/catalog
* tests: Fix the `.` vs `0.` test
* ui: Do not enter DMS inside text
* tests: Display disabled tests in gray
* catalog: Keep a single spelling, e.g. no `add` duplicates
* tests: Add extra delay in the wait for update
* makefile: Add dependency of 'all' to the decimal constants
* save: Improve rendering control when saving files
* stack: Do not save stack in plot, integration or solver
* debug: Disable debugging when launching a program from function key
* simulator: Avoid piling up QT draw requests
* doc: Update performance numbers for 1M loops
* simulator: Add sound support
* simulator: Lazy screen refresh
* dmcp: Add UI refresh callback
* simulator: Move QT-dependent code out of dmcp.cpp
* Add reduced font
* runtime: Various changes to isolate QT build from the rest

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-12 08:04:11 +01:00
Christophe de Dinechin
535072fc87 constants: Represent constants with an index
Instead of identifying a constant using a name, use an index in the
constants list, which takes less space and is more efficient at
runtime.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
887f4173b4 doc: Record performance data for 1000 iterations of SumTest
We need to start recording the performance data of the decimal code on
a release-to-release basis. Definitely much slower than before, hence
the need to be realistic and reduce the number of iterations.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:48:16 +01:00
Christophe de Dinechin
9821018a66 Demo.48S: Small updates to demo file
Tabify correctly, add message to `Patterns` test.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-26 22:46:21 +01:00
Christophe de Dinechin
c0c6174aa1 beep: Implement Beep command
Implement the `Beep` command.

The tricky part was making sure that beeps could be interrupted,
while at the same time allowing single-stepping of `Beep`.

The HP documentation allows beep to last up to 1200s.
That seems quite a lot for the little battery in the DM42/DB42.
Decided to max out at 10s instead.

Fixes: #50

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-26 22:46:21 +01:00
Christophe de Dinechin
6876025828 graphics: Add gray and rgb pattern commands
The `GrayPattern` and `RGBCommand` generate a grayscale or colored
pattern for use by `Foreground` or `Background`. They take an input
between 0 and 1. For example, `0.25 Gray Foreground` generates a 25%
gray pattern, and `1 1 0 RGB Background` geneates a yellow background.

Existing calculators running DB48X currently only have black and white
screens. The commands generate a pattern that simulates the
grayscale. The pattern is always 64-bit, representing an 8x8 pixel
grid.

However, the blitter code has been tested on simulators for the HP50G
and the HP Prime. The HP50G has a 4-bit grayscale screen, and the HP
Prime has a 16 bit per pixel 5-5-6 RGB screen. On such platforms, the
command will generate a real grayscale and a filled color pattern.
The 64-bit in that case represent either a 4x4 grayscale pattern, or a
2x2 color pattern. Using the `GrayPattern` and `RGBPattern` commands
will ensure your code remains portable if/when DB48X is ported to
these platforms.

Fixes: #617

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-26 22:42:12 +01:00
Christophe de Dinechin
9302eb3b9c plot: Implement bar and scatter plot
Implement a bar plot and a scatter plot function.

The bar plot differs from the HP calculators in that it can take pair
of values, which are interpreted as high/low ranges.

The scatter plot differs from the HP calculators in that it connects
data points by default. This can be disabled with `NoCurveFilling`

Fixes: #577
Fixes: #579

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-20 09:20:19 +01:00
Christophe de Dinechin
d696c3ca38 runtime: Remove the execute callback
Defer program and expression execution to the `program` class.
This allows us to remove `execute()`, which applies to every object,
with `run()`, which only exists for `program`. There is also a
`program::run()` static member that dynamic checks if we should run
`evaluate()` or if we can `run()`.

Also reimplement `while`, `until`, `if`, `ift`and `ifte` using a
deferred conditional so as to avoid C++ stack recursion.

This allows us to have really good behaviour on tail recursion, see
the `Collatz` and `CBench` examples in the `Demo.48S` file. For this
particular case, DB48X on DM42 is 25x faster than the HP50G, which
becomes slower as the recursion depth increases.

Fixes: #537

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-09 18:03:43 +01:00
Christophe de Dinechin
328c2e484f Makefile: install demo state and configuration
Better to update the demo and unit configuration files when updating

Fixes: #547

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-06 00:19:11 +01:00