This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Construction /

SparseArray

FilledSmallSquare SparseArray[->, ->, ... ] yields a sparse array in which values appear at positions .

FilledSmallSquare SparseArray[, , ... ->, , ... ] yields the same sparse array.

FilledSmallSquare SparseArray[list] yields a sparse array version of list.

FilledSmallSquare SparseArray[data, , , ... ] yields a sparse array representing a array.

FilledSmallSquare SparseArray[data, dims, val] yields a sparse array in which unspecified elements are taken to have value val.

FilledSmallSquare By default, SparseArray takes unspecified elements to be 0.

FilledSmallSquare SparseArray[data, ... ] is always converted to an optimized standard form with structure SparseArray[Automatic, dims, val, ... ].

FilledSmallSquare Normal[SparseArray[... ]] gives the ordinary array corresponding to a sparse array object.

FilledSmallSquare ArrayRules[SparseArray[... ]] gives the list of rules ->, ->, ... .

FilledSmallSquare The elements in SparseArray need not be numeric.

FilledSmallSquare The position specifications can contain patterns.

FilledSmallSquare Example: SparseArray[i_, i_->1, d, d] gives a identity matrix.

FilledSmallSquare With rules :> the are evaluated separately for each set of indices that match .

FilledSmallSquare SparseArray[list] requires that list be a full array, with all parts at a particular level being lists of the same length.

FilledSmallSquare The individual elements of a sparse array cannot themselves be lists.

FilledSmallSquare SparseArray[rules] yields a sparse array with dimensions exactly large enough to include elements whose positions have been explicitly specified.

FilledSmallSquare SparseArray[rules, Automatic, val] takes unspecified elements to have value val.

FilledSmallSquare List and matrix operations are typically set up to work as they do on Normal[SparseArray[... ]].

FilledSmallSquare Functions with attribute Listable are automatically threaded over the individual elements of the ordinary arrays represented by SparseArray objects.

FilledSmallSquare Part extracts specified parts of the array represented by a SparseArray object, rather than parts of the SparseArray expression itself.

FilledSmallSquare Functions like Map are automatically applied to components in a SparseArray object.

FilledSmallSquare SparseArray is treated as a raw object by functions like AtomQ, and for purposes of pattern matching.

FilledSmallSquare Dimensions gives the dimensions of a sparse array.

FilledSmallSquare The standard output format for a sparse array specified by n rules is SparseArray[<n>, dims].

FilledSmallSquare See Section 2.4.1 and Section 2.4.5.

FilledSmallSquare Implementation Notes: see Section A.9.4.

FilledSmallSquare See also: ArrayRules, Normal, Replace.

FilledSmallSquare New in Version 5.0.

Further Examples