예제 #1
0
        public void Determinant()
        {
            Matrix3x3d m = new Matrix3x3d((double)1, (double)0, (double)0,
                                          (double)2, (double)2, (double)3,
                                          (double)0, (double)5, (double)3);

            Assert.AreEqual((double)-9.0, m.Determinant);
        }
예제 #2
0
        public void Multiplication1()
        {
            Matrix3x3d m = new Matrix3x3d((double)1, (double)0, (double)0,
                                          (double)2, (double)2, (double)3,
                                          (double)0, (double)5, (double)3);

            Assert.IsTrue((m * Matrix3x3d.Identity).Equals(m));
        }
예제 #3
0
        /// <summary>
        /// Prepares system for solving many times with different data.
        /// </summary>
        /// <param name="S">The system.</param>
        /// <returns>Delegate capable of doing such work.</returns>
        public static Vector3d.Processor GetSolutionProcessorOf(Matrix3x3d S)
        {
            Matrix3x3d inverse = S.Inverse;

            return(delegate(Vector3d x)
            {
                return inverse * x;
            });
        }
예제 #4
0
        public void Inverse()
        {
            Matrix3x3d m = new Matrix3x3d((double)1, (double)0, (double)0,
                                          (double)2, (double)2, (double)3,
                                          (double)0, (double)5, (double)3);

            m = m.Inverse;

            Assert.IsTrue(
                Matrix3x3d.NearEqual(m, new Matrix3x3d(
                                         (double)1, (double)0, (double)0,
                                         (double)2.0 / (double)3.0, -1.0 / (double)3.0, 1.0 / (double)3.0,
                                         (double)-10.0 / (double)9.0, (double)5.0 / (double)9.0, (double)-2.0 / (double)9.0)));
        }
예제 #5
0
        public void Multiplication2()
        {
            Matrix3x3d m = new Matrix3x3d((double)1, (double)0, (double)0,
                                          (double)2, (double)2, (double)3,
                                          (double)0, (double)5, (double)3);

            Matrix3x3d m_inv = new Matrix3x3d(
                (double)1, (double)0, (double)0,
                (double)2.0 / (double)3.0, -1.0 / (double)3.0, 1.0 / (double)3.0,
                (double)-10.0 / (double)9.0, (double)5.0 / (double)9.0, (double)-2.0 / (double)9.0);

            Matrix3x3d r = m * m_inv;

            Assert.IsTrue(Matrix3x3d.NearEqual(r, Matrix3x3d.Identity));
        }
예제 #6
0
 /// <summary>
 /// We solve the system of equations, defined as:
 /// M * X = C.
 /// </summary>
 /// <param name="S">The system in matrix form.</param>
 /// <param name="C">constants</param>
 /// <returns></returns>
 public static Vector3d SolveSystem(Matrix3x3d S, Vector3d C)
 {
     return(S.Inverse * C);
 }