3D Math Data structures/SIMD

Janice Caron caron800 at googlemail.com
Sun Dec 23 01:16:12 PST 2007


On 12/23/07, Janice Caron <caron800 at googlemail.com> wrote:
> Even if it couldn't
> be made to work for generic arrays, maybe it could be made to work for
> new primitve types like float4?

Sorry - I need to correct myself there (before anyone else does!)

If we had new primitive types, float3, float4, etc., then for those
types, multiplication would be elementwise /by default/, so no special
syntax or functions would be needed. e.g.

    float4 a, b, c;
    a = b * c; // elementwise multiplication

For vectors and matrices in general, we're back to the foreach problem
again! (Foreach was a bad design decision because you can't step
through more than one array in lockstep). If you /could/ then you
could do

    Matrix!(4,4,float) a, b, c;
    foreach(ref x;a)(y:b)(z:c) x = b * c;

(although that wouldn't be parallelised). So it seems to me that
something really needs to be done to improve (or replace) foreach so
that we can do that, and preferably with parallelisation thrown in for
good measuse.



More information about the Digitalmars-d mailing list