Monday, December 11, 2017

C++11: std::fma()

C++11 added the std::fma() function. Here is an example:

#include <cmath>
#include <iostream>
using namespace std;

int main()
{
  double result      = 0.0;
  double lMuliplier  = 2.0;
  double rMultiplier = 3.0;
  double addendum    = 5.0;

  result = fma(lMuliplier, rMultiplier, addendum);//Fused Multiply Add

  cout << result << endl; // 11

  return 0;
}
// Output: 11
Reference: http://en.cppreference.com/w/cpp/numeric/math/fma

No comments:

Post a Comment