I've only just noticed - should have looked earlier - that Dyalog APL includes a proto-implementation of quaternions in the "dfns" workspace, a set of examples of John Scholes' "Dynamic Functions" . It's described as a work in progress, and partly attributed to Bob Smith,  referring to his paper on "Hypercomplex numbers
in APL",
http://www.sudleyplace.com/APL/Hypercomplex Numbers in APL.pdf

The whole thing is bound into a single APL operator, "H" (for Hamilton),  or adverb
in J-speak.
It picks up a number of primitives such as + - × or * and ÷ or & and applies them as
monads or dyads as required.

Externally, I think it represents quaternions as arrays of quadruples, although it is said to use Cayley-Dickson internally.  Items with fewer than 4 elements are extended
with zeros.

So, for example, copying and pasting from the workspace's description of H,
        1 2 3 4    × H   5 6 7 8                          ⍝ Model multiply
    ¯60 12 30 24

cf my attempt at quaternion multiply, where I assume Cayley-Dickson construction externally (as reported in my email to Jchat in the Quaternions thread on 2 November)

   1j2 3j4 qmult 5j6 7j8
_60j12 30j24

This seems to me to present a useful intermediate way of overloading primitives
with a quaternion-type without burdening the J implementation; whether one
really needs  × H rather than qmult or some such named verb - I don't
know!  I suppose you only need to remember the one adverb H rather than a
whole bundle of verb names.

I'll have a look at adding an H adverb to my small suite of quaternion verbs.

Cheers,

Mike




On 04/11/2018 00:49, bill lam wrote:
J has limited resources, I think it is better to prioritize implementation
of bit boolean over quaternions. Just my 2 cents.

On Sun, Nov 4, 2018, 8:41 AM Don Guinn <[email protected] wrote:

Thank you for your comments. What I did was strictly replace verbs with a
named verb with the same rank as the primitive and also defined an inverse
making them functionally equivalent. So modifiers treat them just like the
primitive, except for fit (!.) and any optimization. All rules for tacit
and modifiers still apply. I tested those statements you mentioned and they
seem to work properly. Since they are named verbs, including (*), J cannot
know that it is supposed to be multiplication or whatever. So optimization
you mentioned in J is not done. And it is not necessary to worry about
tacit and other modifier considerations.

Yes, if optimization is done before the type of noun is encountered,
particularly multiplication, then it would be a real problem.

I guess that for now at least, the best approach for me is to name the
verbs and use them instead of the primitives. It is not hard to enter a
statement, replace the primitive verbs with the appropriate named verbs,
then execute the modified statement. And in some other possible things to
look into may have even more restrictions than quaternions, where even
addition may not communicate.

But it is nice to be able to enter regular J statements and have them
support quaternions.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to