### Merge branch 'devel/README_matrix_update' into 'master'

```Devel/readme matrix update

See merge request exastencils/exastencils!18```
parents f3cdefa0 900e9dde
 ... ... @@ -1756,26 +1756,105 @@ Var v3 : ColumnVector<Int, 3> = {1, 2, 3}T ### Matrices Represents a two-dimensional number of scalar elements #### Syntax #### Declaration syntax
{{expression, expression, ...  }, {expression, expression, ...  }, ... }

#### Details At least one *expression* is required to construct a 1x1 matrix. #### Example
Var m1 : Matrix<Real, 2, 2> = {{1, 2}, {3, 4}}
Var m2 : Matrix<Real, 2, 3> = [1 2 3; 4 5 6]

#### built-in functions * `inverse()` invert a matrix Matrices up to 3x3 are inverted directly at generation time. For larger matrices, a strategy can be selected via the Knowledge parameter`experimental_resolveInverseFunctionCall`: * *Cofactors*: Invert at generation-time using cofactors matrix * *GaussJordan*: Invert at generation-time using the Gauss-Jordan algorithm * *Runtime* Invert only at run-time of the program time #### Access Vectors and Matrices can be written to and read from via the `[]-operator`:
Var quadMat : Matrix <Real, 2, 23> = {{0., 1.}, {1., 0.}}
Var colVecMat : Matrix <Real, 3, 13> = {{0.}, {1.}, {1337.}}
Var rowVec : RowVector <Real, 33> = {0., 1., 1337.}

Var tmp : Real = colVecMat
rowVec = 1

#### Slicing The following functions can be used to obtain or set a submatrix of a given matrix: * `getElement(mat : Matrix, j : Int, i : Int) : T` returns the (j,i)th entry * `setElement(mat : Matrix, j : Int, i : Int) : T` sets the (j,i)th entry * `getSlice(mat : Matrix, offsetRows : Int, offsetCols: Int, nRows : Int, nCols : Int) : Matrix` reads a submatrix of size (nRows x nCols) from position (offsetRows, offsetCols) in mat * `setSlice(mat : Matrix, offsetRows : Int, offsetCols: Int, nRows : Int, nCols : Int, val : T) : Matrix` writes the value val to a submatrix of size (nRows x nCols) at position (offsetRows, offsetCols) in mat * slicing operations can also be executed via the `[]-operator` with index ranges or `:` for a complete dimension.
Some examples:
Var row : Matrix<Real, 1, 2 > = getSlice(quadMat,0,1,1,2) // row = {{5., 5.}}
Var col : Matrix<Real, 2, 1 > = quadMat[:] // col = {{1.},{5.}}
rowVec[0:3] = 4. // colVec = {{4.},{4.},{4.}}

#### Built-in functions * `transpose()` to transpose a matrix * `dot()` and `cross()` to calculate dot or cross product of two matrices * `det()` to calculate the determinant * `norm()` calculates the frobenius-norm of the matrix * `trace()` calculates the trace * `transpose()` transposes the matrix * supported operators for binary expression: `+`, `-`, `*`, `/` * supported element-wise operations: `.*`, `*./`, `.%` (modulo), `.^` (power) #### Direct solution of linear systems Small linear systems can be solved directly at runtime or compiletime with the `solveMatSys`-statement, which takes a system matrix, unknowns and a right-hand-side of fitting dimensions as arguments:
Var A : Matrix<Real, 3, 3> = {{3,2,-1},{2,-2,4},{-1,0.5,-1}}
Var f : Matrix<Real, 3, 1> = {{1},{-2},{0}}
Var u : Matrix<Real, 3, 1>
solveMatSys A,u,f // u = {{1}, {-2}, {-2}}