4625 Commits

Author SHA1 Message Date
Chris Chudzicki
13a3d4c198
Linting: StandardJS for src/, test/; Prettier for types/ (#2544)
* 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
2022-04-29 12:04:01 +02:00
Jos de Jong
ad847cc008
Fix #2524: ignore specific commits when running update-authors.js (#2543)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-04-25 10:45:01 -07:00
Jos de Jong
3c49fca7b1
Fix #2532: matrix index symbol end not working when used inside a sub-expression (#2535)
* 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
2022-04-25 18:13:04 +02:00
Jos de Jong
bb963cae79 Update history 2022-04-25 13:13:37 +02:00
Glen Whitney
82074e85e0
fix: Type declarations for rounding functions (#2539)
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.
2022-04-25 12:07:02 +02:00
Jos de Jong
c96fb1b298 Publish v10.5.0 v10.5.0 2022-04-19 14:41:18 +02:00
simlaticak
45514a832e
Updated ceil types (#2531)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-04-19 14:31:49 +02:00
HanchaiN
9759509c00
Feature: Implementation of Moore–Penrose inverse function (#2521)
* Implement tests

* Implement `math.pinv`

* Add funcion to factory

* Implement LaTeX

* Implement docs

* Add to embedded docs

* Rebase

* Modify tests

* Modify tests

* Fix implementation

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-04-19 14:26:21 +02:00
Jos de Jong
fca1d492fd Fix tests on IE11 2022-04-19 14:15:10 +02:00
Jos de Jong
65e3df98d7 Fix isInternetExplorer test 2022-04-19 14:06:24 +02:00
Jos de Jong
da4fdd465d Make IE11 happy 2022-04-19 13:54:59 +02:00
Jos de Jong
cc193bf96b Add some extra, temporary output to approx equal 2022-04-19 13:49:22 +02:00
Jos de Jong
1628d37ece Test lgamma on IE11 with less precision (next try...) 2022-04-19 13:37:34 +02:00
Jos de Jong
3462f3d881 Test lgamma on IE11 with less precision 2022-04-19 13:32:16 +02:00
Jos de Jong
90a34959d8
Test lgamma on IE11 with less precision (#2527)
* Test lgamma on IE11 with less precision

* Fix testing whether on IE when on Nodejs 12 😂
2022-04-19 13:26:48 +02:00
Jos de Jong
cbeb916c35 Update history 2022-04-14 20:11:10 +02:00
Glen Whitney
80571b7f50
fix(sin): Update to latest complex.js to improve sin(z) for small im(z) (#2525)
Resolves #2523
2022-04-13 07:32:27 -07:00
Divya Yeruva
ac332e6754
Removed the incorrect mail of mine (#2524)
(But we still need to take steps to prevent it from recurring.)
2022-04-12 17:31:27 -07:00
Jos de Jong
ff2f7f089f
test: change mocha reporter to dot (#2520)
Alleviates excessively long log files. Also remove a stray console.log from one of the tests.
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-04-11 20:31:34 -07:00
yifanwww
b3f564f266
feat: Implement lgamma function -- log(gamma(z))) -- for number and Complex (#2417)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-04-11 20:00:16 -07:00
Jos de Jong
c2183c7943 Update history 2022-04-11 12:23:28 +02:00
HanchaiN
c3003be560
Optimize functions (det) (#2516)
* 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>
2022-04-11 12:20:38 +02:00
HanchaiN
7480c11bf7
feat: implement negative integer exponents for square matrices (#2517)
Resolves #2463

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-04-08 12:15:54 -07:00
Jos de Jong
36e7e46289 Publish v10.4.3 v10.4.3 2022-04-08 10:21:03 +02:00
Jos de Jong
29555c04d5 Update history 2022-04-05 17:53:24 +02:00
Jos de Jong
9e2c13ae9f Update history 2022-04-05 09:11:05 +02:00
Glen Whitney
2051fb1412
fix: Allow base argument to log in number-only module (#2515)
Provides a number-only factory for `log` with both signatures 'number'
  and 'number,number'.

  Resolves #2514.
2022-04-04 17:51:41 +02:00
Glen Whitney
f33414a8f7
test(Unit): record questionable cases for unit multiplication (#2513)
This commit captures the cases raised in #2500 as a pending test,
  so that it will be easy to re-check them once UnitMath has been
  adopted.
2022-04-02 22:15:15 -07:00
Glen Whitney
6fbdf767ef
docs(syntax): Highlight ; and update implicit multiplication (#2512)
Partially responsive to #2511.
2022-04-02 09:14:08 -07:00
Jos de Jong
c91d34d634 Update history 2022-04-01 16:25:13 +02:00
Glen Whitney
ecbd877643
fix(combinatorics): Improve precision of stirlingS2 (#2509)
* 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.
2022-04-01 16:23:53 +02:00
Jos de Jong
f89ee9cd83 Publish v10.4.2 v10.4.2 2022-03-29 08:58:01 +02:00
David Contreras
26a0eb7dc5
Included example for embedded documentation (#2507)
Included example as a reference that works inside the expression parser
2022-03-29 08:38:12 +02:00
Jos de Jong
52d195a0ef Update history 2022-03-28 11:54:15 +02:00
Glen Whitney
aa5c9eef76
fix(Unit): Avoid using unit offsets too much (#2501)
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>
2022-03-28 11:51:41 +02:00
Jos de Jong
16a191b9ee Update history 2022-03-28 11:05:08 +02:00
Glen Whitney
c9354ee1a9
chore: Bump complex.js to version 2.1.0 (#2505)
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>
2022-03-28 11:02:52 +02:00
yifanwww
6562edfb21
feat: Improve approx.deepEqual, to support epsilon (#2504)
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>
2022-03-27 22:32:59 -07:00
Jos de Jong
936b7411ae Update history 2022-03-25 16:35:58 +01:00
David Contreras
c9f88f7d3c
Fixed a formula and changed R to degR (#2498)
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>
2022-03-25 16:35:09 +01:00
Jos de Jong
487bf55d2f Update history 2022-03-25 16:11:39 +01:00
Glen Whitney
ba3c58e984
fix(FunctionNode): Improve error message when a non-function is called (#2494)
* 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'
2022-03-25 16:09:33 +01:00
Jos de Jong
c81700c21c Publish v10.4.1 and update dependencies v10.4.1 2022-03-23 12:08:43 +01:00
Glen Whitney
bb434c811c
fix(eigs): Correct tracking of transforms in generating complex eigenvectors (#2496)
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.
2022-03-23 11:57:48 +01:00
Jos de Jong
4f83b786ea Add benchmark to test loading time of a mathjs instance 2022-03-21 17:53:12 +01:00
Jos de Jong
b7bf3896bb Update history 2022-03-21 15:16:03 +01:00
Glen Whitney
7583eac61a
fix(parse): Allow (and ignore) comments wherever white space would be (#2492)
Resolves #2491.
2022-03-21 14:31:31 +01:00
Chris Chudzicki
99839a8da3
Add TypeScript definitions for src/utils/is.js (#2432)
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>
2022-03-17 16:17:32 -07:00
Jos de Jong
ec39c5f3cf Run Node.js CI tests on any branch 2022-03-17 17:33:44 +01:00
NattapongSiri
b8d2e81ee7
fix(TypeScript): Make dim argument optional for std and variance (#2474)
Also adds TypeScript test cases for these functions.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-16 14:01:43 -07:00