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

How not to store 0's #110

Closed
cdelv opened this issue Dec 7, 2022 · 5 comments
Closed

How not to store 0's #110

cdelv opened this issue Dec 7, 2022 · 5 comments

Comments

@cdelv
Copy link

cdelv commented Dec 7, 2022

Hi, given a sparse matrix

 A = GBMatrix{Float64}(300,300)
A[1,2] = 1.0
A[2,2] = 0.0
A[2,3] = 1.0
A
300x300 GraphBLAS double matrix, hypersparse by row
  3 entries, memory: 480 bytes

    (1,2)    1
    (2,2)    0
    (2,3)    1

Note that it is stored in memory element [2,2] although it's 0. Is it possible to do A[2,2] = 0.0 and make the matrix not store it?

However, if A[2,2] were to be different from 0 and then I set it to zero, it will be important to store it as 0 so I can drop it later (or it should drop it automatically). After all, it's a space matrix, zeros should not be stored.

Thanks.

@rayegun
Copy link
Member

rayegun commented Dec 7, 2022

No, this violates one of the core concepts of GraphBLAS: the pattern determines the sparsity not the operator/value. You can do dropzeros! of course at any time.

GraphBLAS collections are not compressed over 0, technically the implicit value is GrB_NO_VALUE. To make things more interoperable with the rest of the Julia ecosystem the default fill is A.fill = 0, but A.fill = missing or A.fill = nothing are perhaps closer to what is actually going on.

The original intent of GraphBLAS is to represent graphs, where it is perfectly reasonable for an edge to both exist and have a weight of 0 in the adjacency matrix.

@rayegun rayegun closed this as completed Dec 7, 2022
@cdelv
Copy link
Author

cdelv commented Dec 7, 2022

@Wimmerer tnahk you for your answer. That's a shame, it makes a bit complicated what I'm trying to do. Although, I want to ask, it it possible to assign a GrB_NO_VALUE? For instance

A[1,2] = GrB_NO_VALUE

Thanks.

@rayegun
Copy link
Member

rayegun commented Dec 7, 2022

You mean to delete that entry by assignment (or no-op if it doesn't exist)? Not in the current wrapper, I'll add that as soon as I get a chance.

It will either be A[...] = GBScalar() or A[...] = novalue (novalue will be a new constant in the next version).

@rayegun
Copy link
Member

rayegun commented Dec 7, 2022

Note also this is the direction that many sparse libraries (potentially including SparseArrays.jl) are going in. The sparsity structure shouldn't necessarily be coupled to the fill.

@cdelv
Copy link
Author

cdelv commented Mar 15, 2023

Hey @Wimmerer,

I come back to ask you if you had a chance to implement the assignment deletion of a matrix entry.

Best regards.

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

No branches or pull requests

2 participants