Fork me on GitHub

Hi @bkamphaus I'd normally just use a Clojure range and reshape or broadcast accordingly


e.g. (m/reshape (range 1 10) [3 3]) [[1 2 3] [4 5 6] [7 8 9]]


Is that what you are after?

Ben Kamphaus15:03:37

@mikera: I guess maybe best to step back. From numpy, IDL, etc. I’m used to using index arrays to accomplish a lot of things - arbitrary re-ordering, filtering out bad data (i.e. find replace Nan or -1 -99999 etc.) — there are some things where it’s obvious what Clojure semantic it makes sense to reach for, and others where I’m not sure of the best way to approach something without stepping through a path where I lose all core.matrix performance characteristics.

Ben Kamphaus15:03:47

where it came up in this case was arbitrarily swapping rows in a matrix (or elements, or 2d in 3d), my first pass impulse was to take a range of indices and do a replace {3 0 0 3} e.g. to swap first and fourth rows and get a re-ordered view.