Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.0 - English

Change language to:
Français - 日本語 - Português

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab manual >> Sparses Matrix > sparse

sparse

sparse matrix definition

Calling Sequence

sp=sparse(X)
sp=sparse(ij,v [,mn])

Arguments

X

real or complex full (or sparse) matrix

ij

two columns integer matrix (indices of non-zeros entries)

v

vector

mn

integer vector with two entries (row-dimension, column-dimension)

sp

sparse matrix

Description

sparse is used to build a sparse matrix. Only non-zero entries are stored.

sp = sparse(X) converts a full matrix to sparse form by squeezing out any zero elements. (If X is already sparse sp is X).

sp=sparse(ij,v [,mn]) builds an mn(1)-by-mn(2) sparse matrix with sp(ij(k,1),ij(k,2))=v(k). ij and v must have the same column dimension. If optional mn parameter is not given the sp matrix dimensions are the max value of ij(:,1) and ij(:,2) respectively.

Operations (concatenation, addition, etc,) with sparse matrices are made using the same syntax as for full matrices.

Elementary functions are also available (abs,maxi,sum,diag,...) for sparse matrices.

Mixed operations (full-sparse) are allowed. Results are full or sparse depending on the operations.

Examples

sp=sparse([1,2;4,5;3,10],[1,2,3])
size(sp)
x=rand(2,2);abs(x)-full(abs(sparse(x)))
<< sp2adj Sparses Matrix spchol >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jan 26 16:23:42 CET 2011