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