Skip to content

Commit 31bd496

Browse files
committed
unit test for split_lincomb
1 parent 787dbd4 commit 31bd496

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

test/merge_graphs.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,48 @@ using LinearAlgebra
3737
)
3838
@test eval_graph(graph_4, A) eval_graph(graph, eval_graph(graph, A))
3939
end
40+
@testset "split_lincomb" begin
41+
42+
A=[
43+
0.196064 -1.18798 0.0 0.0 0.0 0.0 0.0
44+
0.342678 0.793844 0.684638 0.0 0.0 0.0 0.0
45+
1.26005 0.819614 -1.21473 -0.16794 0.0 0.0 0.0
46+
-0.10478 1.50713 0.138891 0.652377 -0.580547 0.0 0.0
47+
-0.803933 -1.96458 0.679152 -0.0471995 -0.0454885 -0.715895 0.0
48+
-0.327724 -1.89847 -0.435685 1.44764 -0.928145 3.06844 1.19071];
49+
B=[1.46284 0.594921 0.0 0.0 0.0 0.0 0.0
50+
0.71404 -0.492136 -0.481715 0.0 0.0 0.0 0.0
51+
0.237897 -0.946491 0.0070323 1.87826 0.0 0.0 0.0
52+
0.0444275 -1.77078 -0.772886 0.89719 1.55139 0.0 0.0
53+
-0.310057 -1.13217 1.40868 0.864775 -1.14717 -0.662986 0.0
54+
-0.160165 -0.525442 0.676407 -0.934459 0.259851 -0.608684 -0.381333];
55+
c=[-0.5210883864869685
56+
-0.5011935108466905
57+
0.9989082416364822
58+
1.1643621428307982
59+
-1.4603489516355923
60+
2.405378746857791
61+
1.7841340060684932
62+
0.233340850959019];
63+
64+
degopt=Degopt(A,B,c);
65+
n=size(A,1);
66+
(g,cref)=graph_degopt(degopt);
67+
g_org=deepcopy(g);
68+
node=cref[50][1];;
69+
ind2=[3;6];
70+
(g,crefs,new_crefs)=split_lincomb!(g,node,ind2;
71+
newnode=Symbol("$(node)_new"),
72+
cref_list=[])
73+
74+
# Check that it is unmodified
75+
@test eval_graph(g,0.1) eval_graph(g_org,0.1)
76+
77+
78+
# Check that changing a variable has the same effect
79+
set_coeffs!(g_org,[3.3],[(node,ind2[1])])
80+
set_coeffs!(g,[3.3],[new_crefs[1]])
81+
82+
@test eval_graph(g,0.3) eval_graph(g_org,0.3)
83+
84+
end

0 commit comments

Comments
 (0)