@@ -0,0 +1,2346 @@
+/*%0D%0A * Copyright (C) 2016 Y.K. Chan%0D%0A *%0D%0A * This program is free software: you can redistribute it and/or modify%0D%0A * it under the terms of the GNU General Public License as published by%0D%0A * the Free Software Foundation, either version 3 of the License, or%0D%0A * (at your option) any later version.%0D%0A *%0D%0A * This program is distributed in the hope that it will be useful,%0D%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0D%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0D%0A * GNU General Public License for more details.%0D%0A *%0D%0A * You should have received a copy of the GNU General Public License%0D%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0D%0A */%0D%0Apackage jacobi.core.impl;%0D%0A%0D%0Aimport jacobi.api.Matrix;%0D%0Aimport jacobi.test.util.Jacobi;%0D%0Aimport org.junit.Assert;%0D%0Aimport org.junit.Test;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author Y.K. Chan%0D%0A */%0D%0Apublic class DefaultMatrixTest %7B%0D%0A    %0D%0A    @Test%0D%0A    public void testConstruct() %7B%0D%0A        double%5B%5D%5B%5D rows = %7B%0D%0A            %7BMath.PI, Math.E, Math.sqrt(2.0)%7D,%0D%0A            %7BMath.E, Math.PI, Double.NaN%7D%0D%0A        %7D;%0D%0A        Matrix matrix = new DefaultMatrix(rows);%0D%0A        for(int i = 0; i %3C rows.length; i++)%7B%0D%0A            Assert.assertTrue(matrix.getRow(i) == rows%5Bi%5D);%0D%0A        %7D%0D%0A        %0D%0A        Matrix matrix2 = new DefaultMatrix(matrix);%0D%0A        for(int i = 0; i %3C rows.length; i++)%7B%0D%0A            Assert.assertTrue(matrix2.getRow(i) != rows%5Bi%5D);%0D%0A        %7D%0D%0A        %0D%0A        Matrix matrix3 = matrix.copy();%0D%0A        for(int i = 0; i %3C rows.length; i++)%7B%0D%0A            Assert.assertTrue(matrix3.getRow(i) != rows%5Bi%5D);%0D%0A        %7D%0D%0A        %0D%0A        Jacobi.assertEquals(matrix, matrix2);%0D%0A        Jacobi.assertEquals(matrix, matrix3);%0D%0A    %7D    %0D%0A    %0D%0A    @Test%0D%0A    public void testSetRow() %7B%0D%0A        double%5B%5D%5B%5D rows = %7B%0D%0A            %7BMath.PI, Math.E, Math.sqrt(2.0)%7D,%0D%0A            %7BMath.E, Math.PI, Math.sqrt(5.0)%7D%0D%0A        %7D;%0D%0A        Matrix matrix = new DefaultMatrix(rows);%0D%0A        double%5B%5D row = matrix.getRow(0);%0D%0A        row%5B1%5D = Math.exp(2.0);%0D%0A        %0D%0A        Assert.assertEquals(rows%5B0%5D%5B1%5D, Math.exp(2.0), 1e-14);%0D%0A        %0D%0A        double%5B%5D elem = %7B1.0, 2.0, 3.0%7D;%0D%0A        matrix.setRow(1, elem);%0D%0A        %0D%0A        Assert.assertTrue(rows%5B1%5D == matrix.getRow(1));%0D%0A        Assert.assertArrayEquals(rows%5B1%5D, elem, 1e-14);%0D%0A    %7D%0D%0A    %0D%0A%7D%0D%0A

Test for default matrix