Mercurial > octave-nkf
diff liboctave/floatAEPBAL.cc @ 8386:a5e080076778
make balance more Matlab-compatible
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 09 Dec 2008 10:08:19 +0100 |
parents | 7ab1ccf4256c |
children | 4c0cdbe0acca |
line wrap: on
line diff
--- a/liboctave/floatAEPBAL.cc Tue Dec 09 03:25:31 2008 +0100 +++ b/liboctave/floatAEPBAL.cc Tue Dec 09 10:08:19 2008 +0100 @@ -2,6 +2,7 @@ Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2007 John W. Eaton +Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. @@ -41,44 +42,52 @@ F77_RET_T F77_FUNC (sgebak, SGEBAK) (F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, - const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, float*, - const octave_idx_type&, float*, const octave_idx_type&, octave_idx_type& + const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, + const float*, const octave_idx_type&, float*, + const octave_idx_type&, octave_idx_type& F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL); } -octave_idx_type -FloatAEPBALANCE::init (const FloatMatrix& a, const std::string& balance_job) +FloatAEPBALANCE::FloatAEPBALANCE (const FloatMatrix& a, + bool noperm, bool noscal) + : base_aepbal<FloatMatrix, FloatColumnVector> () { octave_idx_type n = a.cols (); if (a.rows () != n) { (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix"); - return -1; + return; } octave_idx_type info; - octave_idx_type ilo; - octave_idx_type ihi; - Array<float> scale (n); + scale = FloatColumnVector (n); float *pscale = scale.fortran_vec (); balanced_mat = a; float *p_balanced_mat = balanced_mat.fortran_vec (); - char job = balance_job[0]; + job = noperm ? (noscal ? 'N' : 'S') : (noscal ? 'P' : 'B'); F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1), n, p_balanced_mat, n, ilo, ihi, pscale, info F77_CHAR_ARG_LEN (1))); +} - balancing_mat = FloatMatrix (n, n, 0.0); +FloatMatrix +FloatAEPBALANCE::balancing_matrix (void) const +{ + octave_idx_type n = balanced_mat.rows (); + FloatMatrix balancing_mat (n, n, 0.0); for (octave_idx_type i = 0; i < n; i++) balancing_mat.elem (i ,i) = 1.0; float *p_balancing_mat = balancing_mat.fortran_vec (); + const float *pscale = scale.fortran_vec (); + + octave_idx_type info; char side = 'R'; @@ -89,7 +98,7 @@ F77_CHAR_ARG_LEN (1) F77_CHAR_ARG_LEN (1))); - return info; + return balancing_mat; } /*