Hi William,

> >> Isn't the following a bug ?
> >>
> >>   sage: mat = matrix(ZZ, [[1,1],[1,1]], sparse=False)
> >>   sage: type(mat)
> >>   <type 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
> >>   sage: mat2 = matrix(ZZ, mat, sparse=True)
> 
> I didn't know you could even give a matrix as the input to the matrix
> constructor.  If you type "matrix?" you'll see that of the many types
> of input that matrix takes, a matrix itself is definitely not one of
> them... however the docs specifically say:
> 
>    "Calling matrix() with a Sage object may return something that makes 
> sense."
> 
> That's what's happening here -- your matrix "mat" is just some sage
> object that has an "_matrix_" method.  It's calling that method on
> mat.  That method doesn't even take a sparse parameter.
> 
> So technically the behavior you're seeing agrees with the stated
> documentation, so isn't a bug.  However, I can see how it could be
> misleading!   But fixing it could be a can of worms, so... thank you.

My American language is not very good... I'm not sure what you mean by "could
be a can of worms, so... thank you". Anyway, I'm ok fixing it if it is not too
complicated. Specifically, I'm ready to put a patch which calls the
constructor of MatrixSpace as in
    sage: mat = matrix(ZZ, [[1,1],[1,1]], sparse=False)
    sage: type(mat)
    <type 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
    sage: res = MatrixSpace(ZZ, 2, 2, sparse=True)(mat)
    sage: type(res)
    <type 'sage.matrix.matrix_integer_sparse.Matrix_integer_sparse'>
Is it ok ?

Cheers,

Florent

-- 
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