Skip to content

Commit 72060b4

Browse files
committed
Add test for decimal
1 parent 1ffd24d commit 72060b4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/__tests__/matrix/positiveLinearCombination.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,32 @@ describe('Positive linear combination', () => {
1414
[0, 0, 0, 0, 0, 0, 0, 10, 100, 10, 0, 0, 0, 0, 0, 0, 0, 0],
1515
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 100, 10],
1616
]);
17-
let vector = new Matrix([[0, 20, 100, 20, 0, 0, 0, 0, 0, 5, 100, 5, 0, 0, 0, 20, 200, 20]]);
17+
let vector = new Matrix(
18+
[[0, 20, 100, 20, 0, 0, 0, 0, 0, 5, 100, 5, 0, 0, 0, 20, 200, 20]]);
1819
let solutions = Matrix.zeros(1, base.columns);
1920
let expected = new Matrix([[1, 0, 1, 0, 0, 2]]);
2021

2122
solutions = positiveLinearCombination(base, vector);
2223

2324
expect(solutions).toEqual(expected);
2425
});
25-
});
26+
it('Decimal Base I', () => {
27+
let base = new Matrix([
28+
[0, 20, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29+
[0, 0, 0, 0, 0, 30, 100, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
30+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 100, 5, 0, 0, 0, 0, 0, 0],
31+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 100, 15, 0, 0, 0],
32+
[0, 0, 0, 0, 0, 0, 0, 10, 100, 10, 0, 0, 0, 0, 0, 0, 0, 0],
33+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 100, 10],
34+
]);
35+
let vector = new Matrix(
36+
[[0, 20, 100, 20, 0, 0, 0, 0, 0, 5, 100, 5, 0, 0, 0, 5, 50, 5]]);
37+
let solutions = Matrix.zeros(1, base.columns);
38+
let expected = new Matrix([[1, 0, 1, 0, 0, 0.5]]);
39+
40+
solutions = positiveLinearCombination(base, vector, { lowestDecimal: 0.5 });
2641

42+
console.table(solutions);
43+
expect(solutions).toEqual(expected);
44+
});
45+
});

0 commit comments

Comments
 (0)