compute-io / transpose

Computes the transpose of a matrix.
MIT License
4 stars 0 forks source link

Matrices vs ndarrays? #3

Open rreusser opened 9 years ago

rreusser commented 9 years ago

I can imagine both dstruct ndarrays and matrices having a transpose function. (For ndarrays you specify which dimensions to swap.) At a glance, this module appears duck-typed to work with both dstructs/matrix and dstructs/ndarray. Is the goal to keep that going and make the matrix API a proper subset of the ndarray API so that all code written for 2d ndarrays applies to matrices?

kgryte commented 9 years ago

In general, I would view it as the other way around: a matrix should work fine with fcns accepting ndarrays. The opposite may not hold due to assumptions involved with the matrix data structure.

Re: the transpose fcn specifically. I am not of the opinion that an ndarray is transposable. Conventionally, we apply the concept of a transpose to matrices, not necessarily n-dimensional data structures, where n >= 3. I would, however, consider the permutation of dimensions a generalization, of which a transpose is a special case having a name.

rreusser commented 9 years ago

That makes sense. And I think your opinion is valid. A matter of taste (numpy uses transpose this way, basically), but not so important what it's called.

kgryte commented 9 years ago

Yeah. :) The benefit of creating our own modules is that we get to choose/improve upon/make changes to previous design decisions and effectively cherry pick what we like and don't like. We have the luxury of examining multiple different approaches (R, Python, Matlab, Julia), see what works, and what does not and hopefully make progress to more meaningful and well-intentioned interfaces.