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

[BUG] triu returns wrong matrix when M<N and k<0 #29711

Closed
GiggleLiu opened this issue Oct 18, 2018 · 1 comment
Closed

[BUG] triu returns wrong matrix when M<N and k<0 #29711

GiggleLiu opened this issue Oct 18, 2018 · 1 comment

Comments

@GiggleLiu
Copy link
Contributor

GiggleLiu commented Oct 18, 2018

When I intended to implement rq decomposition, I finded this bug in triu! function by accident.
When the input matrix size (M, N) with M>N, for k<0, the following behavior is not correct

e.g.

julia> mat=[1 2;
            3 4;
            5 6;
            7 8]
4×2 Array{Int64,2}:
 1  2
 3  4
 5  6
 7  8

julia> triu!(mat, -1)
4×2 Array{Int64,2}:
 1  2
 3  4
 0  6
 0  8

which is wrong, it should be

[1 2;
 3 4;
 0 6;
 0 0]

Here, min(n, n + k) should be replaced by min(n, m + k)

for j in 1:min(n, n + k)

A PR is ready to fix this.

@staticfloat
Copy link
Member

Closed by #29712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants