37 double*,
const octave_idx_type&,
double*,
const octave_idx_type&,
38 double*,
double*, octave_idx_type&,
double&,
double&,
double*,
39 const octave_idx_type&, octave_idx_type*,
40 const octave_idx_type&, octave_idx_type&);
44 const octave_idx_type*,
const octave_idx_type&,
45 Complex*,
const octave_idx_type&, Complex*,
const octave_idx_type&,
46 Complex*, octave_idx_type&,
double&,
double&, Complex*,
47 const octave_idx_type&, octave_idx_type &);
51 const octave_idx_type*,
const octave_idx_type&,
52 float*,
const octave_idx_type&,
float*,
const octave_idx_type&,
53 float*,
float*, octave_idx_type&,
float&,
float&,
float*,
54 const octave_idx_type&, octave_idx_type*,
55 const octave_idx_type&, octave_idx_type&);
59 const octave_idx_type*,
const octave_idx_type&,
60 FloatComplex*,
const octave_idx_type&, FloatComplex*,
const octave_idx_type&,
61 FloatComplex*, octave_idx_type&,
float&,
float&, FloatComplex*,
62 const octave_idx_type&, octave_idx_type &);
65 DEFUN (ordschur, args, ,
67 @deftypefn {Loadable Function} {[@var{UR}, @var{SR}] =} ordschur (@var{U}, @var{S}, @var{select})\n\
68 Reorders the real Schur factorization (@var{U},@var{S}) obtained with the\n\
69 @code{schur} function, so that selected eigenvalues appear in the upper left\n\
70 diagonal blocks of the quasi triangular Schur matrix.\n\
72 The logical vector @var{select} specifies the selected eigenvalues as they\n\
73 appear along @var{S}'s diagonal.\n\
75 For example, given the matrix @code{@var{A} = [1, 2; 3, 4]}, and its Schur\n\
79 [@var{U}, @var{S}] = schur (@var{A})\n\
100 It is possible to reorder the decomposition so that the positive eigenvalue\n\
101 is in the upper left corner, by doing:\n\
104 [@var{U}, @var{S}] = ordschur (@var{U}, @var{S}, [0,1])\n\
122 error (
"ordschur: SELECT must be an array of integers");
131 error (
"ordschur: SELECT must have same length as the sides of U and S");
134 else if (n != dimU(0) || n != dimS(0) || n != dimU(1) || n != dimS(1))
136 error (
"ordschur: U and S must be square and of equal sizes");
140 const bool double_type = args(0).is_double_type ()
141 || args(1).is_double_type ();
142 const bool complex_type = args(0).is_complex_type ()
143 || args(1).is_complex_type ();
145 #define PREPARE_ARGS(TYPE, TYPE_M, TYPE_COND) \
146 TYPE ## Matrix U = args(0).TYPE_M ## _value (); \
147 TYPE ## Matrix S = args(1).TYPE_M ## _value (); \
150 error ("ordschur: U and S must be real or complex floating point matrices"); \
153 TYPE ## Matrix w (dim_vector (n, 1)); \
154 TYPE ## Matrix work (dim_vector (n, 1)); \
156 octave_idx_type info; \
157 TYPE_COND cond1, cond2;
159 #define PREPARE_OUTPUT()\
162 error ("ordschur: trsen failed"); \
176 sel.
data (), n, S.fortran_vec (), n, U.fortran_vec (), n,
177 w.fortran_vec (), m, cond1, cond2, work.fortran_vec (), n,
189 sel.
data (), n, S.fortran_vec (), n, U.fortran_vec (), n,
191 work.fortran_vec (), n, iwork.
fortran_vec (), n, info));
203 sel.
data (), n, S.fortran_vec (), n, U.fortran_vec (), n,
204 w.fortran_vec (), m, cond1, cond2, work.fortran_vec (), n,
216 sel.
data (), n, S.fortran_vec (), n, U.fortran_vec (), n,
218 work.fortran_vec (), n, iwork.
fortran_vec (), n, info));
224 #undef PREPARE_OUTPUT
F77_RET_T F77_CONST_CHAR_ARG_DECL
#define PREPARE_ARGS(TYPE, TYPE_M, TYPE_COND)
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
#define F77_XFCN(f, F, args)
F77_RET_T F77_FUNC(dtrsen, DTRSEN)(F77_CONST_CHAR_ARG_DECL
std::complex< double > w(std::complex< double > z, double relerr=0)
const T * data(void) const
#define F77_CONST_CHAR_ARG(x)
std::complex< float > FloatComplex
std::complex< double > Complex
const T * fortran_vec(void) const