public void DotProductTest() { DoubleMatrix target1 = new Double[, ] { { 1F, 2F, 3F } }; DoubleMatrix target2 = new Double[, ] { { 2F, 3F, 4F } }; Double expected = 1F * 2F + 2F * 3F + 3F * 4F; Double actual = DoubleMatrix_Accessor.DotProduct(target1, target2); Assert.AreEqual(expected, actual); }
public void DivisionTest() { DoubleMatrix matrix = new Double[, ] { { 1F, 2F, 3F }, { 2F, 3F, 4F } }; double scalar = 2F; DoubleMatrix expected = new Double[, ] { { 0.5F, 1.0F, 1.5F }, { 1.0F, 1.5F, 2.0F } }; DoubleMatrix actual = DoubleMatrix_Accessor.Division(matrix, scalar); Assert.AreEqual(expected, actual); }
public void MultiplicationTest() { DoubleMatrix matrix = new Double[, ] { { 1F, 2F, 3F }, { 2F, 3F, 4F } }; double scalar = 2F; DoubleMatrix expected = new Double[, ] { { 2F, 4F, 6F }, { 4F, 6F, 8F } }; DoubleMatrix actual; actual = DoubleMatrix_Accessor.Multiplication(matrix, scalar); Assert.AreEqual(expected, actual); }
public void SubtractionTest1() { DoubleMatrix matrix = new Double[, ] { { 1F, 2F, 3F }, { 2F, 3F, 4F } }; Double scalar = 3F; DoubleMatrix expected = new Double[, ] { { -2F, -1F, 0F }, { -1F, 0F, 1F } }; DoubleMatrix actual; actual = DoubleMatrix_Accessor.Subtraction(matrix, scalar); Assert.AreEqual(expected, actual); }
public void AdditionTest1() { DoubleMatrix matrix = new Double[, ] { { 1F, 2F, 3F }, { 2F, 3F, 4F } }; Double scalar = 3F; DoubleMatrix expected = new Double[, ] { { 4F, 5F, 6F }, { 5F, 6F, 7F } }; DoubleMatrix actual = DoubleMatrix_Accessor.Addition(matrix, scalar); Assert.AreEqual(expected, actual); }
public void SubtractionTest() { DoubleMatrix matrix1 = new Double[, ] { { 1F, 2F, 3F }, { 2F, 3F, 4F } }; DoubleMatrix matrix2 = new Double[, ] { { 4F, 3F, 2F }, { 3F, 2F, 1F } }; DoubleMatrix expected = new Double[, ] { { -3F, -1F, 1F }, { -1F, 1F, 3F } }; DoubleMatrix actual = DoubleMatrix_Accessor.Subtraction(matrix1, matrix2); Assert.AreEqual(expected, actual); }
public void MultiplicationTest1() { DoubleMatrix matrix1 = new Double[, ] { { 1F, 0F, 2F }, { -1F, 3F, 1F } }; DoubleMatrix matrix2 = new Double[, ] { { 3F, 1F }, { 2F, 1F }, { 1F, 0F } }; DoubleMatrix expected = new Double[, ] { { 5F, 1F }, { 4F, 2F } }; DoubleMatrix actual; actual = DoubleMatrix_Accessor.Multiplication(matrix1, matrix2); Assert.AreEqual(expected, actual); }
public void InvertTest() { DoubleMatrix target = new Double[, ] { { 4F, 2F, 2F }, { 4F, 6F, 8F }, { -2F, 2F, 4F } }; DoubleMatrix expected = new Double[, ] { { 1.0F, -0.5F, 0.5F }, { -4.0F, 2.5F, -3.0F }, { 2.5F, -1.5F, 2.0F } }; DoubleMatrix actual; actual = DoubleMatrix_Accessor.Invert(target); Assert.AreEqual(expected, actual); }