MCPcopy Create free account
hub / github.com/EarlhamInst/KAT / power

Function power

deps/boost/boost/algorithm/algorithm.hpp:43–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41// Seminumerical Algorithms, Section 4.6.3
42template <typename T, typename Integer>
43typename boost::enable_if<boost::is_integral<Integer>, T>::type
44power (T x, Integer n) {
45 T y = 1; // Should be "T y{1};"
46 if (n == 0) return y;
47 while (true) {
48 if (n % 2 == 1) {
49 y = x * y;
50 if (n == 1)
51 return y;
52 }
53 n = n / 2;
54 x = x * x;
55 }
56 return y;
57 }
58
59/// \fn power ( T x, Integer n, Operation op )
60/// \return the value "x" raised to the power "n"

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 1

identity_operationFunction · 0.85

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68