Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1.     //
  2.     // SmallNumbersApproxPowScalarExp()
  3.     //
  4.     //! x > 0, y >= 0 !
  5.     //
  6.     //*********************************************************************************************
  7.     static inline float SmallNumbersApproxPowScalarExp(float x, float y)
  8.     {
  9.         // Based on algorithm by NN Schraudolph described here: "A Fast, Compact Approximation of the Exponential Function"
  10.         // https://nic.schraudolph.org/pubs/Schraudolph99.pdf
  11.  
  12.         static constexpr int32 CONST = 127 * (1 << 23) - 298765;
  13.  
  14.         return UIntAsFloat(FloorToInt(y * (FloatAsInt(x + 0.0000001f) - CONST) + CONST));
  15.     }
  16.     //*********************************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement