Skip to content

Commit 5602645

Browse files
author
Release Manager
committed
gh-40579: Row rank profile / row pivots: direct extraction from echelon form over prime fields Fixes #40572 - ensure the use of the LUdivine / LQUP strategy with the flag FfpackSlabRecursive - extract row rank profile using FFPACK's `RankProfileFromLU` Concerning the first point, this strategy was already the one used in the single threaded case, since it is the default method in the FFPACK implementation. However it was not the default in the multi threaded case, which means there was actually a bug in Sage when calling `_echelonize_linbox(efd=False)` with 2 or more threads: ``` sage: mat = matrix(GF(3), [[1,0,1,0],[1,0,0,0],[1,0,0,0],[0,1,0,0]]) sage: mat.echelon_form() [1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 0 0] sage: Parallelism().set("linbox", nproc=2) sage: mat = matrix(GF(3), [[1,0,1,0],[1,0,0,0],[1,0,0,0],[0,1,0,0]]) sage: mat.echelon_form() [1 0 0 0] [0 0 1 0] [0 1 0 0] [0 0 0 0] ``` (the latter does not meet Sage's requirements of the reduced row echelon form) Some more complete tests concerning the row rank profile are to be done before merging. URL: #40579 Reported by: Vincent Neiger Reviewer(s): Vincent Neiger, Xavier Caruso
2 parents 3939fbf + 0dfb949 commit 5602645

File tree

3 files changed

+258
-22
lines changed

3 files changed

+258
-22
lines changed

src/sage/libs/linbox/fflas.pxd

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFLAS":
2929
FflasTrans
3030

3131
ctypedef enum FFLAS_SIDE:
32+
FflasLeft
3233
FflasRight
3334

3435
# double
@@ -80,6 +81,16 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFLAS":
8081
size_t C_stride, size_t numthreads)
8182

8283
cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK":
84+
ctypedef enum FFPACK_LU_TAG:
85+
FfpackTileRecursive
86+
87+
void RankProfileFromLU (size_t* P, size_t N, size_t R,
88+
size_t* rkprofile, FFPACK_LU_TAG LuTag)
89+
90+
void PLUQtoEchelonPermutation (size_t N, size_t R, size_t * P, size_t * outPerm)
91+
92+
void MathPerm2LAPACKPerm (size_t * LapackP, size_t * MathP, size_t N)
93+
8394
# double
8495
bint IsSingular (Modular_double F,
8596
size_t nrows, size_t ncols, Modular_double.Element* A,
@@ -104,11 +115,14 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK":
104115

105116
size_t ReducedRowEchelonForm (Modular_double F, size_t a, size_t b,
106117
Modular_double.Element* matrix,
107-
size_t s, size_t* P, size_t* Q)
118+
size_t s, size_t* P, size_t* Q,
119+
bool transform, FFPACK_LU_TAG LuTag)
108120

109121
size_t pReducedRowEchelonForm (Modular_double F, size_t a, size_t b,
110122
Modular_double.Element* matrix,
111-
size_t s, size_t* P, size_t* Q, bool transform, size_t numthreads)
123+
size_t s, size_t* P, size_t* Q,
124+
bool transform, size_t numthreads,
125+
FFPACK_LU_TAG LuTag)
112126

113127
Modular_double.Element* Solve (Modular_double F, size_t M,
114128
Modular_double.Element* A, size_t lda,
@@ -158,11 +172,14 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK":
158172

159173
size_t ReducedRowEchelonForm (Modular_float F, size_t a, size_t b,
160174
Modular_float.Element* matrix,
161-
size_t s, size_t* P, size_t* Q)
175+
size_t s, size_t* P, size_t* Q,
176+
bool transform, FFPACK_LU_TAG LuTag)
162177

163178
size_t pReducedRowEchelonForm (Modular_float F, size_t a, size_t b,
164179
Modular_float.Element* matrix,
165-
size_t s, size_t* P, size_t* Q, bool transform, size_t numthreads)
180+
size_t s, size_t* P, size_t* Q,
181+
bool transform, size_t numthreads,
182+
FFPACK_LU_TAG LuTag)
166183

167184
Modular_float.Element* Solve (Modular_float F, size_t M,
168185
Modular_float.Element* A, size_t lda,

src/sage/matrix/matrix2.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8649,6 +8649,7 @@ cdef class Matrix(Matrix1):
86498649
if v is not None:
86508650
self.cache('echelon_transformation', v)
86518651
self.cache('pivots', E.pivots())
8652+
86528653
if transformation and v is not None:
86538654
return (E, v)
86548655
else:

0 commit comments

Comments
 (0)