Adding rows / columns to existing matrices in core.matrix (Clojure)
clojure, matrix
Solution
You can use the `join` function to append arrays along the major dimension.
And you can combine this with `broadcast` to get a matrix of ones in whatever size you like, e.g.:
e.g.
(join (broadcast 1 [1 3])
[[1 2 3]
[4 5 6]
[7 8 9]])
=> [[1 1 1]
[1 2 3]
[4 5 6]
[7 8 9]]
Problem
How does one add a row or a column to an existing matrix? I'm trying to add a bias-term, a column of ones, as the first row of a matrix. In Octave I can do this with: ``` M = [ones(size(M, 1), 1), M]; ```