function A = mysparse(I,J,a,n,m)
% Funktion constructing an $n\times m$-matrix from two index vectors \texttt{I},
% \texttt{J} and one entry vector \texttt{a} of the same length. The output
% matrix is the same as for the MATLAB built-in function \texttt{sparse}.
% However, it is stored as a dense matrix and \textbf{not} in sparse matrix
% data format. Hence, this function \textbf{must not} be used as a
% substitute for MATLAB's \texttt{sparse}!
k = length(I); % number of index-entry tupels
if ((length(J) ~= k) || (length(a) ~= k)), error('Length mismatch'); end
% Set entries; if an index pair occurs twice, the corresponding entry
% values are added!
A = zeros(n,m); % Initialize a \emph{dense} zero matrix.
for l=1:k
   A(I(l),J(l)) =  A(I(l),J(l)) + a(l);
end
