コード例 #1
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="n"> The number of sample points to be used in the integration, not negative or zero </param>
 /// <param name="generator"> The generator of weights and abscissas </param>
 public GaussianQuadratureIntegrator1D(int n, QuadratureWeightAndAbscissaFunction generator)
 {
     ArgChecker.isTrue(n > 0, "number of intervals must be > 0");
     ArgChecker.notNull(generator, "generating function");
     this.size       = n;
     this.generator  = generator;
     this.quadrature = generator.generate(size);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            const int n = 12;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final GaussianQuadratureData f1 = GAUSS_LEGENDRE.generate(n);
            GaussianQuadratureData f1 = GAUSS_LEGENDRE.generate(n);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final GaussianQuadratureData f2 = GAUSS_JACOBI_GL_EQUIV.generate(n);
            GaussianQuadratureData f2 = GAUSS_JACOBI_GL_EQUIV.generate(n);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final GaussianQuadratureData f3 = GAUSS_JACOBI_CHEBYSHEV_EQUIV.generate(n);
            GaussianQuadratureData f3 = GAUSS_JACOBI_CHEBYSHEV_EQUIV.generate(n);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] w1 = f1.getWeights();
            double[] w1 = f1.Weights;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] w2 = f2.getWeights();
            double[] w2 = f2.Weights;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] x1 = f1.getAbscissas();
            double[] x1 = f1.Abscissas;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] x2 = f2.getAbscissas();
            double[] x2 = f2.Abscissas;
            assertTrue(w1.Length == w2.Length);
            assertTrue(x1.Length == x2.Length);
            for (int i = 0; i < n; i++)
            {
                assertEquals(w1[i], w2[i], EPS);
                assertEquals(x1[i], -x2[i], EPS);
            }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] w3 = f3.getWeights();
            double[] w3 = f3.Weights;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] x3 = f3.getAbscissas();
            double[] x3 = f3.Abscissas;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double chebyshevWeight = Math.PI / n;
            double chebyshevWeight = Math.PI / n;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.function.Function<int, double> chebyshevAbscissa = new java.util.function.Function<int, double>()
            System.Func <int, double> chebyshevAbscissa = (final int?x) =>
            {
                return(-Math.Cos(Math.PI * (x + 0.5) / n));
            };
            for (int i = 0; i < n; i++)
            {
                assertEquals(chebyshevWeight, w3[i], EPS);
                assertEquals(chebyshevAbscissa(i), -x3[i], EPS);
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            GaussianQuadratureData other = new GaussianQuadratureData(X, W);

            assertEquals(F, other);
            assertEquals(F.GetHashCode(), other.GetHashCode());
            other = new GaussianQuadratureData(W, W);
            assertFalse(F.Equals(other));
            other = new GaussianQuadratureData(X, X);
            assertFalse(F.Equals(other));
            assertArrayEquals(F.Abscissas, X, 0);
            assertArrayEquals(F.Weights, W, 0);
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void assertResults(final GaussianQuadratureData f, final double[] x, final double[] w)
        protected internal virtual void assertResults(GaussianQuadratureData f, double[] x, double[] w)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] x1 = f.getAbscissas();
            double[] x1 = f.Abscissas;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] w1 = f.getWeights();
            double[] w1 = f.Weights;
            for (int i = 0; i < x.Length; i++)
            {
                assertEquals(x1[i], x[i], EPS);
                assertEquals(w1[i], w[i], EPS);
            }
        }
コード例 #5
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            GaussianQuadratureData other = (GaussianQuadratureData)obj;

            if (!Arrays.Equals(_abscissas, other._abscissas))
            {
                return(false);
            }
            return(Arrays.Equals(_weights, other._weights));
        }