core-matrix

intended for specific discussion around core.matrix (usage and development) For general data work check out #data-science
2017-05-26T09:04:18.949291Z

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

2017-05-26T09:04:52.954524Z

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

2017-05-26T10:05:34.531404Z

Some implementations support mutable submatrices

2017-05-26T10:05:41.532457Z

e.g. with vectorz-clj

2017-05-26T10:05:42.532634Z

(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]]

2017-05-26T10:07:52.552568Z

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

2017-05-26T10:07:53.552737Z

(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]]

2017-05-26T10:15:28.619825Z

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

2017-05-26T10:15:28.619838Z

is that the default maybe?

2017-05-26T10:15:45.622248Z

set-selection should be fine with any implementation

2017-05-26T10:15:53.623436Z

The fill! method requires a mutable implementation

2017-05-26T10:18:08.643269Z

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

2017-05-26T10:18:19.644837Z

not a whole new matrix with the content changed

2017-05-26T10:18:31.646607Z

Hmmm it should return the whole new matrix

2017-05-26T10:18:39.647774Z

You have a simple example?

2017-05-26T10:19:14.652429Z

ah no sorry my bad

2017-05-26T10:20:13.661022Z

yeah that seems perfect

2017-05-26T10:26:31.714401Z

Cool glad it works for you!

2017-05-26T10:27:31.723035Z

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

octahedrion 2017-05-26T12:49:31.924Z

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