示例#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);
        }