Mercurial > octave
comparison liboctave/dbleAEPBAL.cc @ 457:3d4b4f0fa5ba
[project @ 1994-06-06 00:33:33 by jwe]
Initial revision
author | jwe |
---|---|
date | Mon, 06 Jun 1994 00:33:51 +0000 |
parents | |
children | 714fd17fca28 |
comparison
equal
deleted
inserted
replaced
456:a1b3aae0fbc3 | 457:3d4b4f0fa5ba |
---|---|
1 // -*- C++ -*- | |
2 /* | |
3 | |
4 Copyright (C) 1992, 1993, 1994 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 2, or (at your option) any | |
11 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, write to the Free | |
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
28 #if defined (__GNUG__) | |
29 #pragma implementation | |
30 #endif | |
31 | |
32 #include "dbleAEPBAL.h" | |
33 #include "f77-uscore.h" | |
34 | |
35 extern "C" | |
36 { | |
37 int F77_FCN (dgebal) (const char*, const int*, double*, | |
38 const int*, int*, int*, double*, | |
39 int*, long, long); | |
40 | |
41 int F77_FCN (dgebak) (const char*, const char*, const int*, const int*, | |
42 const int*, double*, const int*, double*, const int*, | |
43 int*, long, long); | |
44 } | |
45 | |
46 int | |
47 AEPBALANCE::init (const Matrix& a, const char *balance_job) | |
48 { | |
49 int a_nc = a.cols (); | |
50 if (a.rows () != a_nc) | |
51 { | |
52 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); | |
53 return -1; | |
54 } | |
55 | |
56 int n = a_nc; | |
57 | |
58 // Parameters for balance call. | |
59 | |
60 int info; | |
61 int ilo; | |
62 int ihi; | |
63 double *scale = new double [n]; | |
64 | |
65 // Copy matrix into local structure. | |
66 | |
67 balanced_mat = a; | |
68 | |
69 F77_FCN (dgebal) (balance_job, &n, balanced_mat.fortran_vec (), | |
70 &n, &ilo, &ihi, scale, &info, 1L, 1L); | |
71 | |
72 // Initialize balancing matrix to identity. | |
73 | |
74 balancing_mat = Matrix (n, n, 0.0); | |
75 for (int i = 0; i < n; i++) | |
76 balancing_mat.elem (i ,i) = 1.0; | |
77 | |
78 F77_FCN (dgebak) (balance_job, "R", &n, &ilo, &ihi, scale, &n, | |
79 balancing_mat.fortran_vec (), &n, &info, 1L, 1L); | |
80 | |
81 delete [] scale; | |
82 | |
83 return info; | |
84 } | |
85 | |
86 /* | |
87 ;;; Local Variables: *** | |
88 ;;; mode: C++ *** | |
89 ;;; page-delimiter: "^/\\*" *** | |
90 ;;; End: *** | |
91 */ |