参考:https://blog.csdn.net/wangh0802/article/details/53977215
https://blog.csdn.net/JohinieLi/article/details/79784863
夹角余弦c代码:
两个长度为100的向量a1和a2,计算余弦距离
Sim += a1[i] * a2[i];
float R1 = 0.0f;
float R2 = 0.0f;
float R = 0.0f;
for (int i = 0; i < 100; i++)
{
R1 += a1[i] * a1[i];
R2 += a2[i] * a2[i];
Sim += a1[i] * a2[i];
}
R = sqrt(R1 * R2);
Sim /= R;