MCPcopy Create free account
hub / github.com/apache/singa / sqrt

Function sqrt

include/half.hpp:1480–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1478 /// \param exp exponent
1479 /// \return square root as Q1.F/2
1480 template<unsigned int F> uint32 sqrt(uint32 &r, int &exp)
1481 {
1482 int i = exp & 1;
1483 r <<= i;
1484 exp = (exp-i) / 2;
1485 uint32 m = 0;
1486 for(uint32 bit=static_cast<uint32>(1)<<F; bit; bit>>=2)
1487 {
1488 if(r < m+bit)
1489 m >>= 1;
1490 else
1491 {
1492 r -= m + bit;
1493 m = (m>>1) + bit;
1494 }
1495 }
1496 return m;
1497 }
1498
1499 /// Fixed point binary exponential.
1500 /// This uses the BKM algorithm in E-mode.

Callers 11

hypotFunction · 0.70
powFunction · 0.70
TESTFunction · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
Cpp>Method · 0.50
Cuda>Method · 0.50
FillMethod · 0.50
FillMethod · 0.50

Calls 3

halfClass · 0.85
signalFunction · 0.85
invalidFunction · 0.85

Tested by 5

TESTFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40