示例#1
0
        public static LSqrSparseMatrix TransposeFromDenseMatrix(double[,] mat)
        {
            LSqrSparseMatrix lsqr_mat = new LSqrSparseMatrix();

            for (int col = 0; col < mat.GetLength(1); col++)
            {
                lsqr_mat.NewRow();
                for (int row = 0; row < mat.GetLength(0); row++)
                {
                    if (mat[row, col] != 0)
                    {
                        lsqr_mat.InsertValue(row, mat[row, col]);
                    }
                }
            }
            return(lsqr_mat);
        }
示例#2
0
 public static LSqrSparseMatrix TransposeFromDenseMatrix(double[,] mat)
 {
     LSqrSparseMatrix lsqr_mat = new LSqrSparseMatrix(mat.GetLength(1));
     for (int col = 0; col < mat.GetLength(1); col++)
     {
         for (int row = 0; row < mat.GetLength(0); row++)
         {
             if (mat[row, col] != 0)
             {
                 lsqr_mat.InsertValue(col, row, mat[row, col]);
             }
         }
     }
     return lsqr_mat;
 }