public void ValidationTest_SymmetricPlusDiagonal_InvalidOperationException()
        {
            var matrix1 = new SymmetricMatrix <int>(2);
            var matrix2 = new DiagonalMatrix <int>(3);

            Assert.Throws <InvalidOperationException>(() => matrix1.Add(matrix2));
        }
예제 #2
0
        public void AdditionMatriciesWithDifferentOrderTestMethod()
        {
            var symMatrix      = new SymmetricMatrix <int>(3);
            var diagonalMatrix = new DiagonalMatrix <int>(4);

            symMatrix.Add(diagonalMatrix);
        }
예제 #3
0
        public void AdditionTest()
        {
            matrix = new SymmetricMatrix <string>("sym1", "sym3", "sym3", "sym1");

            var square = new SquareMatrix <string>(new string[2, 2] {
                { "sq1", "sq2" }, { "sq3", "sq4" }
            });
            var sq1 = matrix.Add(square);
            var sq2 = square.Add(matrix);

            Assert.IsInstanceOf(typeof(SquareMatrix <string>), sq1);
            Assert.IsInstanceOf(typeof(SquareMatrix <string>), sq2);
            CollectionAssert.AreEqual(new string[4] {
                "sym1sq1", "sym3sq2", "sym3sq3", "sym1sq4"
            }, sq1.GetElements());
            CollectionAssert.AreEqual(new string[4] {
                "sq1sym1", "sq2sym3", "sq3sym3", "sq4sym1"
            }, sq2.GetElements());

            var symmetric = new SymmetricMatrix <string>(new string[2, 2] {
                { "1sym", "3sym" }, { "3sym", "1sym" }
            });
            var sum1 = matrix.Add(symmetric);
            var sum2 = symmetric.Add(matrix);

            Assert.IsInstanceOf(typeof(SymmetricMatrix <string>), sum1);
            Assert.IsInstanceOf(typeof(SymmetricMatrix <string>), sum2);
            CollectionAssert.AreEqual(new string[4] {
                "sym11sym", "sym33sym", "sym33sym", "sym11sym"
            }, sum1.GetElements());
            CollectionAssert.AreEqual(new string[4] {
                "1symsym1", "3symsym3", "3symsym3", "1symsym1"
            }, sum2.GetElements());

            var diagonal = new DiagonalMatrix <string>(2, "DIAGONAL");

            sum1 = sum1.Add(diagonal);
            sum2 = diagonal.Add(sum2);
            Assert.IsInstanceOf(typeof(SymmetricMatrix <string>), sum1);
            Assert.IsInstanceOf(typeof(SymmetricMatrix <string>), sum2);
            CollectionAssert.AreEqual(new string[4] {
                "sym11symDIAGONAL", "sym33sym", "sym33sym", "sym11symDIAGONAL"
            }, sum1.GetElements());
            CollectionAssert.AreEqual(new string[4] {
                "DIAGONAL1symsym1", "3symsym3", "3symsym3", "DIAGONAL1symsym1"
            }, sum2.GetElements());
        }
예제 #4
0
        public void Add_Symmetric_Tests()
        {
            SymmetricMatrix <int> lhs = new SymmetricMatrix <int>(symm);

            SquareMatrix <int>    rhs1 = new SquareMatrix <int>(diag);
            DiagonalMatrix <int>  rhs2 = new DiagonalMatrix <int>(diag);
            SymmetricMatrix <int> rhs3 = new SymmetricMatrix <int>(diag);

            int[,] expected = new int[, ]  {
                { 2, 7, 3 },
                { 7, 5, -5 },
                { 3, -5, 7 }
            };

            CollectionAssert.AreEqual(new SquareMatrix <int>(expected), lhs.Add(rhs1));
            CollectionAssert.AreEqual(new SymmetricMatrix <int>(expected), lhs.Add(rhs2));
            CollectionAssert.AreEqual(new SymmetricMatrix <int>(expected), lhs.Add(rhs3));
        }
        public void Add_SymmetricMatrices_DoubleSourceArray()
        {
            int[,] sourceArray = new int[,]
            {
                {1, 5},
                {5, 4}
            };
            SymmetricMatrix<int> lhs = new SymmetricMatrix<int>(sourceArray);
            SymmetricMatrix<int> rhs = new SymmetricMatrix<int>(sourceArray);
            lhs.Add(rhs);

            int[,] actual = lhs.Add(rhs).ToArray();
            bool areDouble = true;
            for (int i = 0; i < sourceArray.GetLength(0); i++)
                for (int j = 0; j < sourceArray.GetLength(1); j++)
                    areDouble &= (sourceArray[i, j] * 2) == actual[i, j];
            Assert.IsTrue(areDouble);
        }
예제 #6
0
        public void AddTestResultMatrixType()
        {
            var array = new[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };

            AbstractSquareMatrix <int> matrix1 = new SquareMatrix <int>(array);
            AbstractSquareMatrix <int> matrix2 = new SquareMatrix <int>(array);
            var result = matrix1.Add(matrix2);

            Assert.AreEqual(typeof(SquareMatrix <int>), result.GetType());

            matrix1 = new SquareMatrix <int>(array);
            matrix2 = new DiagonalMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SquareMatrix <int>), result.GetType());

            matrix1 = new SquareMatrix <int>(array);
            matrix2 = new SymmetricMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SquareMatrix <int>), result.GetType());

            matrix1 = new DiagonalMatrix <int>(array);
            matrix2 = new SquareMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SquareMatrix <int>), result.GetType());

            matrix1 = new DiagonalMatrix <int>(array);
            matrix2 = new DiagonalMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(DiagonalMatrix <int>), result.GetType());

            matrix1 = new DiagonalMatrix <int>(array);
            matrix2 = new SymmetricMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SymmetricMatrix <int>), result.GetType());

            matrix1 = new SymmetricMatrix <int>(array);
            matrix2 = new SymmetricMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SymmetricMatrix <int>), result.GetType());

            matrix1 = new SymmetricMatrix <int>(array);
            matrix2 = new DiagonalMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SymmetricMatrix <int>), result.GetType());

            matrix1 = new SymmetricMatrix <int>(array);
            matrix2 = new SquareMatrix <int>(array);
            result  = matrix1.Add(matrix2);
            Assert.AreEqual(typeof(SquareMatrix <int>), result.GetType());
        }
예제 #7
0
        public void SumOfSymmetricMatrixes()
        {
            var fsm    = new SymmetricMatrix <int>(firstSymmetricMatrix);
            var ssm    = new SymmetricMatrix <int>(secondSymmetricMatrix);
            var result = fsm.Add(ssm);

            CollectionAssert.AreEqual(new int[, ] {
                { 0, 5, 6 }, { 5, 0, 7 }, { 6, 7, 0 }
            },
                                      new int[, ] {
                { result[0, 0], result[0, 1], result[0, 2] },
                { result[1, 0], result[1, 1], result[1, 2] },
                { result[2, 0], result[2, 1], result[2, 2] }
            });
        }
예제 #8
0
        public void SumTest_SymmetricPlusSymmetric_Symmetric()
        {
            var matrix1 = new SymmetricMatrix <int>(new int[, ] {
                { 1, 2 }, { 2, 1 }
            });
            var matrix2 = new SymmetricMatrix <int>(new int[, ] {
                { 1, 2 }, { 2, 1 }
            });

            matrix1.Add(matrix2);

            int[] array = { 2, 4, 4, 2 };

            Assert.IsTrue(IsEqual(matrix1, array));
        }
예제 #9
0
        public void Matrix_Add_SymmetricMatrix()
        {
            var array = new[, ] {
                { 1, 0, 0 }, { 0, 5, 0 }, { 0, 0, 9 }
            };
            var arrayExpected = new[, ] {
                { 2, 0, 0 }, { 0, 10, 0 }, { 0, 0, 18 }
            };
            Matrix <int> lhs      = new SquareMatrix <int>(array);
            Matrix <int> rhs      = new SymmetricMatrix <int>(array);
            var          result   = rhs.Add(lhs);
            Matrix <int> expected = new SquareMatrix <int>(arrayExpected);

            CollectionAssert.AreEqual(expected, result);

            result   = rhs.Add(rhs);
            expected = new SymmetricMatrix <int>(arrayExpected);
            CollectionAssert.AreEqual(expected, result);

            lhs      = new DiagonaleMatrix <int>(array);
            result   = rhs.Add(lhs);
            expected = new DiagonaleMatrix <int>(arrayExpected);
            CollectionAssert.AreEqual(expected, result);
        }
        public void AdditionMatricesTests2()
        {
            SymmetricMatrix <int> lhs = new SymmetricMatrix <int>(_intArr3);
            DiagonalMatrix <int>  rhs = new DiagonalMatrix <int>(_intArr2);

            int[,] expected = new int[, ]
            {
                { 1, 1, 1, 0 },
                { 0, 2, 1, 0 },
                { 0, 0, 2, 0 },
                { 0, 0, 0, 1 }
            };

            CollectionAssert.AreEqual(new SquareMatrix <int>(expected), lhs.Add(rhs));
        }
예제 #11
0
        public void SumMatrixesTest_InputSymmetricMatrixAndDiagonal_AssertExpectedAndActualResult()
        {
            int[,] firstArray = { { 1, 3, 0 }, { 3, 2, 6 }, { 0, 6, 5 } };
            Martix <int> firstMatrix = new SymmetricMatrix <int>(3, firstArray);

            int[]        secondArray  = { 1, 2, 5 };
            Martix <int> secondMatrix = new DiagonalMatrix <int>(3, secondArray);

            int[,] expectedArray = { { 2, 3, 0 }, { 3, 4, 6 }, { 0, 6, 10 } };
            var expectedMatrix = new SymmetricMatrix <int>(3, expectedArray);

            Martix <int> actualMatrix;

            actualMatrix = firstMatrix.Add <int>(secondMatrix);
            CollectionAssert.AreEqual(expectedMatrix, actualMatrix);
        }
예제 #12
0
        public void AdditionTestMethod()
        {
            var symMatrix      = new SymmetricMatrix <int>(3);
            var diagonalMatrix = new DiagonalMatrix <int>(3);
            var expectedMatrix = new[, ] {
                { 1, 1, 2 },
                { 1, 3, 3 },
                { 2, 3, 5 }
            };

            /*
             * 0 1 2
             * 1 2 3
             * 2 3 4
             */
            for (int i = 0; i < symMatrix.Order; i++)
            {
                for (int j = i; j < symMatrix.Order; j++)
                {
                    symMatrix[i, j] = i + j;
                }
            }

            for (int i = 0; i < diagonalMatrix.Order; i++)
            {
                diagonalMatrix[i, i] = 1;
            }

            var actualMatrix = symMatrix.Add(diagonalMatrix);

            bool result = true;

            for (int i = 0; i < symMatrix.Order; i++)
            {
                for (int j = 0; j < symMatrix.Order; j++)
                {
                    if (actualMatrix[i, j] != expectedMatrix[i, j])
                    {
                        result = false;
                        break;
                    }
                }
            }

            Assert.AreEqual(true, result);
        }
예제 #13
0
        public void SumTest_SymmetricPlusDiagonal_Symmetric()
        {
            var matrix1 = new SymmetricMatrix <int>(new int[, ] {
                { 1, 2 }, { 2, 1 }
            });

            var matrix2 = new DiagonalMatrix <int>(2);

            matrix2[0, 0] = 1;
            matrix2[1, 1] = 1;

            matrix1.Add(matrix2);

            int[] array = { 2, 2, 2, 2 };

            Assert.IsTrue(IsEqual(matrix1, array));
        }
        public void SquareMatrixTest()
        {
            int[] elems = new int[] { 1, 2, 3 };
            SymmetricMatrix <int> sm1 = new SymmetricMatrix <int>(elems, 4, 5, 6);

            SymmetricMatrix <int> sm2 = new SymmetricMatrix <int>(elems, 7, 8, 9);
            BaseMatrix <int>      sm3 = sm1.Add(sm2);

            int[,] matrix = sm3.Matrix;
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    Console.Write(matrix[i, j] + " ");
                }
                Console.WriteLine();
            }
        }
예제 #15
0
        public void AddTest()
        {
            // Arrange
            int[,] array1 = new int[4, 4]
            {
                { 1, 1, 1, 4 },
                { 1, 1, 1, 3 },
                { 1, 1, 1, 2 },
                { 4, 3, 2, 1 }
            };

            int[,] array2 = new int[4, 4]
            {
                { 1, 0, 0, 0 },
                { 0, 3, 0, 0 },
                { 0, 0, 2, 0 },
                { 0, 0, 0, 4 }
            };

            int[,] expectedArray = new int[4, 4]
            {
                { 2, 1, 1, 4 },
                { 1, 4, 1, 3 },
                { 1, 1, 3, 2 },
                { 4, 3, 2, 5 }
            };

            SymmetricMatrix <int> matrix1        = new SymmetricMatrix <int>(array1);
            DiagonalMatrix <int>  matrix2        = new DiagonalMatrix <int>(array2);
            SquareMatrix <int>    expectedMatrix = new SquareMatrix <int>(expectedArray);

            // Act
            var result = matrix1.Add(matrix2);

            // Assert
            for (int i = 0; i < result.Order; i++)
            {
                for (int j = 0; j < result.Order; j++)
                {
                    Assert.AreEqual(expectedMatrix[i, j], result[i, j]);
                }
            }
        }
 public void AddingSymmetricMatrix()
 {
     Matrix<int> m = new SymmetricMatrix<int>(new int[3][]
     {
         new int[3] {1, 2, 3},
         new int[3] {2, 3, 4}, new int[3] {3, 4, 5}
     });
     Matrix<int> m2 = new SymmetricMatrix<int>(new int[3][]
     {
         new int[3] {1, 2, 3},
         new int[3] {2, 3, 4}, new int[3] {3, 4, 5}
     });
     Matrix<int> m1 = m.Add(m2);
     Assert.IsTrue(new SquareMatrix<int>(new int[3][]
     {
         new int[3] {2, 4, 6},
         new int[3] {4, 6, 8}, new int[3] {6, 8, 10}
     }).Equals(m1));
 }
        public void AdditionTest()
        {
            testMatrix = new SquareMatrix <int>(9, 8, 7, 6, 0, 4, 3, 2, 1);

            var square = new SquareMatrix <int>(1, 2, 3, 4, 10, 6, 7, 8, 9);
            var sum1   = testMatrix.Add(square);
            var sum2   = square.Add(testMatrix);

            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum1);
            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(Enumerable.Repeat(10, 9), sum1.GetElements());

            var symmetric = new SymmetricMatrix <int>(new int[3, 3] {
                { 3, 3, 3 }, { 3, 2, 2, }, { 3, 2, 1 }
            });

            sum1 = sum1.Add(symmetric);
            sum2 = symmetric.Add(sum2);
            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum1);
            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(new int[9] {
                13, 13, 13, 13, 12, 12, 13, 12, 11
            }, sum1.GetElements());

            var diagonal = new DiagonalMatrix <int>(-13, -12, -11);

            sum1 = sum1.Add(diagonal);
            sum2 = diagonal.Add(sum2);
            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum1);
            Assert.IsInstanceOf(typeof(SquareMatrix <int>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(new int[9] {
                0, 13, 13, 13, 0, 12, 13, 12, 0
            }, sum1.GetElements());

            var matrix1 = new SquareMatrix <bool>(true);
            var matrix2 = new SquareMatrix <bool>(false);

            Assert.Throws <NotSupportedException>(() => matrix1.Add(matrix2));
        }
예제 #18
0
        // Error for one edge
        private double CalculateError(int id_v1, int id_v2, ref Vector3d result, ref Vector3d vbuff, ref SymmetricMatrix smbuff)
        {
            // compute interpolated vertex
            SymmetricMatrix.Add(ref vertices.Data[id_v1].q, ref vertices.Data[id_v2].q, ref smbuff);
            double error = 0;
            double det   = smbuff.Determinant1();

            if (Math.Abs(det) > 1.0e-10)
            {
                // q_delta is invertible
                result.X = -1.0 / det * smbuff.Determinant2(); // vx = A41/det(q_delta)
                result.Y = +1.0 / det * smbuff.Determinant3(); // vy = A42/det(q_delta)
                result.Z = -1.0 / det * smbuff.Determinant4(); // vz = A43/det(q_delta)
                error    = VertexError(ref smbuff, ref result);
            }
            else
            {
                // det = 0 -> try to find best result
                Vector3d p1 = vertices.Data[id_v1].p;
                Vector3d p2 = vertices.Data[id_v2].p;
                Vector3d.Average(ref p1, ref p2, ref vbuff);
                double error1 = VertexError(ref smbuff, ref p1);
                double error2 = VertexError(ref smbuff, ref p2);
                double error3 = VertexError(ref smbuff, ref vbuff);
                error = Math.Min(error1, Math.Min(error2, error3));
                if (error1 == error)
                {
                    result = p1;
                }
                else if (error2 == error)
                {
                    result = p2;
                }
                else
                {
                    result = vbuff;
                    vbuff  = new Vector3d();
                }
            }

            return(error);
        }
예제 #19
0
        public void AdditionTest()
        {
            testMatrix = new DiagonalMatrix <float>(1, 2, 9);

            var square = new SquareMatrix <float>(3u, 5);
            var sum1   = testMatrix.Add(square);
            var sum2   = square.Add(testMatrix);

            Assert.IsInstanceOf(typeof(SquareMatrix <float>), sum1);
            Assert.IsInstanceOf(typeof(SquareMatrix <float>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(new float[9] {
                6, 5, 5, 5, 7, 5, 5, 5, 14
            }, sum1.GetElements());

            var symmetric = new SymmetricMatrix <float>(new float[3, 3] {
                { 3, 3, 3 }, { 3, 2, 2, }, { 3, 2, 1 }
            });

            sum1 = testMatrix.Add(symmetric);
            sum2 = symmetric.Add(testMatrix);
            Assert.IsInstanceOf(typeof(SymmetricMatrix <float>), sum1);
            Assert.IsInstanceOf(typeof(SymmetricMatrix <float>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(new float[9] {
                4, 3, 3, 3, 4, 2, 3, 2, 10
            }, sum1.GetElements());

            var diagonal = new DiagonalMatrix <float>(3, 7);

            sum1 = testMatrix.Add(diagonal);
            sum2 = diagonal.Add(testMatrix);
            Assert.IsInstanceOf(typeof(DiagonalMatrix <float>), sum1);
            Assert.IsInstanceOf(typeof(DiagonalMatrix <float>), sum2);
            CollectionAssert.AreEqual(sum1.GetElements(), sum2.GetElements());
            CollectionAssert.AreEqual(new float[9] {
                8, 0, 0, 0, 9, 0, 0, 0, 16
            }, sum1.GetElements());

            Assert.Throws <InvalidOperationException>(() => diagonal.Add(new DiagonalMatrix <float>(2)));
        }
예제 #20
0
 public void AddMatrixTests()
 {
     Assert.AreEqual(resultSquareSymmetricMatrices, squareMatrix.Add(symmetricMatrix));
     Assert.AreEqual(new SquareMatrix <int>(resultSquareDiagonal), squareMatrix.Add(diagonalMatrix));
     Assert.AreEqual(new SymmetricMatrix <int>(resultSymmetricDiagonal), symmetricMatrix.Add(diagonalMatrix));
 }
예제 #21
0
 public void SymmetricMatrixIntegersSumTests(SymmetricMatrix <int> source1,
                                             SymmetricMatrix <int> source2, SymmetricMatrix <int> expected) =>
 Assert.AreEqual(source1.Add(source2, new SumIntegers()), expected);
예제 #22
0
 public void MatrixStringsSumTests(SymmetricMatrix <string> source1,
                                   SymmetricMatrix <string> source2, SymmetricMatrix <string> expected) =>
 Assert.AreEqual(source1.Add(source2, new SumStrings()), expected);
예제 #23
0
        /// <summary>
        /// Remove vertices and mark deleted triangles
        /// </summary>
        private int RemoveVertexPass(
            int startTrisCount,
            int targetTrisCount,
            double threshold,
            ref Vector3d vbuff,
            ref Vector3d vbuff2,
            ref SymmetricMatrix smbuff)
        {
            int      deletedTriangles = 0;
            Vector3d p = new Vector3d();

            for (int tid = 0; tid < triangles.Length; tid++)
            {
                var t = triangles.Data[tid];
                if (t.dirty || t.deleted || t.err3 > threshold)
                {
                    continue;
                }

                if (vertices.Data[t.v0].IsEdge || vertices.Data[t.v1].IsEdge || vertices.Data[t.v2].IsEdge)
                {
                    // Don't mess with triangles that touch edges
                    continue;
                }

                t.GetErrors(errArr);
                for (int j = 0; j < 3; j++)
                {
                    if (errArr[j] > threshold)
                    {
                        continue;
                    }

                    int i0 = t[j];
                    int i1 = t[(j + 1) % 3];

                    // Compute vertex to collapse to
                    CalculateError(i0, i1, ref p, ref vbuff, ref smbuff);
                    deleted0.Resize(vertices.Data[i0].tcount);
                    deleted1.Resize(vertices.Data[i1].tcount);

                    // Don't remove if flipped
                    if (Flipped(ref p, i0, i1, ref vertices.Data[i0], deleted0.Data))
                    {
                        continue;
                    }

                    if (Flipped(ref p, i1, i0, ref vertices.Data[i1], deleted1.Data))
                    {
                        continue;
                    }

                    // Not flipped, so remove edge
                    vertices.Data[i0].p = p;
                    p = new Vector3d();
                    SymmetricMatrix.Add(ref vertices.Data[i1].q, ref vertices.Data[i0].q, ref vertices.Data[i0].q);

                    UpdateTriangles(i0, ref vertices.Data[i0], deleted0.Data, ref deletedTriangles, ref vbuff, ref vbuff2, ref smbuff);
                    UpdateTriangles(i0, ref vertices.Data[i1], deleted1.Data, ref deletedTriangles, ref vbuff, ref vbuff2, ref smbuff);

                    int tstart = refs.Length;
                    int tcount = refs.Length - tstart;
                    if (tcount <= vertices.Data[i0].tcount)
                    {
                        // Compact
                        if (tcount > 0)
                        {
                            Array.Copy(refs.Data, tstart, refs.Data, vertices.Data[i0].tstart, tcount);
                        }
                    }
                    else
                    {
                        // append
                        vertices.Data[i0].tstart = tstart;
                    }

                    vertices.Data[i0].tcount = tcount;
                    break;
                }
            }

            return(deletedTriangles);
        }
예제 #24
0
        static void Main(string[] args)
        {
            BinarySearchTree <int> intTree = new BinarySearchTree <int>(5);

            intTree.Add(new[] { 8, 10, 3, 2, 7, 6 });
            foreach (var item in intTree.Inorder())
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            BinarySearchTree <int> intTree2 = new BinarySearchTree <int>(5, new IntComparer());

            intTree2.Add(new[] { 8, 10, 3, 2, 7, 6 });
            foreach (var item in intTree2.Inorder())
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            BinarySearchTree <string> stringTree = new BinarySearchTree <string>("5");

            stringTree.Add(new[] { "8", "9", "3", "2", "7", "6" });
            foreach (var item in stringTree.Inorder())
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            BinarySearchTree <string> stringTree2 = new BinarySearchTree <string>("5", new Logic.Comparers.StringComparer());

            stringTree2.Add(new[] { "8", "9", "3", "2", "7", "6" });
            foreach (var item in stringTree2.Inorder())
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();

            BinarySearchTree <Book> bookTree = new BinarySearchTree <Book>(new Book("Aaa", "Bbb", 102));

            bookTree.Add(new [] { new Book("Ccc", "Aaa", 1356), new Book("Zzz", "Qqq", 803), new Book("Lll", "Bbb", 1234) });
            foreach (var item in bookTree.Inorder())
            {
                Console.Write("\"{0}\", {1}, {2}.  ", item.Title, item.Author, item.Pages);
            }
            Console.WriteLine();

            BinarySearchTree <Book> bookTree2 = new BinarySearchTree <Book>(new Book("Aaa", "Bbb", 102), new BookComparer());

            bookTree2.Add(new[] { new Book("Ccc", "Aaa", 1356), new Book("Zzz", "Qqq", 803), new Book("Lll", "Bbb", 1234) });
            foreach (var item in bookTree2.Inorder())
            {
                Console.Write("\"{0}\", {1}, {2}.  ", item.Title, item.Author, item.Pages);
            }
            Console.WriteLine();

            BinarySearchTree <Point> pointTree = new BinarySearchTree <Point>(new Point(10, 12), new PointComparer());

            pointTree.Add(new[] { new Point(10, 6), new Point(11, 2), new Point(94, 1), new Point(5, 11), new Point(99, 0) });
            foreach (var item in pointTree.Inorder())
            {
                Console.Write("X:{0}; Y:{1}.   ", item.X, item.Y);
            }
            Console.WriteLine();


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            SymmetricMatrix <int> symmatr1 = new SymmetricMatrix <int>(new int[, ] {
                { 0, 1, 2 }, { 1, 0, 3 }, { 2, 3, 0 }
            });
            SymmetricMatrix <int> symmatr2 = new SymmetricMatrix <int>(new int[, ] {
                { 0, 1, 2 }, { 1, 0, 3 }, { 2, 3, 0 }
            });

            Console.WriteLine(symmatr1.Add(symmatr2, (a, b) => a + b));

            SquareMatrix <int> sqmatr = new SquareMatrix <int>(new int[, ] {
                { 2, 1, 7 }, { 1, 0, 3 }, { 2, 3, 8 }
            });

            Console.WriteLine(sqmatr.Add(symmatr2, (a, b) => a + b));

            DiagonalMatrix <int> dmatr = new DiagonalMatrix <int>(new int[, ] {
                { 0, 1, 7 }, { 1, 0, 3 }, { 2, 3, 0 }
            });

            Console.WriteLine(dmatr.Add(symmatr2, (a, b) => a + b));
        }