Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype: Arithmetic Types #1

Draft
wants to merge 11 commits into
base: minimalistic-branch-for-prototypes
Choose a base branch
from

Conversation

cshaa
Copy link
Owner

@cshaa cshaa commented Jun 7, 2021

In this prototype, the complex.js and fraction.js packages were replaced with versions that support Arithmetic Types. The Arithmetics object for the number type was also implemented.

The NormedDivisionRing type was added to the typed function. Therefore, math.js recognizes number, Complex and Fraction as instances of NormedDivisionRing and is able to perform operations on them. This has been used to simplify the logic in exp, log. It has also been demonstrated that the approach works for multiargument functions like addScalar.

To demonstrate the flexibility of this new system, a unit test was added, which demonstrates that math.js functions now work even with external types, without any need for prior configuration.

A working example of BigNumber with arithmetic types was not provided because of time constraints – the class is constructed dynamically by math.js which makes it more difficult to maintain an up-to-date Arithmetics object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant