-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix_operations.py
More file actions
57 lines (42 loc) · 1007 Bytes
/
matrix_operations.py
File metadata and controls
57 lines (42 loc) · 1007 Bytes
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
""" creating two dimentional arrayu (matrix) """
from numpy import *
"""a = array ([
[1,2,0,4,5,1],
[0,6,7,0,2,6]
])
print(a)"""
""" operation """
""""print(a.shape,a.size,a.sum(),a.copy(),a.all(1))
print(a.any(),a.argmax(),a.argmin(),a.argsort())"""
""" matix indexing """
"""print(a[0,3])
print(a[1,3])"""
""" converting of array
b=a.flatten()
print(b)
c=b.reshape(2,2,3)
print(c)
print("-------------")
z=b.reshape(4,3)
print(z)
print("----------------------------")
""" creating matrix """"""
m=matrix(a)
print(m)
"""" user defined matrix """
m1=matrix('1 2 3 ; 2 3 4 ; 4 5 6')
print(m1)
print("------------------------------")
"""" addition and multiplication of matrix """
m1=matrix('1 2 3 ; 4 5 6 ; 7 8 9')
m2=matrix('1 2 3 ; 4 5 6 ; 7 8 9')
sum= m1+m2
mul=m1*m2
print( mul)
z=0
r=matrix('')
for i in range(1,4):
for j in range (1,4):
z[i,j]=m1[i,j]*m2[ij]
z=z[i,j]+z
print(z)