-
Notifications
You must be signed in to change notification settings - Fork 21
Direct L2 norm computation with Psydac inner products (no NumPy conversion) #514
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
base: devel
Are you sure you want to change the base?
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
|
@anushkasinghh If this PR is ready, you should request potential reviewers. In general you can choose |
campospinto
left a comment
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.
The changes look good to me, but I don't find the PR title very clear. Instead of describing the changes as a refactor of to array, you should mention the direct computation of array l2 norms using psydac inner products avoiding conversions to numpy arrays. I guess that the point is to save time, did you observe some gain ?
|
I ran the tests before and after the change, and the times are almost the same — around 170 seconds in both cases. The small differences I saw (a few tenths of a second) are just normal fluctuations, so there’s no real speedup. |
| bi12 = B_ILO @ u | ||
| bi22 = B_ILO @ bi12 | ||
|
|
||
| assert norm2((B @ bi12) - u) < tol | ||
| assert norm2((B @ bi22) - bi12 ) < error_est * tol |
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.
We want to test the interaction of a PowerLinearOperator with a InverseLinearOperator here, so we have to check whether bi1 and bi2 have been computed correctly.
| bi12 = B_ILO @ u | |
| bi22 = B_ILO @ bi12 | |
| assert norm2((B @ bi12) - u) < tol | |
| assert norm2((B @ bi22) - bi12 ) < error_est * tol | |
| assert norm2((B @ bi1) - u) < tol | |
| assert norm2((B @ B @ bi2) - u) < error_est * tol |
| si12 = S_ILO @ v | ||
| si22 = S_ILO @ si12 | ||
|
|
||
| assert norm2((S @ si12) - v) < tol | ||
| assert norm2( (S @ si22) - si12 ) < error_est * tol |
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.
Same thing here
| si12 = S_ILO @ v | |
| si22 = S_ILO @ si12 | |
| assert norm2((S @ si12) - v) < tol | |
| assert norm2( (S @ si22) - si12 ) < error_est * tol | |
| assert norm2((S @ si1) - v) < tol | |
| assert norm2((S @ S @ si22) - si2) < error_est * tol |
| assert norm2(v- i0) < 1e-10 | ||
| assert norm2(v - i1) <1e-10 | ||
| assert norm2(v - i2) < 1e-10 |
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.
| assert norm2(v- i0) < 1e-10 | |
| assert norm2(v - i1) <1e-10 | |
| assert norm2(v - i2) < 1e-10 | |
| assert norm2(v - i0) < 1e-10 | |
| assert norm2(v - i1) < 1e-10 | |
| assert norm2(v - i2) < 1e-10 |
| assert norm2((u_approx - u)) < tol | ||
| assert norm2( (v_approx - v)) < tol |
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.
| assert norm2((u_approx - u)) < tol | |
| assert norm2( (v_approx - v)) < tol | |
| assert norm2((u_approx - u)) < tol | |
| assert norm2((v_approx - v)) < tol |
| assert norm2((S @ xs_cg - v)) < tol | ||
| assert norm2( (S @ xs_pcg - v)) < tol | ||
| assert norm2((S @ xs_bicg - v)) < tol |
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.
| assert norm2((S @ xs_cg - v)) < tol | |
| assert norm2( (S @ xs_pcg - v)) < tol | |
| assert norm2((S @ xs_bicg - v)) < tol | |
| assert norm2((S @ xs_cg - v)) < tol | |
| assert norm2((S @ xs_pcg - v)) < tol | |
| assert norm2((S @ xs_bicg - v)) < tol |
| assert (norm2( y1_1- y1_2 ) < 1e-10) & (norm2( y1_2 - y1_3) < 1e-10) | ||
| assert (norm2( y2_1 - y2_2 ) < 1e-10) & (norm2( y2_2 - y2_3) < 1e-10) |
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.
| assert (norm2( y1_1- y1_2 ) < 1e-10) & (norm2( y1_2 - y1_3) < 1e-10) | |
| assert (norm2( y2_1 - y2_2 ) < 1e-10) & (norm2( y2_2 - y2_3) < 1e-10) | |
| assert (norm2(y1_1 - y1_2) < 1e-10) & (norm2(y1_2 - y1_3) < 1e-10) | |
| assert (norm2(y2_1 - y2_2) < 1e-10) & (norm2(y2_2 - y2_3) < 1e-10) |
|
Hey @anushkasinghh, I added a few suggestions. Most of them are just cosmetics, but the |
Use np.sqrt instead of np.ToArray which reduces the computation time while asserting tolerance.
Will solve issue #492 when merged