GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
aepbalance.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2025 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
37template <typename MT>
39{
40public:
41
42 typedef typename MT::real_column_vector_type VT;
43
44 aepbalance () : m_balanced_mat (), m_scale (), m_ilo (), m_ihi (), m_job () { }
45
46 OCTAVE_API aepbalance (const MT& a, bool noperm = false, bool noscal = false);
47
52
54 {
55 if (this != &a)
56 {
58 m_scale = a.m_scale;
59 m_ilo = a.m_ilo;
60 m_ihi = a.m_ihi;
61 m_job = a.m_job;
62 }
63
64 return *this;
65 }
66
67 virtual ~aepbalance () = default;
68
70
71 MT balanced_matrix () const
72 {
73 return m_balanced_mat;
74 }
75
77 {
79
80 VT pv (n);
81
82 for (octave_idx_type i = 0; i < n; i++)
83 pv(i) = i+1;
84
85 for (octave_idx_type i = n-1; i >= m_ihi; i--)
86 {
87 octave_idx_type j = m_scale(i) - 1;
88 std::swap (pv(i), pv(j));
89 }
90
91 for (octave_idx_type i = 0; i < m_ilo-1; i++)
92 {
93 octave_idx_type j = m_scale(i) - 1;
94 std::swap (pv(i), pv(j));
95 }
96
97 return pv;
98 }
99
101 {
103
104 VT scv (n);
105
106 for (octave_idx_type i = 0; i < m_ilo-1; i++)
107 scv(i) = 1;
108
109 for (octave_idx_type i = m_ilo-1; i < m_ihi; i++)
110 scv(i) = m_scale(i);
111
112 for (octave_idx_type i = m_ihi; i < n; i++)
113 scv(i) = 1;
114
115 return scv;
116 }
117
118protected:
119
124 char m_job;
125};
126
127OCTAVE_END_NAMESPACE(math)
128OCTAVE_END_NAMESPACE(octave)
129
130#endif
VT scaling_vector() const
Definition aepbalance.h:100
virtual ~aepbalance()=default
MT balanced_matrix() const
Definition aepbalance.h:71
octave_idx_type m_ihi
Definition aepbalance.h:123
VT permuting_vector() const
Definition aepbalance.h:76
aepbalance(const aepbalance &a)
Definition aepbalance.h:48
octave_idx_type m_ilo
Definition aepbalance.h:122
aepbalance(const MT &a, bool noperm=false, bool noscal=false)
aepbalance & operator=(const aepbalance &a)
Definition aepbalance.h:53
MT::real_column_vector_type VT
Definition aepbalance.h:42
MT m_balanced_mat
Definition aepbalance.h:120
MT balancing_matrix() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition main.in.cc:55