-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTmvmult_un.py
142 lines (110 loc) · 4.08 KB
/
Tmvmult_un.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
# Programmed by: Jasdev Singh
#
import flame
import laff as laff
def Tmvmult_un_unb_var1(U, x, y):
"""
Tmvmult_un_unb_var1(matrix, vector, vector)
Computes y = U * x + y using DOT products.
U is the upper triangular matrix.
Traverses matrix U from TOP-LEFT to BOTTOM-RIGHT,
vector x from TOP to BOTTOM,
vector y from TOP to BOTTOM.
"""
UTL, UTR, \
UBL, UBR = flame.part_2x2(U, \
0, 0, 'TL')
xT, \
xB = flame.part_2x1(x, \
0, 'TOP')
yT, \
yB = flame.part_2x1(y, \
0, 'TOP')
while UTL.shape[0] < U.shape[0]:
U00, u01, U02, \
u10t, upsilon11, u12t, \
U20, u21, U22 = flame.repart_2x2_to_3x3(UTL, UTR, \
UBL, UBR, \
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( upsilon11, chi1, psi1 )
laff.dots( u12t, x2, psi1 )
UTL, UTR, \
UBL, UBR = flame.cont_with_3x3_to_2x2(U00, u01, U02, \
u10t, upsilon11, u12t, \
U20, u21, U22, \
'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 Tmvmult_un_unb_var2(U, x, y):
"""
Tmvmult_un_unb_var2(matrix, vector, vector)
Computes y = U * x + y using AXPY operations.
U is the upper triangular matrix.
Traverses matrix U from TOP-LEFT to BOTTOM-RIGHT,
vector x from TOP to BOTTOM,
vector y from TOP to BOTTOM.
"""
UTL, UTR, \
UBL, UBR = flame.part_2x2(U, \
0, 0, 'TL')
xT, \
xB = flame.part_2x1(x, \
0, 'TOP')
yT, \
yB = flame.part_2x1(y, \
0, 'TOP')
while UTL.shape[0] < U.shape[0]:
U00, u01, U02, \
u10t, upsilon11, u12t, \
U20, u21, U22 = flame.repart_2x2_to_3x3(UTL, UTR, \
UBL, UBR, \
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, u01, y0 )
laff.axpy( chi1, upsilon11, psi1 )
UTL, UTR, \
UBL, UBR = flame.cont_with_3x3_to_2x2(U00, u01, U02, \
u10t, upsilon11, u12t, \
U20, u21, U22, \
'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)