Beispiel #1
0
        public static IMatrix Convert(SymmetricCoordinationalMatrix mat, string type)
        {
            switch (type)
            {
            case "Координатный":
                return(mat);

            case "Плотный":
                return(new SymmetricDenseMatrix(mat));

            case "Профильный":
                //return new SymmetricSkylineMatrix(mat);
                return(mat);

            case "Строчный без выделенной диагонали":
                return(new SymmetricSparseRowMatrix(mat));

            case "Строчно-стобцовый":
                return(new SymmetricSparseRowColumnMatrix(mat));

            default:
                // Должны вызываться конвертеры!!!!!!!!!!!!!!!!!!!!
                return(mat);
            }
        }
        public TestSymmetricCoordinationalMatrix()
        {
            size    = 3;
            values  = new double[] { 1, 4, 2, 5, 3 };
            columns = new int[] { 0, 0, 1, 0, 2 };
            rows    = new int[] { 0, 1, 1, 2, 2 };

            vector = new Vector(new double[] { 1, 1, 1 });

            symmetricCoordinationalMatrix = new SymmetricCoordinationalMatrix(rows, columns, values, size);
        }
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            symmetricCoordinationalMatrix.Fill(fillFunc);

            size    = 3;
            values  = new double[] { 2, 3, 4, 4, 6 };
            columns = new int[] { 0, 0, 1, 0, 2 };
            rows    = new int[] { 0, 1, 1, 2, 2 };

            SymmetricCoordinationalMatrix coordinat = new SymmetricCoordinationalMatrix(rows, columns, values, size);

            Assert.True(new HashSet <(double, int, int)>(symmetricCoordinationalMatrix).SetEquals(coordinat));
        }
        public void ConstructorWithZeros(FormatFactory.Formats type)
        {
            var exploredMatrix  = FormatFactory.Convert(symmetricCoordinationalMatrix, type);
            var backCoordMatrix = exploredMatrix.ConvertToCoordinationalMatrix();

            size    = 3;
            values  = new double[] { 1, 4, 2, 5, 0, 3 };
            columns = new int[] { 0, 0, 1, 0, 1, 2 };
            rows    = new int[] { 0, 1, 1, 2, 2, 2 };

            symmetricCoordinationalMatrix = new SymmetricCoordinationalMatrix(rows, columns, values, size);

            Assert.True(new HashSet <(double, int, int)>(symmetricCoordinationalMatrix).SetEquals(backCoordMatrix));

            // var formatFactory = new FormatFactory();
            //
            // foreach (var type in formatFactory.formats)
            // {
            //     var exploredMatrix = FormatFactory.Convert(symmetricCoordinationalMatrix, type.Key);
            //     var backCoordMatrix = exploredMatrix.ConvertToCoordinationalMatrix();
            //     Assert.True(new HashSet<(double, int, int)>(symmetricCoordinationalMatrix).SetEquals(backCoordMatrix));
            // }
        }
Beispiel #5
0
        public static IMatrix Convert(SymmetricCoordinationalMatrix matrix, Formats type)
        {
            switch (type)
            {
            case Formats.Coordinational:
                return(matrix);

            case Formats.Dense:
                return(new SymmetricDenseMatrix(matrix));

            case Formats.Skyline:
                return(new SymmetricSkylineMatrix(matrix));

            case Formats.SparseRow:
                return(new SymmetricSparseRowMatrix(matrix));

            case Formats.SparseRowColumn:
                return(new SymmetricSparseRowColumnMatrix(matrix));

            default:
                return(matrix);
            }
        }