# -*- coding: utf-8 -*- """ Created on Tue Jan 20 13:37:37 2015 listing_10_3SP Diagonalisation par QR, ˆ l'aide de la fonction qr du module numpy.linalg. @author: grivet """ from pylab import * def affiche_mat(titre,M): print (titre) for row in M: for val in row: print (' %10.5f' %val,end ='') print() F0 = array([[1,1,0.5],[1,1,0.25],[0.5,0.25,2]]) F = copy(F0); S = eye(3) nit = 20; for it in range(nit): Q,R = qr(F) F = dot(R,Q) S = dot(S,Q) affiche_mat('matrice de depart: ',F0) affiche_mat('matrice diagonalisee: ',F) affiche_mat('matrice des vecteurs propres: ',S) affiche_mat('dernier R: ',R) affiche_mat('dernier Q: ',Q)