3
Copyright (C) 1994-2013 John W. Eaton
5
This file is part of Octave.
7
Octave is free software; you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by the
9
Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
12
Octave is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<http://www.gnu.org/licenses/>.
29
#include "floatSCHUR.h"
36
F77_FUNC (sgeesx, SGEESX) (F77_CONST_CHAR_ARG_DECL,
37
F77_CONST_CHAR_ARG_DECL,
38
FloatSCHUR::select_function,
39
F77_CONST_CHAR_ARG_DECL,
40
const octave_idx_type&, float*,
41
const octave_idx_type&, octave_idx_type&,
42
float*, float*, float*, const octave_idx_type&,
43
float&, float&, float*, const octave_idx_type&,
44
octave_idx_type*, const octave_idx_type&,
45
octave_idx_type*, octave_idx_type&
48
F77_CHAR_ARG_LEN_DECL);
51
static octave_idx_type
52
select_ana (const float& a, const float&)
57
static octave_idx_type
58
select_dig (const float& a, const float& b)
60
return (hypot (a, b) < 1.0);
64
FloatSCHUR::init (const FloatMatrix& a, const std::string& ord,
67
octave_idx_type a_nr = a.rows ();
68
octave_idx_type a_nc = a.cols ();
72
(*current_liboctave_error_handler) ("FloatSCHUR requires square matrix");
82
// Workspace requirements may need to be fixed if any of the
94
char ord_char = ord.empty () ? 'U' : ord[0];
96
if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd')
99
if (ord_char == 'A' || ord_char == 'a')
100
selector = select_ana;
101
else if (ord_char == 'D' || ord_char == 'd')
102
selector = select_dig;
106
octave_idx_type n = a_nc;
107
octave_idx_type lwork = 8 * n;
108
octave_idx_type liwork = 1;
109
octave_idx_type info;
110
octave_idx_type sdim;
117
unitary_mat.clear (n, n);
119
float *s = schur_mat.fortran_vec ();
120
float *q = unitary_mat.fortran_vec ();
122
Array<float> wr (dim_vector (n, 1));
123
float *pwr = wr.fortran_vec ();
125
Array<float> wi (dim_vector (n, 1));
126
float *pwi = wi.fortran_vec ();
128
Array<float> work (dim_vector (lwork, 1));
129
float *pwork = work.fortran_vec ();
131
// BWORK is not referenced for the non-ordered Schur routine.
132
octave_idx_type ntmp = (ord_char == 'N' || ord_char == 'n') ? 0 : n;
133
Array<octave_idx_type> bwork (dim_vector (ntmp, 1));
134
octave_idx_type *pbwork = bwork.fortran_vec ();
136
Array<octave_idx_type> iwork (dim_vector (liwork, 1));
137
octave_idx_type *piwork = iwork.fortran_vec ();
139
F77_XFCN (sgeesx, SGEESX, (F77_CONST_CHAR_ARG2 (&jobvs, 1),
140
F77_CONST_CHAR_ARG2 (&sort, 1),
142
F77_CONST_CHAR_ARG2 (&sense, 1),
143
n, s, n, sdim, pwr, pwi, q, n, rconde, rcondv,
144
pwork, lwork, piwork, liwork, pbwork, info
147
F77_CHAR_ARG_LEN (1)));
152
FloatSCHUR::FloatSCHUR (const FloatMatrix& s, const FloatMatrix& u)
153
: schur_mat (s), unitary_mat (u), selector (0)
155
octave_idx_type n = s.rows ();
156
if (s.columns () != n || u.rows () != n || u.columns () != n)
157
(*current_liboctave_error_handler)
158
("schur: inconsistent matrix dimensions");
162
operator << (std::ostream& os, const FloatSCHUR& a)
164
os << a.schur_matrix () << "\n";
165
os << a.unitary_matrix () << "\n";