So I was bored in a meeting and decided to implement a generic template for defining complex numbers, dual numbers, quaternions and many other possible algebras by simply defining a set of rules and the components on which they act:

alias quaternion = Algebra!(
        float,
        "1,i,j,k",
        op("1",     any)  = any,
        op("i,j,k", self) = "-1",
        op("i",     "j")  = "k".antiCommutative,
        op("j",     "k")  = "i".antiCommutative,
        op("k",     "i")  = "j".antiCommutative,
    );

source:

https://gist.github.com/Biotronic/833680b37d4afe774c8562fd21554c6b

--
  Simen

Reply via email to