File tree 2 files changed +32
-0
lines changed
src/com/jwetherell/algorithms/mathematics
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .jwetherell .algorithms .mathematics ;
2
+
3
+ public class MatrixIdentity {
4
+
5
+ public static int [][] getMatrixIdentity (int size ){
6
+ int [][] matrix = new int [size ][size ];
7
+ for (int i = 0 ; i < size ; ++i ){
8
+ matrix [i ][i ] = 1 ;
9
+ }
10
+ return matrix ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ package com .jwetherell .algorithms .mathematics .test ;
2
+
3
+ import static org .junit .Assert .*;
4
+
5
+ import org .junit .Test ;
6
+
7
+ import com .jwetherell .algorithms .mathematics .MatrixIdentity ;
8
+
9
+ public class MatrixIdentityTest {
10
+
11
+ @ Test
12
+ public void test1 () {
13
+ int [][] matrix = MatrixIdentity .getMatrixIdentity (3 );
14
+
15
+ assertEquals (1 , matrix [0 ][0 ]);
16
+ assertEquals (1 , matrix [1 ][1 ]);
17
+ assertEquals (1 , matrix [2 ][2 ]);
18
+ }
19
+
20
+ }
You can’t perform that action at this time.
0 commit comments