Create a matrix given a size and a list of arguments
Parameters: |
|
---|
$ eq eval "matrix( 2, 2, a, b, c, d )"
|¯ ¯|
| a b |
| |
| c d |
|_ _|
The number of argument must be equal to width * height. You can define column and row matrices
$ eq eval "matrix( 1, 4, a, b, c, d )"
|¯ ¯|
| a |
| |
| b |
| |
| c |
| |
| d |
|_ _|
$ eq eval "matrix( 4, 1, a, b, c, d )"
|¯ ¯|
| a b c d |
|_ _|
You also can build matrices directly from lists (which can be dynamically generated)
$ eq eval "matrix( [1, 4, a, b, c, d ] )"
|¯ ¯|
| 1 4 a b c d |
|_ _|
$ eq eval "matrix( [[1, 0], [0, 1]])"
|¯ ¯|
| 1 0 |
| |
| 0 1 |
|_ _|
Matrices support only a subset of all the operators, between them only addition and multiplication are supported (if they size match for the operation that is).
$ eq eval "matrix( 2, 2, a, b, c, d ) + matrix( 2, 2, e, f, g, h )"
|¯ ¯|
| a + e b + f |
| |
| c + g d + h |
|_ _|
$ eq eval "matrix( 2, 2, a, b, c, d ) * matrix( 2, 2, e, f, g, h )"
|¯ ¯|
| a.e + b.g a.f + b.h |
| |
| c.e + d.g c.f + d.h |
|_ _|
Only two operators are allowed between matrices and scalars, multiplication and division.
$ eq eval "matrix( 1, 4, a, b, c, d ) * (x+y)"
|¯ ¯|
| (y + x).a |
| |
| (y + x).b |
| |
| (y + x).c |
| |
| (y + x).d |
|_ _|
$ eq eval "matrix( 4, 1, a, b, c, d ) / x^2"
|¯ ¯|
| a b c d |
| ---- ---- ---- ---- |
| 2 2 2 2 |
| x x x x |
|_ _|