Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Rebase over #24096.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Oct 30, 2017
2 parents 403ba9e + 8d59a70 commit f1fc365
Show file tree
Hide file tree
Showing 62 changed files with 81 additions and 232 deletions.
2 changes: 0 additions & 2 deletions src/doc/en/reference/matrices/index.rst
Expand Up @@ -56,8 +56,6 @@ objects like operation tables (e.g. the multiplication table of a group).

sage/matrix/special

sage/matrix/matrix

sage/matrix/matrix0

sage/matrix/matrix1
Expand Down
Expand Up @@ -21,7 +21,7 @@

from sage.categories.magmatic_algebras import MagmaticAlgebras
from sage.matrix.constructor import Matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.modules.free_module_element import vector
from sage.rings.ring import Algebra
from sage.structure.category_object import normalize_names
Expand Down
Expand Up @@ -18,7 +18,7 @@

from sage.misc.lazy_attribute import lazy_attribute
from sage.matrix.constructor import Matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.modules.free_module_element import vector
from sage.rings.integer import Integer
from sage.structure.element import AlgebraElement, is_Vector, parent
Expand Down
Expand Up @@ -16,7 +16,7 @@
from .finite_dimensional_algebra_element import FiniteDimensionalAlgebraElement

from sage.matrix.constructor import Matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.rings.ideal import Ideal_generic
from sage.structure.element import parent
from sage.structure.sage_object import SageObject
Expand Down
Expand Up @@ -17,7 +17,7 @@
from sage.rings.morphism import RingHomomorphism_im_gens
from sage.rings.homset import RingHomset_generic
from sage.matrix.constructor import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix

class FiniteDimensionalAlgebraMorphism(RingHomomorphism_im_gens):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/jordan_algebra.py
Expand Up @@ -20,7 +20,7 @@
from sage.misc.cachefunc import cached_method
#from sage.misc.lazy_attribute import lazy_attribute
from sage.rings.all import QQ
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.modules.free_module import FreeModule
from sage.sets.family import Family

Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/functions.py
Expand Up @@ -3,7 +3,7 @@
"""
from __future__ import absolute_import
from sage.matrix.all import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.structure.element import is_Vector
from sage.symbolic.ring import is_SymbolicVariable
from .functional import diff
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/cluster_algebra_quiver/quiver.py
Expand Up @@ -211,7 +211,7 @@ def __init__(self, data, frozen=None, user_labels=None):
sage: TestSuite(Q).run()
"""
from sage.combinat.cluster_algebra_quiver.cluster_seed import ClusterSeed
from sage.matrix.matrix import Matrix
from sage.structure.element import is_Matrix

if isinstance(user_labels, list):
user_labels = [tuple(x) if isinstance(x, list) else x for x in user_labels]
Expand Down Expand Up @@ -327,7 +327,7 @@ def __init__(self, data, frozen=None, user_labels=None):
self._description = data._description

# constructs a quiver from a matrix
elif isinstance(data, Matrix):
elif is_Matrix(data):
if not _principal_part(data).is_skew_symmetrizable( positive=True ):
raise ValueError('The principal part of the matrix data must be skew-symmetrizable.')

Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/crystals/monomial_crystals.py
Expand Up @@ -109,7 +109,6 @@
from sage.rings.integer import Integer
from sage.rings.infinity import Infinity
from sage.rings.integer_ring import ZZ
from sage.matrix.matrix import is_Matrix
from sage.matrix.matrix_space import MatrixSpace

import six
Expand Down
5 changes: 2 additions & 3 deletions src/sage/combinat/integer_matrices.py
Expand Up @@ -165,10 +165,9 @@ def __contains__(self, x):
False
sage: matrix([[-1, 3, 1]]) in IM
False
"""
from sage.matrix.matrix import Matrix
if not isinstance(x, Matrix):
from sage.structure.element import is_Matrix
if not is_Matrix(x):
return False
row_sums = [ZZ.zero()] * x.nrows()
col_sums = [ZZ.zero()] * x.ncols()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/cartan_matrix.py
Expand Up @@ -28,7 +28,7 @@

from sage.misc.cachefunc import cached_method
from sage.matrix.constructor import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
from sage.misc.classcall_metaclass import typecall
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/dynkin_diagram.py
Expand Up @@ -28,7 +28,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.misc.cachefunc import cached_method
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.graphs.digraph import DiGraph
from sage.combinat.root_system.cartan_type import CartanType, CartanType_abstract
from sage.combinat.root_system.cartan_matrix import CartanMatrix
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/reflection_group_complex.py
Expand Up @@ -210,7 +210,7 @@
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
from sage.rings.all import ZZ, QQ
from sage.matrix.all import Matrix, identity_matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.interfaces.gap3 import gap3
from sage.rings.universal_cyclotomic_field import E
from sage.modules.free_module_element import vector
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/rsk.py
Expand Up @@ -99,7 +99,7 @@

from builtins import zip

from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.all import matrix


Expand Down
2 changes: 1 addition & 1 deletion src/sage/crypto/mq/sr.py
Expand Up @@ -313,7 +313,7 @@
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing, BooleanPolynomialRing_constructor as BooleanPolynomialRing

from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.constructor import Matrix, random_matrix
from sage.matrix.matrix_space import MatrixSpace

Expand Down
Expand Up @@ -25,7 +25,7 @@
from sage.functions.all import sqrt
from itertools import permutations, combinations
from sage.matrix.constructor import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.misc.misc_c import prod
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.finite_rings.integer_mod_ring import Integers
Expand Down
8 changes: 4 additions & 4 deletions src/sage/games/sudoku.py
Expand Up @@ -79,9 +79,9 @@ def sudoku(m):
...
ValueError: sudoku function expects puzzle to be a matrix, perhaps use the Sudoku class
"""
from sage.matrix.matrix import Matrix
from sage.structure.element import is_Matrix

if not(isinstance(m, Matrix)):
if not is_Matrix(m):
raise ValueError('sudoku function expects puzzle to be a matrix, perhaps use the Sudoku class')
solution = next(Sudoku(m).solve(algorithm='dlx'))
return (solution.to_matrix() if solution else None)
Expand Down Expand Up @@ -173,12 +173,12 @@ def __init__(self, puzzle, verify_input = True):
ValueError: Sudoku puzzle has an invalid entry
"""
from math import sqrt
from sage.matrix.matrix import Matrix
from sage.structure.element import is_Matrix

if isinstance(puzzle, list):
puzzle_size = int(round(sqrt(len(puzzle))))
self.puzzle = tuple(puzzle)
elif isinstance(puzzle, Matrix):
elif is_Matrix(puzzle):
puzzle_size = puzzle.ncols()
if verify_input and not(puzzle.is_square()):
raise ValueError('Sudoku puzzle must be a square matrix')
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/fan_morphism.py
Expand Up @@ -82,7 +82,7 @@
from sage.geometry.cone import Cone
from sage.geometry.fan import Fan, is_Fan, discard_faces
from sage.matrix.all import identity_matrix, matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.misc.all import cached_method, latex, prod, walltime
from sage.modules.free_module_morphism import (FreeModuleMorphism,
is_FreeModuleMorphism)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperbolic_space/hyperbolic_point.py
Expand Up @@ -64,7 +64,7 @@
from sage.structure.richcmp import richcmp, op_NE
from sage.symbolic.all import I
from sage.misc.latex import latex
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.constructor import matrix
from sage.modules.free_module_element import vector
from sage.rings.infinity import infinity
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/lattice_polytope.py
Expand Up @@ -115,7 +115,7 @@
from sage.libs.ppl import (C_Polyhedron, Generator_System, Linear_Expression,
point as PPL_point)
from sage.matrix.constructor import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.misc.all import cached_method, tmp_filename
from sage.misc.superseded import deprecated_function_alias
from sage.modules.all import vector
Expand Down
8 changes: 4 additions & 4 deletions src/sage/graphs/graph_input.py
Expand Up @@ -174,7 +174,7 @@ def from_seidel_adjacency_matrix(G, M):
sage: g.is_isomorphic(graphs.PetersenGraph())
True
"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.rings.integer_ring import ZZ
assert is_Matrix(M)

Expand Down Expand Up @@ -227,7 +227,7 @@ def from_adjacency_matrix(G, M, loops=False, multiedges=False, weighted=False):
sage: g.is_isomorphic(graphs.PetersenGraph())
True
"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.rings.integer_ring import ZZ
assert is_Matrix(M)
# note: the adjacency matrix might be weighted and hence not
Expand Down Expand Up @@ -308,7 +308,7 @@ def from_incidence_matrix(G, M, loops=False, multiedges=False, weighted=False):
sage: g.is_isomorphic(graphs.PetersenGraph())
True
"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
assert is_Matrix(M)

oriented = any(M[pos] < 0 for pos in M.nonzero_positions(copy=False))
Expand Down Expand Up @@ -379,7 +379,7 @@ def from_oriented_incidence_matrix(G, M, loops=False, multiedges=False, weighted
...
ValueError: each column represents an edge: -1 goes to 1
"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
assert is_Matrix(M)

positions = []
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/strongly_regular_db.pyx
Expand Up @@ -2397,7 +2397,7 @@ def strongly_regular_from_two_weight_code(L):
http://dx.doi.org/10.1016/0012-365X(72)90024-6.

"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
if is_Matrix(L):
L = LinearCode(L)
V = map(tuple,list(L))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/affine_gps/group_element.py
Expand Up @@ -40,7 +40,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.misc.cachefunc import cached_method
from sage.structure.element import MultiplicativeGroupElement
from sage.structure.richcmp import richcmp, richcmp_not_equal
Expand Down
3 changes: 0 additions & 3 deletions src/sage/groups/matrix_gps/all.py
Expand Up @@ -10,7 +10,4 @@
lazy_import('sage.groups.matrix_gps.finitely_generated', 'MatrixGroup')
lazy_import('sage.groups.matrix_gps.finitely_generated', 'QuaternionMatrixGroupGF3')

#from matrix_group_element import is_MatrixGroupElement
#from matrix_group import MatrixGroup, is_MatrixGroup

import sage.groups.matrix_gps.pickling_overrides
2 changes: 1 addition & 1 deletion src/sage/groups/matrix_gps/finitely_generated.py
Expand Up @@ -67,7 +67,7 @@
from sage.rings.ring import is_Ring
from sage.rings.finite_rings.finite_field_constructor import is_FiniteField
from sage.interfaces.gap import gap
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.matrix_space import MatrixSpace, is_MatrixSpace
from sage.matrix.all import matrix
from sage.misc.latex import latex
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/matrix_gps/group_element.pyx
Expand Up @@ -82,7 +82,7 @@ from sage.structure.richcmp cimport richcmp
from sage.libs.gap.element cimport GapElement, GapElement_List
from sage.groups.libgap_wrapper cimport ElementLibGAP

from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.structure.factorization import Factorization
from sage.misc.cachefunc import cached_method
from sage.rings.all import ZZ
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx
Expand Up @@ -31,7 +31,7 @@ from __future__ import print_function
include "sage/data_structures/bitset.pxi"
from .data_structures cimport *
from sage.rings.integer cimport Integer
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from .double_coset cimport double_coset


Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/permgroup_element.pyx
Expand Up @@ -69,7 +69,7 @@ from sage.ext.stdsage cimport HAS_DICTIONARY
from sage.rings.all import ZZ, Integer
from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.multi_polynomial import is_MPolynomial
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
from sage.matrix.all import MatrixSpace
from sage.interfaces.all import gap
from sage.interfaces.gap import is_GapElement
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/four_ti_2.py
Expand Up @@ -127,7 +127,7 @@ def write_matrix(self, mat, filename):
sage: four_ti_2.write_matrix([[1,2],[3,4]], "test_file")
"""
from sage.matrix.constructor import matrix
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix
if not is_Matrix(mat):
mat = matrix(ZZ, mat)
if mat.base_ring() != ZZ:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_mat_GF2.pyx
Expand Up @@ -83,7 +83,7 @@ cdef class ntl_mat_GF2(object):
cdef Py_ssize_t i, j
cdef GF2_c _elem

from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix

if is_Matrix(nrows):
_nrows = nrows.nrows()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/libs/ntl/ntl_mat_GF2E.pyx
Expand Up @@ -87,8 +87,8 @@ cdef class ntl_mat_GF2E(object):
cdef unsigned long _nrows, _ncols
cdef unsigned long i, j

import sage.matrix.matrix
if sage.matrix.matrix.is_Matrix(nrows):
from sage.structure.element import is_Matrix
if is_Matrix(nrows):
_nrows = nrows.nrows()
_ncols = nrows.ncols()
v = nrows.list()
Expand Down
19 changes: 1 addition & 18 deletions src/sage/matrix/matrix.pxd
@@ -1,18 +1 @@
"""
Generic matrices
"""

#*****************************************************************************
# Copyright (C) 2006 William Stein <wstein@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

from .matrix2 cimport Matrix as Matrix2

cdef class Matrix(Matrix2):
pass
from .matrix2 cimport Matrix
13 changes: 3 additions & 10 deletions src/sage/matrix/matrix.pyx
Expand Up @@ -13,24 +13,17 @@ For design documentation see matrix/docs.py.
# http://www.gnu.org/licenses/
################################################################################

from sage.ext.stdsage cimport PY_SET_TP_NEW
from sage.misc.superseded import deprecation
deprecation(24096, "the module sage.modules.module_element is deprecated, import from sage.structure.element instead")

def is_Matrix(x):
"""
EXAMPLES::
sage: from sage.matrix.matrix import is_Matrix
sage: from sage.structure.element import is_Matrix
sage: is_Matrix(0)
False
sage: is_Matrix(matrix([[1,2],[3,4]]))
True
"""
return isinstance(x, Matrix)

cdef class Matrix(Matrix2):
pass

# This is pretty nasty low level stuff. The idea is to speed up construction
# of EuclideanDomainElements (in particular Integers) by skipping some tp_new
# calls up the inheritance tree.
PY_SET_TP_NEW(Matrix, Matrix2)
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix2.pyx
Expand Up @@ -10711,7 +10711,7 @@ cdef class Matrix(Matrix1):

- Rob Beezer (2011-03-15, 2015-05-25)
"""
from sage.matrix.matrix import is_Matrix
from sage.structure.element import is_Matrix

if not is_Matrix(other):
raise TypeError('similarity requires a matrix as an argument, not {0}'.format(other))
Expand Down

0 comments on commit f1fc365

Please sign in to comment.