mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Fixed incompatibility with v4 (index.js file)
This commit is contained in:
parent
6d340e0faa
commit
17f07ec098
@ -7,7 +7,7 @@ const babel = require('gulp-babel')
|
||||
const uglify = require('uglify-js')
|
||||
const docgenerator = require('./tools/docgenerator')
|
||||
|
||||
const ENTRY = './src/index.js'
|
||||
const ENTRY = './src/main.js'
|
||||
const HEADER = './src/header.js'
|
||||
const VERSION = './src/version.js'
|
||||
const COMPILE_SRC = './src/**/*.js'
|
||||
|
||||
2
index.js
2
index.js
@ -1 +1 @@
|
||||
module.exports = require('./lib/index')
|
||||
module.exports = require('./lib/main')
|
||||
|
||||
55
src/index.js
55
src/index.js
@ -1,47 +1,10 @@
|
||||
'use strict'
|
||||
// This file contains all factory functions of math.js
|
||||
|
||||
import core from './core/core'
|
||||
|
||||
/**
|
||||
* math.js factory function. Creates a new instance of math.js
|
||||
*
|
||||
* @param {Object} [config] Available configuration options:
|
||||
* {number} epsilon
|
||||
* Minimum relative difference between two
|
||||
* compared values, used by all comparison functions.
|
||||
* {string} matrix
|
||||
* A string 'matrix' (default) or 'array'.
|
||||
* {string} number
|
||||
* A string 'number' (default), 'bignumber', or
|
||||
* 'fraction'
|
||||
* {number} precision
|
||||
* The number of significant digits for BigNumbers.
|
||||
* Not applicable for Numbers.
|
||||
* {boolean} predictable
|
||||
* Predictable output type of functions. When true,
|
||||
* output type depends only on the input types. When
|
||||
* false (default), output type can vary depending
|
||||
* on input values. For example `math.sqrt(-4)`
|
||||
* returns `complex('2i')` when predictable is false, and
|
||||
* returns `NaN` when true.
|
||||
*/
|
||||
function create (config) {
|
||||
// create a new math.js instance
|
||||
const math = core.create(config)
|
||||
math.create = create
|
||||
|
||||
// import data types, functions, constants, expression parser, etc.
|
||||
math['import']([
|
||||
require('./type'), // data types (Matrix, Complex, Unit, ...)
|
||||
require('./constants'), // constants
|
||||
require('./expression'), // expression parsing
|
||||
require('./function'), // functions
|
||||
require('./json'), // serialization utility (math.json.reviver)
|
||||
require('./error') // errors
|
||||
])
|
||||
|
||||
return math
|
||||
}
|
||||
|
||||
// return a new instance of math.js
|
||||
module.exports = create()
|
||||
module.exports = [
|
||||
require('./type'), // data types (Matrix, Complex, Unit, ...)
|
||||
require('./constants'), // constants
|
||||
require('./expression'), // expression parsing
|
||||
require('./function'), // functions
|
||||
require('./json'), // serialization utility (math.json.reviver)
|
||||
require('./error') // errors
|
||||
]
|
||||
|
||||
40
src/main.js
Normal file
40
src/main.js
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict'
|
||||
|
||||
import core from './core/core'
|
||||
|
||||
/**
|
||||
* math.js factory function. Creates a new instance of math.js
|
||||
*
|
||||
* @param {Object} [config] Available configuration options:
|
||||
* {number} epsilon
|
||||
* Minimum relative difference between two
|
||||
* compared values, used by all comparison functions.
|
||||
* {string} matrix
|
||||
* A string 'matrix' (default) or 'array'.
|
||||
* {string} number
|
||||
* A string 'number' (default), 'bignumber', or
|
||||
* 'fraction'
|
||||
* {number} precision
|
||||
* The number of significant digits for BigNumbers.
|
||||
* Not applicable for Numbers.
|
||||
* {boolean} predictable
|
||||
* Predictable output type of functions. When true,
|
||||
* output type depends only on the input types. When
|
||||
* false (default), output type can vary depending
|
||||
* on input values. For example `math.sqrt(-4)`
|
||||
* returns `complex('2i')` when predictable is false, and
|
||||
* returns `NaN` when true.
|
||||
*/
|
||||
function create (config) {
|
||||
// create a new math.js instance
|
||||
const math = core.create(config)
|
||||
math.create = create
|
||||
|
||||
// import data types, functions, constants, expression parser, etc.
|
||||
math['import'](require('./index'))
|
||||
|
||||
return math
|
||||
}
|
||||
|
||||
// return a new instance of math.js
|
||||
module.exports = create()
|
||||
@ -3,7 +3,7 @@ const version = require('../package.json').version
|
||||
|
||||
describe('lib', function () {
|
||||
it('should load lib/index.js', function () {
|
||||
const math = require('../lib/index.js')
|
||||
const math = require('../lib/main')
|
||||
|
||||
assert.equal(math.add(2, 3), 5)
|
||||
assert.equal(math.version, version)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const approx = require('../../../../tools/approx'), math = require('../../../../src/index'), market = require('../../../../tools/matrixmarket')
|
||||
const approx = require('../../../../tools/approx'), math = require('../../../../src/main'), market = require('../../../../tools/matrixmarket')
|
||||
|
||||
describe('slu - matrix market', function () {
|
||||
it('should decompose matrix, 48 x 48, natural ordering (order=0), full pivoting, matrix market', function (done) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../../tools/approx')
|
||||
const market = require('../../../../tools/matrixmarket')
|
||||
const math = require('../../../../src/index').create()
|
||||
const math = require('../../../../src/main').create()
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_amd'))
|
||||
|
||||
const cs_amd = math.sparse.cs_amd
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../../tools/approx')
|
||||
const market = require('../../../../tools/matrixmarket')
|
||||
const math = require('../../../../src/index').create()
|
||||
const math = require('../../../../src/main').create()
|
||||
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_permute'))
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_lu'))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test multiply
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const market = require('../../../tools/matrixmarket')
|
||||
|
||||
describe('multiply', function () {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), math = require('../src/index'), approx = require('../tools/approx')
|
||||
const assert = require('assert'), math = require('../src/main'), approx = require('../tools/approx')
|
||||
|
||||
describe('constants', function () {
|
||||
describe('number', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
|
||||
describe('config', function () {
|
||||
// TODO: test function config
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test import
|
||||
const assert = require('assert')
|
||||
const mathjs = require('../../src/index')
|
||||
const mathjs = require('../../src/main')
|
||||
const approx = require('../../tools/approx')
|
||||
|
||||
describe('import', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
const math2 = math.create()
|
||||
|
||||
describe('typed', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test error messages for deprecated functions
|
||||
const assert = require('assert')
|
||||
const math = require('../src/index')
|
||||
const math = require('../src/main')
|
||||
|
||||
describe('deprecated stuff', function () {
|
||||
it('should throw a deprecation error when using UpdateNode', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test Help
|
||||
const assert = require('assert')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
const Help = math.type.Help
|
||||
|
||||
describe('help', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test parser
|
||||
|
||||
const assert = require('assert'), approx = require('../../tools/approx'), math = require('../../src/index'), Parser = math.expression.Parser
|
||||
const assert = require('assert'), approx = require('../../tools/approx'), math = require('../../src/main'), Parser = math.expression.Parser
|
||||
|
||||
describe('parser', function () {
|
||||
it('should create a parser', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test compile
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
describe('compile', function () {
|
||||
it('should compile an expression', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test eval
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Complex = math.type.Complex
|
||||
const Matrix = math.type.Matrix
|
||||
const Unit = math.type.Unit
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/index')
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/main')
|
||||
|
||||
describe('help', function () {
|
||||
it('should find documentation for a function by its name', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test parse
|
||||
const assert = require('assert')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
|
||||
describe('parse', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Parser = math.expression.Parser
|
||||
|
||||
describe('parser', function () {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// test AccessorNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const bigmath = require('../../../src/index').create({number: 'BigNumber'})
|
||||
const math = require('../../../src/main')
|
||||
const bigmath = require('../../../src/main').create({number: 'BigNumber'})
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const OperatorNode = math.expression.node.OperatorNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test ArrayNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test AssignmentNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const AccessorNode = math.expression.node.AccessorNode
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test BlockNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test ConditionalNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// test ConstantNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const bigmath = require('../../../src/index').create({number: 'BigNumber'})
|
||||
const math = require('../../../src/main')
|
||||
const bigmath = require('../../../src/main').create({number: 'BigNumber'})
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test FunctionAssignmentNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index').create()
|
||||
const math = require('../../../src/main').create()
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test FunctionNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index').create()
|
||||
const math = require('../../../src/main').create()
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test IndexNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test Node
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
|
||||
describe('Node', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test ObjectNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test OperatorNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test SymbolNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const OperatorNode = math.expression.node.OperatorNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test RangeNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test SymbolNode
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const Node = math.expression.node.Node
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const assert = require('assert')
|
||||
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
const operators = require('../../src/expression/operators')
|
||||
const OperatorNode = math.expression.node.OperatorNode
|
||||
const AssignmentNode = math.expression.node.AssignmentNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test parse
|
||||
const assert = require('assert')
|
||||
const approx = require('../../tools/approx')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
const ArgumentsError = require('../../src/error/ArgumentsError')
|
||||
const parse = math.expression.parse
|
||||
const ConditionalNode = math.expression.node.ConditionalNode
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
|
||||
describe('security', function () {
|
||||
it('should not allow calling Function via constructor', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test transforms
|
||||
const assert = require('assert')
|
||||
const approx = require('../../tools/approx')
|
||||
const math = require('../../src/index')
|
||||
const math = require('../../src/main')
|
||||
const parse = math.expression.parse
|
||||
|
||||
describe('transforms', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test lup
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
describe('lup', function () {
|
||||
it('should decompose matrix, n x n, no permutations, array', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test lup
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
/**
|
||||
* Tests whether `Q` and `R` are the valid QR decomposition of `A`.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
describe('slu', function () {
|
||||
it('should decompose matrix, 4 x 4, natural ordering (order=0), partial pivoting', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test derivative
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const OperatorNode = math.expression.node.OperatorNode
|
||||
const ConstantNode = math.expression.node.ConstantNode
|
||||
const SymbolNode = math.expression.node.SymbolNode
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
/**
|
||||
* Transform node, array and single type value in a string with no spaces inside.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test simplify
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
describe('simplify', function () {
|
||||
function simplifyAndCompare (left, right, scope) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test lsolve
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
describe('lsolve', function () {
|
||||
it('should solve linear system 4 x 4, arrays', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test lusolve
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
describe('lusolve', function () {
|
||||
it('should solve linear system 4 x 4, arrays', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test usolve
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/index')
|
||||
const assert = require('assert'), approx = require('../../../../tools/approx'), math = require('../../../../src/main')
|
||||
|
||||
describe('usolve', function () {
|
||||
it('should solve linear system 4 x 4, arrays', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../../tools/approx')
|
||||
const math = require('../../../../src/index').create()
|
||||
const math = require('../../../../src/main').create()
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_permute'))
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_lu'))
|
||||
math.import(require('../../../../src/function/algebra/sparse/cs_sqr'))
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test abs
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
describe('abs', function () {
|
||||
it('should return the abs value of a boolean', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test add
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const add = math.add
|
||||
|
||||
// TODO: make unit tests independent of math
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test add
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const BigNumber = require('decimal.js')
|
||||
const add = math.add
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const cbrt = math.cbrt
|
||||
const bignumber = math.bignumber
|
||||
const complex = math.complex
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test ceil
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const complex = math.complex
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test cube
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const unit = math.unit
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test divide
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const error = require('../../../src/error/index')
|
||||
const approx = require('../../../tools/approx')
|
||||
const divide = math.divide
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test dotDivide (element-wise divide)
|
||||
const assert = require('assert'), math = require('../../../src/index'), approx = require('../../../tools/approx'), dotDivide = math.dotDivide, complex = math.complex
|
||||
const assert = require('assert'), math = require('../../../src/main'), approx = require('../../../tools/approx'), dotDivide = math.dotDivide, complex = math.complex
|
||||
|
||||
describe('dotDivide', function () {
|
||||
it('should divide two numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test dotMultiply (element-wise multiply)
|
||||
const assert = require('assert'), math = require('../../../src/index'), approx = require('../../../tools/approx'), error = require('../../../src/error/index'), dotMultiply = math.dotMultiply, divide = math.divide, matrix = math.matrix, sparse = math.sparse, complex = math.complex, range = math.range, i = math.i, unit = math.unit
|
||||
const assert = require('assert'), math = require('../../../src/main'), approx = require('../../../tools/approx'), error = require('../../../src/error/index'), dotMultiply = math.dotMultiply, divide = math.divide, matrix = math.matrix, sparse = math.sparse, complex = math.complex, range = math.range, i = math.i, unit = math.unit
|
||||
|
||||
describe('dotMultiply', function () {
|
||||
it('should multiply 2 numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test exp
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/index'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, dotPow = math.dotPow
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/main'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, dotPow = math.dotPow
|
||||
|
||||
describe('dotPow', function () {
|
||||
it('should elevate a number to the given power', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test exp
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/index'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, exp = math.exp
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/main'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, exp = math.exp
|
||||
|
||||
describe('exp', function () {
|
||||
it('should exponentiate a boolean', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test expm1
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/index'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, expm1 = math.expm1
|
||||
const assert = require('assert'), approx = require('../../../tools/approx'), math = require('../../../src/main'), complex = math.complex, matrix = math.matrix, sparse = math.sparse, unit = math.unit, expm1 = math.expm1
|
||||
|
||||
describe('expm1', function () {
|
||||
it('should exponentiate a boolean', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test fix
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const complex = math.complex
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test floor
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const complex = math.complex
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test gcd
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, gcd = math.gcd
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, gcd = math.gcd
|
||||
|
||||
describe('gcd', function () {
|
||||
it('should find the greatest common divisor of two or more numbers', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test hypot
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const hypot = math.hypot
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, lcm = math.lcm
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, lcm = math.lcm
|
||||
|
||||
describe('lcm', function () {
|
||||
it('should find the lowest common multiple of two or more numbers', function () {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const complex = math.complex
|
||||
const matrix = math.matrix
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test exp
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const complex = math.complex
|
||||
const matrix = math.matrix
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const complex = math.complex
|
||||
const matrix = math.matrix
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test exp
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const complex = math.complex
|
||||
const matrix = math.matrix
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test mod
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const matrix = math.matrix
|
||||
const sparse = math.sparse
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test multiply
|
||||
const assert = require('assert'), math = require('../../../src/index'), approx = require('../../../tools/approx'), multiply = math.multiply, divide = math.divide, matrix = math.matrix, complex = math.complex, bignumber = math.bignumber, i = math.i, unit = math.unit
|
||||
const assert = require('assert'), math = require('../../../src/main'), approx = require('../../../tools/approx'), multiply = math.multiply, divide = math.divide, matrix = math.matrix, complex = math.complex, bignumber = math.bignumber, i = math.i, unit = math.unit
|
||||
|
||||
describe('multiply', function () {
|
||||
describe('Scalar', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test norm
|
||||
const assert = require('assert'), math = require('../../../src/index')
|
||||
const assert = require('assert'), math = require('../../../src/main')
|
||||
|
||||
describe('norm', function () {
|
||||
it('should return the absolute value of a boolean', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test nthRoot
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const matrix = math.matrix
|
||||
const sparse = math.sparse
|
||||
const unit = math.unit
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test nthRoots
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const complex = math.complex
|
||||
const nthRoots = math.nthRoots
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test round
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
const matrix = math.matrix
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test sign
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
const complex = math.complex
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const mathPredictable = math.create({predictable: true})
|
||||
const sqrt = math.sqrt
|
||||
const bignumber = math.bignumber
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test square
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const unit = math.unit
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// test subtract
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const subtract = math.subtract
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test unary minus
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
const complex = math.complex
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// test unary plus
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const error = require('../../../src/error/index')
|
||||
const bignumber = math.bignumber
|
||||
const fraction = math.fraction
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test xgcd
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/index').create({matrix: 'Array'}), gcd = math.gcd, xgcd = math.xgcd
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/main').create({matrix: 'Array'}), gcd = math.gcd, xgcd = math.xgcd
|
||||
|
||||
describe('xgcd', function () {
|
||||
it('should return extended greatest common divisor of two numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test bitAnd
|
||||
const assert = require('assert'), math = require('../../../src/index'), bignumber = math.bignumber, bitAnd = math.bitAnd
|
||||
const assert = require('assert'), math = require('../../../src/main'), bignumber = math.bignumber, bitAnd = math.bitAnd
|
||||
|
||||
describe('bitAnd', function () {
|
||||
it('should bitwise and two numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test bitNot
|
||||
const assert = require('assert'), math = require('../../../src/index'), bignumber = math.bignumber, bitNot = math.bitNot
|
||||
const assert = require('assert'), math = require('../../../src/main'), bignumber = math.bignumber, bitNot = math.bitNot
|
||||
|
||||
describe('bitNot', function () {
|
||||
it('should return bitwise not of a boolean', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test bitOr
|
||||
const assert = require('assert'), math = require('../../../src/index'), bignumber = math.bignumber, bitOr = math.bitOr
|
||||
const assert = require('assert'), math = require('../../../src/main'), bignumber = math.bignumber, bitOr = math.bitOr
|
||||
|
||||
describe('bitOr', function () {
|
||||
it('should bitwise or two numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test bitXor
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, bitXor = math.bitXor
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, bitXor = math.bitXor
|
||||
|
||||
describe('bitXor', function () {
|
||||
it('should xor two numbers', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test leftShift
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, leftShift = math.leftShift
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, leftShift = math.leftShift
|
||||
|
||||
describe('leftShift', function () {
|
||||
it('should left shift a number by a given amount', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test rightArithShift
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, rightArithShift = math.rightArithShift
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, bignumber = math.bignumber, rightArithShift = math.rightArithShift
|
||||
|
||||
describe('rightArithShift', function () {
|
||||
it('should right arithmetically shift a number by a given amount', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// test rightLogShift
|
||||
const assert = require('assert'), math = require('../../../src/index'), matrix = math.matrix, sparse = math.sparse, rightLogShift = math.rightLogShift
|
||||
const assert = require('assert'), math = require('../../../src/main'), matrix = math.matrix, sparse = math.sparse, rightLogShift = math.rightLogShift
|
||||
|
||||
describe('rightLogShift', function () {
|
||||
it('should right logically shift a number by a given amount', function () {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/index'), bellNumbers = math.bellNumbers
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/main'), bellNumbers = math.bellNumbers
|
||||
|
||||
describe('bellNumbers', function () {
|
||||
it('should calculate the number of partitions of a set', function () {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/index'), catalan = math.catalan
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/main'), catalan = math.catalan
|
||||
|
||||
describe('catalan', function () {
|
||||
it('should calculate the nth catalan number', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const error = require('../../../src/error/index')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const composition = math.composition
|
||||
|
||||
describe('composition', function () {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/index'), stirlingS2 = math.stirlingS2
|
||||
const assert = require('assert'), error = require('../../../src/error/index'), math = require('../../../src/main'), stirlingS2 = math.stirlingS2
|
||||
|
||||
describe('stirlingS2', function () {
|
||||
it('should calculate the number of ways to partition a set of n objects into k non-empty subsets', function () {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const approx = require('../../../tools/approx')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const arg = math.arg
|
||||
|
||||
describe('arg', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
const conj = math.conj
|
||||
|
||||
describe('conj', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
describe('im', function () {
|
||||
it('should return the imaginary part of a complex number', function () {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const math = require('../../../src/index')
|
||||
const math = require('../../../src/main')
|
||||
|
||||
describe('re', function () {
|
||||
it('should return the real part of a complex number', function () {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user