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

Added chktrans macro, test, and several bugfixes for gesvx #11946

Merged
merged 1 commit into from
Jul 1, 2015

Conversation

kshyatt
Copy link
Contributor

@kshyatt kshyatt commented Jun 30, 2015

LAPACK requires that trans be one of N, T, or C. We had a macro to check a similar condition for uplo, and I've added one for trans.

I also added a test for gesvx, which had several bugs. I increased the size of iwork in the real methods because the shorter version was intermittently segfaulting and this seems to have fixed the issue over ~20 runs. x should have been X in the complex version of the method.

@kshyatt kshyatt added test This change adds or pertains to unit tests domain:linear algebra Linear algebra labels Jun 30, 2015
@@ -657,6 +667,7 @@ for (gesvx, elty) in
function gesvx!(fact::Char, trans::Char, A::StridedMatrix{$elty},
AF::StridedMatrix{$elty}, ipiv::Vector{BlasInt}, equed::Char,
R::Vector{$elty}, C::Vector{$elty}, B::StridedVecOrMat{$elty})
@chktrans
lda, n = size(A)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct when A is a SubArray. It should be lda=stride(A,2). The same is true for the calculations of the leading dimensions below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I hadn't checked those lines with a SubArray. I will update them and resubmit the PR. Thanks for the catch! I suspect this is pretty old code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but it is also a bit uncertain how robust our linear algebra code is for SubArrays. Unfortunately, we cannot really capture that with CodeCoverage.

@andreasnoack
Copy link
Member

This is great. As mentioned in the code comment, it would be great if could be verified if we have an error or if the LAPACK documentation has an error here.

macro chktrans()
:((trans=='N' || trans=='C' || trans=='T') ||
throw(ArgumentError(string("trans argument must be 'N' (no transpose), 'T' (transpose), or 'C' (conjugate transpose), got ", repr(trans)))))
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any specific reason trans is not passed in as a parameter and/or make this a function?

I don't think implicitly referencing a variable name is a great idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to match chkuplo. If others feel it should be changed, to match chksquare for instance, I'm happy to do so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote chkuplo a long time ago as one of my first macros. It shouldn't be considered sacred by any means.

I tried passing in the variable name as a parameter in chkuplo in a previous try, but it didn't work for me. I think there were things I didn't escape and quote correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to change both chktrans and chkuplo to functions as part of this PR 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if function or macro is better but explicit variable name should be perferred unless there's a good reason for not doing that.

There's also a few other macros above which implicitly refering info. Might worth changing as well if others do not have trouble with them. (either in this PR or a different one should be fine).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be my guest!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also nothing similar for the diag or side arguments which many functions need so I'll add that function in too.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 30, 2015

PR updated! This passed make test-linalg locally so hopefully I haven't ruined everything.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 30, 2015

The Win64 parallel bug strikes again. Does this updated PR look ok to everyone?

@tkelman
Copy link
Contributor

tkelman commented Jun 30, 2015

Looks like you changed one of the 4n to 2n, but not the one on which #11946 (comment) was commented?

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 30, 2015

work is supposed to have length max(1,2n) for Complex types, and length max(1,4n) for Real types. Looking at my local copy this seems to be what I have now?

@tkelman
Copy link
Contributor

tkelman commented Jun 30, 2015

If that's the case then it looks like your code is right, the comment was in the wrong place.

kshyatt added a commit that referenced this pull request Jul 1, 2015
Added chktrans macro, test, and several bugfixes for gesvx
@kshyatt kshyatt merged commit e063f77 into master Jul 1, 2015
@kshyatt kshyatt deleted the ksh/lapack branch July 1, 2015 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:linear algebra Linear algebra test This change adds or pertains to unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants