I just started leaning Julia, and my command of it is still very preliminary. I am trying to reorder a Schur decomposition. In Matlab, I could use the ordqz command and just had to specify the ordering by passing a string argument. In Julia, my understanding is that this is achieved by the matrix select in the command

ordschur(S, select)

where S is the Schur object as obtained from


However, I have no clue how to specify the select matrix to control for the ordering, and looking at the Julia documentation did not prove helpful. Has anybody already used it? Would it be possible to have an example.

Many thanks in advance


The documentation is a bit terse, I admit.

.. ordschur(Q, T, select) -> Schur

Reorders the Schur factorization of a real matrix A=Q*T*Q' according to the logical array select returning a Schur object F. The selected eigenvalues appear in the leading diagonal of F[:Schur] and the the corresponding leading columns of F[:vectors] form an orthonormal basis of the corresponding right invariant subspace.

The crucial bit of information, easy to overlook, is "logical array": this means that select is a true/false array. The eigenvalues which select[i] is true are brought on top. For instance:

julia> A = randn(3,3);

julia> (T,Q) = schur(A);

julia> S = ordschur(Q,T,[false,true,true]);

julia> T
3x3 Array{Float64,2}:
 2.12232   0.778057  -0.195052
 0.0      -0.162527   0.793454
 0.0       0.0       -1.49427 

julia> S.T
3x3 Array{Float64,2}:
 -0.162527   0.829117  0.7619   
  0.0       -1.49427   0.0711313
  0.0        0.0       2.12232  

The second and third eigenvalue -0.16 and -1.49 are now the leading ones. Note also that the order of the arguments T and Q between the two functions is inconsistent (I should probably file a bug about this).

If you want to bring on top the eigenvalues with absolute value smaller than 1 (a common use for ordschur, which in Matlab is achieved through a hardcoded special string parameter), you can use the following very idiomatic line:

select = abs(eig(T)) .< 1
  • $\begingroup$ This indeed answers perfectly my question. It would actually be great that the documentation explains this a bit further. $\endgroup$ – Foblire Oct 17 '15 at 12:55
  • $\begingroup$ Julia is still an ongoing project, and I am afraid that perfect documentation is not one of the priorities at the moment (especially since many functions and features are still likely to change in the immediate future). And, to be fair, Matlab's documentation isn't any better on this point, in my view. $\endgroup$ – Federico Poloni Oct 18 '15 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.