function H = complex_matrix(w,A,b,c,d)
% H = complex_matrix(w,A,b,c,d)

  warning("Using Octave m-file version of function complex_matrix()!");
  
  % Sanity checks
  if ((nargin~=5) || (nargout>1)) print_usage("H = complex_matrix(w,A,b,c,d)");
  endif
  if isempty(A)
    error("A is empty");
  endif
  if (rows(A) ~= columns(A))
    error("rows(A) ~= columns(A)");
  endif
  if (rows(A) ~= rows(b))
    error("rows(A) ~= rows(b)");
  endif
  if (columns(A) ~= columns(c))
    error("columns(A) ~= columns(c)");
  endif
  if ~isscalar(d)
    error("~isscalar(d)");
  endif

  H=zeros(size(w));
  for k=1:length(w)
    zI=exp(j*w(k))*eye(size(A));
    R=inv(zI-A);
    H(k)=(c*R*b) + d;
  endfor

endfunction
