annotate liboctave/floatAEPBAL.cc @ 8710:739141cde75a ss-3-1-52

fix typo in Array-f.cc
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 09 Feb 2009 21:51:31 +0100
parents a5e080076778
children 4c0cdbe0acca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 2007 John W. Eaton
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
5 Copyright (C) 2008 Jaroslav Hajek
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 This file is part of Octave.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 option) any later version.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 for more details.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 */
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include <config.h>
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #endif
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <string>
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "floatAEPBAL.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "f77-fcn.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 extern "C"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 F77_FUNC (sgebal, SGEBAL) (F77_CONST_CHAR_ARG_DECL,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 const octave_idx_type&, float*, const octave_idx_type&, octave_idx_type&,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 octave_idx_type&, float*, octave_idx_type&
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 F77_CHAR_ARG_LEN_DECL);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 F77_FUNC (sgebak, SGEBAK) (F77_CONST_CHAR_ARG_DECL,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 F77_CONST_CHAR_ARG_DECL,
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
45 const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
46 const float*, const octave_idx_type&, float*,
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
47 const octave_idx_type&, octave_idx_type&
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 F77_CHAR_ARG_LEN_DECL
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 F77_CHAR_ARG_LEN_DECL);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
52 FloatAEPBALANCE::FloatAEPBALANCE (const FloatMatrix& a,
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
53 bool noperm, bool noscal)
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
54 : base_aepbal<FloatMatrix, FloatColumnVector> ()
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 octave_idx_type n = a.cols ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 if (a.rows () != n)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
61 return;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 octave_idx_type info;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
66 scale = FloatColumnVector (n);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 float *pscale = scale.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 balanced_mat = a;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 float *p_balanced_mat = balanced_mat.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
72 job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 n, p_balanced_mat, n, ilo, ihi, pscale, info
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 F77_CHAR_ARG_LEN (1)));
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
77 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
79 FloatMatrix
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
80 FloatAEPBALANCE::balancing_matrix (void) const
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
81 {
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
82 octave_idx_type n = balanced_mat.rows ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
83 FloatMatrix balancing_mat (n, n, 0.0);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 for (octave_idx_type i = 0; i < n; i++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 balancing_mat.elem (i ,i) = 1.0;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 float *p_balancing_mat = balancing_mat.fortran_vec ();
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
88 const float *pscale = scale.fortran_vec ();
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
89
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
90 octave_idx_type info;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 char side = 'R';
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 F77_XFCN (sgebak, SGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 F77_CONST_CHAR_ARG2 (&side, 1),
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 n, ilo, ihi, pscale, n,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 p_balancing_mat, n, info
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 F77_CHAR_ARG_LEN (1)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 F77_CHAR_ARG_LEN (1)));
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
8386
a5e080076778 make balance more Matlab-compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7808
diff changeset
101 return balancing_mat;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 /*
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 ;;; Local Variables: ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 ;;; mode: C++ ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 ;;; End: ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 */