Ejemplo n.º 1
0
 public ElasticMatrix(ElasticMatrix <T> that) : this(that.Rows, that.Columns, that.Capacity)
 {
     Count        = that.Count;
     free         = that.free;
     this.rows    = new List <int>(that.rows);
     this.count   = new List <int>(that.count);
     this.last    = new List <int>(that.last);
     this.columns = new List <int>(that.columns);
     this.next    = new List <int>(that.next);
     this.values  = new List <T>(that.values);
 }
Ejemplo n.º 2
0
        public SparseMatrix(ElasticMatrix <T> that) : this(that.Rows, that.Columns, that.Count)
        {
            for (int i = 0, j = 0; i < Rows; i++)
            {
                that.ForRow(i, (col, x) => rowsColumns[j++] = col);
                rows[i + 1] = j;
            }

            that = that.Transpose();

            int[] index = new int[Rows];
            for (int i = 0; i < index.Length; i++)
            {
                index[i] = rows[i];
            }

            for (int j = 0, i = 0; j < Columns; j++)
            {
                that.ForRow(j, (col, x) =>
                {
                    columnsRows[i] = col;
                    values[i]      = x;

                    rowsColumns[index[col]] = j;
                    positions[index[col]]   = i;

                    index[col]++;
                    i++;
                });
                columns[j + 1] = i;
            }

            Count = that.Count;

            Sorting();
        }