public static void CopyRow(SparseRowMatrixArr to, int row, SparseRowMatrixArr from, int fromRow)
        {
            int frl = from.rowLength(fromRow);

            if (frl == 0)
            {
                return;
            }

            if (to.val[row] == null)
            {
                to.val[row] = new SparseRowValue[frl];
            }
            else if (to.val[row].Length != frl)
            {
                Array.Resize(ref to.val[row], frl);
            }

            Array.Copy(from.val[fromRow], to.val[row], frl);
        }
        public SparseMatrix Transpose()
        {
            SparseRowMatrixArr trans = new SparseRowMatrixArr(colCount, rowCount);

            int[] rowCounts = new int[colCount];
            rowCounts.Initialize();

            for (int i = 0; i < rowCount; i++)
            {
                int len = (val[i] == null) ? 0 : val[i].Length;
                for (int j = 0; j < len; j++)
                {
                    rowCounts[val[i][j].index]++;
                }
            }

            for (int i = 0; i < colCount; i++)
            {
                trans.val[i] = new SparseRowValue[rowCounts[i]];
                rowCounts[i] = 0;
            }

            for (int i = 0; i < val.Length; i++)
            {
                int len = (val[i] == null) ? 0 : val[i].Length;
                for (int j = 0; j < len; j++)
                {
                    int col = val[i][j].index;
                    trans.val[col][rowCounts[col]].index = i;
                    trans.val[col][rowCounts[col]].value = val[i][j].value;
                    rowCounts[col]++;
                }
            }

            return(trans);
        }
 public void CopyRow(int toRow, SparseMatrix from, int fromRow)
 {
     SparseRowMatrixArr.CopyRow(this, toRow, (SparseRowMatrixArr)from, fromRow);
 }