/* 
 * The MIT License
 *
 * Copyright 2016 Y.K. Chan
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package jacobi.test.util;

import jacobi.api.Matrix;
import org.junit.Assert;

/**
 *
 * @author Y.K. Chan
 */
public final class Jacobi {
    
    public static void assertEquals(Matrix expects, Matrix actual) {
        Jacobi.assertEquals(expects, actual, 1e-8);
    }
    
    public static void assertEquals(Matrix expects, Matrix actual, double epilson) {
        Assert.assertNotNull("No expected result.", expects);
        Assert.assertNotNull("No actual result.", actual);
        Assert.assertEquals("Row count mismatch.", expects.getRowCount(), actual.getRowCount());
        Assert.assertEquals("Column count mismatch.", expects.getColCount(), actual.getColCount());
        for(int i = 0; i < actual.getRowCount(); i++){
            for(int j = 0; j < actual.getColCount(); j++){
                Assert.assertEquals(
                    " Element (" + i + "," + j + ") mismatch.",
                    expects.getRow(i)[j],
                    actual.getRow(i)[j],
                    epilson );
            }
        }
    }

}

@@ -1174,17 +1174,19 @@
 st.util;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -1203,16 +1203,108 @@
 .Matrix;
+%0D%0Aimport java.util.Collection;%0D%0Aimport java.util.List;%0D%0Aimport java.util.stream.Collectors;%0D
 %0Aimport 
@@ -1324,16 +1324,20 @@
 ert;
-%0A
+%0D%0A%0D
 %0A/**
+%0D
 %0A *
+%0D
 %0A * 
@@ -1353,20 +1353,22 @@
 .K. Chan
+%0D
 %0A */
+%0D
 %0Apublic 
@@ -1387,21 +1387,23 @@
 Jacobi %7B
+%0D
 %0A    
+%0D
 %0A    pub
@@ -1463,16 +1463,17 @@
 ctual) %7B
+%0D
 %0A       
@@ -1520,19 +1520,22 @@
 -8);
+%0D
 %0A    %7D
+%0D
 %0A    
+%0D
 %0A   
@@ -1611,16 +1611,17 @@
 e ep
+s
 il
-s
 on) %7B
+%0D
 %0A   
@@ -1678,16 +1678,17 @@
 xpects);
+%0D
 %0A       
@@ -1738,16 +1738,17 @@
 actual);
+%0D
 %0A       
@@ -1828,32 +1828,33 @@
 .getRowCount());
+%0D
 %0A        Assert.
@@ -1937,16 +1937,17 @@
 ount());
+%0D
 %0A       
@@ -1989,24 +1989,25 @@
 unt(); i++)%7B
+%0D
 %0A           
@@ -2053,16 +2053,17 @@
 ); j++)%7B
+%0D
 %0A       
@@ -2091,37 +2091,16 @@
 tEquals(
-%0A                    
 %22 Elemen
@@ -2134,16 +2134,17 @@
 match.%22,
+%0D
 %0A       
@@ -2169,32 +2169,33 @@
 ts.getRow(i)%5Bj%5D,
+%0D
 %0A               
@@ -2219,16 +2219,17 @@
 w(i)%5Bj%5D,
+%0D
 %0A       
@@ -2247,16 +2247,250 @@
   ep
+s
 il
-s
 on 
+);%0D%0A            %7D%0D%0A        %7D%0D%0A    %7D%0D%0A    %0D%0A    public static void assertEquals(Collection%3CDouble%3E expects, Collection%3CDouble%3E actual, double epsilon) %7B%0D%0A        List%3CDouble%3E exp = expects.stream().sorted().collect(Collectors.toList()
 );
+%0D
 %0A   
@@ -2490,29 +2490,341 @@
 );%0D%0A        
-    %7D
+List%3CDouble%3E act = actual.stream().sorted().collect(Collectors.toList());%0D%0A        Assert.assertEquals(%22Expects %22 + exp + %22, Actual %22 + act, exp.size(), act.size());%0D%0A        for(int i = 0; i %3C exp.size(); i++)%7B%0D%0A            Assert.assertEquals(%22Expects %22 + exp + %22, Actual %22 + act, exp.get(i), act.get(i), epsilon);%0D
 %0A        %7D%0A 
@@ -2825,14 +2825,18 @@
    %7D
+%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A%7D
+%0D
 %0A

Refactor Francis QR double shift algorithm