Skip to content

Commit

Permalink
Fix couple of methods of Matrix class for 2D-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-punko committed Oct 24, 2024
1 parent 3382836 commit f56db3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/by/andd3dfx/math/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public Matrix() {
this(1);
}

public Matrix(int m) {
this(m, 1);
public Matrix(int n) {
this(1, n);
}

public Matrix(int m, int n) {
assert (m >= 1 && n >= 0);
assert (m > 0 && n > 0);

this.m = m;
this.n = n;
Expand All @@ -43,7 +43,7 @@ public void set(int index, double value) {
}

public double get(int i) {
return get(i, 0);
return get(0, i);
}

public double y(int i) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/by/andd3dfx/math/MatrixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void constructorWithoutParams() {
void constructorWithOneParam() {
var m = new Matrix(5);

assertThat(m.getM()).isEqualTo(5);
assertThat(m.getN()).isEqualTo(1);
assertThat(m.getM()).isEqualTo(1);
assertThat(m.getN()).isEqualTo(5);
}

@Test
Expand Down

0 comments on commit f56db3a

Please sign in to comment.