Skip to content

Fix LAPACK.posv! tests #1192

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

Merged
merged 2 commits into from
Feb 3, 2025
Merged

Fix LAPACK.posv! tests #1192

merged 2 commits into from
Feb 3, 2025

Conversation

dkarrasch
Copy link
Member

The test failures are, unsurprisingly, related to high condition numbers, as can be seen from running the tests many times in a loop and displaying the condition number. We could set an appropriate relative tolerance in the test below, or find a random seed that works. I tried the second option here.

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.95%. Comparing base (c9ad828) to head (5c9cebd).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1192      +/-   ##
==========================================
+ Coverage   91.89%   91.95%   +0.06%     
==========================================
  Files          34       34              
  Lines       15360    15360              
==========================================
+ Hits        14115    14125      +10     
+ Misses       1245     1235      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dkarrasch dkarrasch changed the title Fix random seed in LAPACK.posv! tests Fix LAPACK.posv! tests Feb 3, 2025
@ViralBShah ViralBShah merged commit e7da19f into master Feb 3, 2025
4 checks passed
@ViralBShah ViralBShah deleted the dk/posv-failure branch February 3, 2025 14:52
@ViralBShah
Copy link
Member

The condition number of the randn generated matrices jumps around a fair bit - no doubt because we are squaring. The scaling should greatly help.

@alanedelman
Copy link
Contributor

yehh randn when squared will produce condition numbers of order n^2, von Neumann fell into this trap decades ago, leading to the belief that finite precision could be dreadful on these new machines that were being called computers.
Of course you can generate Q'DQ with any positive diagonal D you like and a random Q. If speed is a concern we can be more clever, and LAPACK probably has such routines, but quick and dirty is to use Q=Matrix(qr(randn(n,n)).Q)
which is O(n^3) (there are O(n^2) ways)

@ViralBShah
Copy link
Member

ViralBShah commented Feb 3, 2025

julia> for i=1:10 
            Q=Matrix(qr(randn(n,n)).Q);
            @show cond(Q'*Diagonal(rand(n))*Q)
       end
cond(Q' * Diagonal(rand(n)) * Q) = 54.84525143924938
cond(Q' * Diagonal(rand(n)) * Q) = 68.73534833441128
cond(Q' * Diagonal(rand(n)) * Q) = 96.3033669626725
cond(Q' * Diagonal(rand(n)) * Q) = 87.56679319167324
cond(Q' * Diagonal(rand(n)) * Q) = 66255.80209047809
cond(Q' * Diagonal(rand(n)) * Q) = 41.302179179853
cond(Q' * Diagonal(rand(n)) * Q) = 45.178741706939526
cond(Q' * Diagonal(rand(n)) * Q) = 164.87644137765756
cond(Q' * Diagonal(rand(n)) * Q) = 93.56871249448481
cond(Q' * Diagonal(rand(n)) * Q) = 257.1891863712371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants