function [ K ] = setSparseStiffnessMatrix(kVector)
% [ K ] = setStiffnessMatrix(kVector) SETKMATRIX - set's entries of sparse tri-diagonal Stiffness 
%  matrix given an input vector of spring coefficents k
%   
% kVector - vector of spring constants
% K       - sparse tridiagonal matrix with interior rows 
%                -k(i) (k(i)+k(i+1)) -k(i+1)
   
   k = kVector(:); % convert to column vector
      
   n = length(k);  % number of springs
   K = spalloc(n,n,3*n); % allocate memory for tridiagonal matrix
   subDiagonal = [ -k(2:n) ; 0 ]; % pad subdiagonal
   diagonal = k - subDiagonal; % diagonal
   superDiagonal = -k;
   
   K = spdiags( [ subDiagonal diagonal superDiagonal ], [-1:1], n,n);
   return
   