static Tensor poly2Tensor(GenPolynomial<BigInteger> poly, Var[] varsArray) {
if (poly.length() == 0)
return Complex.ZERO;
List<Tensor> temp = new ArrayList<>(), sum = new ArrayList<>(poly.length());
long lExp;
BigInteger coefficient;
ExpVector exp;
for (Monomial<BigInteger> monomial : poly) {
coefficient = monomial.coefficient();
exp = monomial.exponent();
temp.clear();
temp.add(new Complex(new Rational(coefficient.getVal())));
for (int i = 0; i < exp.length(); ++i)
if ((lExp = exp.getVal(i)) != 0)
temp.add(Tensors.pow(varsArray[i].simpleTensor, new Complex(lExp)));
sum.add(Tensors.multiply(temp.toArray(new Tensor[temp.size()])));