Opened 16 years ago
Closed 16 years ago
#683 closed doubt (fixed)
Storing in VMatrix Cholmod.Sparse and Cholmod.Triplet
Reported by: | César Pérez Álvarez | Owned by: | Víctor de Buen Remiro |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | Math | Version: | 1.1.7 |
Severity: | minor | Keywords: | VMatrix |
Cc: |
Description (last modified by )
If we run this code:
VMatrix A = Triplet(SetOfSet(SetOfReal(1,1,9)), 8, 8); VMatrix B = Mat2VMat(VMat2Mat(A));
Both VMatrix store the same number of cells (1/(8x8)=1.56%), however bytes stored are different:
A -> Stored bytes 72/552=13.04% B -> Stored bytes 112/552=20.29%
I expected equal number of stored bytes. I suppose that store enging is quite different between Sparse and Triplet.
Change History (2)
comment:1 Changed 16 years ago by
Component: | Kernel → Math |
---|---|
Description: | modified (diff) |
Note: See
TracTickets for help on using
tickets.
Indeed you are correct: different subtypes of sparse matrices have their specific storement engines.
Firstly, all subtypes must to store some auxiliar information as the total number of rows, columns and non zero cells (NNZ: Number of Non Zeroes), not only cell contens. This space is very small and independent of matrix size, but, when you have just one cell it can be larger than data.
In your example A is a Cholmod.R.Triplet virtual matrix that stores just non null cells as triplets with this information
So the total number of bytes of data contens is 16*NNZ
However B is a Cholmod.R.Sparse that store a vector of pointers to column data where cells can be packed in a compact and fast to access way. Most operations returns matrices in packed mode but some times it is not possible. You can force packed mode by means of TOL function
VMatrix Pack(VMatrix data)
. You can see more about this theme hereIn your example NNZ=1 and Cholmod.R.Sparse lost efficience in global.
You can try this code for different values of
n
to view how efficience of Cholmod.R.Sparse growns withn
If you are agree with this explanation you can answer OK or resolve it as fixed yourself.
Thanks for reporting.