%
%   Generalized_Eigen_fea.m  ver 1.0  September 7, 2012
%
function[fn,omega,ModeShapes,MST,nv]=Generalized_Eigen_fea(stiff,mass,rigid)
%
nv=0;
%
%
if(rigid==1)
   disp(' ');
   disp(' A shift frequency is recommended for systems ');
   disp(' with rigid-body modes. ');
   disp(' ');
   disp(' Enter shift frequency (Hz) ');
   fshift=input(' ');
   eshift=(2*pi*fshift)^2;
   stiff=stiff+fshift*mass;	
end
%
disp(' ');
disp(' Calculating eigenvalues... ');
%
pause(1);  % need for previous message display
%
tic
%
disp(' ');
disp(' Select method ');
disp('  1=calculate all eigenvalues ');
disp('  2=calculate first n eigenvalues using subspace iteration ');
eal=input(' ');
if(eal==1)
        [fn,omega,ModeShapes,MST]=Generalized_Eigen(stiff,mass,2);
else
        [fn,omega,ModeShapes,MST,nv]=Generalized_Eigen_subspace(stiff,mass,2);
end    
%
if(rigid==1 && abs(eshift)>1.0e-12)
   for i=1:length(fn)
        eig=omega(i)^2 - eshift;
        omega(i)=sqrt(eig);
        fn(i)=omega(i)/(2*pi);
   end
end
%
for i=1:length(fn)
   if(omega(i)<1.0e-10)
        omega(i)=0.;
        fn(i)=0;
   end    
end
%   
disp(' ');
disp(' Eigenvalue calculation time');
toc