File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/test/java/com/thealgorithms Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .thealgorithms .matrix ;
2+
3+ import static org .junit .jupiter .api .Assertions .*;
4+ import org .junit .jupiter .api .Test ;
5+
6+ class StochasticMatrixTest {
7+
8+ @ Test
9+ void testRowStochasticMatrix () {
10+ double [][] matrix = {
11+ {0.2 , 0.5 , 0.3 },
12+ {0.1 , 0.6 , 0.3 }
13+ };
14+ assertTrue (StochasticMatrix .isRowStochastic (matrix ));
15+ assertFalse (StochasticMatrix .isColumnStochastic (matrix ));
16+ }
17+
18+ @ Test
19+ void testColumnStochasticMatrix () {
20+ double [][] matrix = {
21+ {0.4 , 0.2 },
22+ {0.6 , 0.8 }
23+ };
24+ assertTrue (StochasticMatrix .isColumnStochastic (matrix ));
25+ }
26+
27+ @ Test
28+ void testInvalidMatrix () {
29+ double [][] matrix = {
30+ {0.5 , -0.5 },
31+ {0.5 , 1.5 }
32+ };
33+ assertFalse (StochasticMatrix .isRowStochastic (matrix ));
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments