Compute() 공개 메소드

Computes the area of the function under the selected Range. The computed value will be available at this object's Area.
public Compute ( ) : bool
리턴 bool
        /// <summary>
        ///   Computes the area of the function under the selected <see cref="Range"/>.
        ///   The computed value will be available at this object's <see cref="Area"/>.
        /// </summary>
        ///
        /// <returns>
        ///   True if the integration method succeeds, false otherwise.
        /// </returns>
        ///
        public static double Integrate(Func <double[], double> func, double[] a, double[] b)
        {
            var mc = new MonteCarloIntegration(a.Length, func);

            for (int i = 0; i < a.Length; i++)
            {
                mc.Range[i] = new DoubleRange(a[i], b[i]);
            }
            mc.Compute();
            return(mc.Area);
        }
예제 #2
0
 /// <summary>
 ///   Computes the area of the function under the selected <see cref="Range"/>.
 ///   The computed value will be available at this object's <see cref="Area"/>.
 /// </summary>
 /// 
 /// <returns>
 ///   True if the integration method succeeds, false otherwise.
 /// </returns>
 /// 
 public static double Integrate(Func<double[], double> func, double[] a, double[] b)
 {
     var mc = new MonteCarloIntegration(a.Length, func);
     for (int i = 0; i < a.Length; i++)
         mc.Range[i] = new DoubleRange(a[i], b[i]);
     mc.Compute();
     return mc.Area;
 }