File: gbtest10.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 (70 lines) | stat: -rw-r--r-- 1,407 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function gbtest10
%GBTEST10 test GrB.assign

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

rng ('default') ;

n = 6 ;
A = 100 * sprand (n, n, 0.5) ;
AT = A' ;
M = sparse (rand (n)) > 0.5 ;
Cin = sprand (n, n, 0.5) ;


Cout = GrB.assign (Cin, A) ;
assert (gbtest_eq (A, Cout)) ;

Cout = GrB.assign (Cin, A, { }, { }) ;
assert (gbtest_eq (A, Cout)) ;

Cout = GrB.assign (Cin, M, A) ;
C2 = Cin ;
C2 (M) = A (M) ;
assert (gbtest_eq (C2, Cout)) ;

Cout = GrB.assign (Cin, '+', A) ;
C2 = Cin + A ;
assert (gbtest_eq (C2, Cout)) ;

d.in0 = 'transpose' ;
Cout = GrB.assign (Cin, M, A, d) ;
C2 = Cin ;
C2 (M) = AT (M) ;
assert (gbtest_eq (C2, Cout)) ;

Cout = GrB.assign (Cin, '+', A, d) ;
C2 = Cin + AT ;
assert (gbtest_eq (C2, Cout)) ;

d.mask = 'complement' ;
Cout = GrB.assign (Cin, M, A, d) ;
C2 = Cin ;
C2 (~M) = AT (~M) ;
assert (gbtest_eq (C2, Cout)) ;

I = [2 1 5] ;
J = [3 3 1 2] ;
B = sprandn (length (I), length (J), 0.5) ;
Cout = GrB.assign (Cin, B, {I}, {J}) ;
C2 = Cin ;
C2 (I,J) = B ;
assert (gbtest_eq (C2, Cout)) ;

A = rand (4) ;
G = GrB (A, 'by row') 
M = logical (eye (4)) ;
B = rand (4) ;
H = GrB (B, 'by row') 
A (M) = B (M) 
G (M) = H (M)
assert (isequal (A, G)) ;

A = sprand (4, 4, 0.5) %#ok<*NOPRT>
C1 = pi * spones (A)
C2 = GrB.expand (pi, A)
assert (isequal (C1, C2)) ;

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