GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
aepbalance.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_aepbalance_h)
27#define octave_aepbalance_h 1
28
29#include "octave-config.h"
30
31#include <algorithm>
32
33namespace octave
34{
35 namespace math
36 {
37 template <typename MT>
38 class
40 {
41 public:
42
43 typedef typename MT::real_column_vector_type VT;
44
45 aepbalance (void) : m_balanced_mat (), m_scale (), m_ilo (), m_ihi (), m_job () { }
46
47 OCTAVE_API aepbalance (const MT& a, bool noperm = false, bool noscal = false);
48
50 : m_balanced_mat (a.m_balanced_mat), m_scale (a.m_scale),
51 m_ilo(a.m_ilo), m_ihi(a.m_ihi), m_job(a.m_job)
52 { }
53
54 aepbalance& operator = (const aepbalance& a)
55 {
56 if (this != &a)
57 {
58 m_balanced_mat = a.m_balanced_mat;
59 m_scale = a.m_scale;
60 m_ilo = a.m_ilo;
61 m_ihi = a.m_ihi;
62 m_job = a.m_job;
63 }
64
65 return *this;
66 }
67
68 virtual ~aepbalance (void) = default;
69
71
72 MT balanced_matrix (void) const
73 {
74 return m_balanced_mat;
75 }
76
77 VT permuting_vector (void) const
78 {
79 octave_idx_type n = m_balanced_mat.rows ();
80
81 VT pv (n);
82
83 for (octave_idx_type i = 0; i < n; i++)
84 pv(i) = i+1;
85
86 for (octave_idx_type i = n-1; i >= m_ihi; i--)
87 {
88 octave_idx_type j = m_scale(i) - 1;
89 std::swap (pv(i), pv(j));
90 }
91
92 for (octave_idx_type i = 0; i < m_ilo-1; i++)
93 {
94 octave_idx_type j = m_scale(i) - 1;
95 std::swap (pv(i), pv(j));
96 }
97
98 return pv;
99 }
100
101 VT scaling_vector (void) const
102 {
103 octave_idx_type n = m_balanced_mat.rows ();
104
105 VT scv (n);
106
107 for (octave_idx_type i = 0; i < m_ilo-1; i++)
108 scv(i) = 1;
109
110 for (octave_idx_type i = m_ilo-1; i < m_ihi; i++)
111 scv(i) = m_scale(i);
112
113 for (octave_idx_type i = m_ihi; i < n; i++)
114 scv(i) = 1;
115
116 return scv;
117 }
118
119 protected:
120
125 char m_job;
126 };
127 }
128}
129
130#endif
aepbalance(const aepbalance &a)
Definition: aepbalance.h:49
VT permuting_vector(void) const
Definition: aepbalance.h:77
OCTAVE_API MT balancing_matrix(void) const
octave_idx_type m_ihi
Definition: aepbalance.h:124
octave_idx_type m_ilo
Definition: aepbalance.h:123
VT scaling_vector(void) const
Definition: aepbalance.h:101
MT balanced_matrix(void) const
Definition: aepbalance.h:72
MT::real_column_vector_type VT
Definition: aepbalance.h:43
OCTAVE_API aepbalance(const MT &a, bool noperm=false, bool noscal=false)
virtual ~aepbalance(void)=default
#define OCTAVE_API
Definition: main.in.cc:55