An efficient algorithm for bilinear transformation of multivariable polynomials