## Procedimientos numéricos

Valores y vectores propios (Método de Jacobi)

 `public class Jacobi { //el vector d son los valores propios //Las columnas de la matriz v son los vectores propios //devuelve el número de iteracciones static int calcula(double[][] a, int n, double[] d, double[][] v) { int j,iq,ip,i; double tresh,theta,tau,t,sm,s,h,g,c; double[] b=new double[n]; //b=vector(1,n); double[] z=new double[n]; //z=vector(1,n); for (ip=0;ip 4 && (float)(Math.abs(d[ip])+g) == (float)Math.abs(d[ip]) && (float)(Math.abs(d[iq])+g) == (float)Math.abs(d[iq])) a[ip][iq]=0.0; else if (Math.abs(a[ip][iq]) > tresh) { h=d[iq]-d[ip]; if ((float)(Math.abs(h)+g) == (float)Math.abs(h)) t=(a[ip][iq])/h; // t = 1=(2 ) else { theta=0.5*h/(a[ip][iq]); //Equation (11.1.10). t=1.0/(Math.abs(theta)+Math.sqrt(1.0+theta*theta)); if (theta < 0.0) t = -t; } c=1.0/Math.sqrt(1+t*t); s=t*c; tau=s/(1.0+c); h=t*a[ip][iq]; z[ip] -= h; z[iq] += h; d[ip] -= h; d[iq] += h; a[ip][iq]=0.0; for (j=0;j<=ip-1;j++) { //Case of rotations 1 j < p. g=a[j][ip]; h=a[j][iq]; a[j][ip]=g-s*(h+g*tau); a[j][iq]=h+s*(g-h*tau); } for (j=ip+1;j<=iq-1;j++) { //Case of rotations p < j < q. g=a[ip][j]; h=a[j][iq]; a[ip][j]=g-s*(h+g*tau); a[j][iq]=h+s*(g-h*tau); } for (j=iq+1;jx[j]){ aux=x[j]; for(int k=0; k

## Referencias

Press W. H., Teukolsky S. A., Vetterling W. T., Flannery B. P. Numerical Recipes in C, Second edition,  Eigensystems. Jacobi Transformations of a Symmetric Matrix, Chapter 11º. pp. 463-469. Cambridge University Press. Código en C adaptado por el autor al lenguaje Java