function z = baddet(A)
% BADDET  An m!-time recursive method for computing determinants of m x m
% matrices.  Usage:
%   >> z = baddet(A)
%
%   DO NOT USE UNLESS m <= 8 OR SO !!
%

if length(size(A)) ~= 2
  error("input must be a matrix (not a vector or higher-order-tensor)"), end
if diff(size(A)) ~= 0
  error("input must be a square matrix"), end

if columns(A) == 1   % easy case
  z = A(1,1); return, end

z = 0;  s = +1;
for k = 1:columns(A)
  z = z + s * A(1,k) * baddet([A(2:end,1:k-1) A(2:end,k+1:end)]);
  s = s * -1;
end
