UNPKG

1.67 kBJavaScriptView Raw
1var core = require('./core');
2
3/**
4 * math.js factory function. Creates a new instance of math.js
5 *
6 * @param {Object} [config] Available configuration options:
7 * {number} epsilon
8 * Minimum relative difference between two
9 * compared values, used by all comparison functions.
10 * {string} matrix
11 * A string 'matrix' (default) or 'array'.
12 * {string} number
13 * A string 'number' (default), 'bignumber', or
14 * 'fraction'
15 * {number} precision
16 * The number of significant digits for BigNumbers.
17 * Not applicable for Numbers.
18 * {boolean} predictable
19 * Predictable output type of functions. When true,
20 * output type depends only on the input types. When
21 * false (default), output type can vary depending
22 * on input values. For example `math.sqrt(-4)`
23 * returns `complex('2i')` when predictable is false, and
24 * returns `NaN` when true.
25 */
26function create (config) {
27 // create a new math.js instance
28 var math = core.create(config);
29 math.create = create;
30
31 // import data types, functions, constants, expression parser, etc.
32 math['import'](require('./lib'));
33
34 return math;
35}
36
37// return a new instance of math.js
38module.exports = create();