Mercurial > hg > octave-terminal
changeset 11030:231946a9ad55
make the result of r^m real when r > 0
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 28 Sep 2010 13:56:10 +0200 |
parents | 4ab04ea74b08 |
children | d81b6144c4ba |
files | src/ChangeLog src/xpow.cc |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-09-28 Jaroslav Hajek <highegg@gmail.com> + + * xpow.cc (xpow (double, const Matrix&)): Ensure real result for + positive base. + (xpow (double, const Matrix&)): Likewise. + 2010-09-28 Jaroslav Hajek <highegg@gmail.com> * error.cc (interpreter_try): New function.
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -123,7 +123,11 @@ } ComplexDiagMatrix D (lambda); - retval = ComplexMatrix (Q * D * Q.inverse ()); + ComplexMatrix C = Q * D * Q.inverse (); + if (a > 0) + retval = real (C); + else + retval = C; } else error ("xpow: matrix diagonalization failed"); @@ -1534,7 +1538,12 @@ } FloatComplexDiagMatrix D (lambda); - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + FloatComplexMatrix C = Q * D * Q.inverse (); + + if (a > 0) + retval = real (C); + else + retval = C; } else error ("xpow: matrix diagonalization failed");