Ticket #12020: trac_12020_alt.patch

File trac_12020_alt.patch, 2.2 KB (added by malb, 8 years ago)
  • sage/matrix/docs.py

    # HG changeset patch
    # User Martin Albrecht <martinralbrecht@googlemail.com>
    # Date 1321295917 0
    # Node ID 82598893bea54403977c097610839780bd6953d6
    # Parent  9e29a3d84c48c399daaf3920bcb8b17273a0e876
    #12020 support entries==None in all matrix classes
    
    diff --git a/sage/matrix/docs.py b/sage/matrix/docs.py
    a b  
    376376       * set_unsafe(self, size_t i, size_t j, x) -- doesn't do bounds or any other checks; assumes x is in self._base_ring
    377377       * get_unsafe(self, size_t i, size_t j) -- doesn't do checks
    378378       * __richcmp__    -- always the same (I don't know why its needed -- bug in PYREX).
     379
     380    Note that the __init__ function must construct the all zero matrix if ``entries == None``.
     381
    379382    *********** LEVEL 2  **********
    380383   
    381384    IMPORTANT (and *highly* recommended):
  • sage/matrix/matrix_cyclo_dense.pyx

    diff --git a/sage/matrix/matrix_cyclo_dense.pyx b/sage/matrix/matrix_cyclo_dense.pyx
    a b  
    154154        """
    155155        cdef int i
    156156        z = None
    157         if entries == 0:
     157        if (entries is None) or (entries == 0):
    158158            pass
    159159        elif isinstance(entries, list):
    160160            # This code could be made much faster using Cython, etc.
  • sage/matrix/matrix_modn_sparse.pyx

    diff --git a/sage/matrix/matrix_modn_sparse.pyx b/sage/matrix/matrix_modn_sparse.pyx
    a b  
    181181       
    182182        cdef void** X
    183183
     184        if entries is None:
     185            return
     186
    184187        if isinstance(entries, dict):
    185188            # Sparse input format.
    186189            R = self._base_ring
  • sage/matrix/matrix_space.py

    diff --git a/sage/matrix/matrix_space.py b/sage/matrix/matrix_space.py
    a b  
    397397            True
    398398            sage: mat2 = mat.change_ring(QQ); mat2.is_mutable()
    399399            True
     400
     401        TESTS:
     402
     403            Ensure that trac 12020 is fixed::
     404
     405                sage: A = MatrixSpace(CyclotomicField(4),60,30)(0)
     406                sage: B = A.augment(A)
    400407        """
    401408        if entries is None or entries == 0:
    402409            if self._copy_zero: # faster to copy than to create a new one.