/// <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>
        /// 
        /// <remarks>
        ///   If the integration method fails, the reason will be available at <see cref="Status"/>.
        /// </remarks>
        /// 
        /// <returns>
        ///   True if the integration method succeeds, false otherwise.
        /// </returns>
        /// 
        public bool Compute()
        {
            Status = InfiniteAdaptiveGaussKronrodStatus.Success;

            int errorCode;

            double a = this.Range.Min;
            double b = this.Range.Max;

            if (!Double.IsInfinity(a) && !Double.IsInfinity(b))
            {
                NonAdaptiveGaussKronrod.qng_(Function, a, b, ToleranceAbsolute, ToleranceRelative,
                        out result, out error, out evaluations, out errorCode);
            }

            else
            {
                double bound = 0;
                int inf;
                int last;

                if (Double.IsInfinity(a) && Double.IsInfinity(b))
                {
                    inf = 2;
                }
                else if (Double.IsInfinity(a))
                {
                    bound = b;
                    inf = -1;
                }
                else // if (Double.IsInfinity(b))
                {
                    bound = a;
                    inf = 1;
                }

                qagi_(Function, bound, inf, ToleranceAbsolute, ToleranceRelative,
                    out result, out error, out evaluations, out errorCode,
                    limit, lenw, out last, iwork, work);
            }


            if (errorCode == 6)
            {
                throw new InvalidOperationException("Invalid inputs. If this error happens, the "
                    + "framework didn't check for inputs correctly. If you encounter this error, "
                    + "please feel in a bug report at the framework's issue tracking system.");
            }

            Status = (InfiniteAdaptiveGaussKronrodStatus)errorCode;

            return Status == InfiniteAdaptiveGaussKronrodStatus.Success;
        }
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public object Clone()
        {
            NonAdaptiveGaussKronrod clone = new NonAdaptiveGaussKronrod(
                this.Function, this.Range.Min, this.Range.Max);

            clone.error             = error;
            clone.result            = result;
            clone.ToleranceAbsolute = ToleranceAbsolute;
            clone.ToleranceRelative = ToleranceRelative;

            return(clone);
        }