Mercurial > hg > octave-terminal
changeset 8979:a7c00773a089
optimize also .^-1 case
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 13 Mar 2009 22:54:37 +0100 |
parents | 0a58c4cd1405 |
children | 80d499b82ff3 |
files | src/xpow.cc |
diffstat | 1 files changed, 36 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -1123,6 +1123,11 @@ for (octave_idx_type i = 0; i < a.length (); i++) result.xelem (i) = a(i) * a(i); } + else if (ib == -1) + { + for (octave_idx_type i = 0; i < a.length (); i++) + result.xelem (i) = 1.0 / a(i); + } else { for (octave_idx_type i = 0; i < a.length (); i++) @@ -1282,11 +1287,19 @@ if (xisint (b)) { - for (octave_idx_type i = 0; i < a.length (); i++) - { - OCTAVE_QUIT; - result(i) = std::pow (a(i), static_cast<int> (b)); - } + if (b == -1) + { + for (octave_idx_type i = 0; i < a.length (); i++) + result.xelem (i) = std::conj (a(i)) / std::norm (a(i)); + } + else + { + for (octave_idx_type i = 0; i < a.length (); i++) + { + OCTAVE_QUIT; + result(i) = std::pow (a(i), static_cast<int> (b)); + } + } } else { @@ -2425,6 +2438,11 @@ for (octave_idx_type i = 0; i < a.length (); i++) result.xelem (i) = a(i) * a(i); } + else if (ib == -1) + { + for (octave_idx_type i = 0; i < a.length (); i++) + result.xelem (i) = 1.0f / a(i); + } else { for (octave_idx_type i = 0; i < a.length (); i++) @@ -2584,11 +2602,19 @@ if (xisint (b)) { - for (octave_idx_type i = 0; i < a.length (); i++) - { - OCTAVE_QUIT; - result(i) = std::pow (a(i), static_cast<int> (b)); - } + if (b == -1) + { + for (octave_idx_type i = 0; i < a.length (); i++) + result.xelem (i) = std::conj (a(i)) / std::norm (a(i)); + } + else + { + for (octave_idx_type i = 0; i < a.length (); i++) + { + OCTAVE_QUIT; + result(i) = std::pow (a(i), static_cast<int> (b)); + } + } } else {