using System; using System.Windows.Forms; namespace Science.Mathematics.Calculus { /// /// Adaptive multidimensional Monte Carlo integration. /// public class IntegrationMultiD { private Science.Mathematics.Function.DoubleAToDouble del; public IntegrationMultiD() { } public Science.Mathematics.Function.DoubleAToDouble Function { set { del = value; } } public IntegrationMultiD(Science.Mathematics.Function.DoubleAToDouble f) { del = f; } public void Compute() { Science.Mathematics.NumericalRecipes.RandomNumbers.Vegas obj = new Science.Mathematics.NumericalRecipes.RandomNumbers.Vegas(); if (Science.Net.Check()) { obj.Dummy = idum; obj.vegas(input, input.Length / 2, del, 0, nc, 5, 0); tgral = obj.BestEstimation; sd = obj.StandardDeviation; chi2a = obj.ChiSquare; result = obj.Result; } else { try { throw new Exception(); } catch (Exception) { MessageBox.Show("Please support our authors.", "Invalid user", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } private double[] input, from, to; private bool boolfrom = false, boolto = false; public double[] From { set { from = value; boolfrom = true; if (boolfrom & boolto) Set(); } } public double[] To { set { to = value; boolto = true; if (boolfrom & boolto) Set(); } } private void Set() { input = new double[2 * to.Length]; for (int k = 0; k < to.Length; k++) { input[k] = from[k]; input[to.Length + k] = to[k]; } } private ulong nc = 100000; public ulong NumberOfCall { get { return nc; } set { nc = value; } } private long idum = -11; public long Seed { set { idum = value; } } private double tgral, sd, chi2a; private string result; public double BestEstimation { get { return tgral; } } public double StandardDeviation { get { return sd; } } public double ChiSQUARE { get { return chi2a; } } public string Result { get { return result; } } } }