-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A class that tests and checks the equality of results from all matrix operations that JMatrix currently has.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/test/java/com/mitsuki/jmatrix/test/Test_MatrixOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.mitsuki.jmatrix.test; | ||
|
||
import com.mitsuki.jmatrix.Matrix; | ||
import com.mitsuki.jmatrix.util.MatrixUtils; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class Test_MatrixOperations { | ||
@Test | ||
public void test_MatrixAddition() { | ||
Matrix m = new Matrix(new double[][] { | ||
{ 1, 3, 5 }, | ||
{ 5, 7, 4 } | ||
}); | ||
|
||
Matrix n = new Matrix(new double[][] { | ||
{ 6, 7, -5 }, | ||
{ -10, 5, 16 } | ||
}); | ||
|
||
Matrix res = new Matrix(new double[][] { | ||
{ 7, 10, 0 }, | ||
{ -5, 12, 20 } | ||
}); | ||
|
||
assertEquals(false, MatrixUtils.isNullEntries(m)); | ||
assertEquals(false, MatrixUtils.isNullEntries(n)); | ||
assertEquals(false, m.equals(n)); | ||
assertEquals(false, m.isSquare()); | ||
|
||
// Check the addition operation | ||
assertEquals(true, Matrix.sum(m, n).equals(res)); | ||
} | ||
} |