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 base_aepbal (void) : balanced_mat (), scale (), ilo (), ihi (), job () { }
00035
00036 public:
00037
00038 base_aepbal (const base_aepbal& a)
00039 : balanced_mat (a.balanced_mat), scale (a.scale),
00040 ilo(a.ilo), ihi(a.ihi), job(a.job)
00041 {
00042 }
00043
00044 base_aepbal& operator = (const base_aepbal& a)
00045 {
00046 balanced_mat = a.balanced_mat;
00047 scale = a.scale;
00048 ilo = a.ilo;
00049 ihi = a.ihi;
00050 job = a.job;
00051 return *this;
00052 }
00053
00054 MatrixT balanced_matrix (void) const { return balanced_mat; }
00055
00056 VectorT permuting_vector (void) const
00057 {
00058 octave_idx_type n = balanced_mat.rows ();
00059 VectorT pv (n);
00060 for (octave_idx_type i = 0; i < n; i++)
00061 pv(i) = i+1;
00062 for (octave_idx_type i = n-1; i >= ihi; i--)
00063 {
00064 octave_idx_type j = scale(i) - 1;
00065 octave_idx_type k = pv(j);
00066 pv(j) = pv(i);
00067 pv(i) = k;
00068 }
00069 for (octave_idx_type i = ilo-2; i >= 0; i--)
00070 {
00071 octave_idx_type j = scale(i) - 1;
00072 octave_idx_type k = pv(j);
00073 pv(j) = pv(i);
00074 pv(i) = k;
00075 }
00076
00077 return pv;
00078 }
00079
00080 VectorT scaling_vector (void) const
00081 {
00082 octave_idx_type n = balanced_mat.rows ();
00083 VectorT scv (n);
00084 for (octave_idx_type i = 0; i < ilo-1; i++)
00085 scv(i) = 1;
00086 for (octave_idx_type i = ilo-1; i < ihi; i++)
00087 scv(i) = scale(i);
00088 for (octave_idx_type i = ihi; i < n; i++)
00089 scv(i) = 1;
00090
00091 return scv;
00092 }
00093 };
00094
00095 #endif