Can you show me some examples of where I'd *want* to do the "wrong thing" > from an associativity standpoint? "5 - x" where x is a vector, is kinda > weird. > But maybe you're subtracting off a mean or something, but then I'd probably > write this as "- (x - 5)", because I always associate left to right. :) >
I actually haven't written support for unary_- , that's something i really haven't encountered (yet) until you said it :) While there's a unary negation operatior, there's no unary inversion operator (1/x). This actually an example of fairly frequent operation over vectors. In my in-core ssvd example, i use it to compute inverse of a diagonal matrix (Sigma)^-1 (or any inverse of a diagonal matrix for that matter): diagv(1 /: s) where s is the vector of singular values. elementwise substraction is fairly frequent when comparing matrices and making approximation asserts, e.g. in svg test something like assert (a - u %*% diagv(s) %*% v.t ) norm <= 1e-10 I actually wouldn't know how to encode elementwise inversion if i cannot use colon. Use of colon with operations in scala actually IMO is quite intuitive in a sense that the side that has it, points to "this" and the other side points to "that". The assumption is that use of the colon must not change the result of operation (be functionally equivalent), just like in many cases foldLeft is equivalent to foldRight, i.e. a * b === a :* b === a *: b, it follows that :* means "timesRight" or "solveRight", in Mahout speak, and *: means "timesLeft", or "solveLeft'. FWIW I guess it does take a few minutes to settle (it took a few with me at least), but after that it seems pretty intuitive. > > > > and putting completely different functional meaning into :* and * will > > confuse scala users to no end who got used to things like :/ and /: . > This > > all needs striking a subtle balance unfortunately. > > > > Ok, then like I said, maybe I'll just defer to your judgement on the > operator > syntax, as I've *never* gotten used to the scala :/ and /: uses. I prefer > method calls to method calls masquerading as native operators. Maybe > I should Stop Being Afraid and Learn to Love the DSL, but I'm not quite > there yet: Too Much Magic. :) > > > > > > as i said before, i am not hung on %*% syntax, but i don't think doing :* > > or .* for elementwise would work on scala. > > > > How often do we really do elementwise matrix operations? Is this really > a thing we often want to worry about? addition and subtraction, sure, but > Use of Hadamard product is indeed rare (i had only one case with the PCA pipeline), but elementwise - and / seems to be popular with me. Regardless, it is done for completeness; and if it is done at all, imo it better be done consistently with the rest of the elementwise pack.
