00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include <string>
00029
00030 #include "dbleAEPBAL.h"
00031 #include "f77-fcn.h"
00032
00033 extern "C"
00034 {
00035 F77_RET_T
00036 F77_FUNC (dgebal, DGEBAL) (F77_CONST_CHAR_ARG_DECL,
00037 const octave_idx_type&, double*,
00038 const octave_idx_type&, octave_idx_type&,
00039 octave_idx_type&, double*, octave_idx_type&
00040 F77_CHAR_ARG_LEN_DECL);
00041
00042 F77_RET_T
00043 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL,
00044 F77_CONST_CHAR_ARG_DECL,
00045 const octave_idx_type&, const octave_idx_type&,
00046 const octave_idx_type&, const double*,
00047 const octave_idx_type&, double*,
00048 const octave_idx_type&, octave_idx_type&
00049 F77_CHAR_ARG_LEN_DECL
00050 F77_CHAR_ARG_LEN_DECL);
00051 }
00052
00053 AEPBALANCE::AEPBALANCE (const Matrix& a, bool noperm, bool noscal)
00054 : base_aepbal<Matrix, ColumnVector> ()
00055 {
00056 octave_idx_type n = a.cols ();
00057
00058 if (a.rows () != n)
00059 {
00060 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
00061 return;
00062 }
00063
00064 octave_idx_type info;
00065
00066 scale = ColumnVector (n);
00067 double *pscale = scale.fortran_vec ();
00068
00069 balanced_mat = a;
00070 double *p_balanced_mat = balanced_mat.fortran_vec ();
00071
00072 job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
00073
00074 F77_XFCN (dgebal, DGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
00075 n, p_balanced_mat, n, ilo, ihi, pscale, info
00076 F77_CHAR_ARG_LEN (1)));
00077 }
00078
00079 Matrix
00080 AEPBALANCE::balancing_matrix (void) const
00081 {
00082 octave_idx_type n = balanced_mat.rows ();
00083 Matrix balancing_mat (n, n, 0.0);
00084 for (octave_idx_type i = 0; i < n; i++)
00085 balancing_mat.elem (i ,i) = 1.0;
00086
00087 double *p_balancing_mat = balancing_mat.fortran_vec ();
00088 const double *pscale = scale.fortran_vec ();
00089
00090 octave_idx_type info;
00091
00092 char side = 'R';
00093
00094 F77_XFCN (dgebak, DGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
00095 F77_CONST_CHAR_ARG2 (&side, 1),
00096 n, ilo, ihi, pscale, n,
00097 p_balancing_mat, n, info
00098 F77_CHAR_ARG_LEN (1)
00099 F77_CHAR_ARG_LEN (1)));
00100
00101 return balancing_mat;
00102 }