public static long estimatePartitionedSizeExactSparsity(long rlen,long clen,long brlen,long bclen,double sp){
  long ret=0;
  long tnrblks=(long)Math.ceil((double)rlen / brlen);
  long tncblks=(long)Math.ceil((double)clen / bclen);
  long nnz=(long)Math.ceil(sp * rlen * clen);
  if (nnz < tnrblks * tncblks) {
    long lrlen=Math.min(rlen,brlen);
    long lclen=Math.min(clen,bclen);
    return nnz * estimateSizeExactSparsity(lrlen,lclen,1) + (tnrblks * tncblks - nnz) * estimateSizeEmptyBlock(lrlen,lclen);
  }
  long nrblks=rlen / brlen;
  long ncblks=clen / bclen;
  if (nrblks * ncblks > 0)   ret+=nrblks * ncblks * estimateSizeExactSparsity(brlen,bclen,sp);
  long lrlen=rlen % brlen;
  if (ncblks > 0 && lrlen > 0)   ret+=ncblks * estimateSizeExactSparsity(lrlen,bclen,sp);
  long lclen=clen % bclen;
  if (nrblks > 0 && lclen > 0)   ret+=nrblks * estimateSizeExactSparsity(brlen,lclen,sp);
  if (lrlen > 0 && lclen > 0)   ret+=estimateSizeExactSparsity(lrlen,lclen,sp);
  return ret;
}

public static long estimatePartitionedSizeExactSparsity ( long rlen , long clen , long brlen , long bclen , double sp ) { long ret = 0 ; long tnrblks = ( long ) Math . ceil ( ( double ) rlen / brlen ) ; long tncblks = ( long ) Math . ceil ( ( double ) clen / bclen ) ; long nnz = ( long ) Math . ceil ( sp * rlen * clen ) ; if ( nnz < tnrblks * tncblks ) { long lrlen = Math . min ( rlen , brlen ) ; long lclen = Math . min ( clen , bclen ) ; return nnz * estimateSizeExactSparsity ( lrlen , lclen , 1 ) + ( tnrblks * tncblks - nnz ) * estimateSizeEmptyBlock ( lrlen , lclen ) ; } long nrblks = rlen / brlen ; long ncblks = clen / bclen ; if ( nrblks * ncblks > 0 ) ret += nrblks * ncblks * estimateSizeExactSparsity ( brlen , bclen , sp ) ; long lrlen = rlen % brlen ; if ( ncblks > 0 && lrlen > 0 ) ret += ncblks * estimateSizeExactSparsity ( lrlen , bclen , sp ) ; long lclen = clen % bclen ; if ( nrblks > 0 && lclen > 0 ) ret += nrblks * estimateSizeExactSparsity ( brlen , lclen , sp ) ; if ( lrlen > 0 && lclen > 0 ) ret += estimateSizeExactSparsity ( lrlen , lclen , sp ) ; return ret ; }
estimates the footprint ( in bytes ) for a partitioned in - memory representation of a matrix with dimensions = ( nrows , ncols ) and sparsity = sp .
