File: spok.m

package info (click to toggle)
suitesparse 1%3A5.8.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 152,716 kB
  • sloc: ansic: 774,385; cpp: 24,213; makefile: 6,310; fortran: 1,927; java: 1,826; csh: 1,686; ruby: 725; sh: 535; perl: 225; python: 209; sed: 164; awk: 60
file content (35 lines) | stat: -rw-r--r-- 1,627 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function ok = spok (A)                                                      %#ok
%SPOK checks if a sparse matrix is OK
%
% Returns 1 if the sparse matrix A is OK.  Also returns 1 if A is not sparse
% (but a warning is raised, stating that the non-sparse matrix was not checked.
%
% Aborts with an error if the matrix is corrupted beyond repair.  If that
% happens, you should quit MATLAB since it's possible your workspace has also
% been corrupted.
%
% Returns 0 if the matrix has out-of-order or duplicate row indices, or
% explicit zero entries, and raises a warning.  If the matrix has out-of-order
% row indices, they can be repaired in MATLAB with A=A''.  If the matrix A has
% duplicate row indices, then A=A'' will still have duplicates, and spok(A'')
% will still issue a warning.  If the matrix has explicit zeros, you can remove
% them with A=A*1.
%
% SPOK cannot check everything.  For example, if your mexFunction has created
% a sparse matrix but written beyond the end of the array, spok may see a valid
% matrix.  However, your workspace has still been corrupted beyond repair.
%
% Example:
%
%   load west0479
%   ok = spok (west0479)         % returns 1, for a real sparse matrix
%   ok = spok (west0479 > .5)    % returns 1, for a logical sparse matrix
%   ok = spok (1i*west0479)      % returns 1, for a complex sparse matrix
%   ok = spok (speye (5))        % returns 1, for a real sparse matrix
%   ok = spok (rand (42))        % returns 1, but issues a warning (not sparse)
%
% See also sparse.

% Copyright 2008-2011, Timothy A. Davis, http://suitesparse.com

error ('spok mexFunction not installed') ;