Ignore:
Timestamp:
03/03/07 23:06:15 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Sparse matrices over the integers; also fixed a bug that prevented sparse matrices over ZZ and QQ from pickling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/matrix/matrix_rational_sparse.pyx

    r3114 r3271  
    3838    ######################################################################## 
    3939    def __new__(self, parent, entries, copy, coerce): 
     40        # set the parent, nrows, ncols, etc.  
     41        matrix_sparse.Matrix_sparse.__init__(self, parent) 
     42 
    4043        self._matrix = <mpq_vector*> sage_malloc(parent.nrows()*sizeof(mpq_vector)) 
    4144        if self._matrix == NULL: 
    4245            raise MemoryError, "error allocating sparse matrix" 
     46        # initialize the rows  
     47        for i from 0 <= i < parent.nrows(): 
     48            init_mpq_vector(&self._matrix[i], self._ncols, 0) 
     49 
     50        # record that rows have been initialized 
     51        self._initialized = True 
     52 
    4353         
    4454    def __dealloc__(self): 
     
    6676        cdef Rational z 
    6777        cdef void** X 
    68  
    69         # set the parent, nrows, ncols, etc.  
    70         matrix_sparse.Matrix_sparse.__init__(self, parent) 
    71  
    72         # initialize the rows  
    73         for i from 0 <= i < parent.nrows(): 
    74             init_mpq_vector(&self._matrix[i], self._ncols, 0) 
    75  
    76         # record that rows have been initialized 
    77         self._initialized = True 
    7878 
    7979        # fill in entries in the dict case 
Note: See TracChangeset for help on using the changeset viewer.