feat(quaternion): Add convenience quaternion creator function #48

Merged
glen merged 1 commits from quaternion into main 2022-08-07 03:27:46 +00:00

1 Commits

Author SHA1 Message Date
Glen Whitney e26df5f4fc feat(quaternion): Add convenience quaternion creator function
Even in the setup just prior to this commit, a quaternion with entries
  of type `number` is simply a `Complex<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 is
  absolutely 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 you
  called it again, Pocomath would think "Maybe I will need
  `Complex<Complex<Complex<number>>>`?!" and create that, even though it had
  never 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.
2022-08-06 20:13:50 -07:00