We discussed this briefly on #sage-devel a couple weeks ago, though
the discussion died out and nobody got around to submitting a trac
ticket about it (probably because it's not really clear which way to
go on this...). Here's the log, which might answer some questions:
http://sage.pastebin.com/EBq7Zud5 See also 
http://trac.sagemath.org/sage_trac/ticket/3214
which is mentioned at the end of the IRC log.

-Keshav

On Dec 29, 6:09 am, Johannes <dajo.m...@web.de> wrote:
> Ok, from this point of view see the point. But I dont know if it's
> documented this way somewhere.
>
> greatz
> Am 28.12.2010 23:00, schrieb Iwao Kimura:
>
> > Hi Johannes,
>
> > I'm not sure but if we think gcd(2, 0) is the generator of the ideal
> > generated by 2 and 0 in the rationals, we see gcd(2,0) is 1 because
> > the ideal is not zero (and QQ is a field :)
>
> > Best regards.
>
> > On Wed, Dec 29, 2010 at 6:33 AM, Johannes <dajo.m...@web.de> wrote:
> >> I got it solved. It's a type error:
> >> the matrix sing is a matrix over QQ.
> >> If its a matrix over ZZ it works fine.
>
> >> but why is gcd(2,0) = 1 for 2,0 as Rationals?
> >> in my eyes its not well defined or should be the maximum of those values.
>
> >> greatz
>
> >> Am 28.12.2010 22:08, schrieb Johannes:
> >>> Hi list,
> >>> I've a very confusing problem with some simple algorithm:
>
> >>> following setting: a matrix sing:
> >>> sage: sing
> >>> [ 3  0  1]
> >>> [-2 -1 -2]
> >>> [ 0  1  0]
> >>> sage: l = sings.column(2);l
> >>> (1, -2, 0)
> >>> #my algorithem, code see below:
> >>> sage: extgcd(l)
> >>> #some printoutput for debugging:
> >>> l: (1, -2, 0)
> >>> tlist:  (-2, 0)
> >>> #this should not be, d = gcd(tlist)
> >>> d: 1
> >>> l: [1, 1]
> >>> [u, v]: [0, 1]
> >>> l: (-2, 0)
> >>> [u, v]: [1, 0]
> >>> res: [0, 1, 0]
> >>> #the result:
> >>> [0, 1, 0]
> >>> #now the same but i construct the vector on my own:
> >>> sage: l = vector([1,-2,0]);l
> >>> (1, -2, 0)
> >>> sage: extgcd(l)
> >>> l: (1, -2, 0)
> >>> tlist:  (-2, 0)
> >>> #here it works fine
> >>> d: 2
> >>> l: [1, 2]
> >>> [u, v]: [1, 0]
> >>> l: (-2, 0)
> >>> [u, v]: [1, 0]
> >>> res: [1, 0, 0]
> >>> #getting the expected result:
> >>> [1, 0, 0]
>
> >>> the code of my algorithm:
>
> >>> def extgcd(l):
> >>>     print "l: " + str(l)
> >>>     assert len(l) > 1
>
> >>>     if len(l) == 2:
> >>>         #calculated ext euclidean for two values
> >>>         a = l[0]
> >>>         b = l[1]
>
> >>>         u=t=1
> >>>         v=s=0
> >>>         while b>0:
> >>>             q=a//b
> >>>             a, b = b, a-q*b
> >>>             u, s = s, u-q*s
> >>>             v, t = t, v-q*t
> >>>         print "[u, v]: " + str([u, v])
> >>>         return [u, v]
> >>>     else:
>
> >>>       #this is the part where it does not work!
> >>>         tlist = l[1:]
> >>>         print "tlist:  " + str(tlist)
> >>>         d =  gcd(tlist)
> >>>         print "d: " + str(gcd(tlist))
>
> >>>         #calculate part decomp
> >>>         u, v = extgcd([l[0],d])
> >>>         #calculate rest
> >>>         ttlist = extgcd(tlist)
> >>>         res =  [u]
> >>>         #combine results
> >>>         res.extend([v * item for item in ttlist])
> >>>         print "res: " + str(res)
> >>>         return res
>
> >>> I hope somebody can help me.
> >>> greatz Johannes
>
> >> --
> >> To post to this group, send email to sage-support@googlegroups.com
> >> To unsubscribe from this group, send email to 
> >> sage-support+unsubscr...@googlegroups.com
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/sage-support
> >> URL:http://www.sagemath.org
>
>

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to