public SymmetricSparseRowMatrix(SymmetricCoordinationalMatrix matrix)
        {
            if (matrix == null)
            {
                throw new ArgumentNullException(nameof(matrix));
            }
            var elems = matrix.OrderBy(key => key.row).ThenBy(key => key.col);

            ia = new int[matrix.Size + 1];
            List <int>    list_ja = new List <int>();
            List <double> list_a  = new List <double>();

            foreach (var item in elems)
            {
                if (item.row >= item.col)
                {
                    ia[item.row + 1]++;
                    list_ja.Add(item.col);
                    list_a.Add(item.value);
                }
            }
            for (int i = 1; i < Size; i++)
            {
                ia[i + 1] += ia[i];
            }
            ja = new int[ia[Size]];
            a  = new double[ja.Length];
            ja = list_ja.ToArray();
            a  = list_a.ToArray();
        }
Ejemplo n.º 2
0
        public SymmetricSkylineMatrix(SymmetricCoordinationalMatrix coordinationalMatrix)
        {
            if (coordinationalMatrix == null)
            {
                throw new ArgumentNullException(nameof(coordinationalMatrix));
            }

            var orderedItems = coordinationalMatrix.OrderBy(x => x.row).ThenBy(x => x.col);

            var size = coordinationalMatrix.Size;

            ia = new int[size + 1];
            di = new double[size];

            var itemsProfile = new Dictionary <(int i, int j), double>();
            int flag = 1, jj = 0;

            foreach (var item in orderedItems)
            {
                if (item.row == item.col)
                {
                    di[item.row] = item.value;
                }
                else
                {
                    (int i, int j) = (item.row, item.col);

                    itemsProfile[(i, j)] = item.value;
Ejemplo n.º 3
0
        public SymmetricSkylineMatrix(SymmetricCoordinationalMatrix coordinationalMatrix)
        {
            if (coordinationalMatrix == null)
            {
                throw new ArgumentNullException(nameof(coordinationalMatrix));
            }

            var size     = coordinationalMatrix.Size;
            var pattern  = new SortedSet <int> [size];
            var pattern2 = new Dictionary <(int i, int j), int>();

            for (int i = 0; i < size; i++)
            {
                pattern[i] = new SortedSet <int>();
            }

            foreach (var item in coordinationalMatrix)
            {
                (int i, int j) = item.row > item.col ? (item.row, item.col) : (item.col, item.row);

                if (i != j)
                {
                    pattern[i].Add(j);
                }
            }

            // добавление в шаблон нулей
            for (int i = 1; i < size; i++)
            {
                if (pattern[i].Count != 0)
                {
                    int j = pattern[i].First();

                    pattern2[(i, j)] = 1;
Ejemplo n.º 4
0
        public SymmetricDenseMatrix(SymmetricCoordinationalMatrix coordinationalMatrix)
        {
            if (coordinationalMatrix == null)
            {
                throw new ArgumentNullException(nameof(coordinationalMatrix));
            }

            AllocateMemory(coordinationalMatrix.Size);

            foreach (var item in coordinationalMatrix)
            {
                if (item.row >= item.col)
                {
                    matrix[item.row][item.col] = item.value;
                }
            }
        }
        public SymmetricSparseRowColumnMatrix(SymmetricCoordinationalMatrix coordinationalMatrix)
        {
            if (coordinationalMatrix == null)
            {
                throw new ArgumentNullException(nameof(coordinationalMatrix));
            }

            var orderedItems = coordinationalMatrix
                               .Where(x => x.row >= x.col)
                               .OrderBy(x => x.row)
                               .ThenBy(x => x.col);

            var size  = coordinationalMatrix.Size;
            var count = orderedItems.Count() - size;

            ia = new int[size + 1];
            ja = new int[count];
            di = new double[size];
            aa = new double[count];

            int k = 0;

            foreach (var item in orderedItems)
            {
                if (item.row != item.col)
                {
                    ja[k] = item.col;
                    aa[k] = item.value;

                    ia[item.row + 1]++;
                    k++;
                }
                else
                {
                    di[item.row] = item.value;
                }
            }

            for (int i = 0; i < size; i++)
            {
                ia[i + 1] += ia[i];
            }
        }