(*******************************************************************
This file was generated automatically by the Mathematica front end.
It contains Initialization cells from a Notebook file, which
typically will have the same name as this file except ending in
".nb" instead of ".m".
This file is intended to be loaded into the Mathematica kernel using
the package loading commands Get or Needs. Doing so is equivalent
to using the Evaluate Initialization Cells menu command in the front
end.
DO NOT EDIT THIS FILE. This entire file is regenerated
automatically each time the parent Notebook file is saved in the
Mathematica front end. Any changes you make to this file will be
overwritten.
***********************************************************************)
BeginPackage["ascorderedrealschurdecomp`","rqdecomposition`","LinearAlgebra`MatrixManipulation`"]
(*Copyright \[Copyright] Frank Hespeler 2011*)
ascorderedrealschurdecomp::usage=
"Computes the sorted real generalized schur decomposition of the input matrix-pencil where the generalized eigenvalues are sorted in ascending order along the main diagonal. Input: matrix pencil (mat1,mat2); output: quadruple of matrices and the list of eigenvalues: {{{qq,zz},{tt,ss}}, list of eigenvalues}. qq and zz are unitary matrices, tt is of upper block-triangular form, while ss is upper triangular. qq.tt.Transpose[zz] =mat1, qq.ss.Transpose[zz] = mat2."
Begin["`Private`"]
ascorderedrealschurdecomp[mat1a_,mat2a_,AIMZeroTol_:10^(-15)]:=(
AIMLinearStabConds[mat1_,mat2_]:=
With[{n=Length[mat2]},
Module[{stabconds,q,z,t,s,subdiageltst,subdiageltss,twoblockpos,
blockpos,eigvals,eigvalstemp,changeblock,changepos,changepos2,
change,swaplist},
{q,t,z,s}=
Chop[SchurDecomposition[{mat1,mat2},RealBlockForm\[Rule]True],
AIMZeroTol];
subdiageltst=Map[t[[#+1,#]]&,Range[n-1]];
subdiageltss=Map[s[[#+1,#]]&,Range[n-1]];
twoblockpos=Flatten[Position[subdiageltst,i_/;i!=0]];
blockpos=Drop[Complement[Range[n+1],twoblockpos+1],-1];
eigvals=Join[
Join[Map[{Last[
Eigenvalues[{Take[t,{#-1,#},{#-1,#}],
Take[s,{#-1,#},{#-1,#}]}]],#}&,twoblockpos+1],
Map[{First[
Eigenvalues[{Take[t,{#,#+1},{#,#+1}],
Take[s,{#,#+1},{#,#+1}]}]],#}&,twoblockpos]],
Map[{t[[#,#]]/s[[#,#]],#}&,
Complement[blockpos,twoblockpos]]];
eigvals=Sort[eigvals,#1[[2]]
Abs[#[[2]]](**
eventual code for alternative ordering*
Abs[#[[2]]]<=1