From f9287a1f69fc41b9d14f9e488ce0562fb8d9c728 Mon Sep 17 00:00:00 2001 From: Goneiross Date: Tue, 27 Nov 2018 23:44:56 +0100 Subject: [PATCH] Add non working test case --- .../matrix/positiveLinearCombination.js | 128 +++++++++++++++++- 1 file changed, 125 insertions(+), 3 deletions(-) diff --git a/src/__tests__/matrix/positiveLinearCombination.js b/src/__tests__/matrix/positiveLinearCombination.js index 69bc8588..90c1b689 100644 --- a/src/__tests__/matrix/positiveLinearCombination.js +++ b/src/__tests__/matrix/positiveLinearCombination.js @@ -21,9 +21,12 @@ describe('Positive linear combination', () => { solutions = positiveLinearCombination(base, vector); + expect(solutions).toEqual(expected); }); - it('Decimal Base I', () => { + + + it('Base I Decimal I', () => { let base = new Matrix([ [0, 20, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 30, 100, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -37,9 +40,128 @@ describe('Positive linear combination', () => { let solutions = Matrix.zeros(1, base.columns); let expected = new Matrix([[1, 0, 1, 0, 0, 0.5]]); - solutions = positiveLinearCombination(base, vector, { lowestDecimal: 0.5 }); + solutions = positiveLinearCombination(base, vector, { lowestDecimal: + 0.5 }); + + expect(solutions).toEqual(expected); + }); + + + it('Luc I', () => { + let base = new Matrix([ + [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ]); + let vector = new Matrix([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + let solutions = Matrix.zeros(1, base.columns); + let expected = new Matrix([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + + solutions = positiveLinearCombination(base, vector); - console.table(solutions); expect(solutions).toEqual(expected); }); + + + it('Luc II', () => { + let base = new Matrix([ + [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ]); + let vector = new Matrix([[3, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + let solutions = Matrix.zeros(1, base.columns); + + + let expected = new Matrix([[3, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + + solutions = positiveLinearCombination(base, vector); + expect(solutions).toEqual(expected); + }); + + + it('Luc III', () => { + let base = new Matrix([ + [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ]); + let vector = new Matrix([[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]]); + let solutions = Matrix.zeros(1, base.columns); + + + let expected = new Matrix([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + + solutions = positiveLinearCombination(base, vector); + expect(solutions).toEqual(expected); + }); + it('Luc IV', () => { + let base = new Matrix([ + [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ]); + let vector = new Matrix([[0, 1, 1, 0, 0, 0, 0, 0, 0, 0]]); + let solutions = Matrix.zeros(1, base.columns); + + + let expected = new Matrix([[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]]); + + solutions = positiveLinearCombination(base, vector); + expect(solutions).toEqual(expected); + }); + + /* + + it('Luc V', () => { + let base = new Matrix([ + [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ]); + let vector = new Matrix([[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]); + let solutions = Matrix.zeros(1, base.columns); + + + let expected = new Matrix([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]); + + solutions = positiveLinearCombination(base, vector); + expect(solutions).toEqual(expected); + }); + */ });