function  [x, K] = springDemo(kVector,massVector)
%  [x, K] = springDemo(kVector,massVector)
%  springDemo - solves and plots Kx=rhs for the steady state  position of 
%               a set of springs with spring constants k and masses m
%
% kVector - vector of spring constants
% massVector -- vector of masses
%   
% K - stiffness Matrix
% x- vector of mass positions

   MAX_FULL_SIZE = 100;  % Maximum size of system to handle as a full matrix
   k=kVector;       %laziness copy
   r=massVector; 
   n=length(k);
   if (n > MAX_FULL_SIZE )
      K = setSparseStiffnessMatrix(k);
      condK=condest(K); % calculate estimated condition number
   else
      K = setStiffnessMatrix(k); 
      condK = cond(K); % calculate condition number
   end
   x = K\r ; % solve for positions using gaussian elimination
   figure;
   spy(K);
   title(sprintf('Stiffness Matrix N=%d',n));
   figure;
   plotSprings(x,k);
   title(sprintf('Cond(K) = %g',condK))
   return
   
   
   

