-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSet_to_lower_triangular.py
More file actions
74 lines (52 loc) · 2.08 KB
/
Set_to_lower_triangular.py
File metadata and controls
74 lines (52 loc) · 2.08 KB
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
# Programmed by: jasdev
#
import flame
import laff as laff
def Set_to_lower_triangular_matrix_unb_var1(A):
"""
Set_to_lower_triangular_matrix_unb_var1(matrix)
Sets the above diagonal elements of A to zero.
Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT,
and sets results column-wise.
"""
ATL, ATR, \
ABL, ABR = flame.part_2x2(A, \
0, 0, 'TL')
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')
laff.zerov(a01)
ATL, ATR, \
ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22, \
'TL')
flame.merge_2x2(ATL, ATR, \
ABL, ABR, A)
def Set_to_lower_triangular_matrix_unb_var2(A):
"""
Set_to_lower_triangular_matrix_unb_var2(matrix)
Sets the above diagonal elements of A to zero.
Traverses matrix A from TOP-LEFT to BOTTOM-RIGHT,
and sets results row-wise.
"""
ATL, ATR, \
ABL, ABR = flame.part_2x2(A, \
0, 0, 'TL')
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')
laff.zerov(a12t)
ATL, ATR, \
ABL, ABR = flame.cont_with_3x3_to_2x2(A00, a01, A02, \
a10t, alpha11, a12t, \
A20, a21, A22, \
'TL')
flame.merge_2x2(ATL, ATR, \
ABL, ABR, A)