public void GetColumn() { Matrix22D m = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); Assert.AreEqual(new Vector2D(1.0, 3.0), m.GetColumn(0)); Assert.AreEqual(new Vector2D(2.0, 4.0), m.GetColumn(1)); }
public void SetColumn() { Matrix22D m = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); m.SetColumn(0, new Vector2D(0.1, 0.2)); Assert.AreEqual(new Vector2D(0.1, 0.2), m.GetColumn(0)); Assert.AreEqual(new Vector2D(2.0, 4.0), m.GetColumn(1)); m.SetColumn(1, new Vector2D(0.4, 0.5)); Assert.AreEqual(new Vector2D(0.1, 0.2), m.GetColumn(0)); Assert.AreEqual(new Vector2D(0.4, 0.5), m.GetColumn(1)); }
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]); } } }
public void GetColumnException2() { Matrix22D m = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); m.GetColumn(2); }
public void MultiplyMatrixOperator() { Matrix22D m = new Matrix22D(12, 23, 45, 67); Assert.AreEqual(Matrix22D.Zero, m * Matrix22D.Zero); Assert.AreEqual(Matrix22D.Zero, Matrix22D.Zero * m); Assert.AreEqual(m, m * Matrix22D.Identity); Assert.AreEqual(m, Matrix22D.Identity * m); Assert.IsTrue(Matrix22D.AreNumericallyEqual(Matrix22D.Identity, m * m.Inverse)); Assert.IsTrue(Matrix22D.AreNumericallyEqual(Matrix22D.Identity, m.Inverse * m)); Matrix22D m1 = new Matrix22D(columnMajor, MatrixOrder.ColumnMajor); Matrix22D m2 = new Matrix22D(12, 23, 45, 67); Matrix22D result = 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]); }