时间的Math.sqrt的复杂性()? [英] Time complexity of Math.Sqrt()?
本文介绍了时间的Math.sqrt的复杂性()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能找到这个功能的复杂性?
How can I find the complexity of this function?
private double EuclideanDistance(MFCC.MFCCFrame vec1, MFCC.MFCCFrame vec2)
{
double Distance = 0.0;
for (int K = 0; K < 13; K++)
Distance += (vec1.Features[K] - vec2.Features[K]) * (vec1.Features[K] - vec2.Features[K]);
return Math.Sqrt(Distance);
}
我知道下面的部分是O(1):
I know that the below section is O(1):
double Distance = 0.0;
for (int K = 0; K < 13; K++)
Distance += (vec1.Features[K]-vec2.Features[K])*(vec1.Features[K]-vec2.Features[K]);
但我想不出什么的复杂的Math.sqrt( 。)
是
推荐答案
您可以考虑O(1):
在换句话说,的Math.sqrt()转换为一个单浮点
的机器代码指令
In other words, Math.Sqrt() translates to a single floating point machine code instruction
来源:
C#的Math.sqrt实施
这篇关于时间的Math.sqrt的复杂性()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文