comparison liboctave/fCmplxGEPBAL.cc @ 7792:39c1026191e9

add missing files from single-precision merge
author John W. Eaton <jwe@octave.org>
date Wed, 21 May 2008 09:36:46 -0400
parents
children 25bc2d31e1bf
comparison
equal deleted inserted replaced
7791:975e9540be2c 7792:39c1026191e9
1 /*
2
3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005,
4 2007 John W. Eaton
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 #include <vector>
30
31 #include "fCmplxGEPBAL.h"
32 #include "Array-util.h"
33 #include "f77-fcn.h"
34
35 extern "C"
36 {
37 F77_RET_T
38 F77_FUNC (cggbal, CGGBAL) (F77_CONST_CHAR_ARG_DECL, const octave_idx_type& N,
39 FloatComplex* A, const octave_idx_type& LDA, FloatComplex* B,
40 const octave_idx_type& LDB, octave_idx_type& ILO, octave_idx_type& IHI,
41 float* LSCALE, float* RSCALE,
42 float* WORK, octave_idx_type& INFO
43 F77_CHAR_ARG_LEN_DECL);
44
45 F77_RET_T
46 F77_FUNC (sggbak, SGGBAK) (F77_CONST_CHAR_ARG_DECL,
47 F77_CONST_CHAR_ARG_DECL,
48 const octave_idx_type& N, const octave_idx_type& ILO,
49 const octave_idx_type& IHI, const float* LSCALE,
50 const float* RSCALE, octave_idx_type& M, float* V,
51 const octave_idx_type& LDV, octave_idx_type& INFO
52 F77_CHAR_ARG_LEN_DECL
53 F77_CHAR_ARG_LEN_DECL);
54
55 }
56
57 octave_idx_type
58 FloatComplexGEPBALANCE::init (const FloatComplexMatrix& a, const FloatComplexMatrix& b,
59 const std::string& balance_job)
60 {
61 octave_idx_type n = a.cols ();
62
63 if (a.rows () != n)
64 {
65 (*current_liboctave_error_handler) ("FloatComplexGEPBALANCE requires square matrix");
66 return -1;
67 }
68
69 if (a.dims() != b.dims ())
70 {
71 gripe_nonconformant ("FloatComplexGEPBALANCE", n, n, b.rows(), b.cols());
72 return -1;
73 }
74
75 octave_idx_type info;
76 octave_idx_type ilo;
77 octave_idx_type ihi;
78
79 OCTAVE_LOCAL_BUFFER (float, plscale, n);
80 OCTAVE_LOCAL_BUFFER (float, prscale, n);
81 OCTAVE_LOCAL_BUFFER (float, pwork, 6 * n);
82
83 balanced_mat = a;
84 FloatComplex *p_balanced_mat = balanced_mat.fortran_vec ();
85 balanced_mat2 = b;
86 FloatComplex *p_balanced_mat2 = balanced_mat2.fortran_vec ();
87
88 char job = balance_job[0];
89
90 F77_XFCN (cggbal, CGGBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
91 n, p_balanced_mat, n, p_balanced_mat2,
92 n, ilo, ihi, plscale,prscale, pwork, info
93 F77_CHAR_ARG_LEN (1)));
94
95 balancing_mat = FloatMatrix (n, n, 0.0);
96 balancing_mat2 = FloatMatrix (n, n, 0.0);
97 for (octave_idx_type i = 0; i < n; i++)
98 {
99 OCTAVE_QUIT;
100 balancing_mat.elem (i ,i) = 1.0;
101 balancing_mat2.elem (i ,i) = 1.0;
102 }
103
104 float *p_balancing_mat = balancing_mat.fortran_vec ();
105 float *p_balancing_mat2 = balancing_mat2.fortran_vec ();
106
107 // first left
108 F77_XFCN (sggbak, SGGBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
109 F77_CONST_CHAR_ARG2 ("L", 1),
110 n, ilo, ihi, plscale, prscale,
111 n, p_balancing_mat, n, info
112 F77_CHAR_ARG_LEN (1)
113 F77_CHAR_ARG_LEN (1)));
114
115 // then right
116 F77_XFCN (sggbak, SGGBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
117 F77_CONST_CHAR_ARG2 ("R", 1),
118 n, ilo, ihi, plscale, prscale,
119 n, p_balancing_mat2, n, info
120 F77_CHAR_ARG_LEN (1)
121 F77_CHAR_ARG_LEN (1)));
122
123 return info;
124 }
125
126 /*
127 ;;; Local Variables: ***
128 ;;; mode: C++ ***
129 ;;; End: ***
130 */