-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSymv_u.py
155 lines (112 loc) · 4.1 KB
/
Symv_u.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Programmed by: Jasdev Singh
#
import flame
import laff as laff
def Symv_u_unb_var1(A, x, y):
"""
Symv_u_unb_var1(matrix, vector, vector)
Computes y = A * x + y using DOT products.
A is a symmetric matrix.
Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT,
vector x from TOP to BOTTOM,
vector y from TOP to BOTTOM.
"""
ATL, ATR, \
ABL, ABR = flame.part_2x2(A, \
0, 0, 'TL')
xT, \
xB = flame.part_2x1(x, \
0, 'TOP')
yT, \
yB = flame.part_2x1(y, \
0, 'TOP')
while ATL.shape[0] < A.shape[0]:
A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, \
ABL, ABR, \
1, 1, 'BR')
x0, \
chi1, \
x2 = flame.repart_2x1_to_3x1(xT, \
xB, \
1, 'BOTTOM')
y0, \
psi1, \
y2 = flame.repart_2x1_to_3x1(yT, \
yB, \
1, 'BOTTOM')
laff.dots( a01, x0, psi1 )
laff.dots( alpha11, chi1, psi1 )
laff.dots( a12t, x2, psi1 )
ATL, ATR, \
ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22, \
'TL')
xT, \
xB = flame.cont_with_3x1_to_2x1(x0, \
chi1, \
x2, \
'TOP')
yT, \
yB = flame.cont_with_3x1_to_2x1(y0, \
psi1, \
y2, \
'TOP')
flame.merge_2x1(yT, \
yB, y)
def Symv_u_unb_var2(A, x, y):
"""
Symv_u_unb_var2(matrix, vector, vector)
Computes y = A * x + y using AXPY operations.
A is a symmetric matrix.
Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT,
vector x from TOP to BOTTOM,
vector y from TOP to BOTTOM.
"""
ATL, ATR, \
ABL, ABR = flame.part_2x2(A, \
0, 0, 'TL')
xT, \
xB = flame.part_2x1(x, \
0, 'TOP')
yT, \
yB = flame.part_2x1(y, \
0, 'TOP')
while ATL.shape[0] < A.shape[0]:
A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22 = flame.repart_2x2_to_3x3(ATL, ATR, \
ABL, ABR, \
1, 1, 'BR')
x0, \
chi1, \
x2 = flame.repart_2x1_to_3x1(xT, \
xB, \
1, 'BOTTOM')
y0, \
psi1, \
y2 = flame.repart_2x1_to_3x1(yT, \
yB, \
1, 'BOTTOM')
laff.axpy( chi1, a01, y0 )
laff.axpy( chi1, alpha11, psi1 )
laff.axpy( chi1, a12t, y2 )
ATL, ATR, \
ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22, \
'TL')
xT, \
xB = flame.cont_with_3x1_to_2x1(x0, \
chi1, \
x2, \
'TOP')
yT, \
yB = flame.cont_with_3x1_to_2x1(y0, \
psi1, \
y2, \
'TOP')
flame.merge_2x1(yT, \
yB, y)