Hi Jeff,

You should make a sparse matrix by giving a dictionary of
   (i,j):x
entries.  Use a list to define a dense matrix and a dictionary
to define a sparse matrix.   (The error message you get
below obviously sucks though, and should be fixed.)

On 4/17/07, Jeff Allotta <[EMAIL PROTECTED]> wrote:
> Hi -
>
> How implemented is sparse linear algebra in SAGE?  When I make a
> MatrixSpace of sparse matrices I run into errors that don't happen
> when it is dense.
>
> For example, creating a matrix out of a list of lists.  Although, I
> think I remember that this used to work a month ago -- I would just
> run into problems later on.
>
> Thanks,
> Jeff
>
> Here's my example code:
> **************
>
> [EMAIL PROTECTED]:~$ sage
> ----------------------------------------------------------------------
> | SAGE Version 2.4.2, Release Date: 2007-04-12                       |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
>
> sage: relats = [[0 for i in range(10)] for j in range(10)]
> sage: relats
>
> [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
>
> sage: B = MatrixSpace(ZZ,10,10)
> sage: B
> Full MatrixSpace of 10 by 10 dense matrices over Integer Ring
> sage: D = MatrixSpace(ZZ,10,10,sparse=True)
> sage: D
> Full MatrixSpace of 10 by 10 sparse matrices over Integer Ring
> sage: B(relats)
>
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
>
> sage: D(relats)
> ---------------------------------------------------------------------------
> <type 'exceptions.TypeError'>             Traceback (most recent call
> last)
>
> /home/jallotta/<ipython console> in <module>()
>
> /home/was/s/local/lib/python2.5/site-packages/sage/matrix/matrix_space.py
> in __call__(self, entries, coerce, copy)
>      261         elif
> sage.groups.matrix_gps.matrix_group_element.is_MatrixGroupElement(entries):
>      262             return self(entries.matrix(), copy=False)
> --> 263         return self.matrix(entries, copy=copy, coerce=coerce)
>      264
>      265     def change_ring(self, R):
>
> /home/was/s/local/lib/python2.5/site-packages/sage/matrix/matrix_space.py
> in matrix(self, x, coerce, copy)
>      619             elif isinstance(x[0], tuple):
>      620                 x = list(sum(x,()))
> --> 621         return self.__matrix_class(self, entries=x, copy=copy,
> coerce=coerce)
>      622
>      623     def matrix_space(self, nrows=None, ncols=None,
> sparse=False):
>
> /home/jallotta/matrix_integer_sparse.pyx in
> matrix_integer_sparse.Matrix_integer_sparse.__init__()
>
> /home/jallotta/integer_ring.pyx in
> integer_ring.IntegerRing_class.__call__()
>
> <type 'exceptions.TypeError'>: unable to coerce element to an integer
>
>


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org

--~--~---------~--~----~------------~-------~--~----~
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://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to