3D Math Data structures/SIMD

Lukas Pinkowski Lukas.Pinkowski at web.de
Sat Dec 22 10:40:50 PST 2007


Janice Caron wrote:

> On 12/22/07, 0ffh <frank at frankhirsch.youknow.what.todo.net> wrote:
>> Is it not? Tell Jacques Hadamard!
>> You should be a bit more careful what you write and, especially, how.
>>
>> > I googled
>> > Jacques Hadamard and got that he was a mathematician, but beyond that,
>> > I'm lost. What are you getting at?
>>
>> The element-wise product of matrices (which you called "just not
>> mathemathical") bears his name.
> 
> Cool. I like learning new things. So, elementwise multiplication is
> more properly called Hadamard multiplication is it? That's certainly
> interesting.
> 
> I'm not not quite sure how I'm supposed to "tell Jacques Hadamard"
> anything, though, given that he's been dead for forty four years. I
> still don't completely understand what you were getting at, but I'll
> try to be clearer about what /I/ meant. By "not mathematical", I meant
> /in the context of overloading opMul() with it/ - that is, Hadamard
> multiplication doesn't obey the rules which we normally associate with
> multiplication.

Floating point numbers do not obey the rules which we normally associate
with any elementary operation like addition, subtraction, multiplication
and division.

For floating point numbers this is possible:

a + b == a

Even when b is not 0! We aren't anymore in 'pure mathematical land', but we
are in 'binary numerics land', where all the operations we know, do most of
the time different things than what we are used to.

For a mathematically correct language we would have to rename every operator
into something different. What do you prefer to write?

This:
float a, b;
float c = float_addition(a, b);

Or this:
float a, b;
float c = a + b;

> Consider, for example, the simple equation two times two equals four.
> (They don't get much easier than that). You could represent that in 2D
> vectors using Hadamard multiplication as [2,0] * [2,0] = [4,0]. So
> far, so good. But we also expect four divided by two to yield two.
> How's that done here? Elementwise division of [4,0] by [2,0] would
> involve zero divided by zero for the second element. More bizarrely,
> a*b can equal zero, even when neither a nor b is zero. So while it
> certainly is reasonable to call it a function, I continue to question
> whether or not it is reasonable to call it multiplication. That's what
> I meant.

It's a question of consistency: Either you question all usage of
mathematical operators in programming languages, or you accept that it's
only a thing of definition and documentation.
I think that it is reasonable to call something multiplication if it is
well-defined and has similarities to other uses of multiplication.
As you know, the multiplication dot is used in maths for all kinds of things
that clearly are not multiplications of two scalars; if you don't know what
the multiplication dot means, you look the definition up, don't you?




More information about the Digitalmars-d mailing list