Syntax
Description
position = ftell(fid) returns the location of the file position indicator for the file specified by fid, an integer file identifier obtained from fopen. The position is a nonnegative integer specified in bytes from the beginning of the file. A returned value of -1 for position indicates that the query was unsuccessful; use ferror to determine the nature of the error.
Convert sparse matrix to full matrix
Syntax
Description
A = full(S) converts a sparse matrix S to full storage organization. If S is a full matrix, it is left unchanged. If A is full, issparse(A) is 0.
Remarks
Let X be an m-by-n matrix with nz = nnz(X) nonzero entries. Then full(X) requires space to store m*n real numbers while sparse(X) requires space to store nz real numbers and (nz+n) integers.
On most computers, a real number requires twice as much storage as an integer. On such computers, sparse(X) requires less storage than full(X) if the density, nnz/prod(size(X)), is less than one third. Operations on sparse matrices, however, require more execution time per element than those on full matrices, so density should be considerably less than two-thirds before sparse storage is used.
Examples
Here is an example of a sparse matrix with a density of about two-thirds. sparse(S) and full(S) require about the same number of bytes of storage.
No comments:
Post a Comment