antirez/redis — pull request #1664 by zacstewart (2014-04-06 02:39:33+00:00)
Title: Add matrix datatype

:warning: Work in progress

* Adds support for n-dimensional double arrays
* Supports RDB persistence
* Adds commands
- XSET KEY INDEX[ INDEX[ ...]] VALUE - sets values in subregion selected by index, creates matrix at KEY with dimensions based on INDEX if doesn't exist
- XGET KEY [INDEX[ INDEX[ ...]] - returns subregion selected by INDEX, -1 for any dimension index means "entire dimension"
- XZEROS [SHAPE [SHAPE [...]] - creates a zero-valued nd array
- XONES [SHAPE [SHAPE [...]] - creates a one-valued nd array
- XEYE SIZE - creates a 2d identity matrix of size SIZE
* Would like to add basic linear algebra commands
- XSCALE matrixkey SCALAR [newmatrix]
- XDOT matrixkeya matrixkeyb [newmatrix]
- etc…

Examples:

```
redis 127.0.0.1:6379> xzeros mat 3 3
1) "3"
2) "3"
redis 127.0.0.1:6379> xget mat -1 -1
1) "2"
2) "3"
3) "3"
4) "0"
5) "0"
6) "0"
7) "0"
8) "0"
9) "0"
10) "0"
11) "0"
12) "0"
redis 127.0.0.1:6379> xset mat -1 0 1
1) "3"
2) "3"
redis 127.0.0.1:6379> xget mat -1 -1
1) "2"
2) "3"
3) "3"
4) "1"
5) "0"
6) "0"
7) "1"
8) "0"
9) "0"
10) "1"
11) "0"
12) "0"
redis 127.0.0.1:6379> xget mat -1 0
1) "1"
2) "3"
3) "1"
4) "1"
5) "1"
redis 127.0.0.1:6379> xget mat 0 -1
1) "1"
2) "3"
3) "1"
4) "0"
5) "0"
```

```
redis 127.0.0.1:6379> xeye identitymat 2 2
1) "2"
2) "2"
redis 127.0.0.1:6379> xget identitymat -1 -1
1) "2"
2) "2"
3) "2"
4) "1"
5) "0"
6) "0"
7) "1"
```

Closes #370