On Fri, Oct 16, 2009 at 7:49 PM, StephenMKauffman
<[email protected]> wrote:
>
> OK here's what I managed to type in the very unforgiving shell
Have you tried using the Sage notebook?
sage: notebook()
-- William
>
> sage: def nx(Tableau,pr,pc):
> ....: newtab=Tableau
> ....: nr=newtab.nrows()
> ....: nc=newtab.ncols()
> ....: if not pr in range(nr):
> ....: print('invalid pivot row in function nx')
> ....: return 'invalid pivot row in function nx'
> ....: if not pc in range(nc):
> ....: print('invalid pivot column in function nx')
> ....: return 'invalid pivot column in function nx'
> ....: pivot=newtab[pr,pc]
> ....: if pivot==0:
> ....: print('invalid pivot is 0')
> ....: return 'invalid pivot is 0'
> ....: else:
> ....: cellar=range(nc)
> ....: for j in range(nc):
> ....: if j==pc:
> ....: cellar(j)=0
> ....: else:
> ....: cellar(j)=-1*newtab[pr,j]/pivot
> ....: for i in range(nr):
> ....: for j in range(nc):
> ....: if i<>pr and j<>pc:
> ....: newtab[i,j]=newtab[i,j]+cellar(j)*newtab
> [i,pc]
> ....: elif i==pr and j<>pc:
> ....: newtab[i,j]=cellar(j)
> ....: elif i<>pr and j==pc:
> ....: newtab[i,j]=newtab[i,j]/pivot
> ....: return newtab
> ....:
> sage: save_session('TreeOfLife')
> sage: nx(G,0,0)
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call
> last)
>
> /home/stephen/Desktop/Sage/sage-4.1.1/<ipython console> in <module>()
>
> /home/stephen/Desktop/Sage/sage-4.1.1/<ipython console> in nx(Tableau,
> pr, pc)
>
> /home/stephen/Desktop/Sage/sage-4.1.1/local/lib/python2.6/site-
> packages/sage/symbolic/expression.so in
> sage.symbolic.expression.Expression.function (sage/symbolic/
> expression.cpp:15994)()
>
> TypeError: Must construct a function with a tuple (or list) of
> symbolic variables.
> sage: G #this is the integer matrix I want to pass to the function
> nx
>
> [ 1 1 1 0 0 0 0 0 0 0 0 0 0]
> [-1 0 -1 1 -1 0 1 1 1 1 1 1 0]
> [ 0 -1 0 -1 1 0 -1 -1 -1 -1 -1 -1 0]
> [ 0 0 -1 0 -1 1 1 1 1 1 0 0 0]
> [ 0 0 0 0 0 -1 0 0 0 0 1 1 0]
> [ 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 0]
> [ 0 0 0 0 0 0 0 -1 -1 -1 0 -1 0]
> [ 0 0 0 0 0 0 0 1 0 0 0 1 -1]
> [ 0 0 0 0 0 0 0 -1 0 -1 0 -1 1]
>
>
> >
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---