コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual double?getRoot(System.Func <double, double> function, double?x)
        {
            ArgChecker.notNull(function, "function");
            ArgChecker.notNull(x, "x");
            DoubleFunction1D f = DoubleFunction1D.from(function);

            return(getRoot(f, f.derivative(), x));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testConversion()
        public virtual void testConversion()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.function.Function<double, double> f1 = x -> x * x * x + 2 * x * x - 7 * x + 12;
            System.Func <double, double> f1 = x => x * x * x + 2 * x * x - 7 * x + 12;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final DoubleFunction1D f2 = DoubleFunction1D.from(f1);
            DoubleFunction1D f2 = DoubleFunction1D.from(f1);

            for (int i = 0; i < 100; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double x = Math.random();
                double x = GlobalRandom.NextDouble;
                assertEquals(f2.applyAsDouble(x), F1.applyAsDouble(x), 0);
                assertEquals(f2.derivative().applyAsDouble(x), F1.derivative().applyAsDouble(x), 0);
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void testConvertNull()
        public virtual void testConvertNull()
        {
            DoubleFunction1D.from(null);
        }
コード例 #4
0
 /// <summary>
 /// {@inheritDoc} </summary>
 /// <exception cref="MathException"> If the root is not found in 1000 attempts; if the Newton
 ///   step takes the estimate for the root outside the original bounds. </exception>
 public override double?getRoot(System.Func <double, double> function, double?x1, double?x2)
 {
     ArgChecker.notNull(function, "function");
     return(getRoot(DoubleFunction1D.from(function), x1, x2));
 }
コード例 #5
0
 /// <summary>
 /// Uses the function and its derivative. This method uses an initial guess for the root, rather than bounds. </summary>
 /// <param name="function"> The function, not null </param>
 /// <param name="derivative"> The derivative, not null </param>
 /// <param name="x"> The initial guess for the root, not null </param>
 /// <returns> The root </returns>
 /// <exception cref="MathException"> If the root is not found in 1000 attempts. </exception>
 public virtual double?getRoot(System.Func <double, double> function, System.Func <double, double> derivative, double?x)
 {
     return(getRoot(DoubleFunction1D.from(function), DoubleFunction1D.from(derivative), x));
 }
コード例 #6
0
 /// <summary>
 /// Uses the function and its derivative. </summary>
 /// <param name="function"> The function, not null </param>
 /// <param name="derivative"> The derivative, not null </param>
 /// <param name="x1"> The first bound of the root, not null </param>
 /// <param name="x2"> The second bound of the root, not null </param>
 /// <returns> The root </returns>
 /// <exception cref="MathException"> If the root is not found in 1000 attempts; if the Newton
 ///   step takes the estimate for the root outside the original bounds. </exception>
 public virtual double?getRoot(System.Func <double, double> function, System.Func <double, double> derivative, double?x1, double?x2)
 {
     checkInputs(function, x1, x2);
     ArgChecker.notNull(derivative, "derivative");
     return(getRoot(DoubleFunction1D.from(function), DoubleFunction1D.from(derivative), x1, x2));
 }