Based on a quick test, it looks like it gives a result consistent with the
integer definition of GCD: if you divide both terms by the answer, you get
integer results:

   3 4 5 +.~ 12
3 4 1
   3 4 5 +. 12.5
0.5 0.5 2.5

   gcdDivBy=: 4 : '(x;y)%&><x +. y'

   3 4 5 gcdDivBy 12
1 1  5
4 3 12
   3 4 5 gcdDivBy 12.5
 6  8 2
25 25 5
   3 4 5 gcdDivBy 12.25
12 16 20
49 49 49



On Sun, Jul 24, 2011 at 6:27 PM, Boyko Bantchev <[email protected]> wrote:

> The +. verb computes the `GCD' of all kinds of numbers known to
> J, but the corresponding page of the DoJ does not say what exactly
> +.  produces.  As there is no standard definition of GCD for
> floating-point or complex numbers in mathematics, +. seems to be
> underspecified.  Moreover, the text
>
>    `The greatest common divisor divides both of its arguments x
>    and y to produce results that have no common factor, that is,
>    the GCD of the quotients is 1.  Moreover, these quotients
>    represent the fraction x%y in lowest form.'
>
> seems to suggest only integer arguments.  For example,
>    `the GCD of the quotients is 1'
> apparently does not hold for many reals.
>
> So, what does +. compute?
> (I can imagine several definitions, but I am curious what the actual one
> is.)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to