mikera / core.matrix

core.matrix : Multi-dimensional array programming API for Clojure
Other
702 stars 113 forks source link

What does 'pre-scale' mean as opposed to 'scale'? #19

Closed mjwillson closed 11 years ago

mjwillson commented 11 years ago

Bit confused about this.

(defprotocol PMatrixScaling
  "Protocol to support matrix scaling by scalar values"
  (scale [m a])
  (pre-scale [m a]))

Surely pre- and post-multiplication by a scalar are the same thing (just element-wise scaling)? Or did you have something else in mind?

mjwillson commented 11 years ago

I guess if you want to allow scalars from a non-commutative ring -- although I wonder what consequences that would have for the rest of the API?

mjwillson commented 11 years ago

Ah, perhaps you meant something more like multiplication by a diagonal matrix (so potentially scaling by a different factor for each row/column) and a is a vector? perhaps best to be clear about it if this is the case. (Note this could also be achieved via a broadcasted element-wise multiplication.)

mikera commented 11 years ago

It's for non-commutative stuff like complex scalars if we ever decide to support these

Just thinking ahead :-)

mikera commented 11 years ago

For any normal commutative scalars, it means the same as scale.

heffalump commented 11 years ago

But complex numbers commute under multiplication.

mikera commented 11 years ago

Sorry I meant quaternions :-)

mjwillson commented 11 years ago

Ah, gotcha. If we want to do a complete job of supporting non-commutative scalar rings it might have consequences for other parts of the API though, e.g. decompositions -- since this is no longer just plain old linear algebra but module theory in the sense of http://en.wikipedia.org/wiki/Module_(mathematics) . From the little I remember about decomposition theorems for module homomorphisms I'd probably steer well clear :)