clojure.core.matrix.select

Namespace for fully featured core.matrix select API.

Supports selection functions, which are defined as:
   (fn [array dim] ...) => set of indices for dimension 

calc

(calc f & args)

end

(end a dim)
selector function for sel. selects the last valid index

even

(even a dim)
selector function for sel.
selects all valid even indices

exclude

(exclude idx)
selector function for sel.
selects all valid indices except the ones specified in idx. idx can be a
number, a set or a sequence of indices

irange

(irange)(irange end)(irange start end)(irange start end step)
selector function for sel.
index-range selects the range from start position until (including!) the end
position. Also supports selector functions as arguments
Example: (sel [0 1 2 3 4] (irange 1 end)) ;=> [1 2 3 4]
(irange) is the same as (irange 0 end)

odd

(odd a dim)
selector function for sel.
selects all valid odd indices

sel

(sel a & args)
matlab-like array indexing.
Like clojure.core.matrix/select but also supports selector functions:
 (sel [[1 2][3 4]] (irange) (irange));=> [[1 2][3 4]]
 (sel [[1 2][3 4]] end end) ;=> 4
 (sel [[1 2][3 4]] (exclude 1) (exclude 0)) ;=> 2
 if only one argument is supplied it does linear indexing - selects the
 elements by their position in eseq.
 (sel [[1 2][3 4]] [0 3]) ;=> [1 4]
 sel supports logical indexing:
 (sel [[-1 0][1 2]] (where pos?)) ;=> [1 2]

set-sel

(set-sel a & args)
like sel but sets the values of a at the selected indices to the supplied
values. Leaves a unchanged, returns the modified array. Examples:
(sel-set [[1 2][3 4]] 0 0 2) ;=> [[2 2][3 4]]
(sel-set [[1 2][3 4]] (irange) 0 [[5][6]] ;=> [[5 2][6 4]]
(sel-set [[1 2][3 4]] (irange) (irange) 1) ;=> [[1 1][1 1]]
(sel-set [[-2 -1][0 1]] (where neg?) 0) ;=> [[0 0][0 1]]

set-sel!

(set-sel! a & args)
like set-sel but destructively modifies a in place

where

(where pred?)
selector function for sel.
Enables logical indexing. Selects all indices where pred? succeeds.
Can only be used as second argument to sel. example:
(sel (range 10) (where (partial > 5))) ;=> [0 1 2 3 4]

where-slice

(where-slice pred?)
selector function for sel.
Selects all indices where pred? returns true when called against the respecitive slice on the given dimension
Can only be used as second argument to sel. example:
(sel [1 2 3 -1 -1 4 5 6] (where-slice pos?)) ;=> [1 2 3 4 5 6]