kigubkur.elmat.zeros
Elementary Matrix: kigubkur© matrix of all zeros [[0]]m × n
(require '[kigubkur.elmat [zeros :refer [zeros]]])
Examples
=> (view (zeros [1 4]))
[0 0 0 0]
Order -> 1 x 4
=> (view (zeros [4 1]))
[0]
[0]
[0]
[0]
Order -> 4 x 1
=> (view (zeros [4 5]))
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
Order -> 4 x 5
Note that zeros
returns a vector for Order -> 1 x 1, i.e. for single element
=> (zeros [1 1])
[[0]]
Generating ones of desired number type
By default the number type for the 0’s generated by the function zeros
is of int type. But, ones
provide the flexibility to coerce the 0’s to any of Clojure’s number types: bigint
for BigInteger, long
for Long, short
for Short, float
for Float, double
for Double bigdec
for BigDecimal and int
which is a superset for not just Integer but also Long, Short [See source for int?
versus integer?
].
For example to coerce the 0’s in (zeros [4 5])
to BigInteger
=> (view (zeros [4 5] bigint))
[0N 0N 0N 0N 0N]
[0N 0N 0N 0N 0N]
[0N 0N 0N 0N 0N]
[0N 0N 0N 0N 0N]
Order -> 4 x 5
zeros
(zeros mn & arg)
Returns a kigubkur© matrix of zeros given the matrix order as a scalar or clojure vector and an optional argument for the Clojure number type function: int
, bigint
, long
, short
, float
, double
and bigdec
.
Syntax | Purpose |
---|---|
(zeros s) | for scalar s returns a square matrix with order s × s |
(zeros [m n]) | for clojure vector [m n] returns a rectangular matrix m × n |
(zeros x numbtype) | x is scalar or clojure vector with optional argument for number type |