avx2 fma_fma()函数以及C ++中的示例
avx2 fma
C ++ fma()函數 (C++ fma() function)
fma() function is a library function of cmath header, it is used to find the result of multiply-add, it accepts three arguments and returns the result of the expression where first and second arguments will be multiplied and the third argument will be added to the multiplied result. It the arguments are x, y and z, it returns (x*y+z).
fma()函數是cmath標頭的庫函數,用于查找乘加結果,它接受三個參數并返回表達式的結果,其中第一個和第二個參數將相乘,第三個參數將被添加相乘的結果。 如果參數是x , y和z ,則返回(x * y + z) 。
Note: The fma() function computes and returns the exact result without losing precision.
注意: fma()函數計算并返回精確結果,而不會損失精度。
Syntax of fma() function:
fma()函數的語法:
fma(x, y, z);Parameter(s): x, y, z – are the numbers to calculate the multiply-add.
參數: x,y,z –是用于計算乘加的數字。
Return value: double – it returns double value that is the result of x*y+z.
返回值: double-返回x * y + z的結果double值。
Example:
例:
Input:float x = 10.20;float y = 20.91;float z = 30.12;Function call:fma(x, y, z);Output:243.402C ++代碼演示fma()函數的示例 (C++ code to demonstrate the example of fma() function)
// C++ code to demonstrate the example of // fma() function#include <iostream> #include <cmath> using namespace std;// main() section int main() {float x,y,z;float result;x = 1;y = 2;z = 3;result = fma(x,y,z);cout<<"result: "<<result<<endl;x = 10.20;y = 20.91;z = 30.12;result = fma(x,y,z);cout<<"result: "<<result<<endl; x = -10.21220;y = 20.9122;z = -30.1212;result = fma(x,y,z);cout<<"result: "<<result<<endl; return 0; }Output
輸出量
result: 5 result: 243.402 result: -243.681翻譯自: https://www.includehelp.com/cpp-tutorial/fma-function-with-example.aspx
avx2 fma
總結
以上是生活随笔為你收集整理的avx2 fma_fma()函数以及C ++中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java fmal_fma、fmaf、f
- 下一篇: DNS信息搜集方法