On Wednesday 01 October 2008, Stephen Hartke wrote:
> Hi!  I have some questions about matrices and solving linear systems of
> equations.  These issues arose out of my using Sage for examples in my
> Linear Optimization class (it's great for demonstrating how the simplex
> algorithm works!) and for research I'm doing involving finite fields.
>
> If I have a matrix A defined over some finite field, and a vector b over
> the same finite field, what's the easiest way to solve the equation Ax=b? 

You can either use the "\" operator or the functions solve_left and 
solve_right:

sage: A = random_matrix(GF(127),200,200)
sage: x = random_matrix(GF(127),200,1)
sage: A\x
200 x 1 dense matrix over Finite Field of size 127
sage: b = _
sage: A*b == x
True

sage: A.solve_left(transpose(x))
1 x 200 dense matrix over Finite Field of size 127
sage: b = _
sage: b*A == transpose(x)
True

> Is there any easy way to augment A with b as an extra column?  Is there an
> easy way to insert a row or column?  

sage: A = random_matrix(GF(127),3,3)
sage: A
[76 36 72]
[30  5 51]
[29 58 49]

sage: A.augment(random_matrix(GF(127),3,1))
[76 36 72 49]
[30  5 51 45]
[29 58 49 27]

> Is there an easy way to delete a row or column? The same questions apply for
> matrices over the rationals. 

sage: A.matrix_from_rows([0,2])
[76 36 72]
[29 58 49]

This API should be uniform across base rings.

> The functions stack() and insert_row() are pretty useful, but they seem to
> be only defined for matrices over the integers.

AFAIK stack is available for all matrices:

sage: A = random_matrix(GF(127),20,20)
sage: A.stack(A)
40 x 20 dense matrix over Finite Field of size 127

sage: A = random_matrix(GF(2^4,'a'),20,20)
sage: A.stack(A)
40 x 20 dense matrix over Finite Field in a of size 2^4

but insert_row is not. This could be an oversight.

Cheers,
Martin

-- 
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: [EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to