?? sample5_13.cs
字號:
/*
* 示例程序Sample5_13: NLEquations類的求非線性方程組一組實根的蒙特卡洛法
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
// 建立NLEquation的子類,在其中重載函數func
class NLEq : NLEquations
{
protected override double Func(double[] x)
{
double f,f1,f2,f3;
int n=x.Length;
f1=3.0*x[0]+x[1]+2.0*x[2]*x[2]-3.0;
f2=-3.0*x[0]+5.0*x[1]*x[1]+2.0*x[0]*x[2]-1.0;
f3=25.0*x[0]*x[1]+20.0*x[2]+12.0;
f=Math.Sqrt(f1*f1+f2*f2+f3*f3);
return(f);
}
}
[STAThread]
static void Main(string[] args)
{
// 求解
NLEq nleq = new NLEq();
double[] x={0.0,0.0,0.0};
double b=2.0;
int m=10;
int n=3;
double eps=0.000001;
nleq.GetRootsetMonteCarlo(n, x, b, m, eps);
for (int i=0; i<=n-1; i++)
{
Console.WriteLine(x[i]);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -