core-matrix 2017-05-26

is there a way to fill in a submatrix with a value?

I can easily fetch a submatrix but can't find the right function to generate a new matrix with submatrix filled with the value I want

Some implementations support mutable submatrices

e.g. with vectorz-clj

(let [m (new-array :vectorz [3 3])] (fill! (submatrix m [[1 2] [1 2]]) 7) m) #vectorz/matrix [[0.0,0.0,0.0], [0.0,7.0,7.0], [0.0,7.0,7.0]]

That's probably the most efficient. Otherwise you can use set-selection e.g.

(let [m (new-array :vectorz [3 3])] (set-selection m [1 2] [1 2] 7)) #vectorz/matrix [[0.0,0.0,0.0], [0.0,7.0,7.0], [0.0,7.0,7.0]]

seems to work in the same way also without the :vectorz @mikera

is that the default maybe?

set-selection should be fine with any implementation

The fill! method requires a mutable implementation

set-selection would be good but it only returns the submatrix changed

not a whole new matrix with the content changed

Hmmm it should return the whole new matrix

You have a simple example?

yeah that seems perfect

Cool glad it works for you!

I've been meaning to get something like specter working with core.matrix, this would be a more general tool that would be very useful for examples like this

i may have asked this before but is there a way to get the vector of indices of the max element of a matrix ?