Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Jacobi 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

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Posting what you want your code to do is not a bad first step. Next, I would suggest you make an attempt at writing this yourself in VHDL. When you run into problems, post your VHDL and the specific problem (or error message) you are having.

    Are you trying to write your code for simulation only, or do you plan on implementing this in hardware?

    To write this function in VHDL for hardware, some more information is needed. What environment would the VHDL code be running in? Designing your VHDL to fit into a specific part/dev board can alter how you code. Available clocks/plls are also something to consider. Data rates, data precision, and computational delay (pipelining) also need to factor in the design.