Mercurial > hg > octave-nkf
changeset 5662:1c334f7e7bef
[project @ 2006-03-10 20:27:00 by jwe]
author | jwe |
---|---|
date | Fri, 10 Mar 2006 20:27:00 +0000 |
parents | 13be36ec8279 |
children | 775e065f7dc4 |
files | src/ChangeLog src/xpow.cc |
diffstat | 2 files changed, 39 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2006-03-10 John W. Eaton <jwe@octave.org> + * xpow.cc (elem_xpow): Only use complex pow if really necessary. + * symtab.cc (symbol_table::glob, symbol_table::symbol_list, symbol_table::subsymbol_list): Force result to be a column vector.
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -569,11 +569,15 @@ for (octave_idx_type j = 0; j < nc; j++) for (octave_idx_type i = 0; i < nr; i++) { - OCTAVE_QUIT; - - Complex atmp (a (i, j)); - - result (i, j) = std::pow (atmp, b); + OCTAVE_QUIT; + double ax = a (i, j); + if (ax < 0.0) + { + Complex atmp (ax); + result (i, j) = std::pow (atmp, b); + } + else + result (i, j) = std::pow (ax, b); } retval = result; @@ -637,9 +641,16 @@ for (octave_idx_type i = 0; i < nr; i++) { OCTAVE_QUIT; - Complex atmp (a (i, j)); - Complex btmp (b (i, j)); - complex_result (i, j) = std::pow (atmp, btmp); + double ax = a (i, j); + double bx = b (i, j); + if (ax < 0.0 && static_cast<int> (bx) != bx) + { + Complex atmp (ax); + Complex btmp (bx); + complex_result (i, j) = std::pow (atmp, btmp); + } + else + complex_result (i, j) = std::pow (ax, bx); } retval = complex_result; @@ -953,10 +964,14 @@ for (octave_idx_type i = 0; i < a.length (); i++) { OCTAVE_QUIT; - - Complex atmp (a (i)); - - result(i) = std::pow (atmp, b); + double ax = a (i); + if (ax < 0.0) + { + Complex atmp (ax); + result(i) = std::pow (atmp, b); + } + else + result(i) = std::pow (ax, b); } retval = result; @@ -1017,9 +1032,16 @@ for (octave_idx_type i = 0; i < len; i++) { OCTAVE_QUIT; - Complex atmp (a(i)); - Complex btmp (b(i)); - complex_result(i) = std::pow (atmp, btmp); + double ax = a(i); + double bx = b(i); + if (ax < 0.0 && static_cast<int> (bx) != bx) + { + Complex atmp (ax); + Complex btmp (bx); + complex_result(i) = std::pow (atmp, btmp); + } + else + complex_result(i) = std::pow (ax, bx); } retval = complex_result;