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