347 Commits

Author SHA1 Message Date
Jos de Jong
08ed775fe4 Fix merge conflicts 2020-10-07 12:37:44 +02:00
Jos de Jong
99b738f3e6 Merge branch 'develop' into v8
# Conflicts:
#	AUTHORS
#	HISTORY.md
#	package-lock.json
#	package.json
#	src/expression/embeddedDocs/embeddedDocs.js
#	src/factoriesAny.js
#	src/function/arithmetic/ceil.js
#	src/function/arithmetic/fix.js
#	src/function/arithmetic/floor.js
#	test/unit-tests/function/arithmetic/ceil.test.js
2020-10-07 12:12:35 +02:00
Konrad Linkowski
becab4099b
sqrtm - throw an error for matrices with dimension greater than two (#1977) 2020-09-30 12:37:32 +02:00
rnd-debug
9f06dad72f
floor and cell with precision (#1967)
* floor and cell with precision

* appends missing files

* fixing lint

* fixing ceil and floor tests: string typing issue

* fixing ceil and floor tests: string typing issue

* fixing ceil and floor tests: string typing issue

* fixing ceil and floor tests: string typing issue

* adding fix(x,n); adding more tests for floor and ceil

* rising coverage

* adding docs for fix(x,n)

* completing fix(x, n)

* fixing string typing issue
2020-09-27 17:07:38 +02:00
Colin Holzman
f5d843bbc6
Binary, octal, and hexadecimal literals and formatting (#1968)
* allow binary, octal, and hex literals as in JS (0b, 0o, 0x)

* add tests

* fix lint issues

* add notation for binary, octal, and hex in formatNumber

* remove the extra format notations

* add bin, oct, and hex functions for formatting

* move bin, oct, and hex from base.js to their own files, fixed built test error about documentation

* parse and format treat values as 32 bit signed 2s complement integers

* add section in syntax documentation

* typo

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-09-26 17:45:10 +02:00
ovk
36c53b72af
Fix negative dividend modulo for BigNumber and Fraction (#1973) 2020-09-23 11:42:10 +02:00
Jos de Jong
6f00715754
Specify import require paths (continuation of #1941) (#1962)
* Add `.js` extension to source file imports

* Specify package `exports` in `package.json`

Specify package type as `commonjs` (It's good to be specific)

* Move all compiled scripts into `lib` directory

Remove ./number.js (You can use the compiled ones in `./lib/*`)

Tell node that the `esm` directory is type `module` and enable tree shaking.

Remove unused files from packages `files` property

* Allow importing of package.json

* Make library ESM first

* - Fix merge conflicts
- Refactor `bundleAny` into `defaultInstance.js` and `browserBundle.cjs`
- Refactor unit tests to be able to run with plain nodejs (no transpiling)
- Fix browser examples

* Fix browser and browserstack tests

* Fix running unit tests on Node 10 (which has no support for modules)

* Fix node.js examples (those are still commonjs)

* Remove the need for `browserBundle.cjs`

* Generate minified bundle only

* [Security] Bump node-fetch from 2.6.0 to 2.6.1 (#1963)

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1. **This update includes a security fix.**
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Cleanup console.log

* Add integration tests to test the entry points (commonjs/esm, full/number only)

* Create backward compatibility error messages in the files moved/removed since v8

* Describe breaking changes in HISTORY.md

* Bump karma from 5.2.1 to 5.2.2 (#1965)

Bumps [karma](https://github.com/karma-runner/karma) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v5.2.1...v5.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

Co-authored-by: Lee Langley-Rees <lee@greenimp.co.uk>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-20 18:01:29 +02:00
PoppinL
943f1dbe70
Replace seed-random by seedrandom (#1955) 2020-09-06 10:25:41 +02:00
rnd-debug
d08f2bc893
enable variance() and std() to use arrays with units (#1959) 2020-09-06 09:29:25 +02:00
Michal Grňo
ba4ff2f9c9
Add usolveAll and lsolveAll methods (#1916)
* refactor solveValidation

* refactor usolve

* usolve algorithm implemented (for square mat.)

* added lsolve, consistent return type, fixed tests

* fixed lusolve and its tests, fixed linting issues

* added tests for usolve&lsolve, try-catch in lusolve

* put changes into separate files (u-/lsolveAll), revert changes to u-, l- and lusolve

* made *solveAll return [] for non-solvable, implemented sparse algorithms

* improved documentation for *solve(All)

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-08-29 13:11:16 +02:00
rnd-debug
97a56b8114
feat: implementing norm 2 for matrices (#1931)
* feat: implementing norm 2 for matrices

* norm2: adding edge test cases

* norm2: adding edge test cases

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-08-22 12:24:11 +02:00
Jos de Jong
80fb20fbe7 Fix some unit tests failing on IE 11 2020-07-19 11:50:17 +02:00
Jos de Jong
84f2746128 Merge branch 'Undo' of https://github.com/Veeloxfire/mathjs into Veeloxfire-Undo 2020-07-19 10:59:23 +02:00
Tom Hickson
1fd3c8bd10 Added one-based indexing for diff inside the parse
Also added bignumbers as indexes as that could be useful
2020-07-17 19:54:15 +01:00
Tom Hickson
fbebed77a1 added better(?) support for matrices
Matrices are all treated as arrays (of arrays) now. This was to prep for writing better docs
2020-07-17 18:29:51 +01:00
Tom Hickson
0c61d21c95 added unit tests for diff Errors
Added Unit tests for the 4 Errors. Also changed some small things
2020-07-17 17:49:17 +01:00
Nick Ewing
859cfa208a
Replace recursive calls in typed-functions with this-style calls (#1903)
* Fix #1902: typo in an example in the documentation

* Replace recursive calls in typed-functions with `this`-style calls

* Replace more recursive calls in typed-functions with `this`-style calls

* Refactor compareNatural to use this-style recursion

Co-authored-by: josdejong <wjosdejong@gmail.com>
2020-07-13 17:37:30 +02:00
josdejong
c19492a3c9 Fix functions sum, prod, min, and max not throwing a conversion error when passing a single string, like sum("abc") 2020-06-24 09:47:46 +02:00
josdejong
eef3b9e612 Fix prod("abc") not throwing a conversion error 2020-06-23 20:30:20 +02:00
josdejong
0ae2d49232 Fix sum("abc") not throwing a conversion error 2020-06-23 20:21:07 +02:00
josdejong
6c7f4c860e Fix #1882: have DenseMatrix.resize and SparseMatrix.resize accept DenseMatrix and SparseMatrix as inputs too 2020-06-13 13:19:40 +02:00
josdejong
e44cb97b06 Fix #1855: Fix error in the documentation for math.nthRoots(x) 2020-05-20 09:08:25 +02:00
Jos de Jong
23f32fae9c
Fix #1856: make the library robust against Object prototype pollution (#1860) 2020-05-18 21:33:33 +02:00
Lazersmoke
05860b8c19
Clarify eigs documentation (#1847)
The matrix `math.eigs(H).vectors` contains the eigenvectors as columns, not rows, as previously suggested.
Also includes example of how to access the relevant vectors using `math.column`.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-05-09 12:12:10 +02:00
josdejong
23e38bea60 Remove all deprecated code and warnings 2020-05-06 21:57:33 +02:00
josdejong
aafa456e6f Merge branch 'develop' into v7
# Conflicts:
#	HISTORY.md
#	package-lock.json
#	package.json
2020-05-06 20:50:53 +02:00
Tom Hickson
1348d67b7e Updated diff function to allow selecting a dimension 2020-04-24 18:15:34 +01:00
Jos de Jong
12395f21d0
Merge branch 'develop' into Undo 2020-04-11 13:36:59 +02:00
josdejong
8fcf7d22cf Improve explanation of engineering notation in function format 2020-04-11 13:31:56 +02:00
Tom Hickson
9a66b80bff Finalized Diff function
Added tests and then fixed all linting issues
2020-04-08 19:28:02 +01:00
Tom Hickson
b94a346596 Diff docs 2020-04-08 19:01:35 +01:00
Tom Hickson
bc3cbbcb20 Diff function 2020-04-08 18:55:37 +01:00
jos
7e8d128bd6 Fixed eigs not using config.epsilon (see #1789) 2020-04-04 17:05:30 +02:00
Michal Grňo
aafef5760c
Improve dot product (#1773)
* make dot product faster and correct for ℂ

* minor fixes

* added tests, fixed bugs

* add dot for sparse matrices

* make multiply(vec, vec) use dot

* add test for complex vectors

* added test for mul(vec, vec), removed one TODO comment

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-03-29 17:04:57 +02:00
jos
5624e6938f Fix #1789: Function eigs not calculating with BigNumber precision when input contains BigNumbers 2020-03-29 16:17:19 +02:00
jos
52f6defe1c Fix examples in documentation of row and column, see #230 2020-02-26 11:16:44 +01:00
David Bramwell
88733f70af
Let simplify handle a/(b/c) (#1734)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-02-04 20:34:37 +01:00
jos
1d5ad22296 Remove redundant code causing a vague error, see #1724 2020-02-04 20:30:35 +01:00
jos
b9246d9a45 Replace Array.fill with a helper function, replace var with let/const, return .values as Matrix too when input is a Matrix. See #1705 2020-01-20 20:08:34 +01:00
Arkajit Mandal
0b188e385c Adding eigs function (#1705)
* eigs test file initialize

* file for function for diagonalization of a real symmetrix matrix

* eigs typed function written according to mathjs requirements

* some linting issues addressed

* more linting issues in eigs

* linting passed for eigs (blank template function)

* making eigs fail

* eigs added to factory any

* initial check of input in eigs

* linting issues fix in eigs

* added rotation and theta matrix

* diagonalization loop added

* diagonalization result return

* diagonalization returns eigenvalue and eigenvectors

* function for updating Sij

* function for updating matrix

* a small bug fix

* some linting fixed in eigs

* lint and bug fix at eigs

* linting passed in eigs

* tests for input in eigs

* tests for trivial eigenvalue problem (sanity check)

* 2x2 check for non-diagonal matrix

* sorting added to eigs

* sorting function lint fix in eigs

* example for eigs updated

* 3x3 diagonalization by eigs passed

* bug in eigenvector

* eigenvalues seem to work

* cloning array so that original matrix do not get transformed in eigs

* eigenvector check

* eigenvector deep check and eigs description modified

* embedding dos for eigs

* doc for eigs fix

* slight change in example

* adding checkInput type

* type error for bad matrix elements

* type error for every element

* name change for typecheck function

* check matrix type of array input

* type error message update in eigs

* type error message grammer in eigs

* eigs bug fix

* eigs bug fix in check function

* eigs typecheck test

* some lint fix in eigs and corresponding tests

* before adding bingNumber implementation in eigs

* support for fractions

* obtain angle for bigNumber type

* theta for bignumbers

* update overlap for bigNumber

* jacobi rotation of input matrix for BigNumbers

* largest element for bigNumbers

* diagonalization for bigNumbers

* adding dependedncies

* diagonization for bigNumber

* diag for bigNumber is tested

* linting fix for eig and eigs test

* problem for bigNumber fix

* error message modification for eigs

* more coverage for eigs function

* eigs test bug fix

* simplify test

* is Symmetric function

* use matrix instead in eigs

* slight cleanup

* is symmetric bug fix

* no need to return in isSymmetrix

* small bug fix for fractions

* using scalar function when possible

* small lint correction

* return object in eigs

* bug fix in array eigs

* test object implementation

* description update

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-01-20 19:50:07 +01:00
Veeloxfire
10449b2326 Extend distance with support for n-dimensions 2020-01-04 21:03:53 +01:00
Bartosz Leoniak
1f10538588 Improve performance of factorial for BigNumbers (#1691) 2019-12-31 11:31:35 +01:00
Harry Sarson
462f46947f fix qr and sign edge cases (#1670)
* fix qr and sign edge cases

qr() was throwing an error if the pivots of a matrix were zero.
This commit fixes that and ensures that the results are consistant
with wolfram alpha.

Whilst doing this I found a bug in complex.js, I have added a work
around but we should flag this upstream.

I also addressed the long standing concerns about assert statements
within the body of the qr function.

Fixes #1669
Fixes #942

* further improvements to qr and sign

mainly fixing things I got wrong in previous commit

* add array test

* fix: remove only from tests and disallow

Uses mochas `--forbid-only` flag as advised by
https://github.com/standard/standard/issues/988
2019-11-18 20:03:09 +01:00
Arthur Guiot
34b676a1cc Improved performances for isPrime (#1641)
* Improved performances for isPrime

The prime test performance have been improved compared to previous version.

* Fixed build

* Fixed build for isPrime

* Removed extra semicolons to fix lint
2019-10-06 10:40:48 +02:00
Clinton Curry
69dd165afb Allow taking means of quantities with units. (#1644)
* Allow taking means of quantities with units.

* Fix silly error in test.

The test as written did not test anything about units.

* Fix same error again...
2019-10-03 20:28:25 +02:00
jos
a4f84512cd Fixed #1615: error in the docs of isNumeric 2019-09-11 10:10:46 +02:00
Waseem Yusuf
430a00f7b2 Refactor combinations.js to be more readable (#1607) 2019-08-31 09:54:56 +02:00
Waseem Yusuf
c0e87c4b71 Make combinationsWithRep.js more efficient (#1602)
* Implemented the `multicombinations` function

* Write unit tests for `multicombinations` function

* Integrate the `multicombinations` function throughout codebase

1. Include multicombinations factory function in factoriesAny.js and factoriesNumber.js
2. Write embedded docs for multicombinations
3. Added latex support
4. Refer to multicombinations in the "see also"-section of related functions

* Change name from `multichoose` to `combinationsWithRep`

* Update combinationsWithRep.js

Instead of always cancelling `n-1 factorial` from the denominator and ignoring `k factorial`, added a conditional to cancel the the larger of the two, therefore further reducing redundant calculations.

* Revert "Update combinationsWithRep.js"

This reverts commit efef6d3bd4c381aa12f00869a7624a622268805c.

* Update combinationsWithRep.js

Instead of always cancelling `n-1 factorial` from the denominator and ignoring `k factorial`, added a conditional to cancel the the larger of the two, therefore further reducing redundant calculations.

* Add one more test for the case: k > n-1

* Refactor single for-loop into two separate ones
2019-08-28 15:10:24 +02:00
Harry Sarson
4cfef3ac34 fix no-case-declarations lint 2019-08-21 10:09:10 +01:00
Waseem Yusuf
4cee37232f Added a combinationsWithRep function to calculate combinations with repitition (#1588)
* Implemented the `multicombinations` function

* Write unit tests for `multicombinations` function

* Integrate the `multicombinations` function throughout codebase

1. Include multicombinations factory function in factoriesAny.js and factoriesNumber.js
2. Write embedded docs for multicombinations
3. Added latex support
4. Refer to multicombinations in the "see also"-section of related functions

* Change name from `multichoose` to `combinationsWithRep`
2019-08-15 11:35:51 +02:00