forked from BigMacchia/flame_math
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
176 lines (134 loc) · 3.35 KB
/
test.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import vector
reload(vector)
m= matrix.Matrix44()
n = matrix.Matrix(5,6)
o = matrix.Matrix44()
print m,o
print m == n
print m == o
m.set_to_value(5)
m.set_unit_lower_diagonal()
print m
it = matrix.FullIterator(m)
print m[0]
for i in it:
i["a01"].set_to_value(8)
i["a21"].set_to_value(2)
it.merge(i)
print m
m.transpose()
print m
m.upper_simmetry()
print m
m= matrix.Matrix44()
m.set_to_value(2)
m.set_unit_lower_diagonal()
print m
m.lower_simmetry()
print m
m.set_to_value(2)
m.scale(3)
print m
m= matrix.Matrix44()
m.set_to_value(3)
print m
n = matrix.Matrix44()
n.identity()
print n
m.add(n)
print m
m.identity()
vec = vector.Vector([1,2,3,4])
res = m.mult_vec_by_dot(vec)
print "dot", res
res= m.mult_vec_by_axpy(vec)
print "axpy",res
res= m.mult_vec_by_dot_parted(vec)
print "dot_parted", res
res = m.mult_vec_by_axpy_parted(vec)
print "axpy_parted",res
print "-----------------------------------------"
m.set_to_value(2)
vec = vector.Vector([4,5,6,7])
res = m.mult_vec_by_dot(vec)
print "dot", res
res = m.mult_vec_by_axpy(vec)
print "axpy",res
res= m.mult_vec_by_dot_parted(vec)
print "dot_parted", res
res = m.mult_vec_by_axpy_parted(vec)
print "axpy_parted",res
data = [1,2,3,4,2,2,2,2,3,3,3,3,4,5,7,1]
print len(data)
m = matrix.Matrix.from_list(4,4,data)
print m
vec= vector.Vector([4,3,7,3])
print vec
print "transposed --------------"
res =m.mult_vec_by_transposed_matrix_dot(vec)
print res
res = m.mult_vec_by_transposed_matrix_axpy(vec)
print res
data = [1,0,0,0,2,2,0,0,3,3,3,0,4,5,7,1]
print len(data)
m = matrix.Matrix.from_list(4,4,data)
print m
vec= vector.Vector([4,3,7,3])
res = m.mult_vec_upper_triangular_by_dot(vec)
print res
res = m.mult_vec_upper_triangular_by_axpy(vec)
print res
data = [1,2,3,4,0,2,2,2,0,0,3,3,0,0,0,1]
m = matrix.Matrix.from_list(4,4,data)
print m
res = m.mult_vec_lower_triangular_by_dot(vec)
print res
res = m.mult_vec_lower_triangular_by_axpy(vec)
print res
print "simmetric ----"
data = [1,2,3,4,0,2,2,2,0,0,3,3,0,0,0,1]
m = matrix.Matrix44.from_list(data)
m.upper_simmetry()
nU = matrix.Matrix44.from_list(data)
nU.transpose()
nL = matrix.Matrix44.from_list(data)
res1 = m.mult_vec_by_dot(vec)
res2 = nU.mult_vec_upper_symmetric_by_dot(vec)
print "----- upper symmetric dot"
print res1
print res2
res2 = nL.mult_vec_lower_symmetric_by_dot(vec)
print "----- lower symmetric dot"
print res1
print res2
res2 = nU.mult_vec_upper_symmetric_by_axpy(vec)
print "----- upper symmetrix by axpy"
print res1
print res2
res2 = nL.mult_vec_lower_symmetric_by_axpy(vec)
print "----- lower symmetrix by axpy"
print res1
print res2
m = matrix.Matrix.from_list(3,3,[.4,.4,.2,.3,.3,.4,.1,.6,.3])
res = m.mult_matrix_dot(m)
print res
a = matrix.Matrix.from_list(4,3,[2,-1,1,-1,0,1,3,1,1,0,1,1])
b = matrix.Matrix.from_list(3,4,[2,0,1,1,1,0,2,0,1,1,1,0])
res = a.mult_matrix_dot(b)
print "-----------------------------"
print res
res= b.mult_matrix_dot(a)
print "--------------------------"
print res
m= matrix.Matrix.from_list(3,1,[1,-3,2])
n = matrix.Matrix.from_list(1,2,[-1,-2])
res = m.mult_matrix_dot(n)
print res
a = matrix.Matrix.from_list(4,3,[2,-1,1,-1,0,1,3,1,1,0,1,1])
b = matrix.Matrix.from_list(3,4,[2,0,1,1,1,0,2,0,1,1,1,0])
#at = matrix.Matrix.from_list(4,3,[2,-1,1,-1,0,1,3,1,1,0,1,1])
#bt = matrix.Matrix.from_list(3,4,[2,0,1,1,1,0,2,0,1,1,1,0])
#at.transpose()
#bt.transpose()
#res = at.mult_matrix_dot(bt)
#print res