Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove solve_triu and solve_triu_left for RingElem #1661

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3306,78 +3306,6 @@ function _solve_triu(U::MatElem{T}, b::MatElem{T}, unit::Bool = false) where {T
return X
end

@doc raw"""
_solve_triu(U::MatElem{T}, b::MatElem{T}) where {T <: RingElement}

Given a non-singular $n\times n$ matrix $U$ over a field which is upper
triangular, and an $n\times m$ matrix $b$ over the same ring, return an
$n\times m$ matrix $x$ such that $Ux = b$. If this is not possible, an error
will be raised.

See also [`_solve_triu_left`](@ref).
"""
function _solve_triu(U::MatElem{T}, b::MatElem{T}) where {T <: RingElement}
n = nrows(U)
m = ncols(b)
R = base_ring(U)
X = zero(b)
tmp = Vector{elem_type(R)}(undef, n)
t = R()
for i = 1:m
for j = 1:n
tmp[j] = X[j, i]
end
for j = n:-1:1
s = R(0)
for k = j + 1:n
s = addmul!(s, U[j, k], tmp[k], t)
end
s = b[j, i] - s
tmp[j] = divexact(s, U[j,j])
end
for j = 1:n
X[j, i] = tmp[j]
end
end
return X
end

@doc raw"""
_solve_triu_left(b::MatElem{T}, U::MatElem{T}) where {T <: RingElement}

Given a non-singular $n\times n$ matrix $U$ over a field which is upper
triangular, and an $m\times n$ matrix $b$ over the same ring, return an
$m\times n$ matrix $x$ such that $xU = b$. If this is not possible, an error
will be raised.

See also [`_solve_triu`](@ref).
"""
function _solve_triu_left(b::MatElem{T}, U::MatElem{T}) where {T <: RingElement}
n = ncols(U)
m = nrows(b)
R = base_ring(U)
X = zero(b)
tmp = Vector{elem_type(R)}(undef, n)
t = R()
for i = 1:m
for j = 1:n
tmp[j] = X[i, j]
end
for j = 1:n
s = R()
for k = 1:j-1
s = addmul!(s, U[k, j], tmp[k], t)
end
s = b[i, j] - s
tmp[j] = divexact(s, U[j,j])
end
for j = 1:n
X[i, j] = tmp[j]
end
end
return X
end

#solves A x = B for A intended to be lower triangular
#only the lower part is used. if f is true, then the diagonal is assumed to be 1
#used to use lu!
Expand Down
23 changes: 0 additions & 23 deletions test/generic/Matrix-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2637,29 +2637,6 @@ end

@test M*x == b
end

for dim = 0:10
S = matrix_space(R, dim, dim)
U = matrix_space(R, dim, rand(1:5))

M = randmat_triu(S, 3, -10:10)
b = rand(U, 3, -10:10)
c = M*b

x = AbstractAlgebra._solve_triu(M, c)

@test M*x == c

V = matrix_space(R, rand(1:5), dim)

M = randmat_triu(S, 3, -10:10)
b = rand(V, 3, -10:10)
c = b*M

x = AbstractAlgebra._solve_triu_left(c, M)

@test x*M == c
end
end

@testset "Generic.Mat.rref" begin
Expand Down
Loading