/
tp2.py
69 lines (49 loc) · 1.5 KB
/
tp2.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
import tp1
import math
def main ():
L = []
N = []
N.append(math.sqrt(2)/2)
N.append((math.sqrt(2)/2)*-1)
L.append(N)
N = []
N.append(math.sqrt(2)/2)
N.append(math.sqrt(2)/2)
L.append(N)
tp1.affichage(L)
N = tp1.transposition(L)
tp1.affichage(L)
tp1.affichage(N)
tp1.affichage(tp1.produit_matrice(N,L))
print(verifie_orthogonale(L))
def verifie_symetrique (M):
n=len(M[0])
for i in range(n):
for j in range(i+1,n):
if(abs(M[i][j] - M[j][i]) > 0.00000001):
print("Matrice non symetrique.")
return False
print("Matrice symetrique.")
return True
def verifie_antisymetrique (M):
n=len(M[0])
for i in range(1,n):
for j in range(i,n):
# astuce précédente invalide car la valeur de la diagonale doit être égale à 0
if(abs(M[i][j] + M[j][i]) > 0.00000001):
print("Matrice non anti-symetrique.")
return False
print("Matrice anri-symetrique.")
return True
def strassen (M,N):
# condition M a autant de colonne que N a de ligne
if(len(M[0]) != len(N)):
print("Multiplication impossible")
return 0
def verifie_orthogonale (M):
comp = tp1.compare_matrice(tp1.produit_matrice(tp1.transposition(M),M),tp1.construire_identite(len(M[0])))
if(comp):
print("Matrice orthogonale")
return comp
print("Matrice non orthogonale")
return False