GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
aepbalance.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2024 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 
34 
36 
37 template <typename MT>
38 class
40 {
41 public:
42 
43  typedef typename MT::real_column_vector_type VT;
44 
45  aepbalance () : 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 () = default;
69 
71 
72  MT balanced_matrix () const
73  {
74  return m_balanced_mat;
75  }
76 
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 
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 OCTAVE_END_NAMESPACE(math)
129 OCTAVE_END_NAMESPACE(octave)
130 
131 #endif
VT scaling_vector() const
Definition: aepbalance.h:101
virtual ~aepbalance()=default
MT balanced_matrix() const
Definition: aepbalance.h:72
octave_idx_type m_ihi
Definition: aepbalance.h:124
VT permuting_vector() const
Definition: aepbalance.h:77
aepbalance(const aepbalance &a)
Definition: aepbalance.h:49
octave_idx_type m_ilo
Definition: aepbalance.h:123
aepbalance(const MT &a, bool noperm=false, bool noscal=false)
char m_job
Definition: aepbalance.h:125
MT::real_column_vector_type VT
Definition: aepbalance.h:43
MT m_balanced_mat
Definition: aepbalance.h:121
MT balancing_matrix() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.cc:55
octave_idx_type n
Definition: mx-inlines.cc:761