Is there something like ?
I don't believe so.
sage: [A[z][z] for z in range(A.nrows())]
[3, 6, 7]
could work. But I don't know that this is what you are looking for. Would you find this useful as an attribute? What output would be expected for a non-square matrix?
posted Aug 23 '10kcrisman
7427 ● 17 ● 76 ● 166
Depending on whether you want to do numerics or exact linear algebra, you can use Numpy/Scipy's matrix object. (Numpy and Scipy are included in Sage.) For example:
The diagonal() method also supports rectangular matrices. It does the obvious, which is to continue down the diagonal until a "side" of the matrix is hit. For example, if I add a row to the above matrix I get the following output:
Or if I add a column at the end:
But again, Numpy/Scipy's specialty is in floating point arithmetic. (I.e. numerics) Thankfully, there is a decent amount of compatibility between Numpy's numpy.matrix object and Sage's sage.matrix object.
Asked: Aug 23 '10
Seen: 1,507 times
Last updated: Aug 24 '10
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.