Why is std::sin() and std::cos() slower than sin() and cos()?

前端 未结 4 1826
小蘑菇
小蘑菇 2021-01-01 13:14

Test code:

#include 
#include 

const int N = 4096;
const float PI = 3.1415926535897932384626;

float cosine[N][N];
float sine[N][         


        
4条回答
  •  离开以前
    2021-01-01 13:40

    You're using a different overload:

    Try

            double angle = i*j*2*PI/N;
            cosine[i][j] = cos(angle);
            sine[i][j] = sin(angle);
    

    it should perform the same with or without using namespace std;

提交回复
热议问题