function [U,V,TA,TB,AR,AI,BETA] = gschur(A,B,COND);
% PURPOSE: returns ordered generalized Schur decomposition of a matrix pair (A,B)
%
% ---------------------------------------------------
% USAGE: [U,V,TA,TB,AR,AI,BETA] = gschur(A,B,COND);
% where:
% A,B nxn matrices
% COND 7x1 matrix determining an ordering rule
% or 0 if no ordering
%
% U,V,TA,TB generalized real schur decomposition
%
% A = U' TA V
% B = U' TB V
%
% AR,AI,BETA real vectors describing eigenvalues
%
% lambda[k] = (AR[k]+i AI[k])./BETA[k]
%
% additionally BETA[k]>=0
% left-upper block contains eigenvalues satisfying
%
% COND(1)*AR^2+COND(2)*AI^2+COND(3)*BETA^2 +
% COND(4)*AR +COND(5)*AI +COND(6)*BETA +
% COND(7) > 0
%
% This allows to consider the most standar
% orderings: 1) real(lambda)>m, 2) real(lambda)<m,
% 3) abs(lambda)>m, 4) abs(lambda)<m
%
% COMMENTS:
% mex file, gschur.dll is required
% based on Lapack dgges routine
%
% Copyright (c) Pawel Kowal (2006)
% All rights reserved
% LREM_SOLVE toolbox is available free for noncommercial academic use only.
% pkowal3@sgh.waw.pl