GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
aepbalance.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2017 John W. Eaton
4 Copyright (C) 2008-2016 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 #if ! defined (octave_aepbalance_h)
25 #define octave_aepbalance_h 1
26 
27 #include "octave-config.h"
28 
29 namespace octave
30 {
31  namespace math
32  {
33  template <typename MT>
34  class aepbalance
35  {
36  public:
37 
38  typedef typename MT::real_column_vector_type VT;
39 
40  aepbalance (void) : balanced_mat (), scale (), ilo (), ihi (), job () { }
41 
42  aepbalance (const MT& a, bool noperm = false, bool noscal = false);
43 
46  ilo(a.ilo), ihi(a.ihi), job(a.job)
47  { }
48 
50  {
51  if (this != &a)
52  {
54  scale = a.scale;
55  ilo = a.ilo;
56  ihi = a.ihi;
57  job = a.job;
58  }
59 
60  return *this;
61  }
62 
63  virtual ~aepbalance (void) { }
64 
65  MT balancing_matrix (void) const;
66 
67  MT balanced_matrix (void) const
68  {
69  return balanced_mat;
70  }
71 
72  VT permuting_vector (void) const
73  {
74  octave_idx_type n = balanced_mat.rows ();
75 
76  VT pv (n);
77 
78  for (octave_idx_type i = 0; i < n; i++)
79  pv(i) = i+1;
80 
81  for (octave_idx_type i = n-1; i >= ihi; i--)
82  {
83  octave_idx_type j = scale(i) - 1;
84  std::swap (pv(i), pv(j));
85  }
86 
87  for (octave_idx_type i = 0; i < ilo-1; i++)
88  {
89  octave_idx_type j = scale(i) - 1;
90  std::swap (pv(i), pv(j));
91  }
92 
93  return pv;
94  }
95 
96  VT scaling_vector (void) const
97  {
98  octave_idx_type n = balanced_mat.rows ();
99 
100  VT scv (n);
101 
102  for (octave_idx_type i = 0; i < ilo-1; i++)
103  scv(i) = 1;
104 
105  for (octave_idx_type i = ilo-1; i < ihi; i++)
106  scv(i) = scale(i);
107 
108  for (octave_idx_type i = ihi; i < n; i++)
109  scv(i) = 1;
110 
111  return scv;
112  }
113 
114  protected:
115 
117  VT scale;
120  char job;
121  };
122  }
123 }
124 
125 #endif
MT balancing_matrix(void) const
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
VT scaling_vector(void) const
Definition: aepbalance.h:96
MT::real_column_vector_type VT
Definition: aepbalance.h:38
octave_idx_type ilo
Definition: aepbalance.h:118
aepbalance(const aepbalance &a)
Definition: aepbalance.h:44
VT permuting_vector(void) const
Definition: aepbalance.h:72
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
bool swap
Definition: load-save.cc:725
virtual ~aepbalance(void)
Definition: aepbalance.h:63
octave_idx_type ihi
Definition: aepbalance.h:119
aepbalance & operator=(const aepbalance &a)
Definition: aepbalance.h:49
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
MT balanced_matrix(void) const
Definition: aepbalance.h:67