GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
numeric
dbleAEPBAL.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1994-2013 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 "
dbleAEPBAL.h
"
31
#include "
f77-fcn.h
"
32
33
extern
"C"
34
{
35
F77_RET_T
36
F77_FUNC
(dgebal, DGEBAL) (
F77_CONST_CHAR_ARG_DECL
,
37
const
octave_idx_type
&,
double
*,
38
const
octave_idx_type
&, octave_idx_type&,
39
octave_idx_type&,
double
*, octave_idx_type&
40
F77_CHAR_ARG_LEN_DECL
);
41
42
F77_RET_T
43
F77_FUNC
(dgebak, DGEBAK) (
F77_CONST_CHAR_ARG_DECL
,
44
F77_CONST_CHAR_ARG_DECL
,
45
const
octave_idx_type&,
const
octave_idx_type&,
46
const
octave_idx_type&,
const
double
*,
47
const
octave_idx_type&,
double
*,
48
const
octave_idx_type&, octave_idx_type&
49
F77_CHAR_ARG_LEN_DECL
50
F77_CHAR_ARG_LEN_DECL
);
51
}
52
53
AEPBALANCE::AEPBALANCE
(
const
Matrix
& a,
bool
noperm,
bool
noscal)
54
:
base_aepbal
<
Matrix
,
ColumnVector
> ()
55
{
56
octave_idx_type
n = a.
cols
();
57
58
if
(a.
rows
() != n)
59
{
60
(*current_liboctave_error_handler) (
"AEPBALANCE requires square matrix"
);
61
return
;
62
}
63
64
octave_idx_type
info;
65
66
scale
=
ColumnVector
(n);
67
double
*pscale =
scale
.
fortran_vec
();
68
69
balanced_mat
= a;
70
double
*p_balanced_mat =
balanced_mat
.
fortran_vec
();
71
72
job
= noperm ? (noscal ?
'N'
:
'S'
) : (noscal ?
'P'
:
'B'
);
73
74
F77_XFCN
(dgebal, DGEBAL, (
F77_CONST_CHAR_ARG2
(&
job
, 1),
75
n, p_balanced_mat, n,
ilo
,
ihi
, pscale, info
76
F77_CHAR_ARG_LEN
(1)));
77
}
78
79
Matrix
80
AEPBALANCE::balancing_matrix
(
void
)
const
81
{
82
octave_idx_type
n =
balanced_mat
.
rows
();
83
Matrix
balancing_mat (n, n, 0.0);
84
for
(
octave_idx_type
i = 0; i < n; i++)
85
balancing_mat.
elem
(i ,i) = 1.0;
86
87
double
*p_balancing_mat = balancing_mat.
fortran_vec
();
88
const
double
*pscale =
scale
.
fortran_vec
();
89
90
octave_idx_type
info;
91
92
char
side =
'R'
;
93
94
F77_XFCN
(dgebak, DGEBAK, (
F77_CONST_CHAR_ARG2
(&
job
, 1),
95
F77_CONST_CHAR_ARG2
(&side, 1),
96
n,
ilo
,
ihi
, pscale, n,
97
p_balancing_mat, n, info
98
F77_CHAR_ARG_LEN
(1)
99
F77_CHAR_ARG_LEN
(1)));
100
101
return
balancing_mat;
102
}
Generated on Mon Dec 30 2013 03:04:48 for GNU Octave by
1.8.1.2