Somewhat OT: defining algebras in D
Simen Kjærås
simen.kjaras at gmail.com
Thu Feb 8 15:23:05 UTC 2018
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
More information about the Digitalmars-d
mailing list