Conceptually speaking, this might be handled as a native J type (this would require changing the C implementation of the J engine).
There are four issues that I can think of that would need to be dealt with: [1] parsing support so that 1i2j3k4 (for example) could be recognized as a quaternion. [2] "display" support so that quaternions can be converted back into a representative sequence of characters [3] "type" support so that quaternions could be atoms in arrays. [4] the implementation itself (currently represented in the addons/math/mt/quatern.ijs, for the most part) The first two could also be thought of as deserialization and serialization (if you are inclined to do searches for analogous implementations in other contexts). One "tricky" issue is that we use a fixed width bitmask to represent types in the context of verb domain. If I recall correctly (but it's been probably a year since I spent any time looking at this), we had maybe one bit left in a 32 bit representation. Conceptually speaking, that maybe means we should extend type representation to be 64 bits even on 32 bit machines (which might break some C code for 32 bit machines...). Another issue is that it might be fun for some people to play with types in J (instead of in C). It might make sense to set aside one or more types for such experimentation. Conceptually, a type would have an identifying location in the type bitmask, an element size in arrays of that type, a serialize routine, a deserialize routine, a conversion routine (for quaternions, this would convert non-quaternion numbers to quaternions), conversion priority for dyads (when adding a quaternion and an extended precision number, or a quaternion and some other user defined type number which one gets converted to what?), and finally, for each supported operation a monad and a dyad definition. (That's a lot of detail, but it also gives an idea of the scope of work which has gone into building the engine. But it also hints at why this kind of thing can easily break or maybe feel inadequate when it's handled in some other way.) Anyways... potentially a lot of work... but interesting to think about. Thanks, -- Raul On Thu, Nov 1, 2018 at 8:47 AM Don Guinn <[email protected]> wrote: > > I looked at it and it uses smprompt which is gone now. It was to capture > input. It also uses smcolor which is gone too, though not really neccessary. > > But it made trying things much easier. > > Will be following this thread. > > On Thu, Nov 1, 2018, 6:05 AM bill lam <[email protected]> wrote: > > > I suspected it won't work on jconsole either since it is related > > to J Engine not the front end. > > > > > > Thu, 01 Nov 2018, Don Guinn написал(а): > > > Years ago I got curious about quaternions. After playing with them for a > > > while and found it awkward I wrote a script to run quaterrnions using J > > > primitives. The main problem is that it requires J6 to work right, I > > think. > > > The problem is that it does not work with JQt, I think. I just tried it > > on > > > J6 and it still works. Below is a short sample. > > > > > > load 'd:\don\juser\q3\quaternion.ijs' > > > quatutil > > > quatmath > > > quatint > > > quatjtools > > > quatjdefs > > > Q '' > > > Entering Quaternion Mode > > > ]q=.*/~0i1 0j1 0k1 > > > _1 0k1 0j_1 > > > 0k_1 _1 0i1 > > > 0j1 0i_1 _1 > > > > > > Leaving Quaternion Mode > > > Q '' > > > Entering Quaternion Mode > > > ]q=.*/~0i1 0j1 0k1 > > > _1 0k1 0j_1 > > > 0k_1 _1 0i1 > > > 0j1 0i_1 _1 > > > q > > > _1 0k1 0j_1 > > > 0k_1 _1 0i1 > > > 0j1 0i_1 _1 > > > > > > Leaving Quaternion Mode > > > q > > > ┌────────┬────────┬────────┐ > > > │_1 0 0 0│0 0 0 1 │0 0 _1 0│ > > > ├────────┼────────┼────────┤ > > > │0 0 0 _1│_1 0 0 0│0 1 0 0 │ > > > ├────────┼────────┼────────┤ > > > │0 0 1 0 │0 _1 0 0│_1 0 0 0│ > > > └────────┴────────┴────────┘ > > > Q '' > > > Entering Quaternion Mode > > > 2i1j3^3j2k1 > > > 7.07923i_1.03091j_2.79868k_1.0557 > > > > > > Leaving Quaternion Mode > > > > > > > > > At the time I never found anyone to talk about quaternions. So I moved on > > > to other things. If anyone is interested in it I would be glad to share. > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > > regards, > > ==================================================== > > GPG key 1024D/4434BAB3 2008-08-24 > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 > > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
