Closed jpfairbanks closed 9 years ago
Hi @jpfairbanks,
Thanks for the question. Matrix Depot use Base.SparseMatrix.CHOLMOD.Sparse
to read data in Matrix Market format, which I think is a wrapper of CHOLMOD (http://fossies.org/linux/SuiteSparse/CHOLMOD/Check/cholmod_read.c).
For example,
julia> sparse(Base.SparseMatrix.CHOLMOD.Sparse("polbooks.mtx"))
105x105 Base.LinAlg.Symmetric{Float64,Base.SparseMatrix.SparseMatrixCSC{Float64,Int64}}:
0.0 -1.0 -1.0 -1.0 -1.0 -1.0 … 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 0.0 0.0 0.0 -1.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 -1.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 -1.0 -1.0 -1.0 -1.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0
-1.0 -1.0 0.0 0.0 -1.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
⋮ ⋮ ⋱ ⋮
0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 … -1.0 0.0 -1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0
But unfortunately I didn't find any explanations in the comments. Please let me know if you figure it out yourself.
Best wishes,
Weijian
These comments from your linked file look relevant:
112 *
113 * If Common->prefer_binary is set to its default value of FALSE, then
114 * for symmetric pattern-only matrices, the kth diagonal (if present) is set to
115 * one plus the degree of the row/column k, and the off-diagonal entries are set
116 * to -1. A symmetric pattern-only matrix with a zero-free diagonal is thus
117 * converted into a symmetric positive definite matrix. All entries are set to
118 * one for an unsymmetric pattern-only matrix. This differs from the
119 * Matrix Market format (A = mmread ('file') returns a binary pattern for A for
120 * symmetric pattern-only matrices). If Common->prefer_binary is TRUE, then
121 * this function returns a binary matrix (just like mmread('file')).
I think it is trying to make a graph Laplacian but entry [i,i] is not present in the file so it drops the degrees and keeps the -1's. I can see both behaviors being useful but the principle of least surprise suggests setting Commpn->prefer_binary=true
although I don't know what other consequences that will have.
Great, thanks!
If the mtx file has a blank 3rd column, matrixdepot loads the matrix with values -1. For example the Newman/polbooks matrix now edge weights (values column is empty) This works on Newman/football which provides the values column as ones(n). Is this a bug or the intended behavior? If intended, why?
Here are the files