예제 #1
0
        public void Construct1()
        {
            Matrix32 <double> m = new Matrix32 <double>(1.0);

            for (int i = 0; i < m.NumberOfComponents; ++i)
            {
                Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0], 1e-14);
            }
        }
예제 #2
0
 public static Matrix32 <float> DoubleToFloat(Matrix32 <double> value)
 {
     return(new Matrix32 <float>(
                (float)value.Column0Row0,
                (float)value.Column1Row0,
                (float)value.Column2Row0,
                (float)value.Column0Row1,
                (float)value.Column1Row1,
                (float)value.Column2Row1));
 }
예제 #3
0
        public void TestGetHashCode()
        {
            Matrix32 <double> a = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);
            Matrix32 <double> b = new Matrix32 <double>(0.0);
            Matrix32 <double> c = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);

            Assert.AreEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #4
0
        public void DoubleToFloat()
        {
            Matrix32 <double> m = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);

            Matrix32 <float> mf = Matrix32 <double> .DoubleToFloat(m);

            Assert.AreEqual(1.0f, mf.Column0Row0, 1e-7);
            Assert.AreEqual(2.0f, mf.Column1Row0, 1e-7);
            Assert.AreEqual(3.0f, mf.Column2Row0, 1e-7);
            Assert.AreEqual(4.0f, mf.Column0Row1, 1e-7);
            Assert.AreEqual(5.0f, mf.Column1Row1, 1e-7);
            Assert.AreEqual(6.0f, mf.Column2Row1, 1e-7);
        }
예제 #5
0
        public bool Equals(Matrix32 <T> other)
        {
            if (Matrix4F.ReferenceEquals(other, null))
            {
                return(false);
            }

            for (int i = 0; i < _values.Length; ++i)
            {
                if (!_values[i].Equals(other._values[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #6
0
        public void Construct2()
        {
            Matrix32 <double> m = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);

            Assert.AreEqual(1.0, m.Column0Row0);
            Assert.AreEqual(2.0, m.Column1Row0);
            Assert.AreEqual(3.0, m.Column2Row0);
            Assert.AreEqual(4.0, m.Column0Row1);
            Assert.AreEqual(5.0, m.Column1Row1);
            Assert.AreEqual(6.0, m.Column2Row1);

            Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0]);
            Assert.AreEqual(4.0, m.ReadOnlyColumnMajorValues[1]);
            Assert.AreEqual(2.0, m.ReadOnlyColumnMajorValues[2]);
            Assert.AreEqual(5.0, m.ReadOnlyColumnMajorValues[3]);
            Assert.AreEqual(3.0, m.ReadOnlyColumnMajorValues[4]);
            Assert.AreEqual(6.0, m.ReadOnlyColumnMajorValues[5]);
        }
예제 #7
0
        public void Equals()
        {
            Matrix32 <double> a = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);
            Matrix32 <double> b = new Matrix32 <double>(0.0);
            Matrix32 <double> c = new Matrix32 <double>(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0);

            Assert.IsTrue(a.Equals(c));
            Assert.IsTrue(c.Equals(a));
            Assert.IsTrue(a == c);
            Assert.IsTrue(c == a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);
            Assert.IsTrue(a != b);
            Assert.IsTrue(b != a);

            object objA = a;
            object objB = b;
            object objC = c;

            Assert.IsTrue(a.Equals(objA));
            Assert.IsTrue(a.Equals(objC));
            Assert.IsFalse(a.Equals(objB));

            Assert.IsTrue(objA.Equals(objC));
            Assert.IsFalse(objA.Equals(objB));

            Assert.IsFalse(a.Equals(null));
            Assert.IsFalse(a.Equals(5));
        }