speye

Sparse identity matrix.

Syntax

  • S = speye()

  • S = speye(n)

  • S = speye(n, m)

  • S = speye(sz)

Input argument

  • n, m - dimension sizes: nonnegative integer scalar.

  • sz - dimension sizes: two-element row vector.

Output argument

  • S - a sparse matrix.

Description

S = speye() returns a sparse scalar 1.

S = speye(n) returns a sparse n-by-n identity matrix, with ones on the main diagonal.

S = speye(n, m) returns a sparse n-by-m matrix, with ones on the main diagonal.

S = speye(sz) returns a matrix with ones on the main diagonal.

Example

tic();S = speye(5000, 5000);toc()
tic();S = sparse(eye(5000, 5000));toc()

See also

sparse.

History

VersionDescription

1.0.0

initial version

Author

Allan CORNET

Last updated