The `SINC` function is quite trivial, and the only special case is 0.
Use `IFTE` to special case 0 out and return 1 in that case.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix the units for `I` in several equations.
Signed-off-by: Wiljea <143950411+Wiljea@users.noreply.github.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The focus of this release is on new commands, notably for matrix and vector
operations. This release also ships with a DM48X-specific keymap, which fixes a
problem with teh file selector on the DM32. The equation library has been extended with numerous equations, but they are not fully validated yet.
**Features**
* `con`, `idn` and `ranm` matrix generation commands
* `Array→` and `→Array` commands to convert array to/from stack
* `dot` product and `cross` product commands for vectors
* `DispXY` styled text rendering command
* `DupDup` command duplicating top item twice
* Add a large number of equations to equation library
**Bug fixes**
* Fix `decimal::to_bignum` for small magnitudes
* Return angle unit for `atan2` and `arg` commands
* The `for` loop on lists no longer ends leaving the debugger active
* Interactive stack `DropN` command returns to level 1
* Fix file selector's "New file" on DM32 so that ENTER terminates it
* A few fixes in equations in the equation library
**Improvements**
* Improve graphical rendering of expressions such as multiplication operators
* doc: Update status
* font: Fix `v` glyph vertical placement, add dot and cross glyphs
* ttf2font: Add additional verbose info about source data
* Add `CONSTANTS` as an alias for `ConstantsMenu`
* Replace documentation references to `EEX` with `×10ⁿ`
* Optimize parsing of real numbers in parentheses
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When the decimal value has a negative expoonent, we should not loop
forever building a very large multiplier, and we should not generate a
negative 0 either.
Fixes: #1156Fixes: #1157
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `ranm` command generates a random matrix.
Compared to the HP50G, the DB48X can also generate a random vector
in a way similar to `CON` for constant values.
Fixes: #1155
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `con` command (`ConstantArray`) creates a constant array from
dimensions, another array or vector.
Fixes: #1153
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Update the status information in the documentation:
- List of unimplemented features
- STATUS page
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When running a `for` loop on a list, make sure we cleanup properly on
exit.
Fixes: #1147
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix the vertical bearing of the `v` glyph so that it does not appear
to be one pixel above the others.
Also add glyphs for
* dot-product (`⋅`, U8901)
* cross-product (`⨯`, 10799)
These can be used to refer to the `CROSS` and `DOT` commands.
Fixes: #1117
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Emit the source information from the font, not just the computed one.
Used while investigating #1117
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `DispXY` command on the HP50G takes a font ID that takes 2 values,
1 for small font and 2 for regular font.
In order to implement this in a more easy way, reorder the font IDs so
that they "match", except that 0 gives the even smaller help font and
3 gives the larger editor font.
Fixes: #1146
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When dropping stack items, we need to put the interactive pointer at
the bottom since the stack items have been removed.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add a DM48 keymap that restores correct keybindings in the file
selector dialog.
Fixes: #1002
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The actual label on the keyboard overlays is now `×10ⁿ`.
For completeness, mention in the original description that we have `E`
on the DM42, `EEX` on old overlays.
Also a minor fix regarding bitmap pictures of the stack and command
line.
Fixes: #1123
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add a number of new equations to the equation library, contributed by
Jean Wilson.
Fixes: #1129
Co-authored-by: Jean Wilson <srmjwilson@gmail.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When parsing units or expressions with parentheses, turn ERROR into
SKIP to make sure the higher-level selected expression parsing.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release mostly focuses on issues exposed by the iOS releases.
It's a bug-fixes only release.
***Bug fixes***
* ios: Fix a screen refresh bug delaying the display of computation results
* ios: Increase user-accesssible memory for DB50X to match the DM32
* files: Avoid opening two files when a loaded file contains units/constants
* units: Restrict unit expressions further, e.g. forbid `1_km^s`
* build: Do not add unwanted macOS-specific files in release tar files
* build: Remove irrelevant help file from releae tar file
* constants: Fix numerical value for G constant
* tests: Rename `M` demo helper to `D`, since we use `M` in symbolic tests
* makefile: Add `mv` echo to targets doing image comparison
* units: Use pi constant in definition of radians unit
* parser: Detect syntax error on `(inv(x))` in non-expression mode
* units: Avoid infinite loop for bad unit exponents
* files: Avoid crash in `file_closer` if file does not exist
* tests: Add DMS/HMS operations to math demo
* tests: Add keyboard shortcuts to launch the demos
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The tar file we build should not include macos crap such as
```
help/img/._SimpleShear.bmp
tar: Ignoring unknown extended header keyword
'LIBARCHIVE.xattr.com.apple.provenance'
```
Fixes: #1125
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When distributing a release, only include the relevant help file,
i.e. DB48X.md for DB48X and DB50X.md for DB50x.
Fixes: #1124
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The 'M' name is actually used in a number of other tests, where we
expect a symbolic result and get a bug instead.
Renaming to 'D' ensures we don't disrupt those tests if we run them
after a demo.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Since source file evaluation can involve units, constants, etc, we
need to make sure that the file is closed before evaluating it.
Fixes: #1137
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `r` unit is now defined as a function of `pi`.
As a side effect, fix parsing of expressions in units, allowing `inv`
to parse correctly in the definition of radians.
Fixes: #1136
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we parse `(...` in non-expression mode, this is supposed to be a
complex number. If what we parse is not a complex number, then this
should be a syntax error.
Fixes: #1134
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
If we have a unit expression with a non-numeric exponent, as seen in
bug #1128 where the unit expression parsed as `s^(2*kg)`, we may end
up with an infinite loop trying to factor out the term.
Add two independent fixes to address the problem:
1/ Check if we are making forward progress. If the resulting
expression is the same as before, just stop evaluating the
expression.
2/ In case the heuristic would not work, check if the EXIT key was
pressed by calling `program::interrupted()`.
Fixes: #1133
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
On simulator, `ftell` crashes if the file was not opened correctly,
so we get a crash in the constructor.
Fixes: #1130
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release fixes a number of issues that were discovered primarily
through the Columns and Beams equations.
**Features**
* trigonometrics: Add conversion from non-standard angles, so that
`cos(1_turn)` gives the correct result.
* debug: Debug on error with `DebugOnError` and `KillOnError`
settings. This makes it easier to debug an RPL program, by making it
possible to single-step around the instruction that generated the
error.
* tests: Add three 30 second demo of DB48X features. These are to
generate marketing videos for the iPhone version on the Apple
store (to be done).
**Bug fixes**
* ui: Keep a GC pointer in `draw_object` to avoid a memory crash
* equations: Add missing units in some equations, e.g. `I` and `A` in
second equation of Coilumns and Beams
* equations: Add explicit `radian` unit in Eccentric Columns `cos`,
which ensures we get the correct result from the HP50G manual even
when in Degrees mode.
* units: Correctly factor out non-integral powers, so that we can
compute `1/sqrt(epsilon_0*mu_0)` and get the correct result.
* catalog: Display commands that begin with selection first, so that
`FORE` shows `Foreground` before `AlphaForeground`.
* stats: When computing a sum, evaluate the expression on all
terms. The result for `Variance` with single variables was wrong
because the first term was computed incorrectly due to a misguided
optimization.
* graphics: Error out in `RGBPattern` for negative input. The negative
values were generating an error, but it was not reported, so the next
command was likely to report it.
* help: Render shift keys correctly in the color version. The bitmap
was interpreted as containing color data. Colorize it instead.
**Improvements**
* ui: Select orange as background color during search. The previous
setting of showing seardch using white foreground on a white
background was probably pushing the notion of "blind search" a bit
too far.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `obj` pointer in `user_interface::draw_object` was not a GC pointer, but
there is a `do...while` loop calling `obj->graph` that may cause a garbage
collection, causing the input `obj` to be bogus.
Fixes: #1115
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
There is no unit for some of the equations in the Columns and Beams
category. Notably, some equations are missing the units for `A` and
`I. Adding them back to avoid `Inconsistent units` error when the
variables are not already give a value with a unit (which was the case
from the easlier tests in the test suite).
Fixes: #1113
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `cos` expression in the Eccentric Columns equation should explicitly have an
argument in radians so that it gives the correct result even when in Degrees
mode.
Fixes: #1112
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we evaluate an expression like `1/√(ε₀·µ₀)`, we compute the
square root of unit `F*H`. Unit `F*H` evaluates as `s^2`, so this
ends up with `s`.
This requires evaluating `F^(1/2)*H^(1/2)`, which needs unit mode
flags (`unit::mode` and `unit::factoring`) to be correctly set along
the way, notably while computing powers.
With this, evaluating `'1/√(ε₀·µ₀)' →Num` gives the correct, albeit
unsimplified result `299792458_m/(F^(1/2)*H^(1/2))`. This seems
consistent with the way the HP50G does it. Using `UBase` gives the
correct simplified result `299792458_m/s`.
Fixes: #1110
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When selecting `FORE` in the catalog, show `Foreground` first, before
all other commands that contain `Foreground` (there are many settings
with that name).
Fixes: #1106
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we reach an error during program execution, automatically enter
debugging mode and enable the debug menu.
This is controlled by the `DebugOnError` setting, which is set by
default (the opposite is `KillOnError`)
Fixes: #1109
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `total` internal function performs a sum of terms.
The code was optimizing away the sum to zero for the first term, but
as a result ended up not evaluating the term. So the first term in the
sum for the variance was evaluated as `d` instread if `(d-avg)^2`.
Fixes: #1103
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Both `RGBPattern` and `GrayPattern` would emit a `Bad argument value`
for negative input, but not error out, so the next command could
report it incorrectly.
Fixes: #1108
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>