kigubkur.datafun.minimum

Minimum function

(require '[kigubkur.datafun [minimum :refer [minval]]])

Examples

Minimum element in a vector

This returns the minimum element.

=> (def r [[1 2 3 4]])
=> (def c [[1][2][3][4]])
=> (view r)
[1 2 3 4]
Order -> 1 x 4
=> (minval r)
1
=> (view c)
[1]
[2]
[3]
[4]
Order -> 4 x 1
=> (minval c)
1

Minimum of a matrix

By default this returns a row vector containing the minimum element of each column.

=> (def M [[2 8 4] [7 3 9]])
=> (view M)
[2 8 4]
[7 3 9]
Order -> 2 x 3
=> (view (minval M))
[2 3 4]
Order -> 1 x 3

But for minimum element of each row

=> (minval M "rows")
[[2 3]]

Minimum of a block

(require '[kigubkur.construct [blocking :refer [block]]])
=> (def L [[1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]])
=> (def B (block L 5))
=> (pprint B)
[[{:A11 [[1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]],
   :A12 [[6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]]}]
 [{:A22 [[6 7 8 9 10]
         [6 7 8 9 10]],
   :A21 [[1 2 3 4 5]
         [1 2 3 4 5]]}]]
=> (minval B)
[[1 2 3 4 5 6 7 8 9 10]]
=> (minval B "rows")
[[1 1 1 1 1 1 1]]

minval

(minval M & arg)

Minimum of all vector elements or of each column or row vector elements in a matrix and returns a scalar or a row-vector.

Syntax Purpose
(minval x) minimum element; x is a row/column
(minval x) row containing minimum of each column; x is a matrix/block
(minval x "rows") row containing minimum of each row; x is a matrix/block