Selects diagonals of a matrix.

```
diags(
```*[1,2,3;4,5,6;7,8,9]*, *[2,-1]*)

mtx | The matrix, the diagonals of which are to be selected |

offset | The indices of the diagonals to be selected (optional). Negative (resp. positive) indices denote subdiagonals (resp. superdiagnoals). |

return value | The matrix with the diagonals in its rows. |

Returns a matrix, the rows of which are the diagonals indexed by *offset*. The diagonals of different lengths are padded with zeros to form a matrix in a way that, except for this padding, the function acts as an inverse for the function *diag*, i.e. superdiagonals at the tail, and subdiagonals at the front:
diags(diag(D,d),d) ~ D,
and for a diagonal square matrix M:
diag(diags(M,d),d) = M
hold.

The second argument is optional. The lack of it is equivalent to offset = [0].