3D Math Data structures/SIMD

Lukas Pinkowski Lukas.Pinkowski at web.de
Sat Dec 22 10:12:01 PST 2007


Janice Caron wrote:

> On 12/22/07, Lukas Pinkowski <Lukas.Pinkowski at web.de> wrote:
>> Well, but why do you call the component-wise multiplication nonsense? As
>> a mathematician you should know that an operator/function is exactly
>> that, what you define it to be. If I define vector/vector-multiplication
>> to be component-wise multiplication, then it is component-wise
>> multiplication.
> 
> Well, yes and no. Obviously you are correct in that one can define any
> function to do anything (...just as you can in any programming
> language). However, whether or not it is meaningful to call such a
> function "multiplication" is another matter. Elementwise
> multiplication is not normally considered to be "multiplication" in
> vector algebra.

Well, "imaginary real" isn't normally considered to be enumerable and
imaginary and real. 
Everyone's smart enough to learn such a thing, even that 'adding' two
strings is concatenating them (in C++).

> Googling "vector multiplication" mostly yeilds the expected results of
> dot product and cross product, although Wolfram Mathworld also lists
> the "vector direct product" which yields a tensor. I couldn't find
> anything, anywhere, which considers elementwise multiplication to be
> valid vector multiplication. 

> If such a usage exists, I must assume it 
> to be rare, or limited to some particular field of expertise (e.g. 3D
> graphic programming, which you touch on next).

No it's not rare; the shading languages aren't limited to computer graphics,
but are used for programming highly parallel hardware (= GPU) also. Please
google for GPGPU. It would be a surprise to many people if '*' didn't mean
elementwise multiplication.

>> It's just that 3D-programmers agreed to define
>> vector/vector-multiplication (with the * operator) like this.
> 
> Ah - that would be my problem. I'm not a 3D programmer. (I /am/ three
> dimension, and I /am/ a programmer, but ... well, you get the drift!).
> To me, there's really nothing special about three dimensions. Vector
> arithmetic must work, regardless of the number of elements, be that 3,
> 4, 5, or 87403461.

Well, to INTEL, AMD and IBM (PowerPC) there is something special about three
dimensions, as they have built special instruction sets that can be used
for efficient 3D-maths. And I want to be able to use the available hardware
ressources easily and in a portable way.

If you want vectors of higher dimension than 4D, you can either implement
them traditionally, or on top of the optimized builtin vectors. 
I don't know how hard it would be to implement hardware optimized arbitrary
sized vectors and matrices in the compiler. But who would say no to such a
thing?

> Perhaps there is merit in such a function, of which I am unaware,
> which has benefit to programmers of 3D graphics. That's cool! Not a
> problem. But I still wouldn't call it multiplication. To me,
> multiplication of a vector by a vector is undefined. (Multiplication
> of a vector by a scalar is defined).

It's irrelevant if it's undefined to you; if Walter or someone else defines
vector-vector multiplication to be elementwise multiplication, then it is
elementwise multiplication. 
After all: Walter has brainwashed us to believe 'imaginary real' to be
imaginary 80bit IEEE floating point numbers on x87. ;-)



More information about the Digitalmars-d mailing list