summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen Demeyer <jdemeyer@cage.ugent.be>2017-04-21 16:58:40 +0200
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2017-04-21 17:03:19 +0200
commit841676d4931c9f59019b2b6b82afbbe7df222c10 (patch)
tree7a98c0c83a0183ceb2ddd7de6f140730ab93eeaa
parentUpdated SageMath version to 8.0.beta2 (diff)
Define functions before calling themu/jdemeyer/define_functions_before_calling_them
-rw-r--r--src/sage/matrix/matrix_modn_dense_template.pxi138
-rw-r--r--src/sage/rings/multi_power_series_ring.py1
-rw-r--r--src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx2
-rw-r--r--src/sage/rings/polynomial/polynomial_rational_flint.pyx1
-rw-r--r--src/sage/sets/finite_set_map_cy.pyx94
5 files changed, 118 insertions, 118 deletions
diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi
index 84a2700..ab60bf1 100644
--- a/src/sage/matrix/matrix_modn_dense_template.pxi
+++ b/src/sage/matrix/matrix_modn_dense_template.pxi
@@ -352,6 +352,77 @@ cdef inline linbox_charpoly(celement modulus, Py_ssize_t nrows, celement* entrie
del F
return l
+
+cpdef __matrix_from_rows_of_matrices(X):
+ """
+ Return a matrix whose row ``i`` is constructed from the entries of
+ matrix ``X[i]``.
+
+ INPUT:
+
+ - ``X`` - a nonempty list of matrices of the same size mod a
+ single modulus `n`
+
+ EXAMPLES::
+
+ sage: X = [random_matrix(GF(17), 4, 4) for _ in range(10)]; X
+ [
+ [ 2 14 0 15] [12 14 3 13] [ 9 15 8 1] [ 2 12 6 10]
+ [11 10 16 2] [10 1 14 6] [ 5 8 10 11] [12 0 6 9]
+ [ 9 4 10 14] [ 2 14 13 7] [ 5 12 4 9] [ 7 7 3 8]
+ [ 1 14 3 14], [ 6 14 10 3], [15 2 6 11], [ 2 9 1 5],
+ <BLANKLINE>
+ [12 13 7 16] [ 5 3 16 2] [14 15 16 4] [ 1 15 11 0]
+ [ 7 11 11 1] [11 10 12 14] [14 1 12 13] [16 13 8 14]
+ [ 0 2 0 4] [ 0 7 16 4] [ 5 5 16 13] [13 14 16 4]
+ [ 7 9 8 15], [ 6 5 2 3], [10 12 1 7], [15 6 6 6],
+ <BLANKLINE>
+ [ 4 10 11 15] [13 12 5 1]
+ [11 2 9 14] [16 13 16 7]
+ [12 5 4 4] [12 2 0 11]
+ [ 2 0 12 8], [13 11 6 15]
+ ]
+ sage: X[0]._matrix_from_rows_of_matrices(X) # indirect doctest
+ [ 2 14 0 15 11 10 16 2 9 4 10 14 1 14 3 14]
+ [12 14 3 13 10 1 14 6 2 14 13 7 6 14 10 3]
+ [ 9 15 8 1 5 8 10 11 5 12 4 9 15 2 6 11]
+ [ 2 12 6 10 12 0 6 9 7 7 3 8 2 9 1 5]
+ [12 13 7 16 7 11 11 1 0 2 0 4 7 9 8 15]
+ [ 5 3 16 2 11 10 12 14 0 7 16 4 6 5 2 3]
+ [14 15 16 4 14 1 12 13 5 5 16 13 10 12 1 7]
+ [ 1 15 11 0 16 13 8 14 13 14 16 4 15 6 6 6]
+ [ 4 10 11 15 11 2 9 14 12 5 4 4 2 0 12 8]
+ [13 12 5 1 16 13 16 7 12 2 0 11 13 11 6 15]
+
+ OUTPUT: A single matrix mod ``p`` whose ``i``-th row is ``X[i].list()``.
+
+ .. note::
+
+ Do not call this function directly but use the static method
+ ``Matrix_modn_dense_float/double._matrix_from_rows_of_matrices``
+ """
+ # The code below is just a fast version of the following:
+ ## from constructor import matrix
+ ## K = X[0].base_ring()
+ ## v = sum([y.list() for y in X],[])
+ ## return matrix(K, len(X), X[0].nrows()*X[0].ncols(), v)
+
+ from matrix_space import MatrixSpace
+ cdef Matrix_modn_dense_template A, T
+ cdef Py_ssize_t i, n, m
+ n = len(X)
+
+ T = X[0]
+ m = T._nrows * T._ncols
+ A = T.__class__.__new__(T.__class__, MatrixSpace(X[0].base_ring(), n, m), 0, 0, 0)
+ A.p = T.p
+
+ for i from 0 <= i < n:
+ T = X[i]
+ memcpy(A._entries + i*m, T._entries, sizeof(celement)*m)
+ return A
+
+
cdef class Matrix_modn_dense_template(Matrix_dense):
def __cinit__(self, parent, entries, copy, coerce):
"""
@@ -2994,72 +3065,5 @@ cdef class Matrix_modn_dense_template(Matrix_dense):
for j in range(self._ncols):
to[j] = <mod_int>_from[j]
-cpdef __matrix_from_rows_of_matrices(X):
- """
- Return a matrix whose row ``i`` is constructed from the entries of
- matrix ``X[i]``.
-
- INPUT:
-
- - ``X`` - a nonempty list of matrices of the same size mod a
- single modulus `n`
- EXAMPLES::
-
- sage: X = [random_matrix(GF(17), 4, 4) for _ in range(10)]; X
- [
- [ 2 14 0 15] [12 14 3 13] [ 9 15 8 1] [ 2 12 6 10]
- [11 10 16 2] [10 1 14 6] [ 5 8 10 11] [12 0 6 9]
- [ 9 4 10 14] [ 2 14 13 7] [ 5 12 4 9] [ 7 7 3 8]
- [ 1 14 3 14], [ 6 14 10 3], [15 2 6 11], [ 2 9 1 5],
- <BLANKLINE>
- [12 13 7 16] [ 5 3 16 2] [14 15 16 4] [ 1 15 11 0]
- [ 7 11 11 1] [11 10 12 14] [14 1 12 13] [16 13 8 14]
- [ 0 2 0 4] [ 0 7 16 4] [ 5 5 16 13] [13 14 16 4]
- [ 7 9 8 15], [ 6 5 2 3], [10 12 1 7], [15 6 6 6],
- <BLANKLINE>
- [ 4 10 11 15] [13 12 5 1]
- [11 2 9 14] [16 13 16 7]
- [12 5 4 4] [12 2 0 11]
- [ 2 0 12 8], [13 11 6 15]
- ]
- sage: X[0]._matrix_from_rows_of_matrices(X) # indirect doctest
- [ 2 14 0 15 11 10 16 2 9 4 10 14 1 14 3 14]
- [12 14 3 13 10 1 14 6 2 14 13 7 6 14 10 3]
- [ 9 15 8 1 5 8 10 11 5 12 4 9 15 2 6 11]
- [ 2 12 6 10 12 0 6 9 7 7 3 8 2 9 1 5]
- [12 13 7 16 7 11 11 1 0 2 0 4 7 9 8 15]
- [ 5 3 16 2 11 10 12 14 0 7 16 4 6 5 2 3]
- [14 15 16 4 14 1 12 13 5 5 16 13 10 12 1 7]
- [ 1 15 11 0 16 13 8 14 13 14 16 4 15 6 6 6]
- [ 4 10 11 15 11 2 9 14 12 5 4 4 2 0 12 8]
- [13 12 5 1 16 13 16 7 12 2 0 11 13 11 6 15]
-
- OUTPUT: A single matrix mod ``p`` whose ``i``-th row is ``X[i].list()``.
-
- .. note::
-
- Do not call this function directly but use the static method
- ``Matrix_modn_dense_float/double._matrix_from_rows_of_matrices``
- """
- # The code below is just a fast version of the following:
- ## from constructor import matrix
- ## K = X[0].base_ring()
- ## v = sum([y.list() for y in X],[])
- ## return matrix(K, len(X), X[0].nrows()*X[0].ncols(), v)
-
- from matrix_space import MatrixSpace
- cdef Matrix_modn_dense_template A, T
- cdef Py_ssize_t i, n, m
- n = len(X)
-
- T = X[0]
- m = T._nrows * T._ncols
- A = T.__class__.__new__(T.__class__, MatrixSpace(X[0].base_ring(), n, m), 0, 0, 0)
- A.p = T.p
-
- for i from 0 <= i < n:
- T = X[i]
- memcpy(A._entries + i*m, T._entries, sizeof(celement)*m)
- return A
diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py
index b50090c..521d21e 100644
--- a/src/sage/rings/multi_power_series_ring.py
+++ b/src/sage/rings/multi_power_series_ring.py
@@ -206,7 +206,6 @@ AUTHORS:
from sage.rings.ring import CommutativeRing
from sage.rings.polynomial.all import PolynomialRing
-from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
from sage.rings.polynomial.multi_polynomial import is_MPolynomial
from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing
diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx
index ec7de9b..f3122f1 100644
--- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx
+++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx
@@ -43,8 +43,6 @@ from sage.rings.polynomial.polynomial_element cimport Polynomial
from sage.structure.element cimport ModuleElement, RingElement
from sage.structure.element import coerce_binop
-from sage.rings.polynomial.polynomial_element cimport is_Polynomial
-
from sage.libs.ntl.ntl_ZZX cimport ntl_ZZX
from sage.rings.integer_ring import ZZ
diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
index e50c087..36a8672 100644
--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
@@ -39,7 +39,6 @@ from sage.rings.fraction_field_element import FractionFieldElement
from sage.rings.rational cimport Rational
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_element cimport Polynomial
-from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint
from sage.structure.parent cimport Parent
diff --git a/src/sage/sets/finite_set_map_cy.pyx b/src/sage/sets/finite_set_map_cy.pyx
index 6b20a42..0cbbcf9 100644
--- a/src/sage/sets/finite_set_map_cy.pyx
+++ b/src/sage/sets/finite_set_map_cy.pyx
@@ -384,6 +384,53 @@ cdef class FiniteSetMap_MN(ClonableIntArray):
return res
+cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(t, parent, lst):
+ """
+ Creates a ``FiniteSetMap`` from a list
+
+ .. warning:: no check is performed !
+
+ TESTS::
+
+ sage: from sage.sets.finite_set_map_cy import FiniteSetMap_Set_from_list as from_list
+ sage: F = FiniteSetMaps(["a", "b"], [3, 4, 5])
+ sage: f = from_list(F.element_class, F, [0,2]); f.check(); f
+ map: a -> 3, b -> 5
+ sage: f.parent() is F
+ True
+ sage: f.is_immutable()
+ True
+ """
+ cdef FiniteSetMap_MN res
+ cdef type cls = <type>t
+ res = cls.__new__(cls)
+ super(FiniteSetMap_MN, res).__init__(parent, lst)
+ return res
+
+cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(t, parent, d):
+ """
+ Creates a ``FiniteSetMap`` from a dictionary
+
+ .. warning:: no check is performed !
+
+ TESTS::
+
+ sage: from sage.sets.finite_set_map_cy import FiniteSetMap_Set_from_dict as from_dict
+ sage: F = FiniteSetMaps(["a", "b"], [3, 4, 5])
+ sage: f = from_dict(F.element_class, F, {"a": 3, "b": 5}); f.check(); f
+ map: a -> 3, b -> 5
+ sage: f.parent() is F
+ True
+ sage: f.is_immutable()
+ True
+ """
+ cdef FiniteSetMap_Set res
+ cdef type cls = <type>t
+ res = cls.__new__(cls)
+ res.__init__(parent, d.__getitem__)
+ return res
+
+
cdef class FiniteSetMap_Set(FiniteSetMap_MN):
"""
Data structure for maps
@@ -554,53 +601,6 @@ cdef class FiniteSetMap_Set(FiniteSetMap_MN):
return "map: "+", ".join([("%s -> %s"%(i, self(i))) for i in self.domain()])
-cpdef FiniteSetMap_Set FiniteSetMap_Set_from_list(t, parent, lst):
- """
- Creates a ``FiniteSetMap`` from a list
-
- .. warning:: no check is performed !
-
- TESTS::
-
- sage: from sage.sets.finite_set_map_cy import FiniteSetMap_Set_from_list as from_list
- sage: F = FiniteSetMaps(["a", "b"], [3, 4, 5])
- sage: f = from_list(F.element_class, F, [0,2]); f.check(); f
- map: a -> 3, b -> 5
- sage: f.parent() is F
- True
- sage: f.is_immutable()
- True
- """
- cdef FiniteSetMap_MN res
- cdef type cls = <type>t
- res = cls.__new__(cls)
- super(FiniteSetMap_MN, res).__init__(parent, lst)
- return res
-
-cpdef FiniteSetMap_Set FiniteSetMap_Set_from_dict(t, parent, d):
- """
- Creates a ``FiniteSetMap`` from a dictionary
-
- .. warning:: no check is performed !
-
- TESTS::
-
- sage: from sage.sets.finite_set_map_cy import FiniteSetMap_Set_from_dict as from_dict
- sage: F = FiniteSetMaps(["a", "b"], [3, 4, 5])
- sage: f = from_dict(F.element_class, F, {"a": 3, "b": 5}); f.check(); f
- map: a -> 3, b -> 5
- sage: f.parent() is F
- True
- sage: f.is_immutable()
- True
- """
- cdef FiniteSetMap_Set res
- cdef type cls = <type>t
- res = cls.__new__(cls)
- res.__init__(parent, d.__getitem__)
- return res
-
-
cdef class FiniteSetEndoMap_N(FiniteSetMap_MN):
"""
Maps from ``range(n)`` to itself.