On Jun 20, 2009, at 6:07 PM, rickhg12hs wrote:

>
> On Jun 19, 6:50 am, Pierre <pierre.guil...@gmail.com> wrote:
>> is there an easy way of creating a subdiagonal matrix, that is with 1
>> just under the diagonal and 0's elsewhere ?
>
> This is a hack (especially since I'm no mathematician and no expert in
> Sage or any of its components), but it seems to work.  A formal proof
> would be an interesting read.
>
> Here's an example:
>
> n = 10
> m = matrix(ZZ,n)
> m[range(n-1),range(n-1)] = identity_matrix(n-1)
> m_subd = m.LLL()
>
> Works with some large n I played with.

Another option

sage: n = 10
sage: m = block_matrix([0, zero_matrix(1,1), identity_matrix(n), 0])
sage: m.subdivide() # get rid of the block divisions
sage: m
[0 0 0 0 0 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0 0]
[0 0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 0 1 0]

You can also use this to get anything you want on the sub-diagonal  
(or pretty much anywhere).

sage: m = block_matrix([0, zero_matrix(1,1), diagonal_matrix([10, 20,  
30, 40]), 0]); m.subdivide(); m
[ 0  0  0  0  0]
[10  0  0  0  0]
[ 0 20  0  0  0]
[ 0  0 30  0  0]
[ 0  0  0 40  0]

- Robert

--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to