Skip to content

Warn about non-structural zeros #118

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

Closed
gdalle opened this issue May 21, 2024 · 7 comments · Fixed by #119
Closed

Warn about non-structural zeros #118

gdalle opened this issue May 21, 2024 · 7 comments · Fixed by #119

Comments

@gdalle
Copy link
Contributor

gdalle commented May 21, 2024

I just realized that some coefficients are stored even though their value is zero. Is that intended behavior?

julia> using MatrixDepot, SparseArrays

julia> mat = matrixdepot("Bai/af23560");

julia> nnz(mat)
484256

julia> sum(!iszero, mat)
460598

julia> nnz(dropzeros(mat))
460598
@KlausC
Copy link
Collaborator

KlausC commented May 21, 2024

MatrixDepot reproduces exactly what is found in the database. No editing occurs. A[8,1] is a stored zero.

%%MatrixMarket matrix coordinate real general
%-------------------------------------------------------------------------------
% UF Sparse Matrix Collection, Tim Davis
% http://www.cise.ufl.edu/research/sparse/matrices/Bai/af23560
% name: Bai/af23560
% [ NACA 0012 AIRFOIL  M=0.8, EIGENVALUE CALCULATION]
% id: 291
% date: 1991
% author: A. Mahajan
% ed: Z. Bai, D. Day, J. Demmel, J. Dongarra
% fields: title A Zeros name id date author ed kind
% kind: computational fluid dynamics problem
%-------------------------------------------------------------------------------
23560 23560 484256
1 1 -41.8292081
5 1 10.0716866
6 1 .094830215
7 1 4.26627159
8 1 0
153 1 17.5548016

@KlausC KlausC closed this as completed May 21, 2024
@gdalle
Copy link
Contributor Author

gdalle commented May 21, 2024

Good to know. It's a bit surprising though because when you interrogate the database, you get the number of zero values, not the number of structural zeros

image

I spent a solid hour wondering what I had done wrong, because the number above is also the one reported in some articles

@gdalle
Copy link
Contributor Author

gdalle commented May 21, 2024

Perhaps this would be worth documenting?

@KlausC
Copy link
Collaborator

KlausC commented May 21, 2024

But that can't be blaming this package, because it can be different in each example.
The correct address is found in the documentation in the published data file (see above).

@gdalle
Copy link
Contributor Author

gdalle commented May 21, 2024

I'm not blaming anyone here :) Just suggesting to add one line to the README of MatrixDepot.jl, warning users about the difference between structural and accidental nonzeros, so that they don't fall into the same trap as me

@gdalle gdalle changed the title Remove non-structural zeros Warn about non-structural zeros May 21, 2024
@andreasnoack
Copy link
Member

This reminds me of old discussions like JuliaLang/LinearAlgebra.jl#60 and JuliaLang/julia#23005

@KlausC
Copy link
Collaborator

KlausC commented May 21, 2024

@gdalle you are welcome to provide a PR (or a version of README.md, so I can do that)

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 a pull request may close this issue.

3 participants