Next: , Previous: spalloc, Up: Function Reference


22.6.0.17 sparse

— Loadable Function: sparse_val = sparse (...)

SPARSE: create a sparse matrix

sparse can be called in the following ways:

  1. S = sparse(A) where A is a full matrix
  2. S = sparse(A,1) where A is a full matrix, result is forced back to a full matrix is resulting matrix is sparse
  3. S = sparse(i,j,s,m,n,nzmax) where
      i,j are integer index vectors (1 x nnz)
      s is the vector of real or complex entries (1 x nnz)
      m,n are the scalar dimentions of S
      nzmax is ignored (here for compatability with Matlab)

      if multiple values are specified with the same i,j position, the corresponding values in s will be added

  4. The following usages are equivalent to (2) above:
      S = sparse(i,j,s,m,n)
      S = sparse(i,j,s,m,n,'summation')
      S = sparse(i,j,s,m,n,'sum')
  5. S = sparse(i,j,s,m,n,'unique')
      same as (2) above, except that rather than adding, if more than two values are specified for the same i,j position, then the last specified value will be kept
  6. S= sparse(i,j,sv) uses m=max(i), n=max(j)
  7. S= sparse(m,n) does sparse([],[],[],m,n,0)

    sv, and i or j may be scalars, in which case they are expanded to all have the same length

     
     
See also: full.