Skip to content
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

Update Frobenius norms for better accuracy. #290

Merged
merged 2 commits into from
Nov 9, 2018

Conversation

mgates3
Copy link
Contributor

@mgates3 mgates3 commented Nov 6, 2018

This fixes issue #261.

I added scombssq and dcombssq to merge two sum-of-squares quantities. These functions are taken from ScaLAPACK (TOOLS/pdtreecomb.f), just the documentation is updated to match LAPACK's style.

Updated norms were tested via the LAPACK++ tester, comparing single to double precision on identical matrices, and results from new code with results from old code.

For instance, original results (output abbreviated):

lapackpp/test> ./test lange --norm fro --dim 4000 --verbose 1 --type s
                                            LAPACK++        Ref.
type     norm       m       n      error    time (s)    time (s)  status
norm_tst = 3.0072395019531250e+03
   s      fro    4000    4000   0.00e+00      0.0443      0.0557  pass

lapackpp/test> ./test lange --norm fro --dim 4000 --verbose 1 --type d
norm_tst = 3.0541497549406699e+03
   d      fro    4000    4000   0.00e+00      0.0694      0.0810  pass

Using double precision (type d) as reference, this gives a relative error for single precision (type s) of 1.5360e-02.

With updated code:

lapackpp/test> ./test lange --norm fro --dim 4000 --verbose 1 --type s
                                            LAPACK++        Ref.
type     norm       m       n      error    time (s)    time (s)  status
norm_tst = 3.0541506347656250e+03
   s      fro    4000    4000   0.00e+00      0.0449      0.0524  pass

lapackpp/test> ./test lange --norm fro --dim 4000 --verbose 1 --type d
norm_tst = 3.0541497549404239e+03
   d      fro    4000    4000   0.00e+00      0.0688      0.0808  pass

Again using double-precision as reference, this gives a much better relative error for single precision of 2.8808e-07. Note also that the double-precision result is close to that generated by the old code.

For reference, in LAPACK++ test I ran:

python ./run_tests.py --aux-norm --norm fro --verbose 1 --medium --large --type s > snorm.txt
python ./run_tests.py --aux-norm --norm fro --verbose 1 --medium --large --type d > dnorm.txt

python ./run_tests.py --aux-norm --norm fro --verbose 1 --medium --large --type c > cnorm.txt
python ./run_tests.py --aux-norm --norm fro --verbose 1 --medium --large --type z > znorm.txt

and compared those files. I modified the LAPACK++ matrix_generator.cc to generate exactly the same matrix for single and double precision, e.g., for all i, j:

    A( i, j ) = rand() / float(RAND_MAX);

instead of using larnv.

I did not address RFP matrix norms (dlansf, ...). Nor tridiagonal matrices (dlangt, ...), which due to having fewer entries (only O(n) instead of O(n^2)), are less affected by the accuracy issue.

@codecov
Copy link

codecov bot commented Nov 6, 2018

Codecov Report

Merging #290 into master will decrease coverage by 0.12%.
The diff coverage is 18.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
- Coverage   82.59%   82.46%   -0.13%     
==========================================
  Files        1841     1843       +2     
  Lines      177881   178231     +350     
==========================================
+ Hits       146916   146984      +68     
- Misses      30965    31247     +282
Impacted Files Coverage Δ
SRC/zlanhp.f 62.88% <0%> (-6.44%) ⬇️
SRC/clantb.f 59.86% <0%> (-5.33%) ⬇️
SRC/dlantb.f 59.86% <0%> (-5.33%) ⬇️
SRC/zlantr.f 59.72% <0%> (-5.43%) ⬇️
SRC/clanhp.f 62.88% <0%> (-6.44%) ⬇️
SRC/clantp.f 51.82% <0%> (-4.1%) ⬇️
SRC/slantr.f 59.72% <0%> (-5.43%) ⬇️
SRC/zlantp.f 51.82% <0%> (-4.1%) ⬇️
SRC/slantp.f 51.82% <0%> (-4.1%) ⬇️
SRC/clanhb.f 62.06% <0%> (-7.17%) ⬇️
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f2a965...0d9289b. Read the comment docs.

@julielangou
Copy link
Contributor

Cool! Will close #261
We may need some dedicated testing at some point... but seems the unit testing went fine.
Thanks @mgates3

@julielangou julielangou closed this Nov 9, 2018
@julielangou julielangou reopened this Nov 9, 2018
@julielangou julielangou merged commit 8d23489 into Reference-LAPACK:master Nov 9, 2018
@julielangou julielangou added this to the LAPACK 3.9.0 milestone Nov 16, 2019
christoph-conrads pushed a commit to christoph-conrads/lapack that referenced this pull request May 23, 2021
Update Frobenius norms for better accuracy.
@langou langou mentioned this pull request May 26, 2021
weslleyspereira added a commit to weslleyspereira/lapack that referenced this pull request May 26, 2021
This reverts commit 8d23489, reversing
changes made to c3b03d8.
langou added a commit that referenced this pull request Aug 30, 2021
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.

2 participants