1function C = load (filename)
2%GRB.LOAD Load a single GraphBLAS matrix from a file.
3% C = GrB.load (filename) loads a single @GrB matrix from a file.  The file
4% must have been previously created by GrB.save.  If the filename is not
5% present, it defaults to 'GrB_Matrix.mat'.
6%
7% Examples:
8%
9%   A = GrB.random (4, 4, 0.5)
10%   GrB.save (A) ;              % A can be a @GrB or MATLAB matrix
11%   clear all
12%   A = GrB.load ('A.mat') ;    % A is now a @GrB matrix
13%
14%   % saving a matrix expression
15%   GrB.save (2*A-1)            % save a matrix computation to GrB_Matrix.mat
16%   GrB.load                    % load it back in
17%
18% See also GrB.save, GrB/struct.
19
20% A note to Octave users:  a file written out by GrB.save in MATLAB
21% should be readable by GrB.load in Octave, and visa versa, as long as
22% the same version of GraphBLAS is used.
23
24% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
25% SPDX-License-Identifier: GPL-3.0-or-later
26
27if (nargin < 1)
28    filename = 'GrB_Matrix.mat' ;
29end
30
31% load in the opaque struct from the file
32S = load (filename, 'GraphBLAS_struct_from_GrB_save') ;
33
34% convert it to a @GrB object
35C = GrB (S.GraphBLAS_struct_from_GrB_save) ;
36
37