private int calculateLog2N(int nmax){
  int log2n;
  log2n=(int)(Math.log(nmax) / Math.log(2.0) + ROUNDING_HALF);
  if (nmax > 1 << log2n) {
    log2n+=1;
  }
  return log2n;
}

private int calculateLog2N ( int nmax ) { int log2n ; log2n = ( int ) ( Math . log ( nmax ) / Math . log ( 2.0 ) + ROUNDING_HALF ) ; if ( nmax > 1 << log2n ) { log2n += 1 ; } return log2n ; }
log2n is log2 of max ( nx , ny ) rounded up to next power of 2
