rreusser / ndarray-awise-prototype

Perform axis-wise operations on an ndarary
5 stars 0 forks source link

Refactor for performance #1

Open rreusser opened 9 years ago

rreusser commented 9 years ago

The approach is technically valid but highly questionable. I think this should really have started as a fork of cwise that generates the minimal amount of code to accomplish map-reduce operations. I don't know whether it'd be best to map-reduce one slice at a time or whether it's best to map-reduce over the initial array in whichever order cwise prefers.

@mikolalysenko, @jaspervdg, would be interested to hear if you have a better idea for this. Seemed like ndarray basically just needs a coherent way to talk about reductions over dimensions. But didn't seem like such a good idea that I stuck it in scijs/ right away…

rreusser commented 9 years ago

I'm starting to think it'd be way better to just iterate over the dimensions directly and implement this as as a cwise operation on each slice. This module wouldn't have to do any reduction work and you'd actually gain a lot of features from using cwise directly. Actually, wait, why did I implement things as they are in the first place? Sigh.

mikolalysenko commented 9 years ago

You can already do a reduce operation in cwise, take a look at the sum examples. Global variables can be stored in the this.x properties and reused.

mikolalysenko commented 9 years ago

Still, I think there are always other ways to do things. It would be nice to try out some different ideas. One thing I've long wanted is a way to express things like general tensor operations, for example matrix multiplication or tensor contraction on ndarrays.