feat(quaternion): Add convenience quaternion creator function #48
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "quaternion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Even in the setup just prior to this commit, a quaternion with entries
of type
number
is simply aComplex<Complex<number>>
So if we provide a convenience wrapper to create sucha thing, we
instantly have a quaternion data type. All of the operations come for
"free" if they were properly defined for the
Complex
template.Multiplication already was,
abs
needed a little tweak, but there isabsolutely no "extra" code to support quaternions. (This commit
does not go through and check all arithmetic functions for proper operation
and tweak those that still need some generalization.)
Note that with the recursive template instantiation, a limit had to be placed
on template instantiation depth. The limit moves deeper as actual arguments
that are deeper nested instantiations are seen, so as long as one doesn't
immediately invoke a triply-nested template, for example, the limit will
never prevent an actual computation. It just prevents a runaway in the types
that Pocomath thinks it needs to know about. (Basically before, using the
quaternion creator would produce
Complex<Complex<number>>
. Then when youcalled it again, Pocomath would think "Maybe I will need
Complex<Complex<Complex<number>>>
?!" and create that, even though it hadnever seen that, and then another level next time, and so on. The limit
just stops this progression one level beyond any nesting depth that's
actually been observed.