Hello. I have a question. I have a polynomial with Double coefficients and one with Integer ones, and to perform the integration I have to convert from object Integer to Double,but I found that it is not possible so I've tried to convert it into a String than into Double,but i get some exceptions.Do you have any idea on other solution for conversion or why am i getting this exceptions?:)
Thanks
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3
at Poly.IntegerPolynomial.getCoeff(IntegerPolynomial.java:42)
at Poly.IntegerPolynomial.getCoeff(IntegerPolynomial.java:1)
at Poly.Polynomial.integrate(Polynomial.java:230)
at Poly.Gui.actionPerformed(Gui.java:517)
public RealPolynomial integrate (Polynomial p)
{
Double [] coefficients=new Double[p.getCoeff().length+1];
Double [] finalCoefficients=new Double[p.getCoeff().length+1];
Double [] coeff=new Double[p.getCoeff().length+1];
String s;
for(int v=0;v<coeff.length;v++)
{s=p.getCoeff(v).toString();
System.out.println(s);
coeff[v]=Double.valueOf(s);
}
RealPolynomial result;
//set the coefficients according to the integration rule,we obtain real coefficients
for (int i=1;i<coefficients.length;i++)
coefficients[i]=coeff[i-1]/Double.valueOf(i);
for(int i=0;i<coefficients.length;i++)
{finalCoefficients[i]=coefficients[i];
System.out.println(coefficients[i]);
}
result=new RealPolynomial(coeff,coeff.length-1);
return result;
}