public static double[][] convertToDoubleMatrix(MatrixBlock mb){
  int rows=mb.getNumRows();
  int cols=mb.getNumColumns();
  double[][] ret=new double[rows][cols];
  if (mb.getNonZeros() > 0) {
    if (mb.isInSparseFormat()) {
      Iterator<IJV> iter=mb.getSparseBlockIterator();
      while (iter.hasNext()) {
        IJV cell=iter.next();
        ret[cell.getI()][cell.getJ()]=cell.getV();
      }
    }
 else {
      for (int i=0; i < rows; i++)       for (int j=0; j < cols; j++)       ret[i][j]=mb.getValueDenseUnsafe(i,j);
    }
  }
  return ret;
}

public static double [ ] [ ] convertToDoubleMatrix ( MatrixBlock mb ) { int rows = mb . getNumRows ( ) ; int cols = mb . getNumColumns ( ) ; double [ ] [ ] ret = new double [ rows ] [ cols ] ; if ( mb . getNonZeros ( ) > 0 ) { if ( mb . isInSparseFormat ( ) ) { Iterator < IJV > iter = mb . getSparseBlockIterator ( ) ; while ( iter . hasNext ( ) ) { IJV cell = iter . next ( ) ; ret [ cell . getI ( ) ] [ cell . getJ ( ) ] = cell . getV ( ) ; } } else { for ( int i = 0 ; i < rows ; i ++ ) for ( int j = 0 ; j < cols ; j ++ ) ret [ i ] [ j ] = mb . getValueDenseUnsafe ( i , j ) ; } } return ret ; }
creates a two - dimensional double matrix of the input matrix block .
