On 7/26/07, David Joyner <[EMAIL PROTECTED]> wrote:
> On 7/26/07, mak <[EMAIL PROTECTED]> wrote:
> > 1.  How do I change the entire row or column of a matrix at once?  In
> > pari, I could do e.g. a=[1,2,3;4,5,6], and then put a[1,]=[0,0,0],
> > which would give a=[0,0,0;4,5,6].  What's the sage equivalent?

There is no SAGE equivalent yet.  David's example might be helpful
below though.  The best you could in SAGE is set each entry
one at a time right now.  I should add something.

def set_row(A, r, v):
    for i in range(A.ncols()):
         A[r, i] = v[i]

I'm not sure how we forgot to ever do this.  I've added this
to the trac server:
  http://www.sagemath.org:9002/sage_trac/ticket/405

> sage: a=[[1,2,3],[4,5,6]]
> sage: A = matrix(a)
> sage: A
>
> [1 2 3]
> [4 5 6]
> sage: a[0] = [0,0,0]
> sage: A = matrix(a)
> sage: A
>
> [0 0 0]
> [4 5 6]
>
>
> >
> > 2.  I enter a 100x100 matrix and the notebook doesn't display it; I
> > just get something like '100x100 matrix with integer coefficients'.
> > I'd like the matrix displayed explicitly (at my own risk).  Clicking
> > to the side doesn't have any effect.

If a is the matrix do

  print a.str()

and you'll see it all.

Doing
   show(a)
in the notebook might also be useful.
Also, doing
  print a[5]
would show you just the 5th row
and print a[:5].str() the first 5 rows (I think).

>
> I don't know. Maybe something like this would help:
>
>
> sage: MS = MatrixSpace(IntegerModRing(5),100,100)
> sage: A = MS.random_element()
> sage: A.matrix_from_rows_and_columns(range(10), range(20,38))
>
> [1 2 4 3 2 1 1 2 4 3 4 1 1 2 4 1 1 3]
> [4 1 3 4 1 0 0 1 1 0 0 4 2 0 1 0 0 2]
> [1 0 0 1 2 2 1 1 3 0 0 0 2 2 1 1 2 1]
> [4 1 3 4 1 2 1 0 1 2 3 3 1 2 2 1 3 3]
> [3 4 0 2 1 4 1 1 1 1 0 1 3 4 1 4 1 0]
> [1 1 2 0 3 3 0 1 0 4 3 2 3 1 3 4 3 3]
> [0 0 1 1 0 0 2 3 2 4 2 4 3 2 1 3 2 2]
> [3 2 1 4 1 2 2 3 1 0 1 2 1 0 3 0 1 3]
> [1 3 0 2 2 1 3 4 3 0 3 0 2 2 0 0 0 2]
> [2 0 0 4 3 4 4 3 1 0 4 3 4 0 3 0 2 0]
>
>
>
> >
> > Thanks,
> > Mak
> >
> >
> > >
> >
>
> >
>


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.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
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to