72/// An implementation of the binary-right-to-left method of exponentiation for raising a number to positive, integer power.
73/**
74 This is an implementation of the binary-right-to-left exponentiation algorithm from
75 "The Art of Computer Programming, Vol 2, Seminumerical Algorithms", Knuth.
76 The runtime-algorithmic complexity of this function is O(M), where M is the algorithmic complexity of multiplication on the type V.
77 The compile-time algorithmic complexity of this function is O(lg(power)+v(power)), where v(power) is the number of 1s in the binary representation of power.
138 The runtime-algorithmic complexity of this function is O(M), where M is the algorithmic complexity of multiplication on the type V.
139 The compile-time algorithmic complexity of this function is O(lg(power)+v(power)), where v(power) is the number of 1s in the binary representation of power.
204/// The class to compute the result of raising a value V to an integer power P, at compile-time.
205/**
206 The runtime algorithmic-complexity of this function is O(1).
207 The compile-time algorithmic complexity of this function is O(lg(power)+v(power)), where v(power) is the number of 1s in the binary representation of power.
208 */
209template<
210long V, ///< The value to exponentiate.
211long P ///< The power to which the value should be raised. Negative powers are computed as 1/V^|P|.
212 >
213struct pow : public std::binary_function<long, long, long> {
214staticconstexprlongpower=P; ///< The power to which the value should be raised.
215staticconstexprlongvalue=V; ///< The value to exponentiate. Negative powers are computed as 1/V^|P|.
229/// At compile-time, using the binary-right-to-left method, unroll the exponentiation of raising the value V to the integer power of P.
230/**
231 The runtime-algorithmic complexity of this function is O(M), where M is the algorithmic complexity of multiplication on the type V.
232 The compile-time algorithmic complexity of this function is O(lg(power)+v(power)), where v(power) is the number of 1s in the binary representation of power.
233
234 \param v The value to be exponentiated.
235 */
236template<
237long P, ///< The integer power. Negative powers are computed as 1/V^|P|.
238typename V ///< The type of the value to be exponentiated.
239 > inline__attribute__((const)) const V __fastcallFORCE_INLINE