Skip to content

Commit

Permalink
triu M>N case bugfix
Browse files Browse the repository at this point in the history
(cherry picked from commit dcf0eae)

fix a typo

(cherry picked from commit 1b030b2)
  • Loading branch information
GiggleLiu authored and KristofferC committed Feb 11, 2019
1 parent b48fedb commit 71bd548
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ julia> triu!(M, 1)
function triu!(M::AbstractMatrix, k::Integer)
@assert !has_offset_axes(M)
m, n = size(M)
for j in 1:min(n, n + k)
for j in 1:min(n, m + k)
for i in max(1, j - k + 1):m
M[i,j] = zero(M[i,j])
end
Expand Down
12 changes: 12 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ end # for eltya
end
end

@testset "triu M > N case bug fix" begin
mat=[1 2;
3 4;
5 6;
7 8]
res=[1 2;
3 4;
0 6;
0 0]
@test triu(mat, -1) == res
end

@testset "Tests norms" begin
nnorm = 10
mmat = 10
Expand Down

0 comments on commit 71bd548

Please sign in to comment.