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

Function atan2_args

include/half.hpp:1627–1643  ·  view source on GitHub ↗

Get arguments for atan2 function. \param abs half-precision floating-point value \return \a abs and sqrt(1 - \a abs^2) as Q0.30

Source from the content-addressed store, hash-verified

1625 /// \param abs half-precision floating-point value
1626 /// \return \a abs and sqrt(1 - \a abs^2) as Q0.30
1627 inline std::pair<uint32,uint32> atan2_args(unsigned int abs)
1628 {
1629 int exp = -15;
1630 for(; abs<0x400; abs<<=1,--exp) ;
1631 exp += abs >> 10;
1632 uint32 my = ((abs&0x3FF)|0x400) << 5, r = my * my;
1633 int rexp = 2 * exp;
1634 r = 0x40000000 - ((rexp>-31) ? ((r>>-rexp)|((r&((static_cast<uint32>(1)<<-rexp)-1))!=0)) : 1);
1635 for(rexp=0; r<0x40000000; r<<=1,--rexp) ;
1636 uint32 mx = sqrt<30>(r, rexp);
1637 int d = exp - rexp;
1638 if(d < 0)
1639 return std::make_pair((d<-14) ? ((my>>(-d-14))+((my>>(-d-15))&1)) : (my<<(14+d)), (mx<<14)+(r<<13)/mx);
1640 if(d > 0)
1641 return std::make_pair(my<<14, (d>14) ? ((mx>>(d-14))+((mx>>(d-15))&1)) : ((d==14) ? mx : ((mx<<(14-d))+(r<<(13-d))/mx)));
1642 return std::make_pair(my<<13, (mx<<13)+(r<<12)/mx);
1643 }
1644
1645 /// Get exponentials for hyperbolic computation
1646 /// \param abs half-precision floating-point value

Callers 2

asinFunction · 0.85
acosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected