From 6c71f1d8a9abd23dda8774c193fac4c8a70f7763 Mon Sep 17 00:00:00 2001 From: Johannes Schmitt Date: Mon, 12 Feb 2024 17:21:46 +0100 Subject: [PATCH] Switch to the `Solve.*` methods --- Project.toml | 2 +- benchmarks/solve_polynomials.jl | 2 +- docs/src/matrix.md | 23 -------- src/Exports.jl | 9 --- src/HeckeMiscMatrix.jl | 20 +++---- src/arb/ComplexMat.jl | 14 ++--- src/arb/RealMat.jl | 14 ++--- src/arb/acb_mat.jl | 14 ++--- src/arb/arb_mat.jl | 20 +++---- src/flint/fmpq_mat.jl | 18 +++--- src/flint/fmpz_mat.jl | 56 +++++++++--------- src/flint/fmpz_mod_mat.jl | 8 +-- src/flint/fq_default_mat.jl | 18 +++--- src/flint/fq_mat.jl | 18 +++--- src/flint/fq_nmod_mat.jl | 18 +++--- src/flint/gfp_mat.jl | 14 ++--- src/flint/nmod_mat.jl | 20 +++---- test/arb/ComplexMat-test.jl | 24 ++++---- test/arb/RealMat-test.jl | 24 ++++---- test/arb/acb_mat-test.jl | 24 ++++---- test/arb/arb_mat-test.jl | 26 ++++----- test/flint/fmpq_mat-test.jl | 96 +++++++++++++++---------------- test/flint/fmpz_mat-test.jl | 50 ++++++++-------- test/flint/fmpz_mod_mat-test.jl | 18 +++--- test/flint/fq_default_mat-test.jl | 76 ++++++++++++------------ test/flint/fq_mat-test.jl | 76 ++++++++++++------------ test/flint/fq_nmod_mat-test.jl | 76 ++++++++++++------------ test/flint/gfp_mat-test.jl | 82 +++++++++++++------------- test/flint/nmod_mat-test.jl | 20 +++---- test/generic/Matrix-test.jl | 10 ++-- 30 files changed, 429 insertions(+), 461 deletions(-) diff --git a/Project.toml b/Project.toml index 55677019a..a16134a88 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ RandomExtensions = "fb686558-2515-59ef-acaa-46db3789a887" SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" [compat] -AbstractAlgebra = "0.37.6" +AbstractAlgebra = "0.38.1" Antic_jll = "~0.201.500" Arb_jll = "~200.2300.000" Calcium_jll = "~0.401.100" diff --git a/benchmarks/solve_polynomials.jl b/benchmarks/solve_polynomials.jl index eeea34f6a..79b97d129 100644 --- a/benchmarks/solve_polynomials.jl +++ b/benchmarks/solve_polynomials.jl @@ -20,7 +20,7 @@ function benchmark_solve_poly() end end - tt = @elapsed solve_rational(M, b) + tt = @elapsed _solve_rational(M, b) println("$tt") end diff --git a/docs/src/matrix.md b/docs/src/matrix.md index 632f822af..5a8f95d46 100644 --- a/docs/src/matrix.md +++ b/docs/src/matrix.md @@ -128,29 +128,6 @@ c = det_divisor(A) d = det_given_divisor(A, c) ``` -### Linear solving - -```@docs -cansolve(::ZZMatrix, ::ZZMatrix) -``` - -```@docs -solve_dixon(::ZZMatrix, ::ZZMatrix) -solve_dixon(::QQMatrix, ::QQMatrix) -``` - -**Examples** - -```julia -S = matrix_space(ZZ, 3, 3) -T = matrix_space(ZZ, 3, 1) - -A = S([ZZ(2) 3 5; 1 4 7; 9 2 2]) -B = T([ZZ(4), 5, 7]) - -X, m = solve_dixon(A, B) -``` - ### Pseudo inverse ```@docs diff --git a/src/Exports.jl b/src/Exports.jl index 6d2f3e7a2..3b8757412 100644 --- a/src/Exports.jl +++ b/src/Exports.jl @@ -65,8 +65,6 @@ export CalciumField export CalciumFieldElem export CalciumQQBar export canonical_unit -export cansolve -export cansolve_with_nullspace export cdiv export cdivpow2 export cdivrem @@ -587,13 +585,6 @@ export SkewDiagram export snf export snf_diagonal export solve -export solve_cholesky_precomp -export solve_cholesky_precomp! -export solve_dixon -export solve_lu_precomp -export solve_lu_precomp! -export solve_rational -export solve! export sort_terms! export SparsePolynomialRing export sqr_classical diff --git a/src/HeckeMiscMatrix.jl b/src/HeckeMiscMatrix.jl index 4993d6f39..67742a54f 100644 --- a/src/HeckeMiscMatrix.jl +++ b/src/HeckeMiscMatrix.jl @@ -181,24 +181,24 @@ end # ################################################################################ -function right_kernel(x::fpMatrix) +function _right_kernel(x::fpMatrix) z = zero_matrix(base_ring(x), ncols(x), max(nrows(x), ncols(x))) n = ccall((:nmod_mat_nullspace, libflint), Int, (Ref{fpMatrix}, Ref{fpMatrix}), z, x) return n, z end -function left_kernel(x::fpMatrix) - n, M = right_kernel(transpose(x)) +function _left_kernel(x::fpMatrix) + n, M = _right_kernel(transpose(x)) return n, transpose(M) end @doc raw""" - left_kernel(a::ZZMatrix) -> Int, ZZMatrix + _left_kernel(a::ZZMatrix) -> Int, ZZMatrix It returns a tuple $(n, M)$ where $M$ is a matrix whose rows generate the kernel of $a$ and $n$ is the rank of the kernel. """ -function left_kernel(x::ZZMatrix) +function _left_kernel(x::ZZMatrix) if nrows(x) == 0 return 0, zero(x, 0, 0) end @@ -217,12 +217,12 @@ function left_kernel(x::ZZMatrix) end end -function right_kernel(x::ZZMatrix) - n, M = left_kernel(transpose(x)) +function _right_kernel(x::ZZMatrix) + n, M = _left_kernel(transpose(x)) return n, transpose(M) end -function right_kernel(M::zzModMatrix) +function _right_kernel(M::zzModMatrix) R = base_ring(M) if is_prime(modulus(R)) k = zero_matrix(R, ncols(M), ncols(M)) @@ -250,7 +250,7 @@ function right_kernel(M::zzModMatrix) return 0, zero_matrix(R, nrows(M), 0) end -function right_kernel(M::ZZModMatrix) +function _right_kernel(M::ZZModMatrix) R = base_ring(M) N = hcat(transpose(M), identity_matrix(R, ncols(M))) if nrows(N) < ncols(N) @@ -784,7 +784,7 @@ function eigenspace(M::MatElem{T}, lambda::T; side::Symbol = :left) where T <: F for i = 1:ncols(N) N[i, i] -= lambda end - return kernel(N, side = side)[2] + return kernel(N, side = side) end @doc raw""" diff --git a/src/arb/ComplexMat.jl b/src/arb/ComplexMat.jl index 51a592335..0f8a54b74 100644 --- a/src/arb/ComplexMat.jl +++ b/src/arb/ComplexMat.jl @@ -566,7 +566,7 @@ function lu!(P::Generic.Perm, x::ComplexMat) return min(nrows(x), ncols(x)) end -function solve!(z::ComplexMat, x::ComplexMat, y::ComplexMat) +function _solve!(z::ComplexMat, x::ComplexMat, y::ComplexMat) r = ccall((:acb_mat_solve, libarb), Cint, (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), z, x, y, precision(Balls)) @@ -574,15 +574,15 @@ function solve!(z::ComplexMat, x::ComplexMat, y::ComplexMat) nothing end -function solve(x::ComplexMat, y::ComplexMat) +function _solve(x::ComplexMat, y::ComplexMat) ncols(x) != nrows(x) && error("First argument must be square") ncols(x) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve!(z, x, y) + _solve!(z, x, y) return z end -function solve_lu_precomp!(z::ComplexMat, P::Generic.Perm, LU::ComplexMat, y::ComplexMat) +function _solve_lu_precomp!(z::ComplexMat, P::Generic.Perm, LU::ComplexMat, y::ComplexMat) Q = inv(P) ccall((:acb_mat_solve_lu_precomp, libarb), Nothing, (Ref{ComplexMat}, Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), @@ -590,10 +590,10 @@ function solve_lu_precomp!(z::ComplexMat, P::Generic.Perm, LU::ComplexMat, y::Co nothing end -function solve_lu_precomp(P::Generic.Perm, LU::ComplexMat, y::ComplexMat) +function _solve_lu_precomp(P::Generic.Perm, LU::ComplexMat, y::ComplexMat) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve_lu_precomp!(z, P, LU, y) + _solve_lu_precomp!(z, P, LU, y) return z end @@ -622,7 +622,7 @@ end # ################################################################################ -function AbstractAlgebra.Solve.solve_init(A::ComplexMat) +function solve_init(A::ComplexMat) return AbstractAlgebra.Solve.SolveCtx{ComplexFieldElem, ComplexMat, ComplexMat}(A) end diff --git a/src/arb/RealMat.jl b/src/arb/RealMat.jl index 91088b785..55f7eddef 100644 --- a/src/arb/RealMat.jl +++ b/src/arb/RealMat.jl @@ -508,7 +508,7 @@ function lu!(P::Generic.Perm, x::RealMat) return min(nrows(x), ncols(x)) end -function solve!(z::RealMat, x::RealMat, y::RealMat) +function _solve!(z::RealMat, x::RealMat, y::RealMat) r = ccall((:arb_mat_solve, libarb), Cint, (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), z, x, y, precision(Balls)) @@ -516,15 +516,15 @@ function solve!(z::RealMat, x::RealMat, y::RealMat) nothing end -function solve(x::RealMat, y::RealMat) +function _solve(x::RealMat, y::RealMat) ncols(x) != nrows(x) && error("First argument must be square") ncols(x) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve!(z, x, y) + _solve!(z, x, y) return z end -function solve_lu_precomp!(z::RealMat, P::Generic.Perm, LU::RealMat, y::RealMat) +function _solve_lu_precomp!(z::RealMat, P::Generic.Perm, LU::RealMat, y::RealMat) Q = inv(P) ccall((:arb_mat_solve_lu_precomp, libarb), Nothing, (Ref{RealMat}, Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), @@ -532,10 +532,10 @@ function solve_lu_precomp!(z::RealMat, P::Generic.Perm, LU::RealMat, y::RealMat) nothing end -function solve_lu_precomp(P::Generic.Perm, LU::RealMat, y::RealMat) +function _solve_lu_precomp(P::Generic.Perm, LU::RealMat, y::RealMat) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve_lu_precomp!(z, P, LU, y) + _solve_lu_precomp!(z, P, LU, y) return z end @@ -564,7 +564,7 @@ end # ################################################################################ -function AbstractAlgebra.Solve.solve_init(A::RealMat) +function solve_init(A::RealMat) return AbstractAlgebra.Solve.SolveCtx{RealFieldElem, RealMat, RealMat}(A) end diff --git a/src/arb/acb_mat.jl b/src/arb/acb_mat.jl index a85c80a4b..4c9349aa4 100644 --- a/src/arb/acb_mat.jl +++ b/src/arb/acb_mat.jl @@ -569,7 +569,7 @@ function lu!(P::Generic.Perm, x::AcbMatrix) return nrows(x) end -function solve!(z::AcbMatrix, x::AcbMatrix, y::AcbMatrix) +function _solve!(z::AcbMatrix, x::AcbMatrix, y::AcbMatrix) r = ccall((:acb_mat_solve, libarb), Cint, (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), z, x, y, precision(base_ring(x))) @@ -577,15 +577,15 @@ function solve!(z::AcbMatrix, x::AcbMatrix, y::AcbMatrix) nothing end -function solve(x::AcbMatrix, y::AcbMatrix) +function _solve(x::AcbMatrix, y::AcbMatrix) ncols(x) != nrows(x) && error("First argument must be square") ncols(x) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve!(z, x, y) + _solve!(z, x, y) return z end -function solve_lu_precomp!(z::AcbMatrix, P::Generic.Perm, LU::AcbMatrix, y::AcbMatrix) +function _solve_lu_precomp!(z::AcbMatrix, P::Generic.Perm, LU::AcbMatrix, y::AcbMatrix) Q = inv(P) ccall((:acb_mat_solve_lu_precomp, libarb), Nothing, (Ref{AcbMatrix}, Ptr{Int}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), @@ -593,10 +593,10 @@ function solve_lu_precomp!(z::AcbMatrix, P::Generic.Perm, LU::AcbMatrix, y::AcbM nothing end -function solve_lu_precomp(P::Generic.Perm, LU::AcbMatrix, y::AcbMatrix) +function _solve_lu_precomp(P::Generic.Perm, LU::AcbMatrix, y::AcbMatrix) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve_lu_precomp!(z, P, LU, y) + _solve_lu_precomp!(z, P, LU, y) return z end @@ -625,7 +625,7 @@ end # ################################################################################ -function AbstractAlgebra.Solve.solve_init(A::AcbMatrix) +function solve_init(A::AcbMatrix) return AbstractAlgebra.Solve.SolveCtx{AcbFieldElem, AcbMatrix, AcbMatrix}(A) end diff --git a/src/arb/arb_mat.jl b/src/arb/arb_mat.jl index 4b4b38561..7c47cb461 100644 --- a/src/arb/arb_mat.jl +++ b/src/arb/arb_mat.jl @@ -521,7 +521,7 @@ function lu!(P::Generic.Perm, x::ArbMatrix) return nrows(x) end -function solve!(z::ArbMatrix, x::ArbMatrix, y::ArbMatrix) +function _solve!(z::ArbMatrix, x::ArbMatrix, y::ArbMatrix) r = ccall((:arb_mat_solve, libarb), Cint, (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, x, y, precision(base_ring(x))) @@ -529,15 +529,15 @@ function solve!(z::ArbMatrix, x::ArbMatrix, y::ArbMatrix) nothing end -function solve(x::ArbMatrix, y::ArbMatrix) +function _solve(x::ArbMatrix, y::ArbMatrix) ncols(x) != nrows(x) && error("First argument must be square") ncols(x) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve!(z, x, y) + _solve!(z, x, y) return z end -function solve_lu_precomp!(z::ArbMatrix, P::Generic.Perm, LU::ArbMatrix, y::ArbMatrix) +function _solve_lu_precomp!(z::ArbMatrix, P::Generic.Perm, LU::ArbMatrix, y::ArbMatrix) Q = inv(P) ccall((:arb_mat_solve_lu_precomp, libarb), Nothing, (Ref{ArbMatrix}, Ptr{Int}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), @@ -545,24 +545,24 @@ function solve_lu_precomp!(z::ArbMatrix, P::Generic.Perm, LU::ArbMatrix, y::ArbM nothing end -function solve_lu_precomp(P::Generic.Perm, LU::ArbMatrix, y::ArbMatrix) +function _solve_lu_precomp(P::Generic.Perm, LU::ArbMatrix, y::ArbMatrix) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve_lu_precomp!(z, P, LU, y) + _solve_lu_precomp!(z, P, LU, y) return z end -function solve_cholesky_precomp!(z::ArbMatrix, cho::ArbMatrix, y::ArbMatrix) +function _solve_cholesky_precomp!(z::ArbMatrix, cho::ArbMatrix, y::ArbMatrix) ccall((:arb_mat_solve_cho_precomp, libarb), Nothing, (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, cho, y, precision(base_ring(cho))) nothing end -function solve_cholesky_precomp(cho::ArbMatrix, y::ArbMatrix) +function _solve_cholesky_precomp(cho::ArbMatrix, y::ArbMatrix) ncols(cho) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) - solve_cholesky_precomp!(z, cho, y) + _solve_cholesky_precomp!(z, cho, y) return z end @@ -591,7 +591,7 @@ end # ################################################################################ -function AbstractAlgebra.Solve.solve_init(A::ArbMatrix) +function solve_init(A::ArbMatrix) return AbstractAlgebra.Solve.SolveCtx{ArbFieldElem, ArbMatrix, ArbMatrix}(A) end diff --git a/src/flint/fmpq_mat.jl b/src/flint/fmpq_mat.jl index 8781e142f..359f09c35 100644 --- a/src/flint/fmpq_mat.jl +++ b/src/flint/fmpq_mat.jl @@ -660,20 +660,20 @@ end # ############################################################################### -function solve(a::QQMatrix, b::QQMatrix) +function _solve(a::QQMatrix, b::QQMatrix) nrows(b) != nrows(a) && error("Incompatible dimensions in solve") - fl, z = can_solve_with_solution(a, b) + fl, z = _can_solve_with_solution(a, b) !fl && error("System is inconsistent") return z end @doc raw""" - solve_dixon(a::QQMatrix, b::QQMatrix) + _solve_dixon(a::QQMatrix, b::QQMatrix) Solve $ax = b$ by clearing denominators and using Dixon's algorithm. This is usually faster for large systems. """ -function solve_dixon(a::QQMatrix, b::QQMatrix) +function _solve_dixon(a::QQMatrix, b::QQMatrix) nrows(a) != ncols(a) && error("Not a square matrix in solve") nrows(b) != nrows(a) && error("Incompatible dimensions in solve") z = similar(b) @@ -683,10 +683,10 @@ function solve_dixon(a::QQMatrix, b::QQMatrix) return z end -function can_solve_with_solution(a::QQMatrix, b::QQMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::QQMatrix, b::QQMatrix; side::Symbol = :right) if side == :left (ncols(a) != ncols(b)) && error("Matrices must have same number of columns") - (f, x) = can_solve_with_solution(transpose(a), transpose(b); side=:right) + (f, x) = _can_solve_with_solution(transpose(a), transpose(b); side=:right) return (f, transpose(x)) elseif side == :right (nrows(a) != nrows(b)) && error("Matrices must have same number of rows") @@ -699,8 +699,8 @@ function can_solve_with_solution(a::QQMatrix, b::QQMatrix; side::Symbol = :right end end -function can_solve(a::QQMatrix, b::QQMatrix; side::Symbol = :right) - fl, _ = can_solve_with_solution(a, b, side = side) +function _can_solve(a::QQMatrix, b::QQMatrix; side::Symbol = :right) + fl, _ = _can_solve_with_solution(a, b, side = side) return fl end @@ -717,7 +717,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::QQMatrix, b::QQMa if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, kernel(A)[2] + return Bool(fl), x, kernel(A, side = :right) end ############################################################################### diff --git a/src/flint/fmpz_mat.jl b/src/flint/fmpz_mat.jl index 9dbff82de..fe18ab3c6 100644 --- a/src/flint/fmpz_mat.jl +++ b/src/flint/fmpz_mat.jl @@ -1110,11 +1110,11 @@ function nullspace(x::ZZMatrix) return ncols(x), identity_matrix(x, ncols(x)) end -function AbstractAlgebra.Solve.kernel(A::ZZMatrix; side::Symbol = :left) +function kernel(A::ZZMatrix; side::Symbol = :left) AbstractAlgebra.Solve.check_option(side, [:right, :left], "side") if side === :left - K = AbstractAlgebra.Solve.kernel(transpose(A), side = :right) + K = kernel(transpose(A), side = :right) return transpose(K) end @@ -1251,14 +1251,14 @@ end ############################################################################### @doc raw""" - solve(a::ZZMatrix, b::ZZMatrix) -> ZZMatrix + _solve(a::ZZMatrix, b::ZZMatrix) -> ZZMatrix Return a matrix $x$ such that $ax = b$. An exception is raised if this is not possible. """ -function solve(a::ZZMatrix, b::ZZMatrix) +function _solve(a::ZZMatrix, b::ZZMatrix) nrows(b) != nrows(a) && error("Incompatible dimensions in solve") - fl, z = cansolve(a, b) + fl, z = _cansolve(a, b) if !fl error("system is inconsistent") end @@ -1266,13 +1266,13 @@ function solve(a::ZZMatrix, b::ZZMatrix) end @doc raw""" - cansolve(a::ZZMatrix, b::ZZMatrix) -> Bool, ZZMatrix + _cansolve(a::ZZMatrix, b::ZZMatrix) -> Bool, ZZMatrix Return true and a matrix $x$ such that $ax = b$, or false and some matrix in case $x$ does not exist. """ -function cansolve(a::ZZMatrix, b::ZZMatrix) - nrows(b) != nrows(a) && error("Incompatible dimensions in cansolve") +function _cansolve(a::ZZMatrix, b::ZZMatrix) + nrows(b) != nrows(a) && error("Incompatible dimensions in _cansolve") H, T = hnf_with_transform(transpose(a)) b = deepcopy(b) z = similar(a, ncols(b), ncols(a)) @@ -1320,11 +1320,11 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::ZZMatrix, b::ZZMa return fl, transpose(sol), transpose(K) end - fl, sol = Nemo.cansolve(A, b) + fl, sol = Nemo._cansolve(A, b) if task === :only_check || task === :with_solution return fl, sol, zero(A, 0, 0) end - return fl, sol, AbstractAlgebra.Solve.kernel(A, side = :right) + return fl, sol, kernel(A, side = :right) end Base.reduce(::typeof(hcat), A::AbstractVector{ZZMatrix}) = AbstractAlgebra._hcat(A) @@ -1415,24 +1415,24 @@ function AbstractAlgebra._hcat(A::AbstractVector{ZZMatrix}) end #to override the generic one in AA -function can_solve_with_solution(a::ZZMatrix, b::ZZMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::ZZMatrix, b::ZZMatrix; side::Symbol = :right) if side == :left - fl, x = Nemo.cansolve(transpose(a), transpose(b)) + fl, x = Nemo._cansolve(transpose(a), transpose(b)) return fl, transpose(x) end - return Nemo.cansolve(a, b) + return Nemo._cansolve(a, b) end @doc raw""" - cansolve_with_nullspace(a::ZZMatrix, b::ZZMatrix) -> Bool, ZZMatrix, ZZMatrix + _cansolve_with_nullspace(a::ZZMatrix, b::ZZMatrix) -> Bool, ZZMatrix, ZZMatrix Return true, a matrix $x$ and a matrix $k$ such that $ax = b$ and the columns of $k$ form a basis for the nullspace of $a$. In case $x$ does not exist, false and two arbitrary matrices are returned. """ -function cansolve_with_nullspace(a::ZZMatrix, b::ZZMatrix) - nrows(b) != nrows(a) && error("Incompatible dimensions in cansolve_with_nullspace") +function _cansolve_with_nullspace(a::ZZMatrix, b::ZZMatrix) + nrows(b) != nrows(a) && error("Incompatible dimensions in _cansolve_with_nullspace") H, T = hnf_with_transform(transpose(a)) b = deepcopy(b) z = similar(a, ncols(b), ncols(a)) @@ -1481,37 +1481,37 @@ function cansolve_with_nullspace(a::ZZMatrix, b::ZZMatrix) end @doc raw""" - solve_rational(a::ZZMatrix, b::ZZMatrix) + _solve_rational(a::ZZMatrix, b::ZZMatrix) If it exists, return a tuple $(x, d)$ consisting of a column vector $x$ such that $ax = db$. The element $b$ must be a column vector with the same number of rows as $a$ and $a$ must be a square matrix. If these conditions are not met or $(x, d)$ does not exist, an exception is raised. """ -function solve_rational(a::ZZMatrix, b::ZZMatrix) - nrows(a) != ncols(a) && error("Not a square matrix in solve_rational") - nrows(b) != nrows(a) && error("Incompatible dimensions in solve_rational") +function _solve_rational(a::ZZMatrix, b::ZZMatrix) + nrows(a) != ncols(a) && error("Not a square matrix in _solve_rational") + nrows(b) != nrows(a) && error("Incompatible dimensions in _solve_rational") z = similar(b) d = ZZRingElem() nonsing = ccall((:fmpz_mat_solve, libflint), Bool, (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, d, a, b) - !nonsing && error("Singular matrix in solve_rational") + !nonsing && error("Singular matrix in _solve_rational") return z, d end -function Generic.solve_with_det(a::ZZMatrix, b::ZZMatrix) - return solve_rational(a, b) +function _solve_with_det(a::ZZMatrix, b::ZZMatrix) + return _solve_rational(a, b) end @doc raw""" - solve_dixon(a::ZZMatrix, b::ZZMatrix) + _solve_dixon(a::ZZMatrix, b::ZZMatrix) Return a tuple $(x, m)$ consisting of a column vector $x$ such that $ax = b \pmod{m}$. The element $b$ must be a column vector with the same number > of rows as $a$ and $a$ must be a square matrix. If these conditions are not met or $(x, d)$ does not exist, an exception is raised. """ -function solve_dixon(a::ZZMatrix, b::ZZMatrix) +function _solve_dixon(a::ZZMatrix, b::ZZMatrix) nrows(a) != ncols(a) && error("Not a square matrix in solve") nrows(b) != nrows(a) && error("Incompatible dimensions in solve") z = similar(b) @@ -1523,7 +1523,7 @@ function solve_dixon(a::ZZMatrix, b::ZZMatrix) end #XU = B. only the upper triangular part of U is used -function solve_triu_left(U::ZZMatrix, b::ZZMatrix) +function _solve_triu_left(U::ZZMatrix, b::ZZMatrix) n = ncols(U) m = nrows(b) R = base_ring(U) @@ -1567,7 +1567,7 @@ function solve_triu_left(U::ZZMatrix, b::ZZMatrix) end #UX = B -function solve_triu(U::ZZMatrix, b::ZZMatrix) +function _solve_triu(U::ZZMatrix, b::ZZMatrix) n = nrows(U) m = ncols(b) X = zero(b) @@ -1610,7 +1610,7 @@ function solve_triu(U::ZZMatrix, b::ZZMatrix) return X end -function AbstractAlgebra.solve_tril!(A::ZZMatrix, B::ZZMatrix, C::ZZMatrix, f::Int = 0) +function AbstractAlgebra._solve_tril!(A::ZZMatrix, B::ZZMatrix, C::ZZMatrix, f::Int = 0) # a x u ax = u # b c * y = v bx + cy = v diff --git a/src/flint/fmpz_mod_mat.jl b/src/flint/fmpz_mod_mat.jl index 243072cd6..53ebee958 100644 --- a/src/flint/fmpz_mod_mat.jl +++ b/src/flint/fmpz_mod_mat.jl @@ -487,7 +487,7 @@ end #= Not implemented in Flint yet -function solve(x::T, y::T) where T <: Zmod_fmpz_mat +function _solve(x::T, y::T) where T <: Zmod_fmpz_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") !is_square(x)&& error("First argument not a square matrix in solve") (y.r != x.r) || y.c != 1 && ("Not a column vector in solve") @@ -513,7 +513,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::ZZModMatrix, b::Z if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, AbstractAlgebra.Solve.kernel(A, side = :right) + return Bool(fl), x, kernel(A, side = :right) end ################################################################################ @@ -922,11 +922,11 @@ end # ################################################################################ -function AbstractAlgebra.Solve.kernel(M::ZZModMatrix; side::Symbol = :left) +function kernel(M::ZZModMatrix; side::Symbol = :left) AbstractAlgebra.Solve.check_option(side, [:right, :left], "side") if side === :left - K = AbstractAlgebra.Solve.kernel(transpose(M), side = :right) + K = kernel(transpose(M), side = :right) return transpose(K) end diff --git a/src/flint/fq_default_mat.jl b/src/flint/fq_default_mat.jl index 78ea46b17..f10ebd686 100644 --- a/src/flint/fq_default_mat.jl +++ b/src/flint/fq_default_mat.jl @@ -415,23 +415,23 @@ end # ################################################################################ -function solve(x::FqMatrix, y::FqMatrix) +function _solve(x::FqMatrix, y::FqMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") - !is_square(x)&& error("First argument not a square matrix in solve") - (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in solve") + !is_square(x)&& error("First argument not a square matrix in _solve") + (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in _solve") z = similar(y) r = ccall((:fq_default_mat_solve, libflint), Int, (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, x, y, base_ring(x)) - !Bool(r) && error("Singular matrix in solve") + !Bool(r) && error("Singular matrix in _solve") return z end -function can_solve_with_solution(a::FqMatrix, b::FqMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::FqMatrix, b::FqMatrix; side::Symbol = :right) (base_ring(a) != base_ring(b)) && error("Matrices must have same base ring") if side == :left (ncols(a) != ncols(b)) && error("Matrices must have same number of columns") - (f, x) = can_solve_with_solution(transpose(a), transpose(b); side=:right) + (f, x) = _can_solve_with_solution(transpose(a), transpose(b); side=:right) return (f, transpose(x)) elseif side == :right (nrows(a) != nrows(b)) && error("Matrices must have same number of rows") @@ -445,8 +445,8 @@ function can_solve_with_solution(a::FqMatrix, b::FqMatrix; side::Symbol = :right end end -function can_solve(a::FqMatrix, b::FqMatrix; side::Symbol = :right) - fl, _ = can_solve_with_solution(a, b, side = side) +function _can_solve(a::FqMatrix, b::FqMatrix; side::Symbol = :right) + fl, _ = _can_solve_with_solution(a, b, side = side) return fl end @@ -464,7 +464,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::FqMatrix, b::FqMa if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, AbstractAlgebra.Solve.kernel(A, side = :right) + return Bool(fl), x, kernel(A, side = :right) end ################################################################################ diff --git a/src/flint/fq_mat.jl b/src/flint/fq_mat.jl index f51cd6dde..94c3d1179 100644 --- a/src/flint/fq_mat.jl +++ b/src/flint/fq_mat.jl @@ -422,23 +422,23 @@ end # ################################################################################ -function solve(x::FqPolyRepMatrix, y::FqPolyRepMatrix) +function _solve(x::FqPolyRepMatrix, y::FqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") - !is_square(x)&& error("First argument not a square matrix in solve") - (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in solve") + !is_square(x)&& error("First argument not a square matrix in _solve") + (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in _solve") z = similar(y) r = ccall((:fq_mat_solve, libflint), Int, (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), z, x, y, base_ring(x)) - !Bool(r) && error("Singular matrix in solve") + !Bool(r) && error("Singular matrix in _solve") return z end -function can_solve_with_solution(a::FqPolyRepMatrix, b::FqPolyRepMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::FqPolyRepMatrix, b::FqPolyRepMatrix; side::Symbol = :right) (base_ring(a) != base_ring(b)) && error("Matrices must have same base ring") if side == :left (ncols(a) != ncols(b)) && error("Matrices must have same number of columns") - (f, x) = can_solve_with_solution(transpose(a), transpose(b); side=:right) + (f, x) = _can_solve_with_solution(transpose(a), transpose(b); side=:right) return (f, transpose(x)) elseif side == :right (nrows(a) != nrows(b)) && error("Matrices must have same number of rows") @@ -452,8 +452,8 @@ function can_solve_with_solution(a::FqPolyRepMatrix, b::FqPolyRepMatrix; side::S end end -function can_solve(a::FqPolyRepMatrix, b::FqPolyRepMatrix; side::Symbol = :right) - fl, _ = can_solve_with_solution(a, b, side = side) +function _can_solve(a::FqPolyRepMatrix, b::FqPolyRepMatrix; side::Symbol = :right) + fl, _ = _can_solve_with_solution(a, b, side = side) return fl end @@ -471,7 +471,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::FqPolyRepMatrix, if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, AbstractAlgebra.Solve.kernel(A, side = :right) + return Bool(fl), x, kernel(A, side = :right) end ################################################################################ diff --git a/src/flint/fq_nmod_mat.jl b/src/flint/fq_nmod_mat.jl index e8e5d5715..1ca545540 100644 --- a/src/flint/fq_nmod_mat.jl +++ b/src/flint/fq_nmod_mat.jl @@ -410,23 +410,23 @@ end # ################################################################################ -function solve(x::fqPolyRepMatrix, y::fqPolyRepMatrix) +function _solve(x::fqPolyRepMatrix, y::fqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") - !is_square(x)&& error("First argument not a square matrix in solve") - (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in solve") + !is_square(x)&& error("First argument not a square matrix in _solve") + (nrows(y) != nrows(x)) || ncols(y) != 1 && ("Not a column vector in _solve") z = similar(y) r = ccall((:fq_nmod_mat_solve, libflint), Int, (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), z, x, y, base_ring(x)) - !Bool(r) && error("Singular matrix in solve") + !Bool(r) && error("Singular matrix in _solve") return z end -function can_solve_with_solution(a::fqPolyRepMatrix, b::fqPolyRepMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::fqPolyRepMatrix, b::fqPolyRepMatrix; side::Symbol = :right) (base_ring(a) != base_ring(b)) && error("Matrices must have same base ring") if side == :left (ncols(a) != ncols(b)) && error("Matrices must have same number of columns") - (f, x) = can_solve_with_solution(transpose(a), transpose(b); side=:right) + (f, x) = _can_solve_with_solution(transpose(a), transpose(b); side=:right) return (f, transpose(x)) elseif side == :right (nrows(a) != nrows(b)) && error("Matrices must have same number of rows") @@ -440,8 +440,8 @@ function can_solve_with_solution(a::fqPolyRepMatrix, b::fqPolyRepMatrix; side::S end end -function can_solve(a::fqPolyRepMatrix, b::fqPolyRepMatrix; side::Symbol = :right) - fl, _ = can_solve_with_solution(a, b, side = side) +function _can_solve(a::fqPolyRepMatrix, b::fqPolyRepMatrix; side::Symbol = :right) + fl, _ = _can_solve_with_solution(a, b, side = side) return fl end @@ -459,7 +459,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::fqPolyRepMatrix, if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, AbstractAlgebra.Solve.kernel(A, side = :right) + return Bool(fl), x, kernel(A, side = :right) end ################################################################################ diff --git a/src/flint/gfp_mat.jl b/src/flint/gfp_mat.jl index 590f524fe..0e863e706 100644 --- a/src/flint/gfp_mat.jl +++ b/src/flint/gfp_mat.jl @@ -290,11 +290,11 @@ end # ################################################################################ -function can_solve_with_solution(a::fpMatrix, b::fpMatrix; side::Symbol = :right) +function _can_solve_with_solution(a::fpMatrix, b::fpMatrix; side::Symbol = :right) (base_ring(a) != base_ring(b)) && error("Matrices must have same base ring") if side == :left (ncols(a) != ncols(b)) && error("Matrices must have same number of columns") - (f, x) = can_solve_with_solution(transpose(a), transpose(b); side=:right) + (f, x) = _can_solve_with_solution(transpose(a), transpose(b); side=:right) return (f, transpose(x)) elseif side == :right (nrows(a) != nrows(b)) && error("Matrices must have same number of rows") @@ -307,8 +307,8 @@ function can_solve_with_solution(a::fpMatrix, b::fpMatrix; side::Symbol = :right end end -function can_solve(a::fpMatrix, b::fpMatrix; side::Symbol = :right) - fl, _ = can_solve_with_solution(a, b, side = side) +function _can_solve(a::fpMatrix, b::fpMatrix; side::Symbol = :right) + fl, _ = _can_solve_with_solution(a, b, side = side) return fl end @@ -326,7 +326,7 @@ function AbstractAlgebra.Solve._can_solve_internal_no_check(A::fpMatrix, b::fpMa if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end - return Bool(fl), x, AbstractAlgebra.Solve.kernel(A, side = :right) + return Bool(fl), x, kernel(A, side = :right) end ################################################################################ @@ -515,11 +515,11 @@ end # ################################################################################ -function AbstractAlgebra.Solve.kernel(A::fpMatrix; side::Symbol = :left) +function kernel(A::fpMatrix; side::Symbol = :left) AbstractAlgebra.Solve.check_option(side, [:right, :left], "side") if side === :left - K = AbstractAlgebra.Solve.kernel(transpose(A), side = :right) + K = kernel(transpose(A), side = :right) return transpose(K) end diff --git a/src/flint/nmod_mat.jl b/src/flint/nmod_mat.jl index 2f3e89b8f..d2ca15ee0 100644 --- a/src/flint/nmod_mat.jl +++ b/src/flint/nmod_mat.jl @@ -486,22 +486,22 @@ end # ################################################################################ -function solve(x::T, y::T) where T <: Zmodn_mat +function _solve(x::T, y::T) where T <: Zmodn_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") - !is_square(x)&& error("First argument not a square matrix in solve") - (y.r != x.r) || y.c != 1 && ("Not a column vector in solve") + !is_square(x)&& error("First argument not a square matrix in _solve") + (y.r != x.r) || y.c != 1 && ("Not a column vector in _solve") z = similar(y) r = ccall((:nmod_mat_solve, libflint), Int, (Ref{T}, Ref{T}, Ref{T}), z, x, y) - !Bool(r) && error("Singular matrix in solve") + !Bool(r) && error("Singular matrix in _solve") return z end -function AbstractAlgebra.solve_triu(x::T, y::T) where T <: Zmodn_mat +function AbstractAlgebra._solve_triu(x::T, y::T) where T <: Zmodn_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") is_upper_trangular(x) || error("Matrix must be upper triangular") z = similar(x, nrows(x), ncols(y)) - solve_triu!(z, x, y, 0) + _solve_triu!(z, x, y, 0) return z end @@ -512,14 +512,14 @@ end # useful in the context of solving/ lu decomposition: the lu # is done inplace, so the lower part wil be "l", the upper "u", # both are implicit only. -function solve_triu!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat +function _solve_triu!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat ccall((:nmod_mat_solve_triu, Nemo.libflint), Cvoid, (Ref{T}, Ref{T}, Ref{T}, Cint), A, B, C, unit) end #solves lower_triangular_part(B)A = C, #if unit == 1, then only the strictly lower triangular part is used #and the diagonal is assumed to be 1 -function solve_tril!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat +function AbstractAlgebra._solve_tril!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat ccall((:nmod_mat_solve_tril, Nemo.libflint), Cvoid, (Ref{T}, Ref{T}, Ref{T}, Cint), A, B, C, unit) end @@ -925,11 +925,11 @@ end # ################################################################################ -function AbstractAlgebra.Solve.kernel(M::zzModMatrix; side::Symbol = :left) +function kernel(M::zzModMatrix; side::Symbol = :left) AbstractAlgebra.Solve.check_option(side, [:right, :left], "side") if side === :left - K = AbstractAlgebra.Solve.kernel(transpose(M), side = :right) + K = kernel(transpose(M), side = :right) return transpose(K) end diff --git a/test/arb/ComplexMat-test.jl b/test/arb/ComplexMat-test.jl index 278fe5b4a..48b42d22c 100644 --- a/test/arb/ComplexMat-test.jl +++ b/test/arb/ComplexMat-test.jl @@ -432,7 +432,7 @@ end @test overlaps(L*U, p*A) @test r == 3 - y = solve(A, transpose(b)) + y = Nemo._solve(A, transpose(b)) @test overlaps(A * y, transpose(b)) @@ -440,7 +440,7 @@ end Nemo.lu!(p, A) - y = solve_lu_precomp(p, A, transpose(b)) + y = Nemo._solve_lu_precomp(p, A, transpose(b)) @test overlaps(B*y, transpose(b)) @@ -457,51 +457,51 @@ end b = transpose(CC["6.0 +/- 0.1" "15.0 +/- 0.1" "25.0 +/- 0.1"]) b2 = 2*b - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, b, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(A, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(A, b, side = :right) + y = solve(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - C = AbstractAlgebra.Solve.solve_init(A) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b, side = :right) + C = solve_init(A) + fl, y, K = can_solve_with_solution_and_kernel(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b, side = :right) + y = solve(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b2, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b2)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b2)) @test fl @test overlaps(y*A, transpose(b2)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b2, side = :right) + y = solve(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) diff --git a/test/arb/RealMat-test.jl b/test/arb/RealMat-test.jl index 1962434d1..e9abf98f0 100644 --- a/test/arb/RealMat-test.jl +++ b/test/arb/RealMat-test.jl @@ -398,7 +398,7 @@ end @test overlaps(L*U, p*A) @test r == 3 - y = solve(A, transpose(b)) + y = Nemo._solve(A, transpose(b)) @test overlaps(A*y, transpose(b)) @@ -406,7 +406,7 @@ end Nemo.lu!(p, A) - y = solve_lu_precomp(p, A, transpose(b)) + y = Nemo._solve_lu_precomp(p, A, transpose(b)) @test overlaps(B*y, transpose(b)) @@ -423,51 +423,51 @@ end b = transpose(RR["6.0 +/- 0.1" "15.0 +/- 0.1" "25.0 +/- 0.1"]) b2 = 2*b - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, b, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(A, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(A, b, side = :right) + y = solve(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - C = AbstractAlgebra.Solve.solve_init(A) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b, side = :right) + C = solve_init(A) + fl, y, K = can_solve_with_solution_and_kernel(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b, side = :right) + y = solve(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b2, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b2)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b2)) @test fl @test overlaps(y*A, transpose(b2)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b2, side = :right) + y = solve(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) diff --git a/test/arb/acb_mat-test.jl b/test/arb/acb_mat-test.jl index 7593886a0..f1d034438 100644 --- a/test/arb/acb_mat-test.jl +++ b/test/arb/acb_mat-test.jl @@ -432,7 +432,7 @@ end @test overlaps(L*U, p*A) @test r == 3 - y = solve(A, transpose(b)) + y = Nemo._solve(A, transpose(b)) @test overlaps(A * y, transpose(b)) @@ -440,7 +440,7 @@ end Nemo.lu!(p, A) - y = solve_lu_precomp(p, A, transpose(b)) + y = Nemo._solve_lu_precomp(p, A, transpose(b)) @test overlaps(B*y, transpose(b)) @@ -457,51 +457,51 @@ end b = transpose(CC["6.0 +/- 0.1" "15.0 +/- 0.1" "25.0 +/- 0.1"]) b2 = 2*b - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, b, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(A, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(A, b, side = :right) + y = solve(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - C = AbstractAlgebra.Solve.solve_init(A) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b, side = :right) + C = solve_init(A) + fl, y, K = can_solve_with_solution_and_kernel(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b, side = :right) + y = solve(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b2, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b2)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b2)) @test fl @test overlaps(y*A, transpose(b2)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b2, side = :right) + y = solve(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) diff --git a/test/arb/arb_mat-test.jl b/test/arb/arb_mat-test.jl index 954e4c3c2..bc167bffe 100644 --- a/test/arb/arb_mat-test.jl +++ b/test/arb/arb_mat-test.jl @@ -394,7 +394,7 @@ end b = RR["6.0 +/- 0.1" "4.0 +/- 0.1" "4.0 +/- 0.1"] - y = solve_cholesky_precomp(cho, transpose(b)) + y = Nemo._solve_cholesky_precomp(cho, transpose(b)) @test overlaps(A*y, transpose(b)) @@ -418,7 +418,7 @@ end @test overlaps(L*U, p*A) @test r == 3 - y = solve(A, transpose(b)) + y = Nemo._solve(A, transpose(b)) @test overlaps(A*y, transpose(b)) @@ -426,7 +426,7 @@ end Nemo.lu!(p, A) - y = solve_lu_precomp(p, A, transpose(b)) + y = Nemo._solve_lu_precomp(p, A, transpose(b)) @test overlaps(B*y, transpose(b)) @@ -443,51 +443,51 @@ end b = transpose(RR["6.0 +/- 0.1" "15.0 +/- 0.1" "25.0 +/- 0.1"]) b2 = 2*b - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, b, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(A, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(A, b, side = :right) + y = solve(A, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - C = AbstractAlgebra.Solve.solve_init(A) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b, side = :right) + C = solve_init(A) + fl, y, K = can_solve_with_solution_and_kernel(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b)) @test fl @test overlaps(y*A, transpose(b)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b, side = :right) + y = solve(C, b, side = :right) @test fl @test overlaps(A*y, b) @test contains(transpose(y), ZZ[1 1 1]) - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, b2, side = :right) + fl, y, K = can_solve_with_solution_and_kernel(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) @test ncols(K) == 0 - fl, y, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(C, transpose(b2)) + fl, y, K = can_solve_with_solution_and_kernel(C, transpose(b2)) @test fl @test overlaps(y*A, transpose(b2)) @test nrows(K) == 0 - y = AbstractAlgebra.Solve.solve(C, b2, side = :right) + y = solve(C, b2, side = :right) @test fl @test overlaps(A*y, b2) @test contains(transpose(y), ZZ[2 2 2]) diff --git a/test/flint/fmpq_mat-test.jl b/test/flint/fmpq_mat-test.jl index e11a57e88..0f791bec9 100644 --- a/test/flint/fmpq_mat-test.jl +++ b/test/flint/fmpq_mat-test.jl @@ -541,13 +541,13 @@ end B = T([QQFieldElem(4), 5, 7]) - X = solve(A, B) + X = Nemo._solve(A, B) @test X == T([3, -24, 14]) @test A*X == B - Y = solve_dixon(A, B) + Y = Nemo._solve_dixon(A, B) @test X == Y @@ -556,7 +556,7 @@ end m1Q = matrix(QQ, m1) m2Q = matrix(QQ, m2); - N = solve(m1Q, m2Q) + N = Nemo._solve(m1Q, m2Q) @test N == matrix(QQ, 2, 2, [0 1; 1 -1]) @@ -571,7 +571,7 @@ end A = rand(M, -10:10) B = rand(N, -10:10) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) if fl @test A * X == B @@ -580,55 +580,55 @@ end A = matrix(QQ, 2, 2, [1, 2, 2, 5]) B = matrix(QQ, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(QQ, 2, 2, [1, 2, 2, 4]) B = matrix(QQ, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(QQ, 2, 2, [1, 2, 2, 4]) B = matrix(QQ, 2, 1, [1, 3]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(QQ, 2, 3) B = identity_matrix(QQ, 3) - @test_throws ErrorException can_solve_with_solution(A, B) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B) # Transpose A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(QQ, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(QQ, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(QQ, 2, 1, [1, 3])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - @test !can_solve(A, B, side = :left) + @test !Nemo._can_solve(A, B, side = :left) A = transpose(zero_matrix(QQ, 2, 3)) B = transpose(identity_matrix(QQ, 3)) - @test_throws ErrorException can_solve_with_solution(A, B, side = :left) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :left) - @test_throws ErrorException can_solve_with_solution(A, B, side = :garbage) - @test_throws ErrorException can_solve(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve(A, B, side = :garbage) end @testset "QQMatrix.Solve.solve" begin @@ -640,7 +640,7 @@ end B = T([QQFieldElem(4), 5, 7]) - X = AbstractAlgebra.Solve.solve(A, B, side = :right) + X = solve(A, B, side = :right) @test X == T([3, -24, 14]) @@ -651,7 +651,7 @@ end m1Q = matrix(QQ, m1) m2Q = matrix(QQ, m2); - N = AbstractAlgebra.Solve.solve(m1Q, m2Q, side = :right) + N = solve(m1Q, m2Q, side = :right) @test N == matrix(QQ, 2, 2, [0 1; 1 -1]) @@ -666,13 +666,13 @@ end A = rand(M, -10:10) B = rand(N, -10:10) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) if fl @test A * X == B end - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) if fl @test A*X == B @@ -683,11 +683,11 @@ end A = matrix(QQ, 2, 2, [1, 2, 2, 5]) B = matrix(QQ, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + @test can_solve(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test fl @test A*X == B @test is_zero(A*K) @@ -695,11 +695,11 @@ end A = matrix(QQ, 2, 2, [1, 2, 2, 4]) B = matrix(QQ, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + @test can_solve(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test fl @test A*X == B @test is_zero(A*K) @@ -707,31 +707,31 @@ end A = matrix(QQ, 2, 2, [1, 2, 2, 4]) B = matrix(QQ, 2, 1, [1, 3]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B, side = :right) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + @test !can_solve(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test !fl A = zero_matrix(QQ, 2, 3) B = identity_matrix(QQ, 3) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + @test_throws ErrorException can_solve_with_solution(A, B, side = :right) # Transpose A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(QQ, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(QQ, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B) + @test can_solve(A, B) + fl, X, K = can_solve_with_solution_and_kernel(A, B) @test fl @test X*A == B @test is_zero(K*A) @@ -739,30 +739,30 @@ end A = transpose(matrix(QQ, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(QQ, 2, 1, [1, 3])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B) + @test !can_solve(A, B) + fl, X, K = can_solve_with_solution_and_kernel(A, B) @test !fl A = transpose(zero_matrix(QQ, 2, 3)) B = transpose(identity_matrix(QQ, 3)) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B) + @test_throws ErrorException can_solve_with_solution(A, B) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :garbage) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve(A, B, side = :garbage) + @test_throws ArgumentError can_solve_with_solution(A, B, side = :garbage) + @test_throws ArgumentError can_solve(A, B, side = :garbage) A = matrix(QQ, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(A, side = :right) + K = @inferred kernel(A, side = :right) @test is_zero(A*K) @test ncols(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 0 A = transpose(A) - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 1 end diff --git a/test/flint/fmpz_mat-test.jl b/test/flint/fmpz_mat-test.jl index 455ccdfe2..0a0c1b68d 100644 --- a/test/flint/fmpz_mat-test.jl +++ b/test/flint/fmpz_mat-test.jl @@ -619,7 +619,7 @@ end @test is_snf(snf_diagonal(B)) end -@testset "ZZMatrix.solve_rational" begin +@testset "ZZMatrix._solve_rational" begin S = matrix_space(FlintZZ, 3, 3) A = S([ZZRingElem(2) 3 5; 1 4 7; 9 2 2]) @@ -628,7 +628,7 @@ end B = T([ZZRingElem(4), 5, 7]) - X, d = solve_rational(A, B) + X, d = Nemo._solve_rational(A, B) @test (X, d) == (T([3, -24, 14]), 1) @@ -636,7 +636,7 @@ end @test A*X == B - (Y, k) = solve_dixon(A, B) + (Y, k) = Nemo._solve_dixon(A, B) @test reduce_mod(Y, k) == reduce_mod(X, k) end @@ -650,36 +650,36 @@ end B = T([ZZRingElem(4), 5, 7]) - X = solve(A, B) + X = Nemo._solve(A, B) @test X == T([3, -24, 14]) @test A*X == B - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl && A * X == B A = matrix(ZZ, 2, 2, [1, 0, 0, 0]) B = matrix(ZZ, 2, 2, [0, 0, 0, 1]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - fl, X = cansolve_with_nullspace(A, B) + fl, X = Nemo._cansolve_with_nullspace(A, B) @test !fl A = matrix(ZZ, 2, 2, [1, 0, 0, 0]) B = matrix(ZZ, 2, 2, [0, 1, 0, 0]) - fl, X, Z = cansolve_with_nullspace(A, B) + fl, X, Z = Nemo._cansolve_with_nullspace(A, B) @test fl && A*X == B && iszero(A * Z) A = matrix(ZZ, 2, 2, [1,2,3,4]) b = matrix(ZZ, 1, 2, [1, 6]) - @test Nemo.solve_triu_left(A, b) == matrix(ZZ, 1, 2, [1, 1]) + @test Nemo._solve_triu_left(A, b) == matrix(ZZ, 1, 2, [1, 1]) b = matrix(ZZ, 2, 1, [3, 4]) - @test Nemo.solve_triu(A, b) == matrix(ZZ, 2, 1, [1, 1]) + @test Nemo._solve_triu(A, b) == matrix(ZZ, 2, 1, [1, 1]) b = matrix(ZZ, 2, 1, [1, 7]) c = similar(b) - AbstractAlgebra.solve_tril!(c, A, b) + AbstractAlgebra._solve_tril!(c, A, b) @test c == matrix(ZZ, 2, 1, [1, 1]) end @@ -692,63 +692,63 @@ end B = T([ZZRingElem(4), 5, 7]) - X = AbstractAlgebra.Solve.solve(A, B, side = :right) + X = solve(A, B, side = :right) @test X == T([3, -24, 14]) @test A*X == B - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl && A * X == B A = matrix(ZZ, 2, 2, [1, 0, 0, 0]) B = matrix(ZZ, 2, 2, [0, 0, 0, 1]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test !fl A = matrix(ZZ, 2, 2, [1, 0, 0, 0]) B = matrix(ZZ, 2, 2, [0, 1, 0, 0]) - fl, X, Z = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, Z = can_solve_with_solution_and_kernel(A, B, side = :right) @test fl && A*X == B && iszero(A * Z) # Non-square example A = matrix(ZZ, [1 2 3; 4 5 6]) B = matrix(ZZ, 2, 1, [1, 1]) - fl, x, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, x, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test fl @test A*x == B @test is_zero(A*K) @test ncols(K) + rank(A) == ncols(A) B = matrix(ZZ, 1, 3, [1, 2, 3]) - fl, x, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B) + fl, x, K = can_solve_with_solution_and_kernel(A, B) @test fl @test x*A == B @test is_zero(K*A) @test nrows(K) + rank(A) == nrows(A) A = matrix(ZZ, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(A, side = :right) + K = @inferred kernel(A, side = :right) @test is_zero(A*K) @test ncols(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 0 A = transpose(A) - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(zero_matrix(ZZ, 2, 2), side = :right) + K = @inferred kernel(zero_matrix(ZZ, 2, 2), side = :right) @test ncols(K) == 2 @test hnf(K) == identity_matrix(ZZ, 2) - K = @inferred AbstractAlgebra.Solve.kernel(zero_matrix(ZZ, 2, 2)) + K = @inferred kernel(zero_matrix(ZZ, 2, 2)) @test nrows(K) == 2 @test hnf(K) == identity_matrix(ZZ, 2) end diff --git a/test/flint/fmpz_mod_mat-test.jl b/test/flint/fmpz_mod_mat-test.jl index 160f4c0d6..184b374b3 100644 --- a/test/flint/fmpz_mod_mat-test.jl +++ b/test/flint/fmpz_mod_mat-test.jl @@ -576,13 +576,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) end =# @@ -592,38 +592,38 @@ end a = matrix(Z17, [1 2 3; 3 2 1; 0 0 2]) b = matrix(Z17, [2 1 0 1; 0 0 0 0; 0 1 2 0]) c = a*b - d = AbstractAlgebra.Solve.solve(a, c, side = :right) + d = solve(a, c, side = :right) @test d == b a = zero(a, 3, 3) - @test_throws ArgumentError AbstractAlgebra.Solve.solve(a, c, side = :right) + @test_throws ArgumentError solve(a, c, side = :right) A = matrix(Z17, [1 2 3; 4 5 6]) B = matrix(Z17, 2, 1, [1, 1]) - fl, x, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, x, K = can_solve_with_solution_and_kernel(A, B, side = :right) @test fl @test A*x == B @test is_zero(A*K) @test ncols(K) + rank(A) == ncols(A) B = matrix(Z17, 1, 3, [1, 2, 3]) - fl, x, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B) + fl, x, K = can_solve_with_solution_and_kernel(A, B) @test fl @test x*A == B @test is_zero(K*A) @test nrows(K) + rank(A) == nrows(A) A = matrix(Z17, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(A, side = :right) + K = @inferred kernel(A, side = :right) @test is_zero(A*K) @test ncols(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 0 A = transpose(A) - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 1 end diff --git a/test/flint/fq_default_mat-test.jl b/test/flint/fq_default_mat-test.jl index bdf6e700b..60852f7a9 100644 --- a/test/flint/fq_default_mat-test.jl +++ b/test/flint/fq_default_mat-test.jl @@ -564,13 +564,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) for i in 1:10 m = rand(0:10) @@ -583,7 +583,7 @@ end A = rand(M) B = rand(N) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) if fl @test A * X == B @@ -592,54 +592,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException can_solve_with_solution(A, B) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - @test !can_solve(A, B, side = :left) + @test !Nemo._can_solve(A, B, side = :left) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException can_solve_with_solution(A, B, side = :left) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :left) - @test_throws ErrorException can_solve_with_solution(A, B, side = :garbage) - @test_throws ErrorException can_solve(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve(A, B, side = :garbage) end @testset "FqMatrix.Solve.solve" begin @@ -653,13 +653,13 @@ end c = a*b - d = AbstractAlgebra.Solve.solve(a, c, side = :right) + d = solve(a, c, side = :right) @test d == b a = zero(R) - @test_throws ArgumentError AbstractAlgebra.Solve.solve(a, c, side = :right) + @test_throws ArgumentError solve(a, c, side = :right) for i in 1:10 m = rand(0:10) @@ -672,7 +672,7 @@ end A = rand(M) B = rand(N) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) if fl @test A * X == B @@ -683,54 +683,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + @test_throws ErrorException can_solve_with_solution(A, B, side = :right) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B) + @test !can_solve(A, B) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B) + @test_throws ErrorException can_solve_with_solution(A, B) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :garbage) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve(A, B, side = :garbage) + @test_throws ArgumentError can_solve_with_solution(A, B, side = :garbage) + @test_throws ArgumentError can_solve(A, B, side = :garbage) end @testset "FqMatrix.lu" begin diff --git a/test/flint/fq_mat-test.jl b/test/flint/fq_mat-test.jl index 9595251f2..c18ce2dff 100644 --- a/test/flint/fq_mat-test.jl +++ b/test/flint/fq_mat-test.jl @@ -552,13 +552,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) for i in 1:10 m = rand(0:10) @@ -571,7 +571,7 @@ end A = rand(M) B = rand(N) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) if fl @test A * X == B @@ -580,54 +580,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException can_solve_with_solution(A, B) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - @test !can_solve(A, B, side = :left) + @test !Nemo._can_solve(A, B, side = :left) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException can_solve_with_solution(A, B, side = :left) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :left) - @test_throws ErrorException can_solve_with_solution(A, B, side = :garbage) - @test_throws ErrorException can_solve(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve(A, B, side = :garbage) end @testset "FqPolyRepMatrix.Solve.solve" begin @@ -641,13 +641,13 @@ end c = a*b - d = AbstractAlgebra.Solve.solve(a, c, side = :right) + d = solve(a, c, side = :right) @test d == b a = zero(R) - @test_throws ArgumentError AbstractAlgebra.Solve.solve(a, c, side = :right) + @test_throws ArgumentError solve(a, c, side = :right) for i in 1:10 m = rand(0:10) @@ -660,7 +660,7 @@ end A = rand(M) B = rand(N) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) if fl @test A * X == B @@ -671,54 +671,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test !can_solve(A, B, side = :right) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + @test_throws ErrorException can_solve_with_solution(A, B, side = :right) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B) + @test !can_solve(A, B) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B) + @test_throws ErrorException can_solve_with_solution(A, B) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :garbage) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve(A, B, side = :garbage) + @test_throws ArgumentError can_solve_with_solution(A, B, side = :garbage) + @test_throws ArgumentError can_solve(A, B, side = :garbage) end @testset "FqPolyRepMatrix.lu" begin diff --git a/test/flint/fq_nmod_mat-test.jl b/test/flint/fq_nmod_mat-test.jl index 89b186198..a26526834 100644 --- a/test/flint/fq_nmod_mat-test.jl +++ b/test/flint/fq_nmod_mat-test.jl @@ -552,13 +552,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) for i in 1:10 m = rand(0:10) @@ -571,7 +571,7 @@ end A = rand(M) B = rand(N) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) if fl @test A * X == B @@ -580,54 +580,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException can_solve_with_solution(A, B) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - @test !can_solve(A, B, side = :left) + @test !Nemo._can_solve(A, B, side = :left) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException can_solve_with_solution(A, B, side = :left) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :left) - @test_throws ErrorException can_solve_with_solution(A, B, side = :garbage) - @test_throws ErrorException can_solve(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve(A, B, side = :garbage) end @testset "fqPolyRepMatrix.Solve.solve" begin @@ -641,13 +641,13 @@ end c = a*b - d = AbstractAlgebra.Solve.solve(a, c, side = :right) + d = solve(a, c, side = :right) @test d == b a = zero(R) - @test_throws ArgumentError AbstractAlgebra.Solve.solve(a, c, side = :right) + @test_throws ArgumentError solve(a, c, side = :right) for i in 1:10 m = rand(0:10) @@ -660,7 +660,7 @@ end A = rand(M) B = rand(N) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) if fl @test A * X == B @@ -671,54 +671,54 @@ end A = matrix(F17, 2, 2, [1, 2, 2, 5]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(F17, 2, 2, [1, 2, 2, 4]) B = matrix(F17, 2, 1, [1, 3]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test !can_solve(A, B, side = :right) A = zero_matrix(F17, 2, 3) B = identity_matrix(F17, 3) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + @test_throws ErrorException can_solve_with_solution(A, B, side = :right) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(F17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(F17, 2, 1, [1, 3])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B) + @test !can_solve(A, B) A = transpose(zero_matrix(F17, 2, 3)) B = transpose(identity_matrix(F17, 3)) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B) + @test_throws ErrorException can_solve_with_solution(A, B) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :garbage) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve(A, B, side = :garbage) + @test_throws ArgumentError can_solve_with_solution(A, B, side = :garbage) + @test_throws ArgumentError can_solve(A, B, side = :garbage) end @testset "fqPolyRepMatrix.lu" begin diff --git a/test/flint/gfp_mat-test.jl b/test/flint/gfp_mat-test.jl index aaf5cb9cf..0364503f5 100644 --- a/test/flint/gfp_mat-test.jl +++ b/test/flint/gfp_mat-test.jl @@ -603,13 +603,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) for i in 1:10 m = rand(0:10) @@ -622,7 +622,7 @@ end A = rand(M) B = rand(N) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) if fl @test A * X == B @@ -631,54 +631,54 @@ end A = matrix(Z17, 2, 2, [1, 2, 2, 5]) B = matrix(Z17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(Z17, 2, 2, [1, 2, 2, 4]) B = matrix(Z17, 2, 1, [1, 2]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test fl @test A * X == B - @test can_solve(A, B) + @test Nemo._can_solve(A, B) A = matrix(Z17, 2, 2, [1, 2, 2, 4]) B = matrix(Z17, 2, 1, [1, 3]) - fl, X = can_solve_with_solution(A, B) + fl, X = Nemo._can_solve_with_solution(A, B) @test !fl - @test !can_solve(A, B) + @test !Nemo._can_solve(A, B) A = zero_matrix(Z17, 2, 3) B = identity_matrix(Z17, 3) - @test_throws ErrorException can_solve_with_solution(A, B) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(Z17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(Z17, 2, 1, [1, 2])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test fl @test X * A == B - @test can_solve(A, B, side = :left) + @test Nemo._can_solve(A, B, side = :left) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(Z17, 2, 1, [1, 3])) - fl, X = can_solve_with_solution(A, B, side = :left) + fl, X = Nemo._can_solve_with_solution(A, B, side = :left) @test !fl - @test !can_solve(A, B, side = :left) + @test !Nemo._can_solve(A, B, side = :left) A = transpose(zero_matrix(Z17, 2, 3)) B = transpose(identity_matrix(Z17, 3)) - @test_throws ErrorException can_solve_with_solution(A, B, side = :left) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :left) - @test_throws ErrorException can_solve_with_solution(A, B, side = :garbage) - @test_throws ErrorException can_solve(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve_with_solution(A, B, side = :garbage) + @test_throws ErrorException Nemo._can_solve(A, B, side = :garbage) end @testset "fpMatrix.Solve.solve" begin @@ -692,13 +692,13 @@ end c = a*b - d = AbstractAlgebra.Solve.solve(a, c, side = :right) + d = solve(a, c, side = :right) @test d == b a = zero(R) - @test_throws ArgumentError AbstractAlgebra.Solve.solve(a, c, side = :right) + @test_throws ArgumentError solve(a, c, side = :right) for i in 1:10 m = rand(0:10) @@ -711,7 +711,7 @@ end A = rand(M) B = rand(N) - fl, X, K = AbstractAlgebra.Solve.can_solve_with_solution_and_kernel(A, B, side = :right) + fl, X, K = can_solve_with_solution_and_kernel(A, B, side = :right) if fl @test A * X == B @@ -722,66 +722,66 @@ end A = matrix(Z17, 2, 2, [1, 2, 2, 5]) B = matrix(Z17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(Z17, 2, 2, [1, 2, 2, 4]) B = matrix(Z17, 2, 1, [1, 2]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test fl @test A * X == B - @test AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test can_solve(A, B, side = :right) A = matrix(Z17, 2, 2, [1, 2, 2, 4]) B = matrix(Z17, 2, 1, [1, 3]) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + fl, X = can_solve_with_solution(A, B, side = :right) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B, side = :right) + @test !can_solve(A, B, side = :right) A = zero_matrix(Z17, 2, 3) B = identity_matrix(Z17, 3) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :right) + @test_throws ErrorException can_solve_with_solution(A, B, side = :right) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 5])) B = transpose(matrix(Z17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(Z17, 2, 1, [1, 2])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test fl @test X * A == B - @test AbstractAlgebra.Solve.can_solve(A, B) + @test can_solve(A, B) A = transpose(matrix(Z17, 2, 2, [1, 2, 2, 4])) B = transpose(matrix(Z17, 2, 1, [1, 3])) - fl, X = AbstractAlgebra.Solve.can_solve_with_solution(A, B) + fl, X = can_solve_with_solution(A, B) @test !fl - @test !AbstractAlgebra.Solve.can_solve(A, B) + @test !can_solve(A, B) A = transpose(zero_matrix(Z17, 2, 3)) B = transpose(identity_matrix(Z17, 3)) - @test_throws ErrorException AbstractAlgebra.Solve.can_solve_with_solution(A, B) + @test_throws ErrorException can_solve_with_solution(A, B) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve_with_solution(A, B, side = :garbage) - @test_throws ArgumentError AbstractAlgebra.Solve.can_solve(A, B, side = :garbage) + @test_throws ArgumentError can_solve_with_solution(A, B, side = :garbage) + @test_throws ArgumentError can_solve(A, B, side = :garbage) A = matrix(Z17, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(A, side = :right) + K = @inferred kernel(A, side = :right) @test is_zero(A*K) @test ncols(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 0 A = transpose(A) - K = @inferred AbstractAlgebra.Solve.kernel(A) + K = @inferred kernel(A) @test is_zero(K*A) @test nrows(K) == 1 end diff --git a/test/flint/nmod_mat-test.jl b/test/flint/nmod_mat-test.jl index acec75061..1a81bebaf 100644 --- a/test/flint/nmod_mat-test.jl +++ b/test/flint/nmod_mat-test.jl @@ -606,13 +606,13 @@ end c = a*b - d = solve(a,c) + d = Nemo._solve(a,c) @test d == b a = zero(R) - @test_throws ErrorException solve(a,c) + @test_throws ErrorException Nemo._solve(a,c) end @testset "zzModMatrix.lu" begin @@ -837,16 +837,16 @@ end R, _ = residue_ring(ZZ, 17) M = matrix(R, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(M, side = :right) + K = @inferred kernel(M, side = :right) @test is_zero(M*K) @test ncols(K) == 1 - K = @inferred AbstractAlgebra.Solve.kernel(M) + K = @inferred kernel(M) @test is_zero(K*M) @test nrows(K) == 0 M = transpose(M) - K = @inferred AbstractAlgebra.Solve.kernel(M) + K = @inferred kernel(M) @test is_zero(K*M) @test nrows(K) == 1 @@ -854,25 +854,25 @@ end R, _ = residue_ring(ZZ, 18) M = matrix(R, [ 1 2 3 ; 4 5 6 ]) - K = @inferred AbstractAlgebra.Solve.kernel(M, side = :right) + K = @inferred kernel(M, side = :right) @test is_zero(M*K) @test ncols(K) == 2 - K = @inferred AbstractAlgebra.Solve.kernel(M) + K = @inferred kernel(M) @test is_zero(K*M) @test nrows(K) == 1 M = transpose(M) - K = @inferred AbstractAlgebra.Solve.kernel(M) + K = @inferred kernel(M) @test is_zero(K*M) @test nrows(K) == 2 M = identity_matrix(R, 2) - K = @inferred AbstractAlgebra.Solve.kernel(M, side = :right) + K = @inferred kernel(M, side = :right) @test is_zero(M*K) @test ncols(K) == 0 - K = @inferred AbstractAlgebra.Solve.kernel(M) + K = @inferred kernel(M) @test is_zero(K*M) @test nrows(K) == 0 end diff --git a/test/generic/Matrix-test.jl b/test/generic/Matrix-test.jl index 4a1ab1b3d..a703ae74e 100644 --- a/test/generic/Matrix-test.jl +++ b/test/generic/Matrix-test.jl @@ -91,8 +91,8 @@ end M = randmat_with_rank(S, dim, -100:100) b = rand(T, -100:100) - if isdefined(Generic, :can_solve_with_solution_fflu) - flag, x, d = Generic.can_solve_with_solution_fflu(M, b) + if isdefined(Generic, :_can_solve_with_solution_fflu) + flag, x, d = Generic._can_solve_with_solution_fflu(M, b) @test flag else x, d = Generic.solve_fflu(M, b) @@ -113,8 +113,8 @@ end M = randmat_with_rank(S, dim, -100:100) b = rand(T, -100:100) - if isdefined(Generic, :can_solve_with_solution_lu) - flag, x = Generic.can_solve_with_solution_lu(M, b) + if isdefined(Generic, :_can_solve_with_solution_lu) + flag, x = Generic._can_solve_with_solution_lu(M, b) @test flag else x = Generic.solve_lu(M, b) @@ -135,7 +135,7 @@ end M = randmat_triu(S, -100:100) b = rand(U, -100:100) - x = solve_triu(M, b, false) + x = AbstractAlgebra._solve_triu(M, b, false) @test M*x == b end