-
Notifications
You must be signed in to change notification settings - Fork 49
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
CeedMatrixPseudoinverse utility function #1251
Conversation
52d813a
to
cc3a690
Compare
This is looking good. We now need to use this utility in a few places to cut repeated code. I think the two places to update are |
c0d7027
to
35f2864
Compare
35f2864
to
1c90ed1
Compare
77beca1
to
98d5678
Compare
I don't understand the rust failure. How can I fix it? |
The rust test is saying that the incorrect numerical result was computed, so the pesudoinverse probably isn't right in that case |
Hmm, so how the other tests are fine and rust is not? I checked only with
|
I'd start by seeing if there are any differences between how the Rust test t501 is written vs the C version of the test. It's possible it has a slightly different setup. The Rust tests allow less memory misbehavior on our part, so I'm inclined to trust them when they say something went wrong. |
I see, I checked the pseudoinverse with python. For example CeedScalar A[12] = {1, -1, 4, 1, 4, -2, 1, 4, 2, 1, -1, 0};
CeedScalar A_inv[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
CeedCall(CeedMatrixPseudoinverse(ceed, A, 4, 3, A_inv));
for (CeedInt i =0; i < 12; i++) printf("A_inv[%d]=%f\n", i, A_inv[i]); gives
which is exactly the same as python
so maybe we have memory/size issue in the middle of the code but result is correct. |
1312e88
to
15b6bb3
Compare
Now the error is clear
|
So this gave us a mild degradation in accuracy on this test case, but not enough to be worried. I'd say we bump the tolerance to |
Yeah. I'll update that. |
@jeremylt Do I need to update
in operator.rs to
? |
Probably. And the t501 in main should probably use CeedEpsilon too |
I'll make small PR for that. |
4d97cc7
to
8264405
Compare
9737bf6
to
2bdad50
Compare
2bdad50
to
2a7d7e7
Compare
This is needed but may not fix the Rust issue. There shouldn't be any problem with any slice from raw parts and I can't reproduce that locally $ git diff
diff --git a/examples/rust/ex1-volume/src/main.rs b/examples/rust/ex1-volume/src/main.rs
index ca755438..ed22b9fb 100644
--- a/examples/rust/ex1-volume/src/main.rs
+++ b/examples/rust/ex1-volume/src/main.rs
@@ -247,7 +247,7 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> {
);
}
let tolerance = match dim {
- 1 => 100.0 * libceed::EPSILON,
+ 1 => 500.0 * libceed::EPSILON,
_ => 1E-5,
};
let error = (volume - exact_volume).abs(); |
2a7d7e7
to
9e90ab8
Compare
Well, Rust is doing some crappy misbehavior I haven't been able to identify yet |
Its happening on a different branch too, so the Rust issue isn't related to this branch and is something that happened to the nightly toolchain |
Possibly another solution (though I'm not sure how feasible it would be) is to detect whether the projection should result in an identity matrix and, if it should, just return an identity matrix. Determining that ahead of time while not limiting ourselves to nodal basis functions might be a bit challenging. The other option would be verifying identity after matrix-matrix multiply, but that might be just as ad-hoc as forcing small values to zero. |
I'm a bit surprised by that. Aren't those matrices created by CPU code, not the GPU? Or is the PseudoInverse code also used for generating those projection matrices? |
Do I still need this change? |
The pesudoinverse is use in the core of the library to create the projection matrices. The new computations are in this weird place where they are not different enough to cause appreciable differences on the CPU but they do create differences on the GPU, likely due to slightly different algebra on the machine to apply the basis matrices |
Co-authored-by: Jeremy L Thompson <[email protected]>
I think so, yea |
9e90ab8
to
e882c02
Compare
I don't know why |
Its a minor change and codecov is flaky, so I think we can ignore it |
Cool, so I merge it. |
Oh, I misread the earlier message to be that the interpolation matrices themselves had slightly different values. This makes more sense. |
See #1250