kigubkur.construct.pick
Construct a kigubkur© matrix or a number by selecting from a kigubkur© matrix.
pickpick-blockpick-diagpick-nondiag
Examples
(require '[kigubkur.construct [pick :refer [pick]]])
for pick
=> (def M [[1 2 3][4 5 6]])
=> (view M)
[1 2 3]
[4 5 6]
Order -> 2 x 3
Then,
To pick an element
For element in index i = 1, j = 1
=> (pick M 1 1)
1
To pick a column
For column from rows 1 & 2 and from column 1
=> (view (pick M [1 2] 1))
[1]
[4]
Order -> 2 x 1
To pick a row
For row from row 2 and from columns 2 & 3
=> (view (pick M 2 [2 3]))
[5 6]
Order -> 1 x 2
for pick-block
=> (def B (block [[1 2 3 4 5 6 7 8 9 10]
[11 12 13 14 15 16 17 18 19 20]
[21 22 23 24 35 26 27 28 29 30]] 3))
Then,
=> (view (pick-block :A13 (block B)))
[7 8 9]
[17 18 19]
[27 28 29]
Order -> 3 x 3
for pick-diag
=> (def M [[1 1 2 9][2 4 -3 1][3 6 -5 0]])
=> (view M)
[1 1 2 9]
[2 4 -3 1]
[3 6 -5 0]
Order -> 3 x 4
=> (pick-diag M)
[[1 4 -5]]
=> (pick-diag M 0)
[[1 4 -5]]
=> (pick-diag M 1)
[[1 -3 0]]
=> (pick-diag M 2)
[[2 1]]
=> (pick-diag M 3)
[[9]]
=> (pick-diag M -1)
[[2 6]]
=> (pick-diag M -2)
[[3]]
for pick-nondiag
=> (view M)
[1 1 2 9]
[2 4 -3 1]
[3 6 -5 0]
Order -> 3 x 4
=> (pick-nondiag M)
[[1 2 9 2 -3 1 3 6 0]]
=> (pick-nondiag M 1)
[[1 2 9 2 4 1 3 6 -5]]
=> (pick-nondiag M 2)
[[1 1 9 2 4 -3 3 6 -5 0]]
=> (pick-nondiag M 3)
[[1 1 2 2 4 -3 1 3 6 -5 0]]
=> (pick-nondiag M -1)
[[1 1 2 9 4 -3 1 3 -5 0]]
=> (pick-nondiag M -2)
[[1 1 2 9 2 4 -3 1 6 -5 0]]
pick
(pick M i_ivec j_jvec)Given a matrix Mm×n, pick an element, a row, a column or submatrix. Syntax for picking
ijth element: (pick M i j) s.t i, j ∈ ℤ+ and i ≤ j
ith row: (pick M i (colon [1 n])) s.t 1 ≤ i ≤ m
jth column: (pick M (colon [1 m]) j) s.t 1 ≤ j ≤ n
i–to–kth and j–to–lth submatrix: (pick M (colon [i k]) (colon [j l])) s.t 1 ≤ i ≤ k ≤ m, 1 &le and j ≤ l ≤ n
pick-block
(pick-block ky B)Given a matrix BM×N, pick the embedded number or matrix (also row or column) for a given keyword.
Syntax: (pick-block :Aij B) s.t i, j ∈ ℤ+ and 1 ≤ i ≤ M, 1 ≤ j ≤ N
pick-diag
(pick-diag M & d)Given a matrix Mm×n, returns the main diagonal or for d-th diagonal. Returned result is a row matrix. Note the optional d ∈ ℤ such that,
d | diagonal of M |
|---|---|
| 0 (default) | main diagonal |
0 < d < n | diagonal along triangular part above main diagonal |
-m < d < 0 | diagonal along triangular part below main diagonal |
pick-nondiag
(pick-nondiag M & d)Given a matrix Mm×n, returns the non diagonal elements. Returned result is a row matrix. Note the optional d ∈ ℤ such that,
d | diagonal of M |
|---|---|
| 0 (default) | main diagonal |
0 < d < n | diagonal along triangular part above main diagonal |
-m < d < 0 | diagonal along triangular part below main diagonal |
