* setup linting with eslint-config-standard, prettier
* [autofix] npm run lint -- --fix with new setup
* [manual] fix types/ directory errors
* [manual] fix linting errors in test/ directory
* [manual] fix single linting error in src/
* revert ts-expect-error comment change
* error on .only in mocha tests
* fix test description typo
* move some short objects to single line
* add and gitignore eslintcache
* individually suppress ts any
* set --max-warnings to 0
* extract matrices to constants
* update ts-expect-error comments
* Fix#2532: matrix index symbol `end` not working when used inside a sub-expression
* Refactor IndexNode.prototype._compile: remove redundant logic
* Throw a runtime exception when the context of an IndexNode is not a Matrix, Array, or string
* Describe the behavior of variable `end` nested indices
* Oopsie, fix linting issues
* Add a unit test to validate that `end` resolves to the inner context in case of nested indices
This is a sequel to #2531. Uniformizes the signatures of ceil, fix, floor,
and round, and updates the TypeScript declarations to match. Adds the
optional "number of places" argument to the chain versions of ceil, fix,
and floor. Adds TypeScript tests for all rounding functions.
Also corrects the TypeScript declaration for `bignumber()` and introduces
a couple more common abbreviations for TypeScript types.
Fixes the number-only implementations of floor, ceil, fix, and nthRoot
to match the full implementation behavior on numbers, and tests this for
floor.
Includes some minor documentation updates and additional unit tests for
the rounding functions.
Reverts inclusion in AUTHORS of incorrect email for one contributor,
that occurred in #2531.
Resolves#2526.
Resolves#2529.
* Optimize `det`
Use Bareiss algorithm.
The performance is preserved but lessen the round-off errors.
* Optimize `det`
Use index mapping instead of swapping the rows directly.
Run the benchmark to compare the performance.
* Edit test file
Replace `approx.equal` with `assert.strictEqual`.
The test will fail with the previously implemented LU decomposition.
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
* fix(combinatorics): Improve precision of stirlingS2
Previously the computation of stirlingS2 used the closed form, which
suffers numerically by dividing a sum of very large terms by a large
factorial, causing roundoff errors for unnecessarily small inputs.
This commit switches to using the recurrence relation for the stirling
numbers of the second kind, and caching the partial results for future
calls. This has the advantage that all intermediate results are smaller
than the final value.
Also adds tests for much larger values of the stirlingS2 function and of
bellNumbers, whose computation depends on stirlingS2.
Resolves#2508.
* fix(stirlingS2): Correct lint errors.
Incorporating unit offsets into the internal "value" of the unit
causes more problems than it solves. This commit ends that practice
and instead only uses the offset when converting units or when
computing the absolute value of a unit.
Further, it makes it an error to compute the sign of a unit with an
offset, since that is inherently ambiguous: there is no way to tell
whether "-5 degC" is a temperature change, in which case it is definitely
negative, or if it is a specific temperature of something, in which case
it is "positive" in the sense of being above absolute zero.
(Unclear how valuable this latter concept is anyway, given that there are
no negative temperatures possible in that sense...)
Adds several tests for the various problems the former practice caused,
including all four basic arithmetic operations on units with offsets.
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Also adds tests for math.log() of complex numbers in which the imaginary
part is much larger in absolute value than the real part.
Resolves#2503.
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
fix(approx): Make `approx.deepEqual` respect tolerance argument
Tests already contained calls of the form
`approx.deepEqual(A, B, epsilon)` but the comparison tolerance
argument epsilon was being silently ignored. This commit fixes
that oversight and corrects a couple of tests to reflect the finer-
grained testing.
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Changed `R` to `degR` as there is no unit `R`
`math.createUnit('mile', '1609.347218694', {override: true}})` has a syntax error (an extra `{` ) and is missing units, changed it to `math.createUnit(('mile', '1609.347218694 m', {override: true})` as I think was the original intention.
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
* fix(FunctionNode): Improve error message when a non-function is called
Also adds tests for as many different varieties of function calls
and their associate messages when the entity being called is not
a function as I could come up with.
Resolves#2493.
* feat(format): Add a truncate option to limit result length.
Also uses the new option in FunctionNode.js to limit the length of the value
portion of its new error messages. (As requested in review)
* docs: Add 'truncate' option to the list in the exported version of 'format'
Also adds the test case that revealed the problem and corrects the other test
case that could have found it except the tolerance had been cranked up very
high.
Resolves#2478.
This is a first step toward full publication of these functions,
that were already being exported by mathjs but had not yet
had the associated actions (documentation/available in
parser/typed, etc.) Also, makes most of them into TypeScript
type guards, and adds Matrix as a constructor type. Resolved#2431.
Co-authored-by: Glen Whitney <glen@studioinfinity.org>