Mercurial > hg > octave-lyh
changeset 10831:1646bd8e3735
special case diagonal matrices and scalars in expm
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 29 Jul 2010 08:51:23 +0200 |
parents | b4ebfd675321 |
children | 1b2fcd122c6a |
files | scripts/ChangeLog scripts/linear-algebra/expm.m |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-07-29 Jaroslav Hajek <highegg@gmail.com> + + * linear-algebra/expm.m: Special-case scalars and diagonal matrices. + Suggested by M. Caliari. + 2010-07-26 Rik <octave@nomad.inbox5.com> * linear-algebra/logm.m: Improve documentation string. Add GPL header.
--- a/scripts/linear-algebra/expm.m +++ b/scripts/linear-algebra/expm.m @@ -76,6 +76,14 @@ error ("expm: input must be a square matrix"); endif + if (isscalar (a)) + r = exp (a); + return + elseif (strfind (typeinfo (a), "diagonal matrix")) + r = diag (exp (diag (a))); + return + endif + n = rows (a); ## Trace reduction. a(a == -Inf) = -realmax;