[Haskell-cafe] [Haskell] Defining Cg,
HLSL style vectors in Haskell
Krasimir Angelov
kr.angelov at gmail.com
Wed Nov 29 15:05:00 EST 2006
It is possible of course but your definition doesn't correspond to any
operation in the usual vector algebra. By the way how do you define
(*)? Isn't it 3D vector multiplication?
Krasimir
On 11/29/06, Slavomir Kaslev <slavomir.kaslev at gmail.com> wrote:
> You mean signum = normalize? What do you think of my comments here:
>
> > After giving some thought on signum, I got to the point, that signum
> > should be defined so that abs x * signum x = x holds. So it can be
> > defined as signum (Vec2 x y) = Vec 2 (signum x) (signum y).
>
> > It turns out that all the functions in Num, Floating, etc. classes can
> > be given meaningful definitions for vectors in this pattern. That is f
> > (Vecn x1 x2 .. xn) = Vecn (f x1) ... (f xn). And all expected laws
> > just work. One can think of that like the way SIMD processor works, it
> > does the same operations as on floats but on four floats at parallel.
>
> I think this is the way to define vector instances for Num, Floating,
> etc. For vector specific operations, such as normalize, len, dot,
> cross, etc. are declared in class Vector.
>
> --
> Slavomir Kaslev
>
More information about the Haskell-Cafe
mailing list