File: test67.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (36 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (3)
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
36
function test67
%TEST67 test GrB_apply

% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0

fprintf ('\n---------------------------- quick test of GrB_apply\n') ;

A = sparse (rand (4,3)) ;
C = sparse (rand (4,3)) ;

C0 = GB_mex_apply (C, [ ], '', 'ainv', A) ;
C1 = -A ;
assert (isequal (full (C0.matrix), C1))

C0 = GB_mex_apply (C, [ ], 'plus', 'identity', A) ;
C1 = C + A ;
assert (isequal (full (C0.matrix), C1))

C0 = GB_mex_apply (C, [ ], 'times', 'minv', A) ;
C1 = C .* (1./ A) ;
assert (isequal (full (C0.matrix), C1))

d = struct ('inp0', 'tran') ;
C0 = GB_mex_apply (C', [ ], 'times', 'ainv', A, d) ;
C1 = C' .* (-A') ;
assert (isequal (full (C0.matrix), C1))

A = sparse (zeros (4,3)) ;
C0 = GB_mex_apply (A', [ ], 'plus', 'ainv', A, d) ;
assert (nnz (C0.matrix) == 0)
C0 = GB_mex_apply (A, [ ], '', 'ainv', A) ;
assert (nnz (C0.matrix) == 0)

fprintf ('\ntest67: all tests passed\n') ;