3D Math Data structures/SIMD

Lukas Pinkowski Lukas.Pinkowski at web.de
Fri Dec 21 15:30:25 PST 2007


Janice Caron wrote:

> On 12/21/07, Lukas Pinkowski <Lukas.Pinkowski at web.de> wrote:
>> > What's wrong with Vector!(3,float), Matrix!(4,4,real),
>> > Matrix!(3,4,cdouble), etc.?
>>
>> They are not builtin types.
> 
> And this is a problem because...?

Because those templates would have to use inline assembler to make use of
SIMD-hardware. Well, that's bad, cause it's hard to inline a function that
uses inline assembler, isn't it?
So, we have all that shiny hardware with those funky instructions, but still
it's hard to utilize it...

>> Multiplication should be component-wise
>> multiplication, exactly like addition is component-wise addition
> 
> Now that's just nonsense! Matrix multiplication should be matrix
> multiplication, and nothing else. For example, multiplying a (square)
> matrix by the identity matrix (of the same size) should leave it
> unchanged, not zero every element not on the main diagonal!

Err, we were talking about vector multiplication, in which we have three
cases. Inner product, outer product and component-wise multiplication.
Matrix multiplication is the matrix multiplication as you are used to. Don't
quote out of context.

> Likewise, vector multiplication must mean vector multiplication, and
> nothing else. (Arguably, there are two forms of vector multiplication
> - dot product and cross product - however, cross product only has
> meaning in three-dimensions, whereas dot product has meaning in any
> number of dimensions, so dot production is more general).

> Componentwise multiplication... Pah! That's just not mathemathical.

So you probably don't know much about maths? It is mathematical as long as
you define it correctly. But I'll do it just for you:

F := Set of floating point numbers
V := F^n (set of n-tuples of floating point numbers)

We define component wise multiplication as a function

m: V x V -> V

with: m(a, b) := (a1*b1, a2*b2, ... , an*bn) =: a * b

That's pretty mathematical, isn't it?

> (Imagine doing that for complex numbers instead of proper complex
> multiplication!) No thanks! I'd want my multiplications to actually
> give the right answer!

Multiplication of complex numbers is defined quite clearly, as is for
vectors.
I already mentioned the shader languages, I guess you should look GLSL up
and see how "vec3 * vec3" is handled. Then come back here and tell me about
nonsense.



More information about the Digitalmars-d mailing list