%BDSCHUR  Block-diagonal Schur decomposition.
%
%   [T,AA,BLKS] = BDSCHUR(A,CONDMAX) computes a transformation matrix T
%   such that AA = T\A*T is block diagonal and each diagonal block is a
%   quasi upper-triangular Schur matrix (real case) or an upper-triangular
%   matrix (complex case). The third output BLKS is the vector of block
%   sizes.
%
%   The optional argument CONDMAX specifies an upper bound on the
%   condition number of T. The default value is CONDMAX=1e4. Use CONDMAX
%   to control the trade off between block size and accuracy of the
%   decomposition (the larger CONDMAX, the smaller the blocks are,
%   but the more ill-conditioned T can be).
%
%   [T,AA] = BDSCHUR(A,[],BLKS) prespecifies the desired block sizes.
%   The input matrix A must be in real or complex Schur form when using
%   this syntax (see SCHUR for details).
%
%   See also SCHUR, ORDSCHUR, COND.

%   Author(s): V. Sima, P. Gahinet
%   Copyright 1986-2023 The MathWorks, Inc.

%   Based on LAPACK's DTRSYL, ZTRSYL, DGEES, ZGEES routines and SLICOT's 
%   MB03RD and MB03RZ routines.
