Mercurial > octave
comparison libinterp/corefcn/xpow.cc @ 28637:fb37f50d5ba8
new Range::final_value function
* Range.h (Range::final_value): New function.
* pr-output.cc (octave_print_internal (std::ostream&, const Range&,
bool, int)): Use Range::final_value instead of computing it here.
* xpow.cc (elem_expow (double, const Range&)): Likewise.
(elem_expow (const Complex&, const Range&)): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Aug 2020 15:36:30 -0400 |
parents | a3db48e66ef8 |
children | 98192ec1621f |
comparison
equal
deleted
inserted
replaced
28636:a3db48e66ef8 | 28637:fb37f50d5ba8 |
---|---|
730 for (octave_idx_type i = 1; i < n; i++) | 730 for (octave_idx_type i = 1; i < n; i++) |
731 result(i) = (base *= inc); | 731 result(i) = (base *= inc); |
732 } | 732 } |
733 else | 733 else |
734 { | 734 { |
735 // Don't use Range::limit () here. | 735 double limit = std::pow (a, r.final_value ()); |
736 double limit = std::pow (a, r.base () + (n-1) * r.increment ()); | |
737 double inc = std::pow (a, -r.increment ()); | 736 double inc = std::pow (a, -r.increment ()); |
738 result(n-1) = limit; | 737 result(n-1) = limit; |
739 for (octave_idx_type i = n-2; i >= 0; i--) | 738 for (octave_idx_type i = n-2; i >= 0; i--) |
740 result(i) = (limit *= inc); | 739 result(i) = (limit *= inc); |
741 } | 740 } |
960 for (octave_idx_type i = 1; i < n; i++) | 959 for (octave_idx_type i = 1; i < n; i++) |
961 result(i) = (base *= inc); | 960 result(i) = (base *= inc); |
962 } | 961 } |
963 else | 962 else |
964 { | 963 { |
965 // Don't use Range::limit () here. | 964 Complex limit = std::pow (a, r.final_value ()); |
966 Complex limit = std::pow (a, r.base () + (n-1) * r.increment ()); | |
967 Complex inc = std::pow (a, -r.increment ()); | 965 Complex inc = std::pow (a, -r.increment ()); |
968 result(n-1) = limit; | 966 result(n-1) = limit; |
969 for (octave_idx_type i = n-2; i >= 0; i--) | 967 for (octave_idx_type i = n-2; i >= 0; i--) |
970 result(i) = (limit *= inc); | 968 result(i) = (limit *= inc); |
971 } | 969 } |