This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: quaternions in the numeric tower
- From: Jamison Hope <jrh at theptrgroup dot com>
- To: "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Date: Wed, 12 Nov 2014 22:28:34 -0500
- Subject: Re: quaternions in the numeric tower
- Authentication-results: sourceware.org; auth=none
- References: <6000E8B8-620C-4080-9D53-740C1334B164 at theptrgroup dot com> <546406F6 dot 6020509 at bothner dot com>
On Nov 12, 2014, at 8:18 PM, Per Bothner <per@bothner.com> wrote:
> On 11/12/2014 03:37 PM, Jamison Hope wrote:
>> Hi Per,
>>
>> I finally got around to implementing support for quaternions in the
>> numeric tower (it was originally my idea, after all). Would you be
>> interested in pulling this in before the big version 2.0?
>
> Cool. If it's ready in time (which includes writing documentation) then
> it can go in.
>
> I think the documentation can go in a new @section in @node Numbers.
OK.
>> There are now a handful of new functions in kawa.lib.numbers (jmag-part,
>> kmag-part, colatitude, etc). Where in Scheme#initScheme should those
>> go?
>
> Nowhere, IMO. I think we should require either:
> (import (kawa quaternions))
> or
> (require 'quaternions)
> to use these functions.
>
> Note that implies the new functions should go in kawa/lib/kawa/quaternions.scm,
> not kawa/lib/numbers.scm.
OK, I'll put the new functions there. But what about <quaternion> as
a type? That would still go in the LispLanguage type map, right?
In which case at the very least the quaternion? function should get
defined automatically. It's like complex? and real? in that it should
return #true on both actual instances of <quaternion> as well as the
java.lang number types, so we would get incorrect results if Kawa
decides to do its (TYPE? x) -> (x instanceof TYPE) thing.
Is kawa/lib/numbers.scm permitted to require/import (kawa quaternions)?
Some of its functions now make use of quaternion functions. For example,
real-valued? is now
(define (real-valued? x) ::boolean
(and (quaternion? x)
(zero? (imag-part x))
(zero? (jmag-part x))
(zero? (kmag-part x))
(real? (real-part x))))
--
Jamison Hope
The PTR Group
www.theptrgroup.com