Skip to content

Commit 9aed2ec

Browse files
committed
fix: fixed codestyle and matrix generation in tests
1 parent 9c0e6af commit 9aed2ec

2 files changed

Lines changed: 45 additions & 62 deletions

File tree

Test/test226.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
A.matrix = sprand (5, 10, 0.4) ;
1010
B.matrix = ones (3, 2) ;
1111
B.iso = true ;
12-
M.matrix = sprandn (15, 20,0.2) ~= 0 ;
13-
MT.matrix = sprandn (9, 4, 20,0.2) ~= 0 ;
12+
M.matrix = sprand (15, 20, 0.2) ~= 0 ;
13+
MT.matrix = sprand (9, 4, 20, 0.2) ~= 0 ;
1414

1515
mult.opname = 'times' ;
1616
mult.optype = 'double' ;
@@ -42,4 +42,3 @@
4242
GB_spec_compare (C1, C2) ;
4343

4444
fprintf ('\ntest226: all tests passed\n') ;
45-

Test/test227.m

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,15 @@
3333
bm = 4 ;
3434
bn = 2 ;
3535

36-
Ax_temp = 100 * sprandn (am, an, 0.5);
37-
Bx_temp = 100 * sprandn (bm, bn, 0.5);
38-
39-
Ax = sparse(round(Ax_temp));
40-
Bx = sparse(round(Bx_temp));
36+
Ax = sparse (100 * sprandn (am, an, 0.5)) ;
37+
Bx = sparse (100 * sprandn (bm, bn, 0.5)) ;
4138

4239
cm = am * bm ;
4340
cn = an * bn ;
44-
Cx = sparse (cm,cn) ;
45-
Maskmat = sprandn (cm,cn,0.2) ~= 0 ;
46-
ATmat = Ax' ;
47-
BTmat = Bx' ;
41+
Cx = sparse (cm, cn) ;
42+
Maskmat = sprandn (cm, cn, 0.2) ~= 0 ;
43+
AT = Ax' ;
44+
BT = Bx' ;
4845

4946
for k2 = [4 7 45:52 ]
5047
for k1 = 1:4
@@ -71,26 +68,16 @@
7168
clear A
7269
A.matrix = Ax ;
7370
A.is_hyper = A_is_hyper ;
74-
A.is_csc = A_is_csc ;
71+
A.is_csc = A_is_csc ;
7572

7673
clear B
7774
B.matrix = Bx ;
7875
B.is_hyper = B_is_hyper ;
79-
B.is_csc = B_is_csc ;
76+
B.is_csc = B_is_csc ;
8077

8178
clear C
82-
C.matrix = sparse (cm,cn) ;
83-
C.is_csc = C_is_csc ;
84-
85-
clear AT
86-
AT.matrix = ATmat ;
87-
AT.is_hyper = A_is_hyper ;
88-
AT.is_csc = A.is_csc ;
89-
90-
clear BT
91-
BT.matrix = BTmat ;
92-
BT.is_hyper = B_is_hyper ;
93-
BT.is_csc = B.is_csc ;
79+
C.matrix = Cx ;
80+
C.is_csc = C_is_csc ;
9481

9582
%---------------------------------------
9683
% kron(A,B)
@@ -130,41 +117,39 @@
130117

131118
% tests with Mask
132119
for Mask_is_hyper = 0:1
133-
for Mask_is_csc = 0:1
134-
fprintf('*')
135-
136-
A.is_csc = A_is_csc ;
137-
B.is_csc = B_is_csc ;
138-
A.is_hyper = A_is_hyper ;
139-
B.is_hyper = B_is_hyper ;
140-
141-
clear M
142-
M.matrix = Maskmat ;
143-
M.is_hyper = Mask_is_hyper ;
144-
M.is_csc = Mask_is_csc;
145-
C.is_csc = C_is_csc ;
146-
147-
% kron(A, B) with Mask
148-
C0 = GB_spec_kron (C, M, [ ], op, A, B, dnn) ;
149-
fprintf('#') ;
150-
C1 = GB_mex_kron (C, M, [ ], op, A, B, dnn) ;
151-
GB_spec_compare(C0, C1) ;
152-
153-
% kron(A', B) with Mask
154-
C0 = GB_spec_kron (C, M, [ ], op, AT, B, dtn) ;
155-
C1 = GB_mex_kron (C, M, [ ], op, AT, B, dtn) ;
156-
GB_spec_compare (C0, C1) ;
157-
158-
% kron(A, B') with Mask
159-
C0 = GB_spec_kron (C, M, [ ], op, A, BT, dnt) ;
160-
C1 = GB_mex_kron (C, M, [ ], op, A, BT, dnt) ;
161-
GB_spec_compare (C0, C1) ;
162-
163-
% kron(A', B') with Mask
164-
C0 = GB_spec_kron (C, M, [ ], op, AT, BT, dtt) ;
165-
C1 = GB_mex_kron (C, M, [ ], op, AT, BT, dtt) ;
166-
GB_spec_compare (C0, C1) ;
167-
end
120+
for Mask_is_csc = 0:1
121+
122+
A.is_csc = A_is_csc ;
123+
B.is_csc = B_is_csc ;
124+
A.is_hyper = A_is_hyper ;
125+
B.is_hyper = B_is_hyper ;
126+
127+
clear M
128+
M.matrix = Maskmat ;
129+
M.is_hyper = Mask_is_hyper ;
130+
M.is_csc = Mask_is_csc;
131+
C.is_csc = C_is_csc ;
132+
133+
% kron(A, B) with Mask
134+
C0 = GB_spec_kron (C, M, [ ], op, A, B, dnn) ;
135+
C1 = GB_mex_kron (C, M, [ ], op, A, B, dnn) ;
136+
GB_spec_compare(C0, C1) ;
137+
138+
% kron(A', B) with Mask
139+
C0 = GB_spec_kron (C, M, [ ], op, AT, B, dtn) ;
140+
C1 = GB_mex_kron (C, M, [ ], op, AT, B, dtn) ;
141+
GB_spec_compare (C0, C1) ;
142+
143+
% kron(A, B') with Mask
144+
C0 = GB_spec_kron (C, M, [ ], op, A, BT, dnt) ;
145+
C1 = GB_mex_kron (C, M, [ ], op, A, BT, dnt) ;
146+
GB_spec_compare (C0, C1) ;
147+
148+
% kron(A', B') with Mask
149+
C0 = GB_spec_kron (C, M, [ ], op, AT, BT, dtt) ;
150+
C1 = GB_mex_kron (C, M, [ ], op, AT, BT, dtt) ;
151+
GB_spec_compare (C0, C1) ;
152+
end
168153
end
169154
end
170155
end
@@ -189,4 +174,3 @@
189174
GB_spec_compare (C0, C1) ;
190175

191176
fprintf ('\ntest227: all tests passed\n') ;
192-

0 commit comments

Comments
 (0)