Assignment of a matrix to a matrix slice works as expected except for when
the slice is 1x1; in that case, Sage expects a scalar instead of a 1x1
matrix.  The following code demonstrates the problem:

k=5
A=matrix(RDF,k,k,range(k^2))
for i in range(A.ncols()):
    print i,
    try:
        A[0:i,0:i]=A[0:i,0:i]
        print
    except TypeError as e:
        print "This slice assignment failed:",e
        pass
A[2:3,3:4]=5  # a scalar is expected

Output:

0
1 This slice assignment failed: float() argument must be a string or a number
2
3
4

The fact that assignment to matrix slices fails in this cases is an
annoyance in algorithms (such as Householder orthogonalization) that assign
to submatrices the result of matrix calculations.  Currently, the 1x1 cases
need to be handled separately.

Is there any reason why such an assignment cannot do the appropriate thing
when passed a 1x1 matrix or a scalar?  If this seems a reasonable thing to
do, I'll open a bug report on the trac.

Best wishes,
Stephen

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to