Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_base_aepbal_h)
00024 #define octave_base_aepbal_h 1
00025
00026 template <class MatrixT, class VectorT>
00027 class base_aepbal
00028 {
00029 protected:
00030 MatrixT balanced_mat;
00031 VectorT scale;
00032 octave_idx_type ilo, ihi;
00033 char job;
00034
00035 base_aepbal (void) : balanced_mat (), scale (), ilo (), ihi (), job () { }
00036
00037 public:
00038
00039 base_aepbal (const base_aepbal& a)
00040 : balanced_mat (a.balanced_mat), scale (a.scale),
00041 ilo(a.ilo), ihi(a.ihi), job(a.job)
00042 {
00043 }
00044
00045 base_aepbal& operator = (const base_aepbal& a)
00046 {
00047 balanced_mat = a.balanced_mat;
00048 scale = a.scale;
00049 ilo = a.ilo;
00050 ihi = a.ihi;
00051 job = a.job;
00052 return *this;
00053 }
00054
00055 virtual ~base_aepbal (void) { }
00056
00057 MatrixT balanced_matrix (void) const { return balanced_mat; }
00058
00059 VectorT permuting_vector (void) const
00060 {
00061 octave_idx_type n = balanced_mat.rows ();
00062 VectorT pv (n);
00063 for (octave_idx_type i = 0; i < n; i++)
00064 pv(i) = i+1;
00065 for (octave_idx_type i = n-1; i >= ihi; i--)
00066 {
00067 octave_idx_type j = scale(i) - 1;
00068 std::swap (pv(i), pv(j));
00069 }
00070 for (octave_idx_type i = 0; i < ilo-1; i++)
00071 {
00072 octave_idx_type j = scale(i) - 1;
00073 std::swap (pv(i), pv(j));
00074 }
00075
00076 return pv;
00077 }
00078
00079 VectorT scaling_vector (void) const
00080 {
00081 octave_idx_type n = balanced_mat.rows ();
00082 VectorT scv (n);
00083 for (octave_idx_type i = 0; i < ilo-1; i++)
00084 scv(i) = 1;
00085 for (octave_idx_type i = ilo-1; i < ihi; i++)
00086 scv(i) = scale(i);
00087 for (octave_idx_type i = ihi; i < n; i++)
00088 scv(i) = 1;
00089
00090 return scv;
00091 }
00092 };
00093
00094 #endif