3D Math Data structures/SIMD

Janice Caron caron800 at googlemail.com
Sat Dec 22 02:06:59 PST 2007


On 12/22/07, "Jérôme M. Berger" <jeberger at free.fr> wrote:
>         Of the four, component-wise is the only one that makes sense for a
> multiplication *operator* because it's the only one that is defined
> as taking exactly two input operands in vector space and returning a
> value in the same vector space.

By which you mean, you'd like the product of a Vector!(N,T) and a
Vector!(N,T) to be a Vector!(N,T)?

That seems an artificial restriction to me. After all, the product of
a Matrix!(N,M,T) and a Matrix!(N,M,T) is not a Matrix!(N,M,T), unless
N==M. (In general, it's undefined). But you wouldn't want to say "Aha
- in general, it's undefined, so let's define it" (especially not with
componentwise multiplication, because that would conflict with regular
matrix multiplication when N==M).

As I'm sure you know, the product of a Matrix!(N,M,T) and
Matrix!(M,L,T) is a Matrix!(N,L,T). So there is no requirement that
the product be of the same type as either of the originals.

Anyway, for reasons of all the arguments listed in this thread, I am
now convinced that opMul() and opMulAssign() should not be overloaded
at all for the type Vector!. It seems far better to be explicit about
what kind of multiply you actually want.




More information about the Digitalmars-d mailing list