Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testKroneckerProduct()
        public virtual void testKroneckerProduct()
        {
            Matrix m = ALGEBRA.kroneckerProduct(M3, M4);

            assertTrue(m is DoubleMatrix);
            assertMatrixEquals(m, DoubleMatrix.of(4, 4, 5, 6, 10, 12, 7, 8, 14, 16, 15, 18, 20, 24, 21, 24, 28, 32));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSubtract()
        public virtual void testSubtract()
        {
            Matrix m = ALGEBRA.subtract(M1, M2);

            assertTrue(m is DoubleArray);
            assertMatrixEquals(m, DoubleArray.of(-2, -2));
            m = ALGEBRA.subtract(M3, M4);
            assertTrue(m is DoubleMatrix);
            assertMatrixEquals(m, DoubleMatrix.of(2, 2, -4d, -4d, -4d, -4d));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAdd()
        public virtual void testAdd()
        {
            Matrix m = ALGEBRA.add(M1, M2);

            assertTrue(m is DoubleArray);
            assertMatrixEquals(m, DoubleArray.of(4, 6));
            m = ALGEBRA.add(M3, M4);
            assertTrue(m is DoubleMatrix);
            assertMatrixEquals(m, DoubleMatrix.of(2, 2, 6d, 8d, 10d, 12d));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testScale()
        public virtual void testScale()
        {
            Matrix m = ALGEBRA.scale(M1, 10);

            assertTrue(m is DoubleArray);
            assertMatrixEquals(m, DoubleArray.of(10, 20));
            m = ALGEBRA.scale(m, 0.1);
            assertMatrixEquals(m, M1);
            m = ALGEBRA.scale(M3, 10);
            assertTrue(m is DoubleMatrix);
            assertMatrixEquals(m, DoubleMatrix.of(2, 2, 10d, 20d, 30d, 40d));
            m = ALGEBRA.scale(m, 0.1);
            assertMatrixEquals(m, M3);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Finds the second derivatives.
        /// </summary>
        /// <param name="pp">  the PiecewisePolynomialResult </param>
        /// <param name="xKeys">  the key </param>
        /// <returns> the second derivatives of piecewise polynomial functions at xKeys
        ///   When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains
        ///   multiple piecewise polynomials, a row vector of return value corresponds to each piecewise polynomial </returns>
        public virtual DoubleMatrix differentiateTwice(PiecewisePolynomialResult pp, double[] xKeys)
        {
            ArgChecker.notNull(pp, "pp");
            ArgChecker.isFalse(pp.Order < 3, "polynomial degree < 2");

            DoubleArray  knots               = pp.Knots;
            int          nCoefs              = pp.Order;
            int          rowCount            = pp.Dimensions * pp.NumberOfIntervals;
            int          colCount            = nCoefs - 2;
            DoubleMatrix coef                = DoubleMatrix.of(rowCount, colCount, (i, j) => pp.CoefMatrix.get(i, j) * (nCoefs - j - 1) * (nCoefs - j - 2));
            PiecewisePolynomialResult ppDiff = new PiecewisePolynomialResult(knots, coef, nCoefs - 1, pp.Dimensions);

            return(evaluate(ppDiff, xKeys));
        }
Exemplo n.º 6
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 testAddDifferentColumnNumber2D()
        public virtual void testAddDifferentColumnNumber2D()
        {
            ALGEBRA.add(M3, DoubleMatrix.of(2, 3, 1d, 2d, 3d, 4d, 5d, 6d));
        }
Exemplo n.º 7
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 testAddDifferentRowNumber2D()
        public virtual void testAddDifferentRowNumber2D()
        {
            ALGEBRA.add(M3, DoubleMatrix.of(3, 2, 1d, 2d, 3d, 4d, 5d, 6d));
        }
Exemplo n.º 8
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 testSubtractDifferentColumnNumber2D()
        public virtual void testSubtractDifferentColumnNumber2D()
        {
            ALGEBRA.subtract(M3, DoubleMatrix.of(2, 3, 1d, 2d, 3d, 4d, 5d, 6d));
        }
//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()
        {
            VolatilityAndBucketedSensitivities @object = VolatilityAndBucketedSensitivities.of(VOL, SENSITIVITIES);

            assertEquals(VOL, @object.Volatility);
            assertEquals(SENSITIVITIES, @object.Sensitivities);
            VolatilityAndBucketedSensitivities other = VolatilityAndBucketedSensitivities.of(VOL, DoubleMatrix.of(2, 3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6));

            assertEquals(@object, other);
            assertEquals(@object.GetHashCode(), other.GetHashCode());
            other = VolatilityAndBucketedSensitivities.of(VOL + 0.01, SENSITIVITIES);
            assertFalse(other.Equals(@object));
            other = VolatilityAndBucketedSensitivities.of(VOL, SENSITIVITIES2);
            assertFalse(other.Equals(@object));
        }