Intial Commit
This commit is contained in:
+117
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
|
||||
var object = require('../utils/object');
|
||||
var string = require('../utils/string');
|
||||
|
||||
function factory (type, config, load, typed) {
|
||||
var parser = load(require('./function/parser'))();
|
||||
|
||||
/**
|
||||
* Documentation object
|
||||
* @param {Object} doc Object containing properties:
|
||||
* {string} name
|
||||
* {string} category
|
||||
* {string} description
|
||||
* {string[]} syntax
|
||||
* {string[]} examples
|
||||
* {string[]} seealso
|
||||
* @constructor
|
||||
*/
|
||||
function Help(doc) {
|
||||
if (!(this instanceof Help)) {
|
||||
throw new SyntaxError('Constructor must be called with the new operator');
|
||||
}
|
||||
|
||||
if (!doc) throw new Error('Argument "doc" missing');
|
||||
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach type information
|
||||
*/
|
||||
Help.prototype.type = 'Help';
|
||||
Help.prototype.isHelp = true;
|
||||
|
||||
/**
|
||||
* Generate a string representation of the Help object
|
||||
* @return {string} Returns a string
|
||||
* @private
|
||||
*/
|
||||
Help.prototype.toString = function () {
|
||||
var doc = this.doc || {};
|
||||
var desc = '\n';
|
||||
|
||||
if (doc.name) {
|
||||
desc += 'Name: ' + doc.name + '\n\n';
|
||||
}
|
||||
if (doc.category) {
|
||||
desc += 'Category: ' + doc.category + '\n\n';
|
||||
}
|
||||
if (doc.description) {
|
||||
desc += 'Description:\n ' + doc.description + '\n\n';
|
||||
}
|
||||
if (doc.syntax) {
|
||||
desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n';
|
||||
}
|
||||
if (doc.examples) {
|
||||
desc += 'Examples:\n';
|
||||
for (var i = 0; i < doc.examples.length; i++) {
|
||||
var expr = doc.examples[i];
|
||||
desc += ' ' + expr + '\n';
|
||||
|
||||
var res;
|
||||
try {
|
||||
res = parser.eval(expr);
|
||||
}
|
||||
catch (e) {
|
||||
res = e;
|
||||
}
|
||||
if (res && !res.isHelp) {
|
||||
desc += ' ' + string.format(res, {precision: 14}) + '\n';
|
||||
}
|
||||
}
|
||||
desc += '\n';
|
||||
}
|
||||
if (doc.seealso) {
|
||||
desc += 'See also: ' + doc.seealso.join(', ') + '\n';
|
||||
}
|
||||
|
||||
return desc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the help object to JSON
|
||||
*/
|
||||
Help.prototype.toJSON = function () {
|
||||
var obj = object.clone(this.doc);
|
||||
obj.mathjs = 'Help';
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate a Help object from a JSON object
|
||||
* @param {Object} json
|
||||
* @returns {Help} Returns a new Help object
|
||||
*/
|
||||
Help.fromJSON = function (json) {
|
||||
var doc = {};
|
||||
for (var prop in json) {
|
||||
if (prop !== 'mathjs') { // ignore mathjs field
|
||||
doc[prop] = json[prop];
|
||||
}
|
||||
}
|
||||
return new Help(doc);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string representation of the Help object
|
||||
*/
|
||||
Help.prototype.valueOf = Help.prototype.toString;
|
||||
|
||||
return Help;
|
||||
}
|
||||
|
||||
exports.name = 'Help';
|
||||
exports.path = 'type';
|
||||
exports.factory = factory;
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
'use strict';
|
||||
|
||||
var extend = require('../utils/object').extend;
|
||||
|
||||
function factory (type, config, load, typed, math) {
|
||||
var _parse = load(require('./parse'));
|
||||
|
||||
/**
|
||||
* @constructor Parser
|
||||
* Parser contains methods to evaluate or parse expressions, and has a number
|
||||
* of convenience methods to get, set, and remove variables from memory. Parser
|
||||
* keeps a scope containing variables in memory, which is used for all
|
||||
* evaluations.
|
||||
*
|
||||
* Methods:
|
||||
* var result = parser.eval(expr); // evaluate an expression
|
||||
* var value = parser.get(name); // retrieve a variable from the parser
|
||||
* var values = parser.getAll(); // retrieve all defined variables
|
||||
* parser.set(name, value); // set a variable in the parser
|
||||
* parser.remove(name); // clear a variable from the
|
||||
* // parsers scope
|
||||
* parser.clear(); // clear the parsers scope
|
||||
*
|
||||
* Example usage:
|
||||
* var parser = new Parser();
|
||||
* // Note: there is a convenience method which can be used instead:
|
||||
* // var parser = new math.parser();
|
||||
*
|
||||
* // evaluate expressions
|
||||
* parser.eval('sqrt(3^2 + 4^2)'); // 5
|
||||
* parser.eval('sqrt(-4)'); // 2i
|
||||
* parser.eval('2 inch in cm'); // 5.08 cm
|
||||
* parser.eval('cos(45 deg)'); // 0.7071067811865476
|
||||
*
|
||||
* // define variables and functions
|
||||
* parser.eval('x = 7 / 2'); // 3.5
|
||||
* parser.eval('x + 3'); // 6.5
|
||||
* parser.eval('function f(x, y) = x^y'); // f(x, y)
|
||||
* parser.eval('f(2, 3)'); // 8
|
||||
*
|
||||
* // get and set variables and functions
|
||||
* var x = parser.get('x'); // 7
|
||||
* var f = parser.get('f'); // function
|
||||
* var g = f(3, 2); // 9
|
||||
* parser.set('h', 500);
|
||||
* var i = parser.eval('h / 2'); // 250
|
||||
* parser.set('hello', function (name) {
|
||||
* return 'hello, ' + name + '!';
|
||||
* });
|
||||
* parser.eval('hello("user")'); // "hello, user!"
|
||||
*
|
||||
* // clear defined functions and variables
|
||||
* parser.clear();
|
||||
*
|
||||
*/
|
||||
function Parser() {
|
||||
if (!(this instanceof Parser)) {
|
||||
throw new SyntaxError(
|
||||
'Constructor must be called with the new operator');
|
||||
}
|
||||
this.scope = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach type information
|
||||
*/
|
||||
Parser.prototype.type = 'Parser';
|
||||
Parser.prototype.isParser = true;
|
||||
|
||||
/**
|
||||
* Parse an expression and return the parsed function node.
|
||||
* The node tree can be compiled via `code = node.compile(math)`,
|
||||
* and the compiled code can be executed as `code.eval([scope])`
|
||||
* @param {string} expr
|
||||
* @return {Node} node
|
||||
* @throws {Error}
|
||||
*/
|
||||
Parser.prototype.parse = function (expr) {
|
||||
throw new Error('Parser.parse is deprecated. Use math.parse instead.');
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse and compile an expression, return the compiled javascript code.
|
||||
* The node can be evaluated via code.eval([scope])
|
||||
* @param {string} expr
|
||||
* @return {{eval: function}} code
|
||||
* @throws {Error}
|
||||
*/
|
||||
Parser.prototype.compile = function (expr) {
|
||||
throw new Error('Parser.compile is deprecated. Use math.compile instead.');
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse and evaluate the given expression
|
||||
* @param {string} expr A string containing an expression, for example "2+3"
|
||||
* @return {*} result The result, or undefined when the expression was empty
|
||||
* @throws {Error}
|
||||
*/
|
||||
Parser.prototype.eval = function (expr) {
|
||||
// TODO: validate arguments
|
||||
return _parse(expr)
|
||||
.compile()
|
||||
.eval(this.scope);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a variable (a function or variable) by name from the parsers scope.
|
||||
* Returns undefined when not found
|
||||
* @param {string} name
|
||||
* @return {* | undefined} value
|
||||
*/
|
||||
Parser.prototype.get = function (name) {
|
||||
// TODO: validate arguments
|
||||
return this.scope[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a map with all defined variables
|
||||
* @return {Object} values
|
||||
*/
|
||||
Parser.prototype.getAll = function () {
|
||||
return extend({}, this.scope);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a symbol (a function or variable) by name from the parsers scope.
|
||||
* @param {string} name
|
||||
* @param {* | undefined} value
|
||||
*/
|
||||
Parser.prototype.set = function (name, value) {
|
||||
// TODO: validate arguments
|
||||
return this.scope[name] = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a variable from the parsers scope
|
||||
* @param {string} name
|
||||
*/
|
||||
Parser.prototype.remove = function (name) {
|
||||
// TODO: validate arguments
|
||||
delete this.scope[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the scope with variables and functions
|
||||
*/
|
||||
Parser.prototype.clear = function () {
|
||||
for (var name in this.scope) {
|
||||
if (this.scope.hasOwnProperty(name)) {
|
||||
delete this.scope[name];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return Parser;
|
||||
}
|
||||
|
||||
exports.name = 'Parser';
|
||||
exports.path = 'expression';
|
||||
exports.factory = factory;
|
||||
exports.math = true; // requires the math namespace as 5th argument
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'Infinity',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'Infinity'
|
||||
],
|
||||
'description': 'Infinity, a number which is larger than the maximum number that can be handled by a floating point number.',
|
||||
'examples': [
|
||||
'Infinity',
|
||||
'1 / 0'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'LN10',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'LN10'
|
||||
],
|
||||
'description': 'Returns the natural logarithm of 10, approximately equal to 2.302',
|
||||
'examples': [
|
||||
'LN10',
|
||||
'log(10)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'LN2',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'LN2'
|
||||
],
|
||||
'description': 'Returns the natural logarithm of 2, approximately equal to 0.693',
|
||||
'examples': [
|
||||
'LN2',
|
||||
'log(2)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'LOG10E',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'LOG10E'
|
||||
],
|
||||
'description': 'Returns the base-10 logarithm of E, approximately equal to 0.434',
|
||||
'examples': [
|
||||
'LOG10E',
|
||||
'log(e, 10)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'LOG2E',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'LOG2E'
|
||||
],
|
||||
'description': 'Returns the base-2 logarithm of E, approximately equal to 1.442',
|
||||
'examples': [
|
||||
'LOG2E',
|
||||
'log(e, 2)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'NaN',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'NaN'
|
||||
],
|
||||
'description': 'Not a number',
|
||||
'examples': [
|
||||
'NaN',
|
||||
'0 / 0'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'SQRT1_2',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'SQRT1_2'
|
||||
],
|
||||
'description': 'Returns the square root of 1/2, approximately equal to 0.707',
|
||||
'examples': [
|
||||
'SQRT1_2',
|
||||
'sqrt(1/2)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'SQRT2',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'SQRT2'
|
||||
],
|
||||
'description': 'Returns the square root of 2, approximately equal to 1.414',
|
||||
'examples': [
|
||||
'SQRT2',
|
||||
'sqrt(2)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'e',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'e'
|
||||
],
|
||||
'description': 'Euler\'s number, the base of the natural logarithm. Approximately equal to 2.71828',
|
||||
'examples': [
|
||||
'e',
|
||||
'e ^ 2',
|
||||
'exp(2)',
|
||||
'log(e)'
|
||||
],
|
||||
'seealso': ['exp']
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'false',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'false'
|
||||
],
|
||||
'description': 'Boolean value false',
|
||||
'examples': [
|
||||
'false'
|
||||
],
|
||||
'seealso': ['true']
|
||||
};
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'i',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'i'
|
||||
],
|
||||
'description': 'Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.',
|
||||
'examples': [
|
||||
'i',
|
||||
'i * i',
|
||||
'sqrt(-1)'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'null',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'null'
|
||||
],
|
||||
'description': 'Value null',
|
||||
'examples': [
|
||||
'null'
|
||||
],
|
||||
'seealso': ['true', 'false']
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'phi',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'phi'
|
||||
],
|
||||
'description': 'Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...',
|
||||
'examples': [
|
||||
'tau'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'pi',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'pi'
|
||||
],
|
||||
'description': 'The number pi is a mathematical constant that is the ratio of a circle\'s circumference to its diameter, and is approximately equal to 3.14159',
|
||||
'examples': [
|
||||
'pi',
|
||||
'sin(pi/2)'
|
||||
],
|
||||
'seealso': ['tau']
|
||||
};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'tau',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'tau'
|
||||
],
|
||||
'description': 'Tau is the ratio constant of a circle\'s circumference to radius, equal to 2 * pi, approximately 6.2832.',
|
||||
'examples': [
|
||||
'tau',
|
||||
'2 * pi'
|
||||
],
|
||||
'seealso': ['pi']
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'true',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'true'
|
||||
],
|
||||
'description': 'Boolean value true',
|
||||
'examples': [
|
||||
'true'
|
||||
],
|
||||
'seealso': ['false']
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'version',
|
||||
'category': 'Constants',
|
||||
'syntax': [
|
||||
'version'
|
||||
],
|
||||
'description': 'A string with the version number of math.js',
|
||||
'examples': [
|
||||
'version'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'bignumber',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'bignumber(x)'
|
||||
],
|
||||
'description':
|
||||
'Create a big number from a number or string.',
|
||||
'examples': [
|
||||
'0.1 + 0.2',
|
||||
'bignumber(0.1) + bignumber(0.2)',
|
||||
'bignumber("7.2")',
|
||||
'bignumber("7.2e500")',
|
||||
'bignumber([0.1, 0.2, 0.3])'
|
||||
],
|
||||
'seealso': [
|
||||
'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
'name': 'boolean',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'x',
|
||||
'boolean(x)'
|
||||
],
|
||||
'description':
|
||||
'Convert a string or number into a boolean.',
|
||||
'examples': [
|
||||
'boolean(0)',
|
||||
'boolean(1)',
|
||||
'boolean(3)',
|
||||
'boolean("true")',
|
||||
'boolean("false")',
|
||||
'boolean([1, 0, 1, 1])'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'complex', 'index', 'matrix', 'number', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'complex',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'complex()',
|
||||
'complex(re, im)',
|
||||
'complex(string)'
|
||||
],
|
||||
'description':
|
||||
'Create a complex number.',
|
||||
'examples': [
|
||||
'complex()',
|
||||
'complex(2, 3)',
|
||||
'complex("7 - 2i")'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'index', 'matrix', 'number', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'createUnit',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'createUnit(definitions)',
|
||||
'createUnit(name, definition)'
|
||||
],
|
||||
'description':
|
||||
'Create a user-defined unit and register it with the Unit type.',
|
||||
'examples': [
|
||||
'createUnit("foo")',
|
||||
'createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})',
|
||||
'createUnit("mph", "1 mile/hour")'
|
||||
],
|
||||
'seealso': [
|
||||
'unit', 'splitUnit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'fraction',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'fraction(num)',
|
||||
'fraction(num,den)'
|
||||
],
|
||||
'description':
|
||||
'Create a fraction from a number or from a numerator and denominator.',
|
||||
'examples': [
|
||||
'fraction(0.125)',
|
||||
'fraction(1, 3) + fraction(2, 5)'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'index', 'matrix', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'name': 'index',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'[start]',
|
||||
'[start:end]',
|
||||
'[start:step:end]',
|
||||
'[start1, start 2, ...]',
|
||||
'[start1:end1, start2:end2, ...]',
|
||||
'[start1:step1:end1, start2:step2:end2, ...]'
|
||||
],
|
||||
'description':
|
||||
'Create an index to get or replace a subset of a matrix',
|
||||
'examples': [
|
||||
'[]',
|
||||
'[1, 2, 3]',
|
||||
'A = [1, 2, 3; 4, 5, 6]',
|
||||
'A[1, :]',
|
||||
'A[1, 2] = 50',
|
||||
'A[0:2, 0:2] = ones(2, 2)'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'matrix,', 'number', 'range', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'name': 'matrix',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'[]',
|
||||
'[a1, b1, ...; a2, b2, ...]',
|
||||
'matrix()',
|
||||
'matrix("dense")',
|
||||
'matrix([...])'
|
||||
],
|
||||
'description':
|
||||
'Create a matrix.',
|
||||
'examples': [
|
||||
'[]',
|
||||
'[1, 2, 3]',
|
||||
'[1, 2, 3; 4, 5, 6]',
|
||||
'matrix()',
|
||||
'matrix([3, 4])',
|
||||
'matrix([3, 4; 5, 6], "sparse")',
|
||||
'matrix([3, 4; 5, 6], "sparse", "number")'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'sparse'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
'name': 'number',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'x',
|
||||
'number(x)'
|
||||
],
|
||||
'description':
|
||||
'Create a number or convert a string or boolean into a number.',
|
||||
'examples': [
|
||||
'2',
|
||||
'2e3',
|
||||
'4.05',
|
||||
'number(2)',
|
||||
'number("7.2")',
|
||||
'number(true)',
|
||||
'number([true, false, true, true])',
|
||||
'number("52cm", "m")'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'sparse',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'sparse()',
|
||||
'sparse([a1, b1, ...; a1, b2, ...])',
|
||||
'sparse([a1, b1, ...; a1, b2, ...], "number")'
|
||||
],
|
||||
'description':
|
||||
'Create a sparse matrix.',
|
||||
'examples': [
|
||||
'sparse()',
|
||||
'sparse([3, 4; 5, 6])',
|
||||
'sparse([3, 0; 5, 0], "number")'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'matrix'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'splitUnit',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'splitUnit(unit: Unit, parts: Unit[])'
|
||||
],
|
||||
'description':
|
||||
'Split a unit in an array of units whose sum is equal to the original unit.',
|
||||
'examples': [
|
||||
'splitUnit(1 m, ["feet", "inch"])'
|
||||
],
|
||||
'seealso': [
|
||||
'unit', 'createUnit'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'string',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'"text"',
|
||||
'string(x)'
|
||||
],
|
||||
'description':
|
||||
'Create a string or convert a value to a string',
|
||||
'examples': [
|
||||
'"Hello World!"',
|
||||
'string(4.2)',
|
||||
'string(3 + 2i)'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'unit'
|
||||
]
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'unit',
|
||||
'category': 'Construction',
|
||||
'syntax': [
|
||||
'value unit',
|
||||
'unit(value, unit)',
|
||||
'unit(string)'
|
||||
],
|
||||
'description':
|
||||
'Create a unit.',
|
||||
'examples': [
|
||||
'5.5 mm',
|
||||
'3 inch',
|
||||
'unit(7.1, "kilogram")',
|
||||
'unit("23 deg")'
|
||||
],
|
||||
'seealso': [
|
||||
'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'string'
|
||||
]
|
||||
};
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'config',
|
||||
'category': 'Core',
|
||||
'syntax': [
|
||||
'config()',
|
||||
'config(options)'
|
||||
],
|
||||
'description': 'Get configuration or change configuration.',
|
||||
'examples': [
|
||||
'config()',
|
||||
'1/3 + 1/4',
|
||||
'config({number: "Fraction"})',
|
||||
'1/3 + 1/4'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'import',
|
||||
'category': 'Core',
|
||||
'syntax': [
|
||||
'import(functions)',
|
||||
'import(functions, options)'
|
||||
],
|
||||
'description': 'Import functions or constants from an object.',
|
||||
'examples': [
|
||||
'import({myFn: f(x)=x^2, myConstant: 32 })',
|
||||
'myFn(2)',
|
||||
'myConstant'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'typed',
|
||||
'category': 'Core',
|
||||
'syntax': [
|
||||
'typed(signatures)',
|
||||
'typed(name, signatures)'
|
||||
],
|
||||
'description': 'Create a typed function.',
|
||||
'examples': [
|
||||
'double = typed({ "number, number": f(x)=x+x })',
|
||||
'double(2)',
|
||||
'double("hello")'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
'name': 'derivative',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'derivative(expr)',
|
||||
'derivative(expr, {simplify: boolean})'
|
||||
],
|
||||
'description': 'Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.',
|
||||
'examples': [
|
||||
'derivative("2x^3", "x")',
|
||||
'derivative("2x^3", "x", {simplify: false})',
|
||||
'derivative("2x^2 + 3x + 4", "x")',
|
||||
'derivative("sin(2x)", "x")',
|
||||
'f = parse("x^2 + x")',
|
||||
'x = parse("x")',
|
||||
'df = derivative(f, x)',
|
||||
'df.eval({x: 3})'
|
||||
],
|
||||
'seealso': [
|
||||
'simplify', 'parse', 'eval'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'lsolve',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'x=lsolve(L, b)'
|
||||
],
|
||||
'description':
|
||||
'Solves the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.',
|
||||
'examples': [
|
||||
'a = [-2, 3; 2, 1]',
|
||||
'b = [11, 9]',
|
||||
'x = lsolve(a, b)'
|
||||
],
|
||||
'seealso': [
|
||||
'lup', 'lusolve', 'usolve', 'matrix', 'sparse'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'lup',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'lup(m)'
|
||||
],
|
||||
'description':
|
||||
'Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U',
|
||||
'examples': [
|
||||
'lup([[2, 1], [1, 4]])',
|
||||
'lup(matrix([[2, 1], [1, 4]]))',
|
||||
'lup(sparse([[2, 1], [1, 4]]))'
|
||||
],
|
||||
'seealso': [
|
||||
'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'slu'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'lusolve',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'x=lusolve(A, b)',
|
||||
'x=lusolve(lu, b)'
|
||||
],
|
||||
'description': 'Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.',
|
||||
'examples': [
|
||||
'a = [-2, 3; 2, 1]',
|
||||
'b = [11, 9]',
|
||||
'x = lusolve(a, b)'
|
||||
],
|
||||
'seealso': [
|
||||
'lup', 'slu', 'lsolve', 'usolve', 'matrix', 'sparse'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'simplify',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'simplify(expr)',
|
||||
'simplify(expr, rules)'
|
||||
],
|
||||
'description': 'Simplify an expression tree.',
|
||||
'examples': [
|
||||
'simplify("3 + 2 / 4")',
|
||||
'simplify("2x + x")',
|
||||
'f = parse("x * (x + 2 + x)")',
|
||||
'simplified = simplify(f)',
|
||||
'simplified.eval({x: 2})'
|
||||
],
|
||||
'seealso': [
|
||||
'derivative', 'parse', 'eval'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'slu',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'slu(A, order, threshold)'
|
||||
],
|
||||
'description': 'Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U',
|
||||
'examples': [
|
||||
'slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)'
|
||||
],
|
||||
'seealso': [
|
||||
'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'lup'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'usolve',
|
||||
'category': 'Algebra',
|
||||
'syntax': [
|
||||
'x=usolve(U, b)'
|
||||
],
|
||||
'description':
|
||||
'Solves the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.',
|
||||
'examples': [
|
||||
'x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])'
|
||||
],
|
||||
'seealso': [
|
||||
'lup', 'lusolve', 'lsolve', 'matrix', 'sparse'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'abs',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'abs(x)'
|
||||
],
|
||||
'description': 'Compute the absolute value.',
|
||||
'examples': [
|
||||
'abs(3.5)',
|
||||
'abs(-4.2)'
|
||||
],
|
||||
'seealso': ['sign']
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'add',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x + y',
|
||||
'add(x, y)'
|
||||
],
|
||||
'description': 'Add two values.',
|
||||
'examples': [
|
||||
'a = 2.1 + 3.6',
|
||||
'a - 3.6',
|
||||
'3 + 2i',
|
||||
'3 cm + 2 inch',
|
||||
'"2.3" + "4"'
|
||||
],
|
||||
'seealso': [
|
||||
'subtract'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'name': 'cbrt',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'cbrt(x)',
|
||||
'cbrt(x, allRoots)'
|
||||
],
|
||||
'description':
|
||||
'Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned',
|
||||
'examples': [
|
||||
'cbrt(64)',
|
||||
'cube(4)',
|
||||
'cbrt(-8)',
|
||||
'cbrt(2 + 3i)',
|
||||
'cbrt(8i)',
|
||||
'cbrt(8i, true)',
|
||||
'cbrt(27 m^3)'
|
||||
],
|
||||
'seealso': [
|
||||
'square',
|
||||
'sqrt',
|
||||
'cube',
|
||||
'multiply'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'ceil',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'ceil(x)'
|
||||
],
|
||||
'description':
|
||||
'Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.',
|
||||
'examples': [
|
||||
'ceil(3.2)',
|
||||
'ceil(3.8)',
|
||||
'ceil(-4.2)'
|
||||
],
|
||||
'seealso': ['floor', 'fix', 'round']
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'cube',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'cube(x)'
|
||||
],
|
||||
'description': 'Compute the cube of a value. The cube of x is x * x * x.',
|
||||
'examples': [
|
||||
'cube(2)',
|
||||
'2^3',
|
||||
'2 * 2 * 2'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'square',
|
||||
'pow'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'divide',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x / y',
|
||||
'divide(x, y)'
|
||||
],
|
||||
'description': 'Divide two values.',
|
||||
'examples': [
|
||||
'a = 2 / 3',
|
||||
'a * 3',
|
||||
'4.5 / 2',
|
||||
'3 + 4 / 2',
|
||||
'(3 + 4) / 2',
|
||||
'18 km / 4.5'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'dotDivide',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x ./ y',
|
||||
'dotDivide(x, y)'
|
||||
],
|
||||
'description': 'Divide two values element wise.',
|
||||
'examples': [
|
||||
'a = [1, 2, 3; 4, 5, 6]',
|
||||
'b = [2, 1, 1; 3, 2, 5]',
|
||||
'a ./ b'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'dotMultiply',
|
||||
'divide'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'dotMultiply',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x .* y',
|
||||
'dotMultiply(x, y)'
|
||||
],
|
||||
'description': 'Multiply two values element wise.',
|
||||
'examples': [
|
||||
'a = [1, 2, 3; 4, 5, 6]',
|
||||
'b = [2, 1, 1; 3, 2, 5]',
|
||||
'a .* b'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'divide',
|
||||
'dotDivide'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'dotpow',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x .^ y',
|
||||
'dotpow(x, y)'
|
||||
],
|
||||
'description':
|
||||
'Calculates the power of x to y element wise.',
|
||||
'examples': [
|
||||
'a = [1, 2, 3; 4, 5, 6]',
|
||||
'a .^ 2'
|
||||
],
|
||||
'seealso': [
|
||||
'pow'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'exp',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'exp(x)'
|
||||
],
|
||||
'description': 'Calculate the exponent of a value.',
|
||||
'examples': [
|
||||
'exp(1.3)',
|
||||
'e ^ 1.3',
|
||||
'log(exp(1.3))',
|
||||
'x = 2.4',
|
||||
'(exp(i*x) == cos(x) + i*sin(x)) # Euler\'s formula'
|
||||
],
|
||||
'seealso': [
|
||||
'pow',
|
||||
'log'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'fix',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'fix(x)'
|
||||
],
|
||||
'description':
|
||||
'Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.',
|
||||
'examples': [
|
||||
'fix(3.2)',
|
||||
'fix(3.8)',
|
||||
'fix(-4.2)',
|
||||
'fix(-4.8)'
|
||||
],
|
||||
'seealso': ['ceil', 'floor', 'round']
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'floor',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'floor(x)'
|
||||
],
|
||||
'description':
|
||||
'Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.',
|
||||
'examples': [
|
||||
'floor(3.2)',
|
||||
'floor(3.8)',
|
||||
'floor(-4.2)'
|
||||
],
|
||||
'seealso': ['ceil', 'fix', 'round']
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'gcd',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'gcd(a, b)',
|
||||
'gcd(a, b, c, ...)'
|
||||
],
|
||||
'description': 'Compute the greatest common divisor.',
|
||||
'examples': [
|
||||
'gcd(8, 12)',
|
||||
'gcd(-4, 6)',
|
||||
'gcd(25, 15, -10)'
|
||||
],
|
||||
'seealso': [ 'lcm', 'xgcd' ]
|
||||
};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'hypot',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'hypot(a, b, c, ...)',
|
||||
'hypot([a, b, c, ...])'
|
||||
],
|
||||
'description': 'Calculate the hypotenusa of a list with values. ',
|
||||
'examples': [
|
||||
'hypot(3, 4)',
|
||||
'sqrt(3^2 + 4^2)',
|
||||
'hypot(-2)',
|
||||
'hypot([3, 4, 5])'
|
||||
],
|
||||
'seealso': [ 'abs', 'norm' ]
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'lcm',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'lcm(x, y)'
|
||||
],
|
||||
'description': 'Compute the least common multiple.',
|
||||
'examples': [
|
||||
'lcm(4, 6)',
|
||||
'lcm(6, 21)',
|
||||
'lcm(6, 21, 5)'
|
||||
],
|
||||
'seealso': [ 'gcd' ]
|
||||
};
|
||||
Generated
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
'name': 'log',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'log(x)',
|
||||
'log(x, base)'
|
||||
],
|
||||
'description': 'Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).',
|
||||
'examples': [
|
||||
'log(3.5)',
|
||||
'a = log(2.4)',
|
||||
'exp(a)',
|
||||
'10 ^ 4',
|
||||
'log(10000, 10)',
|
||||
'log(10000) / log(10)',
|
||||
'b = log(1024, 2)',
|
||||
'2 ^ b'
|
||||
],
|
||||
'seealso': [
|
||||
'exp',
|
||||
'log10'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'log10',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'log10(x)'
|
||||
],
|
||||
'description': 'Compute the 10-base logarithm of a value.',
|
||||
'examples': [
|
||||
'log10(0.00001)',
|
||||
'log10(10000)',
|
||||
'10 ^ 4',
|
||||
'log(10000) / log(10)',
|
||||
'log(10000, 10)'
|
||||
],
|
||||
'seealso': [
|
||||
'exp',
|
||||
'log'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'mod',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x % y',
|
||||
'x mod y',
|
||||
'mod(x, y)'
|
||||
],
|
||||
'description':
|
||||
'Calculates the modulus, the remainder of an integer division.',
|
||||
'examples': [
|
||||
'7 % 3',
|
||||
'11 % 2',
|
||||
'10 mod 4',
|
||||
'function isOdd(x) = x % 2',
|
||||
'isOdd(2)',
|
||||
'isOdd(3)'
|
||||
],
|
||||
'seealso': ['divide']
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'multiply',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x * y',
|
||||
'multiply(x, y)'
|
||||
],
|
||||
'description': 'multiply two values.',
|
||||
'examples': [
|
||||
'a = 2.1 * 3.4',
|
||||
'a / 3.4',
|
||||
'2 * 3 + 4',
|
||||
'2 * (3 + 4)',
|
||||
'3 * 2.1 km'
|
||||
],
|
||||
'seealso': [
|
||||
'divide'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'norm',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'norm(x)',
|
||||
'norm(x, p)'
|
||||
],
|
||||
'description': 'Calculate the norm of a number, vector or matrix.',
|
||||
'examples': [
|
||||
'abs(-3.5)',
|
||||
'norm(-3.5)',
|
||||
'norm(3 - 4i))',
|
||||
'norm([1, 2, -3], Infinity)',
|
||||
'norm([1, 2, -3], -Infinity)',
|
||||
'norm([3, 4], 2)',
|
||||
'norm([[1, 2], [3, 4]], 1)',
|
||||
'norm([[1, 2], [3, 4]], \'inf\')',
|
||||
'norm([[1, 2], [3, 4]], \'fro\')'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
'name': 'nthRoot',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'nthRoot(a)',
|
||||
'nthRoot(a, root)'
|
||||
],
|
||||
'description': 'Calculate the nth root of a value. ' +
|
||||
'The principal nth root of a positive real number A, ' +
|
||||
'is the positive real solution of the equation "x^root = A".',
|
||||
'examples': [
|
||||
'4 ^ 3',
|
||||
'nthRoot(64, 3)',
|
||||
'nthRoot(9, 2)',
|
||||
'sqrt(9)'
|
||||
],
|
||||
'seealso': [
|
||||
'sqrt',
|
||||
'pow'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'pow',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x ^ y',
|
||||
'pow(x, y)'
|
||||
],
|
||||
'description':
|
||||
'Calculates the power of x to y, x^y.',
|
||||
'examples': [
|
||||
'2^3 = 8',
|
||||
'2*2*2',
|
||||
'1 + e ^ (pi * i)'
|
||||
],
|
||||
'seealso': [ 'multiply' ]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'round',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'round(x)',
|
||||
'round(x, n)'
|
||||
],
|
||||
'description':
|
||||
'round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.',
|
||||
'examples': [
|
||||
'round(3.2)',
|
||||
'round(3.8)',
|
||||
'round(-4.2)',
|
||||
'round(-4.8)',
|
||||
'round(pi, 3)',
|
||||
'round(123.45678, 2)'
|
||||
],
|
||||
'seealso': ['ceil', 'floor', 'fix']
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'sign',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'sign(x)'
|
||||
],
|
||||
'description':
|
||||
'Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.',
|
||||
'examples': [
|
||||
'sign(3.5)',
|
||||
'sign(-4.2)',
|
||||
'sign(0)'
|
||||
],
|
||||
'seealso': [
|
||||
'abs'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'sqrt',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'sqrt(x)'
|
||||
],
|
||||
'description':
|
||||
'Compute the square root value. If x = y * y, then y is the square root of x.',
|
||||
'examples': [
|
||||
'sqrt(25)',
|
||||
'5 * 5',
|
||||
'sqrt(-1)'
|
||||
],
|
||||
'seealso': [
|
||||
'square',
|
||||
'multiply'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
'name': 'square',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'square(x)'
|
||||
],
|
||||
'description':
|
||||
'Compute the square of a value. The square of x is x * x.',
|
||||
'examples': [
|
||||
'square(3)',
|
||||
'sqrt(9)',
|
||||
'3^2',
|
||||
'3 * 3'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'pow',
|
||||
'sqrt',
|
||||
'cube'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'subtract',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'x - y',
|
||||
'subtract(x, y)'
|
||||
],
|
||||
'description': 'subtract two values.',
|
||||
'examples': [
|
||||
'a = 5.3 - 2',
|
||||
'a + 2',
|
||||
'2/3 - 1/6',
|
||||
'2 * 3 - 3',
|
||||
'2.1 km - 500m'
|
||||
],
|
||||
'seealso': [
|
||||
'add'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'unaryMinus',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'-x',
|
||||
'unaryMinus(x)'
|
||||
],
|
||||
'description':
|
||||
'Inverse the sign of a value. Converts booleans and strings to numbers.',
|
||||
'examples': [
|
||||
'-4.5',
|
||||
'-(-5.6)',
|
||||
'-"22"'
|
||||
],
|
||||
'seealso': [
|
||||
'add', 'subtract', 'unaryPlus'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'unaryPlus',
|
||||
'category': 'Operators',
|
||||
'syntax': [
|
||||
'+x',
|
||||
'unaryPlus(x)'
|
||||
],
|
||||
'description':
|
||||
'Converts booleans and strings to numbers.',
|
||||
'examples': [
|
||||
'+true',
|
||||
'+"2"'
|
||||
],
|
||||
'seealso': [
|
||||
'add', 'subtract', 'unaryMinus'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'xgcd',
|
||||
'category': 'Arithmetic',
|
||||
'syntax': [
|
||||
'xgcd(a, b)'
|
||||
],
|
||||
'description': 'Calculate the extended greatest common divisor for two values',
|
||||
'examples': [
|
||||
'xgcd(8, 12)',
|
||||
'gcd(8, 12)',
|
||||
'xgcd(36163, 21199)'
|
||||
],
|
||||
'seealso': [ 'gcd', 'lcm' ]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'bitAnd',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'x & y',
|
||||
'bitAnd(x, y)'
|
||||
],
|
||||
'description': 'Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0',
|
||||
'examples': [
|
||||
'5 & 3',
|
||||
'bitAnd(53, 131)',
|
||||
'[1, 12, 31] & 42'
|
||||
],
|
||||
'seealso': [
|
||||
'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'bitNot',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'~x',
|
||||
'bitNot(x)'
|
||||
],
|
||||
'description': 'Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.',
|
||||
'examples': [
|
||||
'~1',
|
||||
'~2',
|
||||
'bitNot([2, -3, 4])'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'bitOr',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'x | y',
|
||||
'bitOr(x, y)'
|
||||
],
|
||||
'description': 'Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.',
|
||||
'examples': [
|
||||
'5 | 3',
|
||||
'bitOr([1, 2, 3], 4)'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitNot', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'bitXor',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'bitXor(x, y)'
|
||||
],
|
||||
'description': 'Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.',
|
||||
'examples': [
|
||||
'bitOr(1, 2)',
|
||||
'bitXor([2, 3, 4], 4)'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitNot', 'bitOr', 'leftShift', 'rightArithShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'name': 'leftShift',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'x << y',
|
||||
'leftShift(x, y)'
|
||||
],
|
||||
'description': 'Bitwise left logical shift of a value x by y number of bits.',
|
||||
'examples': [
|
||||
'4 << 1',
|
||||
'8 >> 1'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'rightArithShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'rightArithShift',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'x >> y',
|
||||
'leftShift(x, y)'
|
||||
],
|
||||
'description': 'Bitwise right arithmetic shift of a value x by y number of bits.',
|
||||
'examples': [
|
||||
'8 >> 1',
|
||||
'4 << 1',
|
||||
'-12 >> 2'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightLogShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'rightLogShift',
|
||||
'category': 'Bitwise',
|
||||
'syntax': [
|
||||
'x >> y',
|
||||
'leftShift(x, y)'
|
||||
],
|
||||
'description': 'Bitwise right logical shift of a value x by y number of bits.',
|
||||
'examples': [
|
||||
'8 >>> 1',
|
||||
'4 << 1',
|
||||
'-12 >>> 2'
|
||||
],
|
||||
'seealso': [
|
||||
'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'bellNumbers',
|
||||
'category': 'Combinatorics',
|
||||
'syntax': [
|
||||
'bellNumbers(n)'
|
||||
],
|
||||
'description': 'The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.',
|
||||
'examples': [
|
||||
'bellNumbers(3)',
|
||||
'bellNumbers(8)'
|
||||
],
|
||||
'seealso': ['stirlingS2']
|
||||
};
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'name': 'catalan',
|
||||
'category': 'Combinatorics',
|
||||
'syntax': [
|
||||
'catalan(n)'
|
||||
],
|
||||
'description': 'The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.',
|
||||
'examples': [
|
||||
'catalan(3)',
|
||||
'catalan(8)'
|
||||
],
|
||||
'seealso': ['bellNumbers']
|
||||
};
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'composition',
|
||||
'category': 'Combinatorics',
|
||||
'syntax': [
|
||||
'composition(n, k)'
|
||||
],
|
||||
'description': 'The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.',
|
||||
'examples': [
|
||||
'composition(5, 3)'
|
||||
],
|
||||
'seealso': ['combinations']
|
||||
};
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
'name': 'stirlingS2',
|
||||
'category': 'Combinatorics',
|
||||
'syntax': [
|
||||
'stirlingS2(n, k)'
|
||||
],
|
||||
'description': 'he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.',
|
||||
'examples': [
|
||||
'stirlingS2(5, 3)'
|
||||
],
|
||||
'seealso': ['bellNumbers']
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'arg',
|
||||
'category': 'Complex',
|
||||
'syntax': [
|
||||
'arg(x)'
|
||||
],
|
||||
'description':
|
||||
'Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).',
|
||||
'examples': [
|
||||
'arg(2 + 2i)',
|
||||
'atan2(3, 2)',
|
||||
'arg(2 + 3i)'
|
||||
],
|
||||
'seealso': [
|
||||
're',
|
||||
'im',
|
||||
'conj',
|
||||
'abs'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'conj',
|
||||
'category': 'Complex',
|
||||
'syntax': [
|
||||
'conj(x)'
|
||||
],
|
||||
'description':
|
||||
'Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.',
|
||||
'examples': [
|
||||
'conj(2 + 3i)',
|
||||
'conj(2 - 3i)',
|
||||
'conj(-5.2i)'
|
||||
],
|
||||
'seealso': [
|
||||
're',
|
||||
'im',
|
||||
'abs',
|
||||
'arg'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'im',
|
||||
'category': 'Complex',
|
||||
'syntax': [
|
||||
'im(x)'
|
||||
],
|
||||
'description': 'Get the imaginary part of a complex number.',
|
||||
'examples': [
|
||||
'im(2 + 3i)',
|
||||
're(2 + 3i)',
|
||||
'im(-5.2i)',
|
||||
'im(2.4)'
|
||||
],
|
||||
'seealso': [
|
||||
're',
|
||||
'conj',
|
||||
'abs',
|
||||
'arg'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 're',
|
||||
'category': 'Complex',
|
||||
'syntax': [
|
||||
're(x)'
|
||||
],
|
||||
'description': 'Get the real part of a complex number.',
|
||||
'examples': [
|
||||
're(2 + 3i)',
|
||||
'im(2 + 3i)',
|
||||
're(-5.2i)',
|
||||
're(2.4)'
|
||||
],
|
||||
'seealso': [
|
||||
'im',
|
||||
'conj',
|
||||
'abs',
|
||||
'arg'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'eval',
|
||||
'category': 'Expression',
|
||||
'syntax': [
|
||||
'eval(expression)',
|
||||
'eval([expr1, expr2, expr3, ...])'
|
||||
],
|
||||
'description': 'Evaluate an expression or an array with expressions.',
|
||||
'examples': [
|
||||
'eval("2 + 3")',
|
||||
'eval("sqrt(" + 4 + ")")'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'help',
|
||||
'category': 'Expression',
|
||||
'syntax': [
|
||||
'help(object)',
|
||||
'help(string)'
|
||||
],
|
||||
'description': 'Display documentation on a function or data type.',
|
||||
'examples': [
|
||||
'help(sqrt)',
|
||||
'help("complex")'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'distance',
|
||||
'category': 'Geometry',
|
||||
'syntax': [
|
||||
'distance([x1, y1], [x2, y2])',
|
||||
'distance([[x1, y1], [x2, y2])'
|
||||
],
|
||||
'description': 'Calculates the Euclidean distance between two points.',
|
||||
'examples': [
|
||||
'distance([0,0], [4,4])',
|
||||
'distance([[0,0], [4,4]])'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
'name': 'intersect',
|
||||
'category': 'Geometry',
|
||||
'syntax': [
|
||||
'intersect(expr1, expr2, expr3, expr4)',
|
||||
'intersect(expr1, expr2, expr3)'
|
||||
],
|
||||
'description': 'Computes the intersection point of lines and/or planes.',
|
||||
'examples': [
|
||||
'intersect([0, 0], [10, 10], [10, 0], [0, 10])',
|
||||
'intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])'
|
||||
],
|
||||
'seealso': []
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'and',
|
||||
'category': 'Logical',
|
||||
'syntax': [
|
||||
'x and y',
|
||||
'and(x, y)'
|
||||
],
|
||||
'description': 'Logical and. Test whether two values are both defined with a nonzero/nonempty value.',
|
||||
'examples': [
|
||||
'true and false',
|
||||
'true and true',
|
||||
'2 and 4'
|
||||
],
|
||||
'seealso': [
|
||||
'not', 'or', 'xor'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'not',
|
||||
'category': 'Logical',
|
||||
'syntax': [
|
||||
'not x',
|
||||
'not(x)'
|
||||
],
|
||||
'description': 'Logical not. Flips the boolean value of given argument.',
|
||||
'examples': [
|
||||
'not true',
|
||||
'not false',
|
||||
'not 2',
|
||||
'not 0'
|
||||
],
|
||||
'seealso': [
|
||||
'and', 'or', 'xor'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'or',
|
||||
'category': 'Logical',
|
||||
'syntax': [
|
||||
'x or y',
|
||||
'or(x, y)'
|
||||
],
|
||||
'description': 'Logical or. Test if at least one value is defined with a nonzero/nonempty value.',
|
||||
'examples': [
|
||||
'true or false',
|
||||
'false or false',
|
||||
'0 or 4'
|
||||
],
|
||||
'seealso': [
|
||||
'not', 'and', 'xor'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'xor',
|
||||
'category': 'Logical',
|
||||
'syntax': [
|
||||
'x or y',
|
||||
'or(x, y)'
|
||||
],
|
||||
'description': 'Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.',
|
||||
'examples': [
|
||||
'true xor false',
|
||||
'false xor false',
|
||||
'true xor true',
|
||||
'0 or 4'
|
||||
],
|
||||
'seealso': [
|
||||
'not', 'and', 'or'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'name': 'concat',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'concat(A, B, C, ...)',
|
||||
'concat(A, B, C, ..., dim)'
|
||||
],
|
||||
'description': 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.',
|
||||
'examples': [
|
||||
'A = [1, 2; 5, 6]',
|
||||
'B = [3, 4; 7, 8]',
|
||||
'concat(A, B)',
|
||||
'concat(A, B, 1)',
|
||||
'concat(A, B, 2)'
|
||||
],
|
||||
'seealso': [
|
||||
'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'name': 'cross',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'cross(A, B)'
|
||||
],
|
||||
'description': 'Calculate the cross product for two vectors in three dimensional space.',
|
||||
'examples': [
|
||||
'cross([1, 1, 0], [0, 1, 1])',
|
||||
'cross([3, -3, 1], [4, 9, 2])',
|
||||
'cross([2, 3, 4], [5, 6, 7])'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'dot'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'name': 'det',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'det(x)'
|
||||
],
|
||||
'description': 'Calculate the determinant of a matrix',
|
||||
'examples': [
|
||||
'det([1, 2; 3, 4])',
|
||||
'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])'
|
||||
],
|
||||
'seealso': [
|
||||
'concat', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'diag',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'diag(x)',
|
||||
'diag(x, k)'
|
||||
],
|
||||
'description': 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.',
|
||||
'examples': [
|
||||
'diag(1:3)',
|
||||
'diag(1:3, 1)',
|
||||
'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]',
|
||||
'diag(a)'
|
||||
],
|
||||
'seealso': [
|
||||
'concat', 'det', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
'name': 'dot',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'dot(A, B)'
|
||||
],
|
||||
'description': 'Calculate the dot product of two vectors. ' +
|
||||
'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' +
|
||||
'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn',
|
||||
'examples': [
|
||||
'dot([2, 4, 1], [2, 2, 3])',
|
||||
'[2, 4, 1] * [2, 2, 3]'
|
||||
],
|
||||
'seealso': [
|
||||
'multiply',
|
||||
'cross'
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'name': 'eye',
|
||||
'category': 'Matrix',
|
||||
'syntax': [
|
||||
'eye(n)',
|
||||
'eye(m, n)',
|
||||
'eye([m, n])',
|
||||
'eye'
|
||||
],
|
||||
'description': 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.',
|
||||
'examples': [
|
||||
'eye(3)',
|
||||
'eye(3, 5)',
|
||||
'a = [1, 2, 3; 4, 5, 6]',
|
||||
'eye(size(a))'
|
||||
],
|
||||
'seealso': [
|
||||
'concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros'
|
||||
]
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user