GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
floatAEPBAL.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2015 John W. Eaton
4 Copyright (C) 2008 Jaroslav Hajek
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <string>
29 
30 #include "floatAEPBAL.h"
31 #include "f77-fcn.h"
32 
33 extern "C"
34 {
35  F77_RET_T
36  F77_FUNC (sgebal, SGEBAL) (F77_CONST_CHAR_ARG_DECL,
37  const octave_idx_type&, float*,
38  const octave_idx_type&, octave_idx_type&,
39  octave_idx_type&, float*, octave_idx_type&
41 
42  F77_RET_T
43  F77_FUNC (sgebak, SGEBAK) (F77_CONST_CHAR_ARG_DECL,
45  const octave_idx_type&, const octave_idx_type&,
46  const octave_idx_type&, const float*,
47  const octave_idx_type&, float*,
48  const octave_idx_type&, octave_idx_type&
51 }
52 
54  bool noperm, bool noscal)
56 {
57  octave_idx_type n = a.cols ();
58 
59  if (a.rows () != n)
60  {
61  (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
62  return;
63  }
64 
65  octave_idx_type info;
66 
68  float *pscale = scale.fortran_vec ();
69 
70  balanced_mat = a;
71  float *p_balanced_mat = balanced_mat.fortran_vec ();
72 
73  job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
74 
75  F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
76  n, p_balanced_mat, n, ilo, ihi, pscale, info
77  F77_CHAR_ARG_LEN (1)));
78 }
79 
82 {
84  FloatMatrix balancing_mat (n, n, 0.0);
85  for (octave_idx_type i = 0; i < n; i++)
86  balancing_mat.elem (i ,i) = 1.0;
87 
88  float *p_balancing_mat = balancing_mat.fortran_vec ();
89  const float *pscale = scale.fortran_vec ();
90 
91  octave_idx_type info;
92 
93  char side = 'R';
94 
95  F77_XFCN (sgebak, SGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
96  F77_CONST_CHAR_ARG2 (&side, 1),
97  n, ilo, ihi, pscale, n,
98  p_balancing_mat, n, info
100  F77_CHAR_ARG_LEN (1)));
101 
102  return balancing_mat;
103 }
#define F77_CHAR_ARG_LEN(l)
Definition: f77-fcn.h:253
F77_RET_T F77_CONST_CHAR_ARG_DECL
Definition: floatAEPBAL.cc:44
F77_RET_T const octave_idx_type float const octave_idx_type octave_idx_type octave_idx_type float octave_idx_type & F77_CHAR_ARG_LEN_DECL
Definition: floatAEPBAL.cc:37
T & elem(octave_idx_type n)
Definition: Array.h:380
FloatMatrix balancing_matrix(void) const
Definition: floatAEPBAL.cc:81
#define F77_XFCN(f, F, args)
Definition: f77-fcn.h:51
octave_idx_type rows(void) const
Definition: Array.h:313
#define F77_CONST_CHAR_ARG2(x, l)
Definition: f77-fcn.h:251
#define F77_RET_T
Definition: f77-fcn.h:264
F77_RET_T F77_FUNC(sgebal, SGEBAL)(F77_CONST_CHAR_ARG_DECL
FloatAEPBALANCE(void)
Definition: floatAEPBAL.h:40
const T * fortran_vec(void) const
Definition: Array.h:481
octave_idx_type cols(void) const
Definition: Array.h:321