public void Fill(FillFunc elems)
 {
     foreach (var elem in this)
     {
         matrix[elem.row][elem.col] = elems(elem.row, elem.col);
     }
 }
        // заполнение матрицы
        public void Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }
            int i = 0, j = 0, k = 0;

            ia[0] = 0;
            ia[1] = 0;
            foreach (var elem in this)
            {
                if (elem.col == elem.row)
                {
                    di[i] = elems(elem.row, elem.col);
                }
                else
                if (elem.col < elem.row)
                {
                    al[j] = elems(elem.row, elem.col);
                    j++;
                }

                if (elem.row == i && i > 0)
                {
                    k++; // подсчет количества элементов в профиле
                }
                else
                {
                    ia[i + 1] = k;
                    i++;
                    k = 0;
                }
            }
        }
        public void Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }

            foreach (var elem in this)
            {
                matrix[elem.row][elem.col] = elems(elem.row, elem.col);
            }
        }
Exemple #4
0
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            denseSymmetricMatrix.Fill(fillFunc);
            _matrix = new double[][] { new double[] { 2 },
                                       new double[] { 3, 4 },
                                       new double[] { 4, 5, 6 } };

            SymmetricDenseMatrix dense = new SymmetricDenseMatrix(_matrix);

            Assert.True(new HashSet <(double, int, int)>(denseSymmetricMatrix).SetEquals(dense));
        }
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            symmetricSparseRowMatrix.Fill(fillFunc);

            _a  = new double[] { 2, 4, 4, 6, 6, 8 };
            _ia = new int[] { 0, 1, 2, 4, 6 };
            _ja = new int[] { 0, 1, 0, 2, 1, 3 };

            SymmetricSparseRowMatrix sparseRow = new SymmetricSparseRowMatrix(_a, _ja, _ia);

            Assert.True(new HashSet <(double, int, int)>(symmetricSparseRowMatrix).SetEquals(sparseRow));
        }
        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 Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }

            for (int i = 0; i < Size; i++)
            {
                for (int ia1 = ia[i]; ia1 < ia[i + 1]; ia1++)
                {
                    a[ia1] = elems(i, ja[ia1]);
                }
            }
        }
        public void Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }

            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    matrix[i][j] = elems(i, j);
                }
            }
        }
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            denseMatrix.Fill(fillFunc);
            _matrix = new double[3, 3]
            {
                { 2, 3, 4 },
                { 3, 4, 5 },
                { 4, 5, 6 }
            };
            DenseMatrix dense = new DenseMatrix(_matrix);

            Assert.True(new HashSet <(double, int, int)>(denseMatrix).SetEquals(dense));
        }
Exemple #10
0
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            skylineMatrix.Fill(fillFunc);

            di = new double[] { 2, 4, 6 };
            al = new double[] { 3, 4, 5 };
            au = new double[] { 3, 4, 5 };
            ia = new int[] { 1, 1, 2, 4 };


            SkylineMatrix skyline = new SkylineMatrix(di, ia, al, au);

            Assert.True(new HashSet <(double, int, int)>(skylineMatrix).SetEquals(skyline));
        }
        public void Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }

            for (int i = 0; i < Size; i++)
            {
                di[i] = elems(i, i);

                for (int j = ia[i]; j < ia[i + 1]; j++)
                {
                    aa[j] = elems(i, ja[j]);
                }
            }
        }
Exemple #12
0
        public void Fill()
        {
            FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); };

            sparseRowColumnMatrix.Fill(fillFunc);
            //di = new double[] { 1, 2, 3 };
            //al = new double[] { 1, 2, 3 };
            //au = new double[] { 3, 2, 1 };
            //ja = new int[] { 1, 1, 2 };
            //ia = new int[] { 1, 1, 2, 4 };

            di = new double[] { 2, 4, 6 };
            al = new double[] { 3, 4, 5 };
            au = new double[] { 3, 4, 5 };
            ja = new int[] { 1, 1, 2 };
            ia = new int[] { 1, 1, 2, 4 };


            SparseRowColumnMatrix sparseRowColumn = new SparseRowColumnMatrix(di, al, au, ia, ja);

            Assert.True(new HashSet <(double, int, int)>(sparseRowColumnMatrix).SetEquals(sparseRowColumn));
        }
Exemple #13
0
        //заполнение
        public void Fill(FillFunc elems)
        {
            if (elems == null)
            {
                throw new ArgumentNullException(nameof(elems));
            }
            int i = 0, j = 0;

            ia[i]     = 0;
            ia[i + 1] = 0;
            foreach (var item in this)
            {
                ja[j] = item.col <= Size ? item.col : throw new ArgumentNullException("col>size, i=" + i.ToString() + " j=" + j.ToString(), nameof(elems));
                a[j]  = elems(item.row, item.col);
                j++;
                if (item.row != i)
                {
                    i++;
                    ia[i] = item.row - i == 0 && i < Size ? ia[i - 1] : throw new ArgumentNullException("matrix[i,_]=0 || i>size, i=" + i.ToString() + " j=" + j.ToString(), nameof(elems));
                }
                ia[i + 1]++;
            }
        }