close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of Ticket #683


Ignore:
Timestamp:
Apr 22, 2009, 10:57:07 AM (16 years ago)
Author:
Víctor de Buen Remiro
Comment:

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

. row: integer of 4 bytes . col: integer of 4 bytes . value: real of 8 bytes

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 here

In 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 with n

Real n = 10;
Set triplets = 
  For(1,n, Set(Real k) { SetOfReal(Max(1,k-1),k,Rand(-1,1)) }) <<
  For(1,n, Set(Real k) { SetOfReal(n-k+1,Min(n,k+1),Rand(-1,1)) });

VMatrix A = Triplet(triplets, n, n) ;
VMatrix B = Mat2VMat(VMat2Mat(A));

If you are agree with this explanation you can answer OK or resolve it as fixed yourself.

Thanks for reporting.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #683

    • Property Component changed from Kernel to Math
  • Ticket #683 – Description

    initial v1  
    11If we run this code:
    22
     3{{{
    34VMatrix A = Triplet(SetOfSet(SetOfReal(1,1,9)), 8, 8);
    45
    56VMatrix B = Mat2VMat(VMat2Mat(A));
    6 
     7}}}
    78Both VMatrix store the same number of cells (1/(8x8)=1.56%), however bytes stored are different:
    89
     10{{{
    911A -> Stored bytes 72/552=13.04%
    1012
    1113B -> Stored bytes 112/552=20.29%
     14}}}
    1215
    1316I expected equal number of stored bytes. I suppose that store enging is quite different between Sparse and Triplet.