-
Notifications
You must be signed in to change notification settings - Fork 419
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 isEye and isZero to the Linear Algebra module. #22695
Conversation
Signed-off-by: Iain Moncrief <[email protected]>
Signed-off-by: Iain Moncrief <[email protected]>
Signed-off-by: Iain Moncrief <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall, I just have a few questions:
return _isZero(A); | ||
} | ||
|
||
private proc _isZero(A: [?D] ?eltType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you have a separate implementation and public proc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the implicit convention that I saw. Such as
/* Return `true` if matrix is diagonal. */
proc isDiag(A: [?D] ?eltType) where isDenseMatrix(A) {
return _isDiag(A);
}
private proc _isDiag(A: [?D] ?eltType) {
if D.rank != 2 then
compilerError("Rank is not 2");
// Check if any element not along the diagonal is nonzero
for (i, j) in D {
if i != j && A[i, j] != 0 then return false;
}
return true;
}
where _isDiag
is used in two different functions, one for dense matrices and one for sparse matrices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that makes sense. I suspect other procs do it this way so that sparse and dense versions can use the same underlying implementation. I'd keep it this way.
Signed-off-by: Iain Moncrief <[email protected]>
Relevant issue:
#22682
It was pointed out that we should have
isZero
andisEye
methods in the Linear Algebra module. This PR adds these.Added two
isEye
andisZero
to the linear algebra module.