Altera_Forum
Honored Contributor
13 years agoJacobi rotation based EVD implementation
I've to implement jacobi rotation method for eigen value decomposition in vhdl. I've to assume that angle, sine and cosine values are given for each iteration i.e from test bench I need to give this values. I've written corresponding matlab code and its working fine. Please help me out in writing VHDL for the same.
Thanks function[out] = jacobi2(a) [n,~]= size(a); %#codegen for i= 1:1:n for j = n:-1:(i+1) if (a(i,j) ~=0) x=i; y=j; angle= (1/2)*(atan((2*a(x,y))/(a(y,y)-a(x,x)))); b= a; b(x,x)= a(x,x)*cos(angle)*cos(angle)+a(y,y)*sin(angle)*sin(angle)-2*a(x,y)*cos(angle)*sin(angle); b(y,y)= a(x,x)*sin(angle)*sin(angle)+a(y,y)*cos(angle)*cos(angle)+2*a(x,y)*cos(angle)*sin(angle); b(x,y)=(a(x,x)-a(y,y))*cos(angle)*sin(angle)+a(x,y)*((cos(angle)*cos(angle))-(sin(angle)*sin(angle))); b(y,x)=(a(x,x)-a(y,y))*cos(angle)*sin(angle)+a(x,y)*((cos(angle)*cos(angle))-(sin(angle)*sin(angle))); for z=x+1:1:y-1 b(x,z)= (a(z,x)*cos(angle))-(a(z,y)*sin(angle)); b(z,x)=b(x,z); b(z,y)= (a(z,y)*cos(angle))+(a(z,x)*sin(angle)); b(y,z)=b(z,y); end a=b; end end end out=a; end