cmatrix.Matrix.nth_diagonal¶
- Matrix.nth_diagonal()¶
Get the nth diagonal from the current matrix and given n as a list.
Parameters
Type
Description
n
int
the diagonal index to xtract
mode
int
- mode define the profile of algorithm between :
0 => ascendant
1=> descendent
rec
boolean
Recursion manager
- Returns
- List
the list containing the expected n-th diagonal
See also
Examples
>>> m=rand(4) >>> print(m) | +13.000 | +6.000 | +9.000 | +9.000 | | +12.000 | +16.000 | +2.000 | +13.000 | | +3.000 | +8.000 | +5.000 | +2.000 | | +12.000 | +11.000 | +11.000 | +9.000 | printed >>> for i in range(0,7): ... print(m.nth_diagonal(i,0)) ... [13.0] [6.0, 12.0] [9.0, 16.0, 3.0] [9.0, 2.0, 8.0, 12.0] [13.0, 5.0, 11.0] [2.0, 11.0] [9.0] >>> for i in range(0,7): ... print(m.nth_diagonal(i,1)) ... [12.0] [3.0, 11.0] [12.0, 8.0, 11.0] [13.0, 16.0, 5.0, 9.0] [6.0, 2.0, 2.0] [9.0, 13.0] [9.0]