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.

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 Víctor de Buen Remiro)

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 Víctor de Buen Remiro

Component: KernelMath
Description: modified (diff)

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.

comment:2 Changed 16 years ago by César Pérez Álvarez

Resolution: fixed
Status: newclosed

Ok, thank you

Note: See TracTickets for help on using tickets.