1function [x no_value] = GB_spec_Matrix_extractElement (A, i, j, xclass)
2%GB_SPEC_MATRIX_EXTRACTELEMENT a MATLAB mimic of GrB_Matrix_extractElement
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7A = GB_spec_matrix (A) ;
8if (nargin < 4)
9    xclass = A.class ;
10end
11
12% GraphBLAS indices are zero based, but (i,j) below must be 1-based
13i = i+1 ;
14j = j+1 ;
15
16no_value = ~(A.pattern (i,j)) ;
17
18if (no_value)
19    % The spec says x is not modified, but a MATLAB function must assign a
20    % value to all its outputs.  The mexFunction interface to GraphBLAS
21    % also returns zero in this case.
22    x = 0 ;
23else
24    x = A.matrix (i,j) ;
25end
26
27x = GB_mex_cast (x, xclass) ;
28
29
30