-
Notifications
You must be signed in to change notification settings - Fork 56
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
Introduces renormalized Hermite Polynomials #108
Conversation
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
==========================================
+ Coverage 97.74% 97.95% +0.21%
==========================================
Files 12 12
Lines 885 978 +93
==========================================
+ Hits 865 958 +93
Misses 20 20
Continue to review full report at Codecov.
|
This PR addresses #86 |
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.
Really cool! Not sure if this is ready yet, but it looks like it's still missing C++ and Python tests.
Also, don't forget to run ASTYLE on the C++ code! (it's the C++ formatter we were using)
for (int i = 1; i < n; i++) | ||
x[i] = x[i-1]*base; | ||
eg::Matrix<T, eg::Dynamic, eg::Dynamic> R = eg::Map<eg::Matrix<T, eg::Dynamic, eg::Dynamic>, eg::Unaligned>(R_mat.data(), dim, dim); | ||
eg::Matrix<T, eg::Dynamic, eg::Dynamic> y = eg::Map<eg::Matrix<T, eg::Dynamic, eg::Dynamic>, eg::Unaligned>(y_mat.data(), dim, dim); |
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.
Just out of curiousity, do these two variables R
and y
need to be eigen matrices? I scanned through the code below, and couldn't see a spot that uses eigen methods (unless I missed it)
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.
You are correct. Eigen is not used here, at all.
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.
Might get even faster then by avoiding this conversion 😆
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 might be worth checking...
Co-Authored-By: Josh Izaac <josh146@gmail.com>
Co-Authored-By: Josh Izaac <josh146@gmail.com>
Co-Authored-By: Josh Izaac <josh146@gmail.com>
Hey Josh --- The new functions reuse the tests from the old functions so no new test are needed. IN a way I am just replacing existing functionality with much better implementations. |
|
||
for (int i = 0; i < res; i++) | ||
expected_re[i*res+i] = pow(0.5, static_cast<double>(i)/2.0); | ||
|
||
out = libwalrus::hermite_multidimensional_cpp(B, d, res, renorm); | ||
out = libwalrus::renorm_hermite_multidimensional_cpp(B, d, res); |
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.
here we test the new renorm_hermite_multidimensional_cpp
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.
Awesome 👍
The only question I have left is with respect to the Python tests (since they don't show up in this PR). But I suppose the Python tests were already testing both renorm=True
and renorm=False
, so nothing is needed to be added there?
Exactly! For example all the test in |
This PR removes the extra parameter renorm from the
hermite_multimendional_cpp
and instead introduce a newrenorm_hermite_multimendional_cpp
. These new polynomials are given by rH^B_n(y) = H^B_n(y)/\sqrt(n!). Instead of calculating the ratio of H^B_n(y) and \sqrt(n!) the renormalized polynomials use a modified recursion relation that avoids overflows. At the same the renormalized polynomials are faster to calculate than the regular polynomials + dividing by factorials thus speeding upstate_vector
,density_matrix
,fock_tensor
and all the functions infock_gradients
.