public void Multiplication() { double s = 0.1234; Matrix22D m = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); m = Matrix22D.Multiply(s, m); for (int i = 0; i < 4; i++) { Assert.AreEqual(rowMajor[i] * s, m[i]); } }
public void MultiplyVector() { Vector2D v = new Vector2D(2.34, 3.45); Assert.AreEqual(v, Matrix22D.Multiply(Matrix22D.Identity, v)); Assert.AreEqual(Vector2D.Zero, Matrix22D.Multiply(Matrix22D.Zero, v)); Matrix22D m = new Matrix22D(12, 23, 45, 67); Assert.IsTrue(Vector2D.AreNumericallyEqual(v, Matrix22D.Multiply(m * m.Inverse, v))); for (int i = 0; i < 2; i++) { Assert.AreEqual(Vector2D.Dot(m.GetRow(i), v), Matrix22D.Multiply(m, v)[i]); } }
public void MultiplyMatrix() { Matrix22D m = new Matrix22D(12, 23, 45, 67); Assert.AreEqual(Matrix22D.Zero, Matrix22D.Multiply(m, Matrix22D.Zero)); Assert.AreEqual(Matrix22D.Zero, Matrix22D.Multiply(Matrix22D.Zero, m)); Assert.AreEqual(m, Matrix22D.Multiply(m, Matrix22D.Identity)); Assert.AreEqual(m, Matrix22D.Multiply(Matrix22D.Identity, m)); Assert.IsTrue(Matrix22D.AreNumericallyEqual(Matrix22D.Identity, Matrix22D.Multiply(m, m.Inverse))); Assert.IsTrue(Matrix22D.AreNumericallyEqual(Matrix22D.Identity, Matrix22D.Multiply(m.Inverse, m))); Matrix22D m1 = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); Matrix22D m2 = new Matrix22D(12, 23, 45, 67); Matrix22D result = Matrix22D.Multiply(m1, m2); for (int column = 0; column < 2; column++) { for (int row = 0; row < 2; row++) { Assert.AreEqual(Vector2D.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]); } } }