spEye

Purpose

Creates a sparse identity matrix.

Format

y = spEye(n)
Parameters:n (scalar) – order of identity matrix.
Returns:y (n x n sparse matrix) – sparse identity matrix.

Examples

// Declare 'y' a sparse matrix
sparse matrix y;

// Create 3x3 sparse identity matrix
y = spEye(3);

y is now equal to:

1  0  1
0  1  0
0  0  1

Remarks

Since sparse matrices are strongly typed in GAUSS, y must be defined as a sparse matrix before the call to spEye().

See also

Functions spCreate(), spOnes(), denseToSp()