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 "floatAEPBAL.h"
00031 #include "f77-fcn.h"
00032
00033 extern "C"
00034 {
00035 F77_RET_T
00036 F77_FUNC (sgebal, SGEBAL) (F77_CONST_CHAR_ARG_DECL,
00037 const octave_idx_type&, float*,
00038 const octave_idx_type&, octave_idx_type&,
00039 octave_idx_type&, float*, octave_idx_type&
00040 F77_CHAR_ARG_LEN_DECL);
00041
00042 F77_RET_T
00043 F77_FUNC (sgebak, SGEBAK) (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 float*,
00047 const octave_idx_type&, float*,
00048 const octave_idx_type&, octave_idx_type&
00049 F77_CHAR_ARG_LEN_DECL
00050 F77_CHAR_ARG_LEN_DECL);
00051 }
00052
00053 FloatAEPBALANCE::FloatAEPBALANCE (const FloatMatrix& a,
00054 bool noperm, bool noscal)
00055 : base_aepbal<FloatMatrix, FloatColumnVector> ()
00056 {
00057 octave_idx_type n = a.cols ();
00058
00059 if (a.rows () != n)
00060 {
00061 (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
00062 return;
00063 }
00064
00065 octave_idx_type info;
00066
00067 scale = FloatColumnVector (n);
00068 float *pscale = scale.fortran_vec ();
00069
00070 balanced_mat = a;
00071 float *p_balanced_mat = balanced_mat.fortran_vec ();
00072
00073 job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B');
00074
00075 F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),
00076 n, p_balanced_mat, n, ilo, ihi, pscale, info
00077 F77_CHAR_ARG_LEN (1)));
00078 }
00079
00080 FloatMatrix
00081 FloatAEPBALANCE::balancing_matrix (void) const
00082 {
00083 octave_idx_type n = balanced_mat.rows ();
00084 FloatMatrix balancing_mat (n, n, 0.0);
00085 for (octave_idx_type i = 0; i < n; i++)
00086 balancing_mat.elem (i ,i) = 1.0;
00087
00088 float *p_balancing_mat = balancing_mat.fortran_vec ();
00089 const float *pscale = scale.fortran_vec ();
00090
00091 octave_idx_type info;
00092
00093 char side = 'R';
00094
00095 F77_XFCN (sgebak, SGEBAK, (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 return balancing_mat;
00103 }