def test_est_transvection(): nbErreur = 0 for i in range(2, 20): lig = random.randint(0, i-1) col = random.randint(0, i-1) while col == lig : col = random.randint(0, i-1) a = random.randint(1, 10) mat = transvection.matrice_transvection(lig, a, col, i) if not transvection.est_transvection(mat): nbErreur += 1 print "Erreur lors du test de est_transvection(", mat , ")" listeMatrice = [] listeResultAttendu = [] listeMatrice.append([[1,0,0],[0,1,0],[0,0,1]]) listeResultAttendu.append(False) listeMatrice.append([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]) listeResultAttendu.append(False) listeMatrice.append([[0,0],[0,0]]) listeResultAttendu.append(False) listeMatrice.append([[1,0],[1,0]]) listeResultAttendu.append(False) listeMatrice.append([[1,1,1],[0,1,0],[0,0,1]]) listeResultAttendu.append(False) listeMatrice.append([[1,1,0],[0,1,0],[0,0,0]]) listeResultAttendu.append(False) for i, mat in enumerate(listeMatrice): if not transvection.est_transvection(mat) == listeResultAttendu[i]: nbErreur += 1 print "Erreur lors du test de est_transvection(", mat , "). Le resutat attendu est", listeResultAttendu[i] return nbErreur
def test_transvection_associee(): nbErreur = 0 for i in range(2, 20): lig = random.randint(0, i-1) col = random.randint(0, i-1) while col == lig : col = random.randint(0, i-1) a = random.randint(1, 10) mat = transvection.matrice_transvection(lig, a, col, i) upletT = transvection.transvection_associee(mat) if not all([upletT[0] == lig, upletT[1] == a, upletT[2] == col, upletT[3] == i]): nbErreur += 1 print "Erreur lors du test de transvection_associee(", mat, ")" return nbErreur
def test_matrice_transvection(): nbErreur = 0 for i in range(2,20): lig = random.randint(0, i-1) col = random.randint(0, i-1) a = random.randint(1, 10) while col == lig : col = random.randint(0, i-1) mat = transvection.matrice_transvection(lig, a, col, i) resLig =[j for j in range(len(mat)) if mat[j].count(0) != len(mat)-1][0] resCol =[j for j in range(len(mat)) if mat[resLig][j] != 0 and j != resLig][0] resTaille = len(mat) resA = mat[resLig][resCol] if not all([resLig == lig, resCol == col, resTaille == i, resA == a]): nbErreur += 1 print "Erreur lors du test de matrice_transvection(", lig, ",", a, ",", col, ",", i, ")" return nbErreur
def test_produit_transvection_g(): nbErreur = 0 for i in range(2,20): mat = permutation.matrice_aleatoire(i); matSave = [lig[:] for lig in mat] j = random.randint(0,i-1) k = random.randint(0,i-1) alpha = random.randint(-10, 10) while(k==j): k=random.randint(0,i-1) mTransvec = transvection.matrice_transvection(j, alpha, k, i) mat = transvection.produit_transvection_g(mTransvec, mat) if not(all([(mat[j][l] == matSave[j][l]+matSave[k][l]*alpha) for l in range(len(mat))])): print "erreur lors du test de :" print "mat = ", matSave print "i =", j print "j =", k print "alpha =", alpha print "" nbErreur +=1 return nbErreur