如何在算法c#中转换数学公式 [英] How to convert mathematical formula in algorithm c#
本文介绍了如何在算法c#中转换数学公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
...................................... X ........ .... y
edge - density =Σ..........Σ............ | ed(i,j)|
...................................... i = 1 .. ...... j = 1
.............. __________________________
.......... ................ x * y
我需要一些有知识的人帮我解决这个算法将其转换为使用它在C#
感谢您的关注和宝贵的时间
解决方案
对我而言,这看起来非常简单,类似于:
double result = 0 。 0 ;
for ( int i = 1 ; i< = x; ++ i)
{
for ( int j = 1 ; j< = y; ++ j)
{
result + = Math.Abs(led(i,j) )); // 假设led是一个函数,接受两个参数并返回一个双
}
}
结果/ = x * y; // 边缘密度(假设x> 0和y> 0)
......................................x............y
edge - density = ∑.......... ∑ ............|ed(i,j)|
......................................i=1........j=1
.............. __________________________
.......................... x * y
I need some person with knowledge help me solve this algorithm converting it to use it in C#
Thanks for your attention and valuable time
解决方案
It looks pretty straightforward to me, something like:
double result = 0.0; for (int i=1; i<=x; ++i) { for (int j=1; j<=y; ++j) { result += Math.Abs(led(i,j)); // assuming led is a function accepting two parameters and returning a double } } result /= x*y; // edge-density (assuming both x>0 and y>0)
这篇关于如何在算法c#中转换数学公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文