Skip to content

Commit

Permalink
data is enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
fibo committed Apr 11, 2016
1 parent 857ee94 commit 74df065
Show file tree
Hide file tree
Showing 5 changed files with 754 additions and 6,363 deletions.
10 changes: 7 additions & 3 deletions _data/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "algebra",
"description": "means completeness and balancing, from the Arabic word الجبر",
"version": "0.8.0",
"version": "0.9.0",
"engines": {
"node": ">= 4.4.0"
},
Expand Down Expand Up @@ -62,28 +62,32 @@
],
"devDependencies": {
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-destructuring": "^6.6.5",
"babelify": "^7.2.0",
"browserify": "^13.0.0",
"coveralls": "^2.11.9",
"install": "^0.6.1",
"istanbul": "^0.4.1",
"katex": "^0.5.1",
"mocha": "^2.3.4",
"mocha-lcov-reporter": "1.2.0",
"npm": "^3.8.6",
"pre-commit": "^1.1.2",
"should": "^8.3.0",
"standard": "^6.0.8",
"uglify-js": "^2.6.2"
},
"dependencies": {
"algebra-cyclic": "^0.1.0",
"algebra-cyclic": "^0.2.0",
"cayley-dickson": "^0.3.0",
"indices-permutations": "^0.2.0",
"inherits": "^2.0.1",
"is-integer": "^1.0.6",
"laplace-determinant": "^0.1.0",
"matrix-multiplication": "^0.4.0",
"multidim-array-index": "^0.2.0",
"not-defined": "^1.0.0",
"static-props": "^0.2.0",
"static-props": "^0.3.0",
"strict-mode": "^0.5.0",
"tensor-contraction": "^0.1.1",
"tensor-product": "^0.2.0"
Expand Down
9 changes: 9 additions & 0 deletions _data/tags.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"name": "v0.9.0",
"zipball_url": "https://api.github.com/repos/fibo/algebra/zipball/v0.9.0",
"tarball_url": "https://api.github.com/repos/fibo/algebra/tarball/v0.9.0",
"commit": {
"sha": "147a79fbb6b9f59c0087d3f32ed99a1854387416",
"url": "https://api.github.com/repos/fibo/algebra/commits/147a79fbb6b9f59c0087d3f32ed99a1854387416"
}
},
{
"name": "v0.8.0",
"zipball_url": "https://api.github.com/repos/fibo/algebra/zipball/v0.8.0",
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Changelog format adheres to [Keep a Changelog](http://keepachangelog.com/)</sub>
- algebra-cyclic
- using matrix-multiplication package
- removed console.log from README.md examples
- data prop is enumerable

## [v0.9.0] - 2016-04-05

Expand Down
81 changes: 62 additions & 19 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ title: algebra
- [Quaternion](#quaternion)
- [Octonion](#octonion)
- [Common spaces](#common-spaces)
- [R](#r)
- [R2](#r2)
- [R3](#r3)
- [C](#c)
- [Vector](#vector)
- [attributes](#vector-attributes)
- [operators](#vector-operators)
Expand Down Expand Up @@ -79,6 +81,7 @@ Many functionalities of previous versions are now in separated atomic packages:
* [cayley-dickson](http://npm.im/cayley-dickson)
* [indices-permutations](http://npm.im/indices-permutations)
* [laplace-determinant](http://npm.im/laplace-determinant)
* [matrix-multiplication](http://npm.im/matrix-multiplication)
* [multidim-array-index](http://npm.im/multidim-array-index)
* [tensor-contraction](http://npm.im/tensor-contraction)
* [tensor-permutation](http://npm.im/tensor-product)
Expand Down Expand Up @@ -140,7 +143,7 @@ Static operators return raw data, while class methods return object instances.
Use static addition operator to add three numbers.

```javascript
console.log(R.add(1, 2, 3)) // 1 + 2 + 3 = 6
R.add(1, 2, 3) // 1 + 2 + 3 = 6
```

Create two real number objects: x = 2, y = -2
Expand All @@ -154,17 +157,17 @@ The value *r* is the result of x multiplied by y.

```javascript
var r = x.mul(y)
console.log(r.data) // 2 * (-2) = -4
console.log(x.data) // still 2
console.log(y.data) // still -2
r.data // 2 * (-2) = -4
x.data // still 2
y.data // still -2
```

Raw numbers are coerced, operators can be chained when it makes sense.
Of course you can reassign x, for example, x value will be 0.1: x -> x + 3 -> x * 2 -> x ^-1

```javascript
x = x.add(3).mul(2).inv()
console.log(x.data) // ((2 + 3) * 2)^(-1) = 0.1
x.data // ((2 + 3) * 2)^(-1) = 0.1
```

Comparison operators *equal* and *notEqual* are available, but they cannot be chained.
Expand All @@ -184,11 +187,11 @@ var z2 = new C([3, 4])

z1 = z1.mul(z2)

console.log(z1.data) // [-5, 10]
z1.data // [-5, 10]

z1 = z1.conj().mul([2, 0])

console.log(z1.data) // [-10, -20]
z1.data // [-10, -20]
```

### Vectors
Expand All @@ -208,7 +211,7 @@ var v2 = new R2([1, -2])
// v1 -> v1 + v2 -> [0, 1] + [1, -2] = [1, -1]
v1 = v1.add(v2)

console.log(v1.data) // [1, -1]
v1.data // [1, -1]
```

### Matrices
Expand Down Expand Up @@ -247,7 +250,7 @@ Then, following the row by column multiplication law we have

var v3 = m1.mul(v1)

console.log(v3.data) // [0, -1, 1]
v3.data // [0, -1, 1]
```

Let's try with two square matrices 2 x 2.
Expand All @@ -262,14 +265,14 @@ var m3 = new R2x2([0, -1,
m2 = m2.mul(m3)
console.log(m2.data) // [0, -1,
// 2, 0]
m2.data // [0, -1,
// 2, 0]
```

Since m2 is a square matrix we can calculate its determinant.

```javascript
console.log(m2.determinant.data) // 2
m2.determinant.data // 2
```

## API
Expand Down Expand Up @@ -300,6 +303,8 @@ The following object methods, give the same result: a vector instance with data
```javascript
var vector3 = vector1.addition([3, 4])
var vector4 = vector1.addition(vector2)

R2.equal(vector3, vector4) // true
```

Operators can be chained and accept multiple arguments when it makes sense.
Expand All @@ -311,7 +316,7 @@ vector1.addition(vector1, vector1).equality([4, 6]) // true
Objects are immutable

```javascript
console.log(vector1.data) // still [1, 2]
vector1.data // still [1, 2]
```

### Scalar
Expand All @@ -323,19 +328,18 @@ Let's use for example the [src/booleanField][booleanField] which exports an obje
```javascript
var algebra = require('algebra')
var Scalar = algebra.Scalar
var ring = require('algebra-ring')

var booleanField = require('algebra/src/booleanField')

var Bool = Scalar(booleanField)

console.log(Bool.contains(true)) // true
console.log(Bool.contains(1)) // false
Bool.contains(true) // true
Bool.contains(1) // false

console.log(Bool.addition(true, false)) // true
Bool.addition(true, false) // true

var t = new Bool(true)
console.log(t.negation().data) // false
t.negation().data // false
```

Not so exciting, let's build something more interesting.
Expand Down Expand Up @@ -414,6 +418,13 @@ Inherits everything from [Scalar](#scalar).

```javascript
var Real = algebra.Real

Real.addition(1, 2) // 3

var pi = new Real(Math.PI)
var twoPi = pi.mul(2)

Real.subtraction(twoPi, 2 * Math.PI) // 0
```

### Complex
Expand All @@ -424,6 +435,8 @@ Inherits everything from [Scalar](#scalar).
var Complex = algebra.Complex

var complex1 = new Complex([1, 2])

complex1.conjugation().data // [1, -2]
```

### Quaternion
Expand All @@ -436,6 +449,16 @@ Inherits everything from [Scalar](#scalar).

### Common spaces

#### R

The real line.

It is in alias of [Real](#real).

```javascript
var R = algebra.R
```

#### R2

The real plane.
Expand All @@ -456,6 +479,26 @@ var R3 = algebra.R3

It is in alias of `VectorSpace(Real)(3)`.

#### C

The complex numbers.

It is in alias of [Complex](#complex).

```javascript
var C = algebra.C
```

#### H

Usually it is used the **H** in honour of [Sir Hamilton](https://en.wikipedia.org/wiki/William_Rowan_Hamilton).

It is in alias of [Quaternion](#quaternion).

```javascript
var H = algebra.H
```

### Vector

Inherits everything from [Tensor](#tensor).
Expand Down Expand Up @@ -486,7 +529,7 @@ var vector2 = new R3([4, 9, 2])

var vector3 = vector1.crossProduct(vector2)

console.log(vector3.data) // [-15, 2, 39]
vector3.data // [-15, 2, 39]
```

### Matrix
Expand Down
Loading

0 comments on commit 74df065

Please sign in to comment.