1function test30
2%TEST30 test GxB_subassign
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7    [save save_chunk] = nthreads_get ;
8    chunk = 4096 ;
9    nthreads = feature ('numcores') ;
10    nthreads_set (nthreads, chunk) ;
11
12    Prob = ssget (2662) ;
13    A = Prob.A ;
14
15    [m n] = size (A) ;
16
17    ni =  500 ;
18    nj = 1000 ;
19    I = randperm (m,ni) ;
20    J = randperm (n,nj) ;
21    I0 = uint64 (I-1) ;
22    J0 = uint64 (J-1) ;
23
24    scalar = sparse (pi) ;
25
26    % tic/toc includes the mexFunction overhead of making a deep copy
27    % of the input matrix.  MATLAB can modify C in place, as can GraphBLAS,
28    % but GraphBLAS cannot safely do that through a mexFunction interface
29    % to MATLAB.
30
31    fprintf ('start GraphBLAS:\n') ;
32
33    tic
34    C2 = GB_mex_subassign (A, [], [], scalar, I0, J0, []) ;
35    toc
36    t = grbresults
37
38    C = A ;
39    fprintf ('start MATLAB:\n') ;
40    tic
41    C (I,J) = scalar ;
42    tm = toc
43
44    fprintf ('GraphBLAS speedup over MATLAB: %g\n',  tm/t) ;
45
46    assert (isequal (C, C2.matrix)) ;
47    fprintf ('\ntest30: all tests passed\n') ;
48
49