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 (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00024 #pragma implementation
00025 #endif
00026
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031 #include <string>
00032
00033 #include "dbleAEPBAL.h"
00034 #include "f77-fcn.h"
00035
00036 extern "C"
00037 {
00038 F77_RET_T
00039 F77_FUNC (dgebal, DGEBAL) (F77_CONST_CHAR_ARG_DECL,
00040 const int&, double*, const int&, int&,
00041 int&, double*, int&
00042 F77_CHAR_ARG_LEN_DECL);
00043
00044 F77_RET_T
00045 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL,
00046 F77_CONST_CHAR_ARG_DECL,
00047 const int&, const int&, const int&, double*,
00048 const int&, double*, const int&, int&
00049 F77_CHAR_ARG_LEN_DECL
00050 F77_CHAR_ARG_LEN_DECL);
00051 }
00052
00053 int
00054 AEPBALANCE::init (const Matrix& a, const std::string& balance_job)
00055 {
00056 int n = a.cols ();
00057
00058 if (a.rows () != n)
00059 {
00060 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
00061 return -1;
00062 }
00063
00064 int info;
00065 int ilo;
00066 int ihi;
00067
00068 Array<double> scale (n);
00069 double *pscale = scale.fortran_vec ();
00070
00071 balanced_mat = a;
00072 double *p_balanced_mat = balanced_mat.fortran_vec ();
00073
00074 char job = balance_job[0];
00075
00076 F77_XFCN (dgebal, DGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
00077 n, p_balanced_mat, n, ilo, ihi, pscale, info
00078 F77_CHAR_ARG_LEN (1)));
00079
00080 if (f77_exception_encountered)
00081 (*current_liboctave_error_handler) ("unrecoverable error in dgebal");
00082 else
00083 {
00084 balancing_mat = Matrix (n, n, 0.0);
00085 for (int i = 0; i < n; i++)
00086 balancing_mat.elem (i ,i) = 1.0;
00087
00088 double *p_balancing_mat = balancing_mat.fortran_vec ();
00089
00090 char side = 'R';
00091
00092 F77_XFCN (dgebak, DGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),
00093 F77_CONST_CHAR_ARG2 (&side, 1),
00094 n, ilo, ihi, pscale, n,
00095 p_balancing_mat, n, info
00096 F77_CHAR_ARG_LEN (1)
00097 F77_CHAR_ARG_LEN (1)));
00098
00099 if (f77_exception_encountered)
00100 (*current_liboctave_error_handler) ("unrecoverable error in dgebak");
00101 }
00102
00103 return info;
00104 }
00105
00106
00107
00108
00109
00110