mustBeNonsparse

Checks that an array is stored in full, not sparse, form.

Category: Programming > Functions

Syntax

mustBeNonsparse(A)

Checks that A is not a sparse array. Returns nothing if the check passes and throws an error if not.

Description

mustBeNonsparse is a validator: it inspects its input and either returns silently or raises an error with the identifier MATLAB:validators:mustBeNonsparse. The error message states the requirement that was violated, so the caller sees what was expected rather than a generic failure.

Ordinary dense arrays pass. A sparse array would fail with a message saying the value must not be sparse.

Input arguments

A
The value to check. Any array of the class the validator accepts.

Example

Dense input passes

mustBeNonsparse([1 0 0 2]);
disp('passed')
try
    mustBeSparse([1 0 0 2])
catch err
    disp(err.message)
end
Output
passed
Value must be sparse.

Notes

MatLivre has no real sparse storage, so no value fails this check.

See also

mustBeSparse issparse full sparse