コード例 #1
0
        public void MultiplyMatrix()
        {
            Matrix33D m = new Matrix33D(12, 23, 45,
                                        67, 89, 90,
                                        43, 65, 87);

            Assert.AreEqual(Matrix33D.Zero, Matrix33D.Multiply(m, Matrix33D.Zero));
            Assert.AreEqual(Matrix33D.Zero, Matrix33D.Multiply(Matrix33D.Zero, m));
            Assert.AreEqual(m, Matrix33D.Multiply(m, Matrix33D.Identity));
            Assert.AreEqual(m, Matrix33D.Multiply(Matrix33D.Identity, m));
            Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, Matrix33D.Multiply(m, m.Inverse)));
            Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, Matrix33D.Multiply(m.Inverse, m)));

            Matrix33D m1 = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor);
            Matrix33D m2 = new Matrix33D(12, 23, 45,
                                         67, 89, 90,
                                         43, 65, 87);
            Matrix33D result = Matrix33D.Multiply(m1, m2);

            for (int column = 0; column < 3; column++)
            {
                for (int row = 0; row < 3; row++)
                {
                    Assert.AreEqual(Vector3D.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]);
                }
            }
        }
コード例 #2
0
 public void Multiplication()
 {
   double s = 0.1234;
   Matrix33D m = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor);
   m = Matrix33D.Multiply(s, m);
   for (int i = 0; i < 9; i++)
     Assert.AreEqual(rowMajor[i] * s, m[i]);
 }
コード例 #3
0
    public void MultiplyVector()
    {
      Vector3D v = new Vector3D(2.34, 3.45, 4.56);
      Assert.AreEqual(v, Matrix33D.Multiply(Matrix33D.Identity, v));
      Assert.AreEqual(Vector3D.Zero, Matrix33D.Multiply(Matrix33D.Zero, v));

      Matrix33D m = new Matrix33D(12, 23, 45,
                                67, 89, 90,
                                43, 65, 87);
      Assert.IsTrue(Vector3D.AreNumericallyEqual(v, Matrix33D.Multiply(m * m.Inverse, v)));

      for (int i = 0; i < 3; i++)
        Assert.AreEqual(Vector3D.Dot(m.GetRow(i), v), Matrix33D.Multiply(m, v)[i]);
    }