From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-01-17 09:35:37
> --- In boost_at_y..., Toon Knapen <toon.knapen_at_s...> wrote:
>>I noticed that in ublas 'a = 2 * b' works but 'a = b * 2' does
> not ?!
> Meanwhile we've found two reasons for this restriction. First, as far
> as I know multiplication with a scalar is mathematically always
> defined as left multiplication for vectors and matrices.
theoretically scalar-matrix multiplication is commutative and thus a * M
== M * a.
> multiplication is left associative in C++ (as Mathias told me ;-), so
> if we compare a = 2 * 2 * b to a = 2 * b * 2, the former is always
> guaranteed to need fewer operations.
I can understand your implementation issues and it's good to know now
that Matrix * scalar can not be done but one needs to do scalar * matrix
instead. I just took me fifteen minutes to find out and maybe it's a
good idea to put it in the docs.
e.g. in the mean time again I had the same trouble with division, I
tried M /a but to make it compile I redefined it as (1/a) * M : one just
needs to know.
Although I think in the long term, all mathematical correct expressions
should be supported but it is not highest priority.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk