Comparing version 0.4.0 to 0.5.0
# math.js changelog | ||
https://github.com/josdejong/mathjs | ||
## 2013-04-06, version 0.5.0 | ||
*Note: version 0.5 is incompatible with previous versions.* | ||
- Implemented data types Matrix and Range. | ||
- Implemented matrix methods clone, concat, det, diag, eye, inv, ones, size, | ||
squeeze, transpose, zeros. | ||
- Implemented range operator (:), and transpose operator (') in parser.s | ||
- Changed: created construction methods for easy object creation for all data | ||
types and for the parser. For example, a complex value is now created | ||
with "math.complex(2, 3)" instead of "new math.Complex(2, 3)", and a parser | ||
is now created with "math.parser()" instead of "new math.parser.Parser()". | ||
- Changed: moved all data types under the namespace math.type, and moved the | ||
Parser, Workspace, etc. under the namespace math.expr. | ||
- Changed: changed operator precedence of the power operator: | ||
- it is now right associative instead of left associative like most scripting | ||
languages. So 2^3^4 is now calculated as 2^(3^4). | ||
- it has now higher precedence than unary minus most languages, thus -3^2 is | ||
now calculated as -(3^2). | ||
- Changed: renamed the parsers method 'put' into 'set'. | ||
- Fixed: method 'in' did not check for units to have the same base. | ||
## 2013-03-16, version 0.4.0 | ||
@@ -12,5 +36,5 @@ | ||
- Improved method help: it now evaluates the examples. | ||
- Fixed a scoping issue with the Parser when defining functions. | ||
- Fixed method typeof which was not working well with minified and mangled code. | ||
- Fixed errors in determining the best prefix for a unit. | ||
- Fixed: a scoping issue with the Parser when defining functions. | ||
- Fixed: method 'typeof' was not working well with minified and mangled code. | ||
- Fixed: errors in determining the best prefix for a unit. | ||
@@ -17,0 +41,0 @@ |
{ | ||
"name": "mathjs", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features real and complex numbers, units, matrices, a large set of mathematical functions, and a flexible expression parser.", | ||
@@ -21,2 +21,3 @@ "author": "Jos de Jong <wjosdejong@gmail.com>", | ||
"functions", | ||
"numeric", | ||
"parser", | ||
@@ -23,0 +24,0 @@ "expression", |
168
README.md
@@ -13,3 +13,3 @@ ![math.js](https://raw.github.com/josdejong/mathjs/master/img/mathjs.png) | ||
- Supports numbers, complex numbers, units, strings, arrays, and matrices\*. | ||
- Supports numbers, complex numbers, units, strings, arrays, and matrices. | ||
- Contains a large set of built-in functions and constants. | ||
@@ -21,5 +21,3 @@ - Contains a flexible expression parser. | ||
\* Note: matrices are to be implemented. | ||
## Install | ||
@@ -31,6 +29,7 @@ | ||
Alternatively, the latest stable version of math.js can be downloaded from github: | ||
Or the latest version of math.js can be downloaded from | ||
[mathjs.org](http://mathjs.org/#install_or_download): | ||
- [math.js](https://raw.github.com/josdejong/mathjs/master/math.js) | ||
- [math.min.js](https://raw.github.com/josdejong/mathjs/master/math.min.js) (minified) | ||
- [math.js](http://mathjs.org/js/lib/math.js) (Development version) | ||
- [math.min.js](http://mathjs.org/js/lib/math.min.js) (Production version) | ||
@@ -77,5 +76,3 @@ | ||
```js | ||
var math = require('mathjs'), | ||
Complex = math.Complex, | ||
Unit = math.Unit; | ||
var math = require('mathjs'); | ||
@@ -86,3 +83,3 @@ // use methods and types available in the math object | ||
var c = new Complex(3, -4); // 3 - 4i | ||
var c = math.complex(3, -4); // 3 - 4i | ||
math.sqrt(c); // 2 - i | ||
@@ -92,3 +89,3 @@ | ||
var f = new Unit(60, 'deg'); // 60 deg | ||
var f = math.unit(60, 'deg'); // 60 deg | ||
var g = math.cos(f); // 0.5 | ||
@@ -105,3 +102,3 @@ ``` | ||
The parser supports variable and function definitions. | ||
Variables and functions can be manipulated using the methods `get` and `put`. | ||
Variables and functions can be manipulated using the methods `get` and `set`. | ||
@@ -114,4 +111,4 @@ The following example code shows how to create and use a parser. | ||
// create a new parser | ||
var parser = new math.parser.Parser(); | ||
// create a parser | ||
var parser = math.parser(); | ||
@@ -130,9 +127,9 @@ // evaluate expressions | ||
// get and put variables and functions | ||
// get and set variables and functions | ||
var x = parser.get('x'); // x = 7 | ||
var f = parser.get('f'); // f = function | ||
var g = f(3, 3); // g = 27 | ||
parser.put('h', 500); | ||
parser.set('h', 500); | ||
parser.eval('h / 2'); // 250 | ||
parser.put('hello', function (name) { | ||
parser.set('hello', function (name) { | ||
return 'hello, ' + name + '!'; | ||
@@ -150,3 +147,3 @@ }); | ||
var value = parser.get(name); // retrieve a variable from the parser | ||
parser.put(name, value); // put a variable in the parser | ||
parser.set(name, value); // set a variable in the parser | ||
@@ -169,4 +166,4 @@ var node = parser.parse(expr); // parse an expression into a node tree | ||
// create a new workspace | ||
var workspace = new math.parser.Workspace(); | ||
// create a workspace | ||
var workspace = math.workspace(); | ||
@@ -207,4 +204,2 @@ // add expressions to the workspace | ||
```js | ||
var math = require('mathjs'); | ||
math.subtract(7.1, 2.3); // 4.8 | ||
@@ -220,4 +215,2 @@ math.round(math.pi, 3); // 3.142 | ||
```js | ||
var math = require('math.js'); | ||
math.add('hello ', 'world'); // 'hello world' | ||
@@ -232,7 +225,4 @@ math.max('A', 'D', 'C'); // 'D' | ||
```js | ||
var math = require('math.js'), | ||
Complex = math.Complex; | ||
var a = new Complex(2, 3); // 2 + 3i | ||
var b = new Complex('4 - 2i'); // 4 - 2i | ||
var a = math.complex(2, 3); // 2 + 3i | ||
var b = math.complex('4 - 2i'); // 4 - 2i | ||
math.add(a, b); // 6 + i | ||
@@ -247,29 +237,65 @@ math.sqrt(-4); // 2i | ||
```js | ||
var math = require('math.js'), | ||
Unit = math.Unit; | ||
var a = new Unit(55, 'cm'); // 550 mm | ||
var b = new Unit(0.1, 'm'); // 100 mm | ||
var a = math.unit(55, 'cm'); // 550 mm | ||
var b = math.unit('0.1m'); // 100 mm | ||
math.add(a, b); // 0.65 m | ||
var parser = new math.parser.Parser(); | ||
var parser = math.parser(); | ||
parser.eval('2 inch in cm'); // 5.08 cm | ||
``` | ||
### Array | ||
### Array and Matrix | ||
Math.js supports n-dimensional arrays. Arrays can be created via JavaScript or | ||
using the Parser. | ||
Math.js supports n-dimensional arrays and matrices. Both regular JavaScript | ||
`Array` and the math.js `Matrix` can be used interchangeably in all math.js | ||
functions. | ||
A `Matrix` is an object wrapped around a regular JavaScript Array, providing | ||
utility methods for easy matrix manipulation such as `get`, `set`, `size`, | ||
`resize`, `clone`, and more. | ||
```js | ||
var matrix = math.matrix([1, 4, 9, 16, 25]); // Matrix, [1, 4, 9, 16, 25] | ||
math.sqrt(matrix); // Matrix, [1, 2, 3, 4, 5] | ||
var array = [1, 2, 3, 4, 5]; | ||
math.factorial(array); // Array, [1, 2, 6, 24, 120] | ||
var a = [[1, 2], [3, 4]]; // Array, [[1, 2], [3, 4]] | ||
var b = math.matrix([[5, 6], [1, 1]]); // Matrix, [[5, 6], [1, 1]] | ||
b.set([2, [1, 2]], [[7, 8]]); // Matrix, [[5, 6], [7, 8]] | ||
var c = math.multiply(a, b); // Matrix, [[19, 22], [43, 50]] | ||
var d = c.get([2, 1]); // 43 | ||
``` | ||
Matrices are supported by the parser: | ||
```js | ||
parser = math.parser(); | ||
parser.eval('a = [1, 2; 3, 4]'); // Matrix, [[1, 2], [3, 4]] | ||
parser.eval('b = [5, 6; 7, 8]'); // Matrix, [[5, 6], [1, 1]] | ||
parser.eval('b(2, 1:2) = [7, 8]'); // Matrix, [[5, 6], [7, 8]] | ||
parser.eval('c = a * b'); // Matrix, [[19, 22], [43, 50]] | ||
parser.eval('d = c(2, 1)'); // 43 | ||
``` | ||
### Range | ||
A `Range` creates a range with a start, end, and optionally a step. | ||
A `Range` can be used to create indexes to get or set submatrices. | ||
```js | ||
var math = require('math.js'), | ||
parser = new math.parser.Parser(); | ||
parser = math.parser(); | ||
math.sqrt([1, 4, 9, 16, 25]); // [1, 2, 3, 4, 5] | ||
math.factorial(math.range(1,5)); // Array, [1, 2, 6, 24, 120] | ||
var a = [[1, 2], [3, 4]]; // [1, 2; 3, 4] | ||
var b = parser.eval('[5, 6; 7, 8]'); // [5, 6; 7, 8] | ||
var c = math.multiply(a, b); | ||
math.format(c); // [19, 22; 43, 50] | ||
var a = math.matrix(); // Matrix, [] | ||
a.set([math.range('2:5')], [7, 2, 1, 5]); // Matrix, [0, 7, 2, 1, 5] | ||
var b = math.range(2, -1, -2); // Range, 2:-1:-2 | ||
var c = b.valueOf(); // Array, [2, 1, 0, -1, -2] | ||
var d = parser.eval('3:7'); // Range, 3:7 | ||
``` | ||
@@ -333,2 +359,15 @@ | ||
### Matrix | ||
- math.concat(a, b, c, ... [, dim]) | ||
- math.det(x) | ||
- math.diag(x) | ||
- math.eye(m, n, p, ...) | ||
- math.inv(x) | ||
- math.ones(m, n, p, ...) | ||
- math.size(x) | ||
- math.squeeze(x) | ||
- math.transpose(x) | ||
- math.zeros(m, n, p, ...) | ||
### Probability | ||
@@ -363,2 +402,3 @@ | ||
- math.clone(x) | ||
- math.format([template, ] values) | ||
@@ -391,3 +431,3 @@ - math.help(fn) | ||
var parser = new math.parser.Parser(); | ||
var parser = math.parser(); | ||
parser.eval('myvalue + 10'); // 52 | ||
@@ -407,3 +447,3 @@ parser.eval('hello("user")'); // 'hello, user!' | ||
var math = require('mathjs'), | ||
parser = new math.parser.Parser(); | ||
parser = math.parser(); | ||
@@ -425,16 +465,20 @@ // import the numbers.js library into math.js | ||
The project uses [jake](https://github.com/mde/jake) as build tool, | ||
which must be installed globally. After jake is installed, the project | ||
dependencies can be downloaded using npm. Then the project can be build by | ||
executing jake in the root of the project. | ||
The project uses [jake](https://github.com/mde/jake) as build tool. | ||
To be able to run jake from the command line, jake must be installed globally: | ||
sudo npm install -g jake | ||
Then, the project can be build by executing jake in the root of the project: | ||
cd mathjs | ||
sudo npm install -g jake | ||
npm install | ||
jake | ||
When jake is executed, it will generate the library math.js and math.min.js | ||
from the source files, and will test the library. | ||
This will build the library math.js and math.min.js from the source files and | ||
execute tests. | ||
Alternatively, when jake is not installed on your system, the project can be | ||
build by running `npm install` in the root of the project. npm will then | ||
use a local installation of jake to build the project. | ||
## Test | ||
@@ -449,19 +493,21 @@ | ||
- Version 0.1.0 (2013-02-18): | ||
- Version 0.1.0 (2013-02-18) | ||
- Implement all methods and constants available in the built-in Math library | ||
- Implement data types Complex and Unit | ||
- Version 0.2.0 (2013-02-25): | ||
- Version 0.2.0 (2013-02-25) | ||
- Implement Parser, Scope, Node tree | ||
- Implement more methods | ||
- Version 0.3.0 (2013-03-09): | ||
- Version 0.3.0 (2013-03-09) | ||
- Implement Workspace | ||
- Implement more methods | ||
- Build a website (2013-03-11) | ||
- Version 0.4.0 (2013-03-16): | ||
- Version 0.4.0 (2013-03-16) | ||
- Implement Arrays | ||
- Version 0.5.0 | ||
- Implement Matrices | ||
- Version 0.5.0 (2013-04-06) | ||
- Implement Matrix and Range | ||
- Version 0.6.0 | ||
- More on matrices | ||
- Version 1.0.0 | ||
- Extensive testing | ||
- Add examples and documentation | ||
- Examples and documentation | ||
@@ -468,0 +514,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
410810
9558
509