//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void penaltyMatrix1DTest() public virtual void penaltyMatrix1DTest() { int n = 10; DoubleMatrix p0 = PenaltyMatrixGenerator.getPenaltyMatrix(n, 0); //zeroth order AssertMatrix.assertEqualsMatrix(DoubleMatrix.identity(n), p0, 1e-15); //constant DoubleArray x = DoubleArray.filled(n, 2.0); DoubleMatrix p = PenaltyMatrixGenerator.getPenaltyMatrix(n, 2); double r = MA.getInnerProduct(x, MA.multiply(p, x)); assertEquals(0.0, r); DoubleArray x2 = DoubleArray.of(n, i => i); r = MA.getInnerProduct(x2, MA.multiply(p, x2)); assertEquals(0.0, r); DoubleArray x3 = DoubleArray.of(n, i => 0.4 + 0.4 * i + i * i); r = MA.getInnerProduct(x3, MA.multiply(p, x3)); //The second order diff is 2; for 2nd order difference use 8 values (n-2), so expect 8 * 2^2 = 32 assertEquals(32.0, r, 1e-11); p = PenaltyMatrixGenerator.getPenaltyMatrix(n, 3); r = MA.getInnerProduct(x3, MA.multiply(p, x3)); assertEquals(0.0, r, 1e-13); }