passagemath-linbox 10.6.43__cp313-cp313-macosx_13_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_linbox/.dylibs/libfflas.1.dylib +0 -0
- passagemath_linbox/.dylibs/libffpack.1.dylib +0 -0
- passagemath_linbox/.dylibs/libflint.22.0.dylib +0 -0
- passagemath_linbox/.dylibs/libgd.3.dylib +0 -0
- passagemath_linbox/.dylibs/libgfortran.5.dylib +0 -0
- passagemath_linbox/.dylibs/libgivaro.9.dylib +0 -0
- passagemath_linbox/.dylibs/libgmp.10.dylib +0 -0
- passagemath_linbox/.dylibs/libgmpxx.4.dylib +0 -0
- passagemath_linbox/.dylibs/libiml.0.dylib +0 -0
- passagemath_linbox/.dylibs/liblinbox.0.dylib +0 -0
- passagemath_linbox/.dylibs/libm4ri.1.dylib +0 -0
- passagemath_linbox/.dylibs/libm4rie.1.dylib +0 -0
- passagemath_linbox/.dylibs/libmpfr.6.dylib +0 -0
- passagemath_linbox/.dylibs/libopenblasp-r0.3.29.dylib +0 -0
- passagemath_linbox/.dylibs/libpng16.16.dylib +0 -0
- passagemath_linbox/.dylibs/libquadmath.0.dylib +0 -0
- passagemath_linbox/.dylibs/libz.1.3.1.dylib +0 -0
- passagemath_linbox/__init__.py +3 -0
- passagemath_linbox-10.6.43.dist-info/METADATA +100 -0
- passagemath_linbox-10.6.43.dist-info/RECORD +75 -0
- passagemath_linbox-10.6.43.dist-info/WHEEL +6 -0
- passagemath_linbox-10.6.43.dist-info/top_level.txt +3 -0
- sage/all__sagemath_linbox.py +2 -0
- sage/geometry/all__sagemath_linbox.py +1 -0
- sage/geometry/integral_points.pxi +1426 -0
- sage/geometry/integral_points_integer_dense.cpython-313-darwin.so +0 -0
- sage/geometry/integral_points_integer_dense.pyx +7 -0
- sage/libs/all__sagemath_linbox.py +1 -0
- sage/libs/iml.pxd +10 -0
- sage/libs/linbox/__init__.py +1 -0
- sage/libs/linbox/conversion.pxd +185 -0
- sage/libs/linbox/fflas.pxd +189 -0
- sage/libs/linbox/givaro.pxd +109 -0
- sage/libs/linbox/linbox.pxd +219 -0
- sage/libs/linbox/linbox_flint_interface.cpython-313-darwin.so +0 -0
- sage/libs/linbox/linbox_flint_interface.pxd +18 -0
- sage/libs/linbox/linbox_flint_interface.pyx +192 -0
- sage/libs/m4ri.pxd +198 -0
- sage/libs/m4rie.pxd +204 -0
- sage/matrix/all__sagemath_linbox.py +1 -0
- sage/matrix/matrix_cyclo_linbox.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_cyclo_linbox.pyx +361 -0
- sage/matrix/matrix_gf2e_dense.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_gf2e_dense.pxd +15 -0
- sage/matrix/matrix_gf2e_dense.pyx +1573 -0
- sage/matrix/matrix_integer_iml.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_integer_iml.pyx +316 -0
- sage/matrix/matrix_integer_linbox.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_integer_linbox.pxd +5 -0
- sage/matrix/matrix_integer_linbox.pyx +358 -0
- sage/matrix/matrix_integer_sparse_linbox.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_integer_sparse_linbox.pyx +465 -0
- sage/matrix/matrix_mod2_dense.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_mod2_dense.pxd +14 -0
- sage/matrix/matrix_mod2_dense.pyx +2789 -0
- sage/matrix/matrix_modn_dense_double.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_modn_dense_double.pyx +179 -0
- sage/matrix/matrix_modn_dense_float.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_modn_dense_float.pyx +154 -0
- sage/matrix/matrix_modn_sparse.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_modn_sparse.pyx +871 -0
- sage/matrix/matrix_rational_linbox.cpython-313-darwin.so +0 -0
- sage/matrix/matrix_rational_linbox.pyx +36 -0
- sage/matrix/misc.cpython-313-darwin.so +0 -0
- sage/matrix/misc.pyx +418 -0
- sage/modules/all__sagemath_linbox.py +1 -0
- sage/modules/numpy_util.cpython-313-darwin.so +0 -0
- sage/modules/numpy_util.pxd +10 -0
- sage/modules/numpy_util.pyx +136 -0
- sage/modules/vector_mod2_dense.cpython-313-darwin.so +0 -0
- sage/modules/vector_mod2_dense.pxd +11 -0
- sage/modules/vector_mod2_dense.pyx +547 -0
- sage/rings/all__sagemath_linbox.py +1 -0
- sage/rings/finite_rings/all__sagemath_linbox.py +1 -0
- sage/rings/polynomial/all__sagemath_linbox.py +1 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-linbox
|
|
2
|
+
# distutils: extra_compile_args = LINBOX_CFLAGS -std=gnu++14
|
|
3
|
+
# distutils: include_dirs = LINBOX_INCDIR
|
|
4
|
+
# distutils: libraries = LINBOX_LIBRARIES
|
|
5
|
+
# distutils: library_dirs = LINBOX_LIBDIR
|
|
6
|
+
# distutils: extra_link_args = LINBOX_LIBEXTRA
|
|
7
|
+
# distutils: language = c++
|
|
8
|
+
|
|
9
|
+
from libc.stdint cimport uint32_t, uint64_t
|
|
10
|
+
from libcpp.vector cimport vector as cppvector
|
|
11
|
+
|
|
12
|
+
from sage.libs.linbox.givaro cimport *
|
|
13
|
+
|
|
14
|
+
cdef extern from "linbox/matrix/dense-matrix.h":
|
|
15
|
+
## template <class _Field, class _blasRep=typename Vector<_Field>::Dense >
|
|
16
|
+
## class DenseMatrix ;
|
|
17
|
+
##
|
|
18
|
+
## template <class _Field>
|
|
19
|
+
## using DenseMatrix = DenseMatrix<_Field> ;
|
|
20
|
+
cdef cppclass DenseMatrix_integer "LinBox::DenseMatrix<Givaro::ZRing<Givaro::Integer>>":
|
|
21
|
+
ctypedef ZRing Field
|
|
22
|
+
ctypedef Integer Element
|
|
23
|
+
DenseMatrix_integer(Field &F, size_t m, size_t n)
|
|
24
|
+
size_t rowdim()
|
|
25
|
+
size_t coldim()
|
|
26
|
+
void setEntry(size_t i, size_t j, Element &a)
|
|
27
|
+
Element &getEntry(size_t i, size_t j)
|
|
28
|
+
Field& field()
|
|
29
|
+
|
|
30
|
+
ostream& write(ostream&)
|
|
31
|
+
|
|
32
|
+
cdef cppclass DenseMatrix_Modular_double "LinBox::DenseMatrix<Givaro::Modular<double>>":
|
|
33
|
+
ctypedef Modular_double Field
|
|
34
|
+
ctypedef double Element
|
|
35
|
+
DenseMatrix_Modular_double(Field F, size_t m, size_t n)
|
|
36
|
+
void setEntry(size_t i, size_t j, Element& a)
|
|
37
|
+
Element &getEntry(size_t i, size_t j)
|
|
38
|
+
|
|
39
|
+
ostream& write(ostream&)
|
|
40
|
+
|
|
41
|
+
cdef cppclass DenseMatrix_Modular_float "LinBox::DenseMatrix<Givaro::Modular<float>>":
|
|
42
|
+
ctypedef Modular_float Field
|
|
43
|
+
ctypedef float Element
|
|
44
|
+
DenseMatrix_Modular_float(Field F, size_t m, size_t n)
|
|
45
|
+
void setEntry(size_t i, size_t j, Element& a)
|
|
46
|
+
Element &getEntry(size_t i, size_t j)
|
|
47
|
+
|
|
48
|
+
ostream& write(ostream&)
|
|
49
|
+
|
|
50
|
+
cdef extern from "linbox/matrix/sparse-matrix.h":
|
|
51
|
+
## template<class _Field, class _Storage = SparseMatrixFormat::SparseSeq >
|
|
52
|
+
## class SparseMatrix ;
|
|
53
|
+
cdef cppclass SparseMatrix_integer "LinBox::SparseMatrix<Givaro::ZRing<Givaro::Integer>>":
|
|
54
|
+
ctypedef ZRing Field
|
|
55
|
+
ctypedef Integer Element
|
|
56
|
+
SparseMatrix_integer(Field &F, size_t m, size_t n)
|
|
57
|
+
size_t rowdim()
|
|
58
|
+
size_t coldim()
|
|
59
|
+
void setEntry(size_t i, size_t j, Element &a)
|
|
60
|
+
Element &getEntry(size_t i, size_t j)
|
|
61
|
+
Field& field()
|
|
62
|
+
|
|
63
|
+
ostream& write(ostream&)
|
|
64
|
+
|
|
65
|
+
cdef cppclass SparseMatrix_Modular_uint64 "LinBox::SparseMatrix<Givaro::Modular<uint64_t>, LinBox::SparseMatrixFormat::SparseSeq>":
|
|
66
|
+
ctypedef Modular_uint64 Field
|
|
67
|
+
ctypedef uint64_t Element
|
|
68
|
+
SparseMatrix_Modular_uint64(Field &F, size_t m, size_t n)
|
|
69
|
+
SparseMatrix_Modular_uint64(SparseMatrix_Modular_uint64&)
|
|
70
|
+
size_t rowdim()
|
|
71
|
+
size_t coldim()
|
|
72
|
+
void setEntry(size_t i, size_t j, Element &a)
|
|
73
|
+
Element &getEntry(size_t i, size_t j)
|
|
74
|
+
Field& field()
|
|
75
|
+
|
|
76
|
+
ostream& write(ostream&)
|
|
77
|
+
|
|
78
|
+
cdef extern from "linbox/polynomial/dense-polynomial.h":
|
|
79
|
+
## template<class Field>
|
|
80
|
+
## class DensePolynomial : public Givaro::Poly1FactorDom<Field, Givaro::Dense>::Element
|
|
81
|
+
cdef cppclass DensePolynomial_integer "LinBox::DensePolynomial<Givaro::ZRing<Givaro::Integer>>":
|
|
82
|
+
ctypedef ZRing BaseRing
|
|
83
|
+
ctypedef Integer BaseRingElement
|
|
84
|
+
DensePolynomial_integer(BaseRing &F)
|
|
85
|
+
DensePolynomial_integer(BaseRing &F, size_t s)
|
|
86
|
+
BaseRingElement& operator[](size_t i)
|
|
87
|
+
size_t size()
|
|
88
|
+
|
|
89
|
+
cdef extern from "linbox/ring/polynomial-ring.h":
|
|
90
|
+
## template <class BaseRing, class StorageTag= Givaro::Dense>
|
|
91
|
+
## class PolynomialRing : public Givaro::Poly1FactorDom<BaseRing,StorageTag>
|
|
92
|
+
cdef cppclass PolynomialRing_integer "LinBox::PolynomialRing<Givaro::ZRing<Givaro::Integer>, Givaro::Dense>":
|
|
93
|
+
ctypedef DensePolynomial_integer Element
|
|
94
|
+
ctypedef DensePolynomial_integer Polynomial
|
|
95
|
+
|
|
96
|
+
cdef extern from "linbox/vector/vector.h":
|
|
97
|
+
cdef cppclass DenseVector_integer "LinBox::DenseVector<Givaro::ZRing<Givaro::Integer>>":
|
|
98
|
+
ctypedef ZRing Field
|
|
99
|
+
ctypedef Integer Element
|
|
100
|
+
DenseVector_integer (Field &F)
|
|
101
|
+
DenseVector_integer (Field &F, long& m)
|
|
102
|
+
DenseVector_integer (Field &F, cppvector[Integer]&)
|
|
103
|
+
size_t size()
|
|
104
|
+
void resize(size_t)
|
|
105
|
+
void resize(size_t n, const Element&)
|
|
106
|
+
void push_back(Element&)
|
|
107
|
+
void clear()
|
|
108
|
+
void reserve(const size_t&)
|
|
109
|
+
void setEntry(size_t i, Element&)
|
|
110
|
+
Element& getEntry(size_t i)
|
|
111
|
+
|
|
112
|
+
cdef extern from "linbox/matrix/matrix-domain.h":
|
|
113
|
+
## template <class Field_ >
|
|
114
|
+
## class MatrixDomain : public MVProductDomain<Field_> {
|
|
115
|
+
cdef cppclass MatrixDomain_integer "LinBox::MatrixDomain<Givaro::ZRing<Givaro::Integer>>":
|
|
116
|
+
MatrixDomain_integer(ZRing&)
|
|
117
|
+
DenseMatrix_integer& mul(DenseMatrix_integer ans,
|
|
118
|
+
DenseMatrix_integer left,
|
|
119
|
+
DenseMatrix_integer right)
|
|
120
|
+
|
|
121
|
+
cdef extern from "linbox/solutions/methods.h" namespace "LinBox":
|
|
122
|
+
cdef struct HybridSpecifier:
|
|
123
|
+
pass
|
|
124
|
+
cdef struct BlackboxSpecifier:
|
|
125
|
+
pass
|
|
126
|
+
cdef struct EliminationSpecifier:
|
|
127
|
+
pass
|
|
128
|
+
cdef struct WiedemannTraits:
|
|
129
|
+
pass
|
|
130
|
+
cdef struct DenseEliminationTraits:
|
|
131
|
+
pass
|
|
132
|
+
cdef struct SparseEliminationTraits:
|
|
133
|
+
pass
|
|
134
|
+
|
|
135
|
+
cdef cppclass Method:
|
|
136
|
+
ctypedef HybridSpecifier Hybrid
|
|
137
|
+
ctypedef BlackboxSpecifier Blackbox
|
|
138
|
+
ctypedef EliminationSpecifier Elimination
|
|
139
|
+
ctypedef WiedemannTraits Wiedemann
|
|
140
|
+
ctypedef DenseEliminationTraits DenseElimination
|
|
141
|
+
ctypedef SparseEliminationTraits SparseElimination
|
|
142
|
+
|
|
143
|
+
cdef extern from "linbox/solutions/charpoly.h" namespace "LinBox":
|
|
144
|
+
PolynomialRing_integer.Element& charpoly (PolynomialRing_integer.Element&, DenseMatrix_integer&)
|
|
145
|
+
PolynomialRing_integer.Element& charpoly (PolynomialRing_integer.Element&, SparseMatrix_integer&)
|
|
146
|
+
|
|
147
|
+
cdef extern from "linbox/solutions/minpoly.h" namespace "LinBox":
|
|
148
|
+
PolynomialRing_integer.Element& minpoly (PolynomialRing_integer.Element&, DenseMatrix_integer&)
|
|
149
|
+
PolynomialRing_integer.Element& minpoly (PolynomialRing_integer.Element&, SparseMatrix_integer&)
|
|
150
|
+
|
|
151
|
+
cdef extern from "linbox/algorithms/gauss.h":
|
|
152
|
+
cdef cppclass GaussDomain_Modular_uint64 "LinBox::GaussDomain<Givaro::Modular<uint64_t>>":
|
|
153
|
+
ctypedef Modular_uint64 Field
|
|
154
|
+
ctypedef uint64_t Element
|
|
155
|
+
GaussDomain_Modular_uint64(Field &)
|
|
156
|
+
unsigned long& InPlaceLinearPivoting(unsigned long &rank,
|
|
157
|
+
Element& determinant,
|
|
158
|
+
SparseMatrix_Modular_uint64 &A,
|
|
159
|
+
unsigned long Ni,
|
|
160
|
+
unsigned long Nj)
|
|
161
|
+
|
|
162
|
+
cdef extern from "linbox/solutions/echelon.h" namespace "LinBox":
|
|
163
|
+
size_t rowEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&)
|
|
164
|
+
size_t rowEchelonize (DenseMatrix_Modular_float&)
|
|
165
|
+
size_t reducedRowEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&)
|
|
166
|
+
size_t reducedRowEchelonize (DenseMatrix_Modular_float&)
|
|
167
|
+
size_t colEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&)
|
|
168
|
+
size_t colEchelonize (DenseMatrix_Modular_float&)
|
|
169
|
+
size_t reducedColEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&)
|
|
170
|
+
size_t reducedColEchelonize (DenseMatrix_Modular_float&)
|
|
171
|
+
|
|
172
|
+
size_t rowEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&)
|
|
173
|
+
size_t rowEchelonize (DenseMatrix_Modular_double&)
|
|
174
|
+
size_t reducedRowEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&)
|
|
175
|
+
size_t reducedRowEchelonize (DenseMatrix_Modular_double&)
|
|
176
|
+
size_t colEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&)
|
|
177
|
+
size_t colEchelonize (DenseMatrix_Modular_double&)
|
|
178
|
+
size_t reducedColEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&)
|
|
179
|
+
size_t reducedColEchelonize (DenseMatrix_Modular_double&)
|
|
180
|
+
|
|
181
|
+
cdef extern from "linbox/solutions/rank.h" namespace "LinBox":
|
|
182
|
+
unsigned long & rank (unsigned long&, DenseMatrix_integer)
|
|
183
|
+
unsigned long & rank (unsigned long&, SparseMatrix_integer)
|
|
184
|
+
|
|
185
|
+
cdef extern from "linbox/solutions/det.h" namespace "LinBox":
|
|
186
|
+
Integer& det (Integer&, DenseMatrix_integer)
|
|
187
|
+
Integer& det (Integer&, SparseMatrix_integer)
|
|
188
|
+
|
|
189
|
+
cdef extern from "linbox/solutions/solve.h" namespace "LinBox":
|
|
190
|
+
# integer solve
|
|
191
|
+
|
|
192
|
+
DenseVector_integer& solve (DenseVector_integer &,
|
|
193
|
+
Integer &,
|
|
194
|
+
SparseMatrix_integer &,
|
|
195
|
+
DenseVector_integer &,
|
|
196
|
+
Method.DenseElimination) except +
|
|
197
|
+
|
|
198
|
+
DenseVector_integer& solve (DenseVector_integer &,
|
|
199
|
+
Integer &,
|
|
200
|
+
SparseMatrix_integer &,
|
|
201
|
+
DenseVector_integer &,
|
|
202
|
+
Method.SparseElimination) except +
|
|
203
|
+
|
|
204
|
+
DenseVector_integer& solve (DenseVector_integer &,
|
|
205
|
+
Integer &,
|
|
206
|
+
SparseMatrix_integer &,
|
|
207
|
+
DenseVector_integer &,
|
|
208
|
+
Method.Blackbox) except +
|
|
209
|
+
|
|
210
|
+
DenseVector_integer& solve (DenseVector_integer &,
|
|
211
|
+
Integer &,
|
|
212
|
+
SparseMatrix_integer &,
|
|
213
|
+
DenseVector_integer &,
|
|
214
|
+
Method.Wiedemann) except +
|
|
215
|
+
|
|
216
|
+
DenseVector_integer& solve (DenseVector_integer &,
|
|
217
|
+
Integer &,
|
|
218
|
+
SparseMatrix_integer &,
|
|
219
|
+
DenseVector_integer &)
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-linbox
|
|
2
|
+
|
|
3
|
+
from sage.libs.flint.types cimport fmpz_t, fmpz_mat_t, fmpz_poly_t
|
|
4
|
+
|
|
5
|
+
# set C <- A * B
|
|
6
|
+
cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B) noexcept
|
|
7
|
+
|
|
8
|
+
# set cp to the characteristic polynomial of A
|
|
9
|
+
cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A) noexcept
|
|
10
|
+
|
|
11
|
+
# set mp to the minimal polynomial of A
|
|
12
|
+
cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A) noexcept
|
|
13
|
+
|
|
14
|
+
# return the rank of A
|
|
15
|
+
cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A) noexcept
|
|
16
|
+
|
|
17
|
+
# set det to the determinant of A
|
|
18
|
+
cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A) noexcept
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-linbox
|
|
2
|
+
# distutils: libraries = LINBOX_LIBRARIES
|
|
3
|
+
# distutils: library_dirs = LINBOX_LIBDIR
|
|
4
|
+
# distutils: extra_link_args = LINBOX_LIBEXTRA
|
|
5
|
+
r"""
|
|
6
|
+
Interface between flint matrices and linbox
|
|
7
|
+
|
|
8
|
+
This module only contains C++ code (and the interface is fully C
|
|
9
|
+
compatible). It basically contains what used to be in the LinBox
|
|
10
|
+
source code under interfaces/sage/linbox-sage.C written by M. Albrecht
|
|
11
|
+
and C. Pernet. The functions available are:
|
|
12
|
+
|
|
13
|
+
- ``void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B)``: set
|
|
14
|
+
``C`` to be the result of the multiplication ``A * B``
|
|
15
|
+
|
|
16
|
+
- ``void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A)``: set ``cp``
|
|
17
|
+
to be the characteristic polynomial of the square matrix ``A``
|
|
18
|
+
|
|
19
|
+
- ``void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A)``: set ``mp``
|
|
20
|
+
to be the minimal polynomial of the square matrix ``A``
|
|
21
|
+
|
|
22
|
+
- ``size_t linbox_fmpz_mat_rank(fmpz_mat_t A)``: return the rank of the
|
|
23
|
+
matrix ``A``
|
|
24
|
+
|
|
25
|
+
- ``void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A)``: set ``det`` to the
|
|
26
|
+
determinant of the square matrix ``A``
|
|
27
|
+
"""
|
|
28
|
+
# ****************************************************************************
|
|
29
|
+
# Copyright (C) 2007 Martin Albrecht
|
|
30
|
+
# Copyright (C) 2008 Clement Pernet
|
|
31
|
+
# Copyright (C) 2017-2018 Vincent Delecroix
|
|
32
|
+
#
|
|
33
|
+
# This program is free software: you can redistribute it and/or modify
|
|
34
|
+
# it under the terms of the GNU General Public License as published by
|
|
35
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
36
|
+
# (at your option) any later version.
|
|
37
|
+
# https://www.gnu.org/licenses/
|
|
38
|
+
# ****************************************************************************
|
|
39
|
+
|
|
40
|
+
from sage.libs.gmp.types cimport mpz_t
|
|
41
|
+
from sage.libs.flint.types cimport fmpz_t
|
|
42
|
+
from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
|
|
43
|
+
from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
|
|
44
|
+
from sage.libs.flint.fmpz_poly cimport fmpz_poly_fit_length, _fmpz_poly_set_length
|
|
45
|
+
from sage.libs.flint.fmpz_poly_sage cimport fmpz_poly_set_coeff_mpz
|
|
46
|
+
|
|
47
|
+
cimport sage.libs.linbox.givaro as givaro
|
|
48
|
+
cimport sage.libs.linbox.linbox as linbox
|
|
49
|
+
from sage.libs.linbox.linbox cimport PolynomialRing_integer
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
cdef void fmpz_mat_get_linbox(linbox.DenseMatrix_integer& A, fmpz_mat_t m) noexcept:
|
|
53
|
+
r"""
|
|
54
|
+
Set the entries of A from m (no allocation performed).
|
|
55
|
+
|
|
56
|
+
NOTE: this function does not appear in the Cython header
|
|
57
|
+
(the .pxd file) in order to keep the header C-compatible
|
|
58
|
+
"""
|
|
59
|
+
cdef size_t i,j
|
|
60
|
+
cdef givaro.Integer t
|
|
61
|
+
|
|
62
|
+
for i in range(fmpz_mat_nrows(m)):
|
|
63
|
+
for j in range(fmpz_mat_ncols(m)):
|
|
64
|
+
fmpz_get_mpz(t.get_mpz(), fmpz_mat_entry(m, i, j))
|
|
65
|
+
A.setEntry(i, j, t)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
cdef void fmpz_mat_set_linbox(fmpz_mat_t m, linbox.DenseMatrix_integer& A) noexcept:
|
|
69
|
+
r"""
|
|
70
|
+
Set the entries of m from A (no allocation performed).
|
|
71
|
+
|
|
72
|
+
NOTE: this function does not appear in the Cython header
|
|
73
|
+
(the .pxd file) in order to keep the header C-compatible
|
|
74
|
+
"""
|
|
75
|
+
cdef size_t i,j
|
|
76
|
+
for i in range(A.rowdim()):
|
|
77
|
+
for j in range(A.coldim()):
|
|
78
|
+
fmpz_set_mpz(fmpz_mat_entry(m, i, j), A.getEntry(i, j).get_mpz_const())
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q) noexcept:
|
|
82
|
+
r"""
|
|
83
|
+
Set the entries of the polynomial p from q (no allocation performed).
|
|
84
|
+
|
|
85
|
+
NOTE: this function does not appear in the Cython header
|
|
86
|
+
(the .pxd file) in order to keep the header C-compatible
|
|
87
|
+
"""
|
|
88
|
+
cdef size_t i
|
|
89
|
+
cdef mpz_t tmp
|
|
90
|
+
|
|
91
|
+
fmpz_poly_fit_length(p, q.size())
|
|
92
|
+
|
|
93
|
+
for i in range(q.size()):
|
|
94
|
+
tmp = q[i].get_mpz_const()
|
|
95
|
+
fmpz_poly_set_coeff_mpz(p, i, tmp)
|
|
96
|
+
|
|
97
|
+
_fmpz_poly_set_length(p, q.size())
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B) noexcept:
|
|
101
|
+
r"""
|
|
102
|
+
Set C to be A * B.
|
|
103
|
+
"""
|
|
104
|
+
cdef givaro.ZRing ZZ
|
|
105
|
+
cdef linbox.DenseMatrix_integer *LBA
|
|
106
|
+
cdef linbox.DenseMatrix_integer *LBB
|
|
107
|
+
cdef linbox.DenseMatrix_integer *LBC
|
|
108
|
+
cdef linbox.MatrixDomain_integer * MD
|
|
109
|
+
|
|
110
|
+
LBA = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
|
|
111
|
+
fmpz_mat_get_linbox(LBA[0], A)
|
|
112
|
+
|
|
113
|
+
LBB = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(B), fmpz_mat_ncols(B))
|
|
114
|
+
fmpz_mat_get_linbox(LBB[0], B)
|
|
115
|
+
|
|
116
|
+
LBC = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(B))
|
|
117
|
+
|
|
118
|
+
MD = new linbox.MatrixDomain_integer(ZZ)
|
|
119
|
+
MD.mul(LBC[0], LBA[0], LBB[0])
|
|
120
|
+
|
|
121
|
+
del MD
|
|
122
|
+
|
|
123
|
+
fmpz_mat_set_linbox(C, LBC[0])
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A) noexcept:
|
|
127
|
+
r"""
|
|
128
|
+
Set cp to the characteristic polynomial of A.
|
|
129
|
+
"""
|
|
130
|
+
cdef givaro.ZRing ZZ
|
|
131
|
+
cdef linbox.DenseMatrix_integer * LBA
|
|
132
|
+
cdef linbox.DensePolynomial_integer * m_A
|
|
133
|
+
|
|
134
|
+
LBA = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
|
|
135
|
+
fmpz_mat_get_linbox(LBA[0], A)
|
|
136
|
+
m_A = new linbox.DensePolynomial_integer(ZZ, fmpz_mat_nrows(A))
|
|
137
|
+
linbox.charpoly(m_A[0], LBA[0])
|
|
138
|
+
fmpz_poly_set_linbox(cp, m_A[0])
|
|
139
|
+
|
|
140
|
+
del LBA
|
|
141
|
+
del m_A
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A) noexcept:
|
|
145
|
+
r"""
|
|
146
|
+
Set mp to the minimal polynomial of A.
|
|
147
|
+
"""
|
|
148
|
+
cdef givaro.ZRing ZZ
|
|
149
|
+
cdef linbox.DenseMatrix_integer * LBA
|
|
150
|
+
cdef linbox.DensePolynomial_integer * m_A
|
|
151
|
+
|
|
152
|
+
LBA = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
|
|
153
|
+
m_A = new linbox.DensePolynomial_integer(ZZ)
|
|
154
|
+
fmpz_mat_get_linbox(LBA[0], A)
|
|
155
|
+
linbox.minpoly(m_A[0], LBA[0])
|
|
156
|
+
fmpz_poly_set_linbox(mp, m_A[0])
|
|
157
|
+
|
|
158
|
+
del LBA
|
|
159
|
+
del m_A
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
cdef size_t linbox_fmpz_mat_rank(fmpz_mat_t A) noexcept:
|
|
163
|
+
r"""
|
|
164
|
+
Return the rank of A
|
|
165
|
+
"""
|
|
166
|
+
cdef givaro.ZRing ZZ
|
|
167
|
+
cdef linbox.DenseMatrix_integer * LBA
|
|
168
|
+
cdef size_t r = 0
|
|
169
|
+
|
|
170
|
+
LBA = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
|
|
171
|
+
fmpz_mat_get_linbox(LBA[0], A)
|
|
172
|
+
linbox.rank(r, LBA[0])
|
|
173
|
+
|
|
174
|
+
del LBA
|
|
175
|
+
|
|
176
|
+
return r
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
cdef void linbox_fmpz_mat_det(fmpz_t det, fmpz_mat_t A) noexcept:
|
|
180
|
+
r"""
|
|
181
|
+
Set det to the determinant of A.
|
|
182
|
+
"""
|
|
183
|
+
cdef givaro.ZRing ZZ
|
|
184
|
+
cdef linbox.DenseMatrix_integer * LBA
|
|
185
|
+
cdef givaro.Integer d
|
|
186
|
+
|
|
187
|
+
LBA = new linbox.DenseMatrix_integer(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
|
|
188
|
+
fmpz_mat_get_linbox(LBA[0], A)
|
|
189
|
+
linbox.det(d, LBA[0])
|
|
190
|
+
fmpz_set_mpz(det, d.get_mpz_const())
|
|
191
|
+
|
|
192
|
+
del LBA
|
sage/libs/m4ri.pxd
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-linbox
|
|
2
|
+
# distutils: extra_compile_args = -std=c++14
|
|
3
|
+
# distutils: language = c++
|
|
4
|
+
|
|
5
|
+
cdef extern from "m4ri/m4ri.h":
|
|
6
|
+
ctypedef int rci_t
|
|
7
|
+
ctypedef int wi_t
|
|
8
|
+
ctypedef unsigned long long m4ri_word "word"
|
|
9
|
+
ctypedef int BIT
|
|
10
|
+
|
|
11
|
+
ctypedef struct mzd_t:
|
|
12
|
+
rci_t nrows
|
|
13
|
+
rci_t ncols
|
|
14
|
+
wi_t width
|
|
15
|
+
|
|
16
|
+
ctypedef struct mzp_t:
|
|
17
|
+
rci_t *values
|
|
18
|
+
rci_t size
|
|
19
|
+
|
|
20
|
+
cdef int m4ri_radix
|
|
21
|
+
|
|
22
|
+
##############
|
|
23
|
+
# Maintenance
|
|
24
|
+
##############
|
|
25
|
+
|
|
26
|
+
# builds all gray codes up to a certain size
|
|
27
|
+
cdef void m4ri_build_all_codes()
|
|
28
|
+
cdef void m4ri_destroy_all_codes()
|
|
29
|
+
|
|
30
|
+
##############
|
|
31
|
+
# Constructors
|
|
32
|
+
##############
|
|
33
|
+
|
|
34
|
+
# create empty matrix
|
|
35
|
+
cdef mzd_t *mzd_init(rci_t , rci_t)
|
|
36
|
+
|
|
37
|
+
# create the identity permutation
|
|
38
|
+
cdef mzp_t *mzp_init(rci_t)
|
|
39
|
+
|
|
40
|
+
# free memory for the matrix
|
|
41
|
+
cdef void mzd_free(mzd_t *)
|
|
42
|
+
|
|
43
|
+
# free memory for the permutation
|
|
44
|
+
cdef void mzp_free(mzp_t *)
|
|
45
|
+
|
|
46
|
+
# filled uniformly random
|
|
47
|
+
cdef void mzd_randomize(mzd_t *)
|
|
48
|
+
|
|
49
|
+
# identity matrix if i%2
|
|
50
|
+
cdef void mzd_set_ui(mzd_t *, unsigned int )
|
|
51
|
+
|
|
52
|
+
# [A],[B] -> [AB]
|
|
53
|
+
cdef mzd_t *mzd_concat(mzd_t *, mzd_t *, mzd_t *)
|
|
54
|
+
|
|
55
|
+
# [A],[B] -> | A |
|
|
56
|
+
# | B |
|
|
57
|
+
cdef mzd_t *mzd_stack(mzd_t *, mzd_t *, mzd_t *)
|
|
58
|
+
|
|
59
|
+
# returns a submatrix from a
|
|
60
|
+
cdef mzd_t *mzd_submatrix(mzd_t *, mzd_t *, rci_t lowr, rci_t lowc, rci_t highr, rci_t highc)
|
|
61
|
+
|
|
62
|
+
# return a matrix window to A
|
|
63
|
+
cdef mzd_t *mzd_init_window(mzd_t *, rci_t lowr, rci_t lowc, rci_t highr, rci_t highc)
|
|
64
|
+
|
|
65
|
+
cdef void mzd_free_window(mzd_t *)
|
|
66
|
+
|
|
67
|
+
# deep copy
|
|
68
|
+
cdef mzd_t *mzd_copy(mzd_t *, mzd_t *)
|
|
69
|
+
|
|
70
|
+
# printing
|
|
71
|
+
cdef void mzd_print(mzd_t *)
|
|
72
|
+
|
|
73
|
+
##############
|
|
74
|
+
# Bit Level IO
|
|
75
|
+
##############
|
|
76
|
+
|
|
77
|
+
# set BIT
|
|
78
|
+
cdef void mzd_write_bit( mzd_t *m, rci_t row, rci_t col, BIT value)
|
|
79
|
+
|
|
80
|
+
# get BIT
|
|
81
|
+
cdef BIT mzd_read_bit( mzd_t *m, rci_t row, rci_t col )
|
|
82
|
+
|
|
83
|
+
# get BITs (n<=64)
|
|
84
|
+
cdef m4ri_word mzd_read_bits( mzd_t *m, rci_t row, rci_t col, int n)
|
|
85
|
+
|
|
86
|
+
#####################
|
|
87
|
+
# Row/Column Based IO
|
|
88
|
+
#####################
|
|
89
|
+
|
|
90
|
+
cdef m4ri_word *mzd_row(mzd_t *, rci_t)
|
|
91
|
+
|
|
92
|
+
cdef void mzd_row_swap(mzd_t *, rci_t, rci_t)
|
|
93
|
+
|
|
94
|
+
cdef void mzd_col_swap(mzd_t *, rci_t, rci_t)
|
|
95
|
+
|
|
96
|
+
cdef void mzd_row_clear_offset(mzd_t *m, rci_t, rci_t)
|
|
97
|
+
|
|
98
|
+
cdef void mzd_row_add_offset(mzd_t *m, rci_t, rci_t, rci_t)
|
|
99
|
+
|
|
100
|
+
############
|
|
101
|
+
# Arithmetic
|
|
102
|
+
############
|
|
103
|
+
|
|
104
|
+
# matrix addition
|
|
105
|
+
cdef mzd_t *mzd_add(mzd_t *, mzd_t *, mzd_t *)
|
|
106
|
+
|
|
107
|
+
# naive cubic matrix multiply
|
|
108
|
+
cdef mzd_t *mzd_mul_naive(mzd_t *, mzd_t *, mzd_t *)
|
|
109
|
+
|
|
110
|
+
# naive cubic matrix multiply (b is pre-transposed)
|
|
111
|
+
cdef mzd_t *_mzd_mul_naive(mzd_t *, mzd_t *, mzd_t *, int)
|
|
112
|
+
|
|
113
|
+
# matrix multiply using Gray codes
|
|
114
|
+
cdef mzd_t *mzd_mul_m4rm(mzd_t *, mzd_t *, mzd_t *, int k)
|
|
115
|
+
|
|
116
|
+
# matrix multiply using Gray codes (transposed)
|
|
117
|
+
cdef mzd_t *mzd_mul_m4rm_t(mzd_t *, mzd_t *, mzd_t *, int k)
|
|
118
|
+
|
|
119
|
+
# matrix multiply and addition using Gray codes: C = C + AB
|
|
120
|
+
cdef mzd_t *mzd_addmul_m4rm(mzd_t *, mzd_t *, mzd_t *, int k)
|
|
121
|
+
|
|
122
|
+
# matrix multiplication via Strassen's formula
|
|
123
|
+
cdef mzd_t *mzd_mul(mzd_t *, mzd_t *, mzd_t *, int cutoff)
|
|
124
|
+
|
|
125
|
+
# C = C + AB via Strassen's formula
|
|
126
|
+
cdef mzd_t *mzd_addmul(mzd_t *, mzd_t *, mzd_t *, int cutoff)
|
|
127
|
+
|
|
128
|
+
# equality testing
|
|
129
|
+
cdef int mzd_equal(mzd_t *, mzd_t *)
|
|
130
|
+
|
|
131
|
+
# returns -1,0,1
|
|
132
|
+
cdef int mzd_cmp(mzd_t *, mzd_t *)
|
|
133
|
+
|
|
134
|
+
# transpose
|
|
135
|
+
cdef mzd_t *mzd_transpose(mzd_t *, mzd_t *)
|
|
136
|
+
|
|
137
|
+
# density with given resolution
|
|
138
|
+
cdef double mzd_density(mzd_t *, int resolution)
|
|
139
|
+
|
|
140
|
+
########################
|
|
141
|
+
# LAPACK Level Functions
|
|
142
|
+
########################
|
|
143
|
+
|
|
144
|
+
# cubic Gaussian elimination
|
|
145
|
+
cdef int mzd_echelonize_naive(mzd_t *, int full)
|
|
146
|
+
|
|
147
|
+
# row echelon form using Gray codes
|
|
148
|
+
cdef int mzd_echelonize_m4ri(mzd_t *m, int full, int k)
|
|
149
|
+
|
|
150
|
+
# reduced row echelon form from upper triangular form
|
|
151
|
+
cdef void mzd_top_echelonize_m4ri(mzd_t *m, int k)
|
|
152
|
+
|
|
153
|
+
# heuristic choice of algorithms
|
|
154
|
+
cdef int mzd_echelonize(mzd_t *m, int full)
|
|
155
|
+
|
|
156
|
+
# matrix inversion using Gray codes
|
|
157
|
+
cdef mzd_t *mzd_inv_m4ri(mzd_t *dst, mzd_t *src, int k)
|
|
158
|
+
|
|
159
|
+
# asymptotically fast PLUQ factorization
|
|
160
|
+
cdef long mzd_pluq(mzd_t *A, mzp_t *P, mzp_t *Q, int cutoff)
|
|
161
|
+
|
|
162
|
+
# PLUQ factorization using Gray codes
|
|
163
|
+
cdef long _mzd_pluq_russian(mzd_t *A, mzp_t *P, mzp_t *Q, int k)
|
|
164
|
+
|
|
165
|
+
# cubic PLUQ factorization
|
|
166
|
+
cdef long _mzd_pluq_naive(mzd_t *A, mzp_t *P, mzp_t *Q)
|
|
167
|
+
|
|
168
|
+
# asymptotically fast PLS factorization
|
|
169
|
+
cdef long mzd_ple(mzd_t *A, mzp_t *P, mzp_t *Q, int cutoff)
|
|
170
|
+
|
|
171
|
+
# PLS factorization using Gray codes
|
|
172
|
+
cdef long _mzd_ple_russian(mzd_t *A, mzp_t *P, mzp_t *Q, int k)
|
|
173
|
+
|
|
174
|
+
# cubic PLS factorization
|
|
175
|
+
cdef long _mzd_ple_naive(mzd_t *A, mzp_t *P, mzp_t *Q)
|
|
176
|
+
|
|
177
|
+
# reduced row echelon form using PLUQ factorization
|
|
178
|
+
cdef long mzd_echelonize_pluq(mzd_t *A, int full)
|
|
179
|
+
|
|
180
|
+
# reduced row echelon form using PLUQ factorization
|
|
181
|
+
cdef mzd_t *mzd_kernel_left_pluq(mzd_t *A, int cutoff)
|
|
182
|
+
|
|
183
|
+
# system solving
|
|
184
|
+
cdef int mzd_solve_left(mzd_t *A, mzd_t *B, int cutoff, int inconsistency_check)
|
|
185
|
+
|
|
186
|
+
########################
|
|
187
|
+
# Bit operations
|
|
188
|
+
########################
|
|
189
|
+
|
|
190
|
+
cdef m4ri_word __M4RI_LEFT_BITMASK(int)
|
|
191
|
+
|
|
192
|
+
cdef m4ri_word m4ri_swap_bits(m4ri_word)
|
|
193
|
+
|
|
194
|
+
##################################
|
|
195
|
+
# Internal Functions for Debugging
|
|
196
|
+
##################################
|
|
197
|
+
|
|
198
|
+
cdef void mzd_clear_bits(mzd_t *m, int x, int y, int n)
|