/** * @return the coefficients of the polynomial function. */ protected double[] getCoefficients() { return polynomialFunction.getCoefficients(); } }
public AD7718(SPI spi) throws IOException { this.spi = spi; this.cs = "CS1"; // Populate Calibrations populateCalibrationMap(); // Set SPI Parameters spi.setParameters(2, 1, 0, 1, 1); writeRegister(FILTER, 20); writeRegister(MODE, MODE_SINGLE | MODE_CHCON | MODE_REFSEL); for (String key : calibs.keySet()) { double[] convertedList = new PolynomialFunction(calibs.get(key)).getCoefficients(); ArrayUtils.reverse(convertedList); caldata.put(key, convertedList); } }
private double[] rootsToPolynomial(Complex[] x){ /* Returns a double array of coefficients of the polynomial, assuming the each complex root has it's conjugate in the same array. */ PolynomialFunction[] polynomialFunctionArray = new PolynomialFunction[x.length/2]; PolynomialFunction product = new PolynomialFunction(new double[]{1}); for(int i = 0; i < x.length / 2; i++){ PolynomialFunction complexRoot = new PolynomialFunction(new double[]{-x[i].getReal(), 1}); complexRoot = complexRoot.multiply(complexRoot); complexRoot = complexRoot.subtract(new PolynomialFunction(new double[]{-1 * x[i].getImaginary() * x[i].getImaginary()})); System.out.println((complexRoot)); polynomialFunctionArray[i] = complexRoot; } for (PolynomialFunction aPolynomialFunctionArray : polynomialFunctionArray) product = aPolynomialFunctionArray.multiply(product); return product.getCoefficients(); }
/** * @return the coefficients of the polynomial function. */ protected double[] getCoefficients() { return polynomialFunction.getCoefficients(); } }
/** * @return the coefficients of the polynomial function. */ protected double[] getCoefficients() { return polynomialFunction.getCoefficients(); } }
/** * @param p * polynomial function * @return degree of the function */ public static int getDegree(PolynomialFunction p) { return getDegree(p.getCoefficients()); }
/** * @param p * polynomial function * @return leading coefficient */ public static double getLeadingCoeff(PolynomialFunction p) { return getLeadingCoeff(p.getCoefficients()); }
/** * calculates the quotient of p/d (no calculation of the remainder is done) * * @param p * dividend * @param d * divisor * @return quotient of p/d */ public static PolynomialFunction polynomialDivision(PolynomialFunction p, PolynomialFunction d) { return new PolynomialFunction( polynomialDivision(p.getCoefficients(), d.getCoefficients())); }
/** * Converts a PolynomialFunction to the (polynomial) expression * representation. * * @param pf * the polynomial function * @param sym * the name of the polynomial functions variable * @return */ public static IExpr polynomialFunction2Expr(final PolynomialFunction pf, ISymbol sym) { double[] coefficients = pf.getCoefficients(); return polynomialFunction2Expr(coefficients, sym); }
double[] x = {0, 1, 2, 3, 4, 5}; double[] y = new double[6]; for (int i = 0; i < 6; i++) { y[i] = 1 + 2 * x[i] + 3 * x[i] * x[i]; } DividedDifferenceInterpolator divider = new DividedDifferenceInterpolator(); PolynomialFunctionNewtonForm polynom = divider.interpolate(x, y); double[] coefficients = polynom.getCoefficients(); System.out.println(Arrays.toString(coefficients)); PolynomialFunction derivative = (PolynomialFunction) new PolynomialFunction(coefficients).derivative(); System.out.println(Arrays.toString(derivative.getCoefficients()));
protected void doCalc(PolynomialFunction rootsPoly) { double[] roots = rootsPoly.getCoefficients(); int nrRealRoots = 0; if (roots.length > 1) { nrRealRoots = getRoots(roots, eqnSolver); } makePoints(roots, nrRealRoots); }
public RecalibrationFunction toPolynomial() { final UnivariateFunction f = getRecalibrationFunction(); if (f instanceof PolynomialFunction) return new RecalibrationFunction(((PolynomialFunction) f).getCoefficients()); else if (f instanceof Identity) return RecalibrationFunction.identity(); else throw new RuntimeException("Cannot represent " + f + " as polynomial function"); } }
protected void doCalc(PolynomialFunction rootsPoly, double min, double max) { double[] roots = rootsPoly.getCoefficients(); int nrRealRoots = 0; if (roots.length > 1) { nrRealRoots = getRoots(roots, eqnSolver); } for (int i = 0; i < nrRealRoots; ++i) { if (DoubleUtil.isGreater(roots[i], max, Kernel.STANDARD_PRECISION) || DoubleUtil.isGreater(min, roots[i], Kernel.STANDARD_PRECISION)) { roots[i] = Double.NaN; } } makePoints(roots, nrRealRoots); }
private void setRootsPolynomialWithinRange( ArrayList<Coords> intersectCoords2, PolynomialFunction rootsPoly, double min, double max) { double[] roots = rootsPoly.getCoefficients(); int nrRealRoots = 0; if (roots.length > 1) {
debug("Degrees > "+ lastDegree + " ignored: Not enough data points"); final double[] coefficients = (pFunction == null) ? null : pFunction.getCoefficients(); for (int deg = firstDegree; deg <= lastDegree; deg++) { fitPolynomial(deg);
PolynomialFunction poly = new PolynomialFunction(roots); double[] rootsDerivative = poly.polynomialDerivative() .getCoefficients(); double[] c = poly.getCoefficients(); int n = c.length - 1; if (n > 0) {
new double[] { 0, 1 }); double[] res = AlgoIntersectImplicitpolyPolyLine .lineIntersect(a.getCoeff(), tx, ty).getCoefficients(); int xRoots = getNearRoots(res, eqnSolver, 1E-5); for (int j = 0; j < xRoots; j++) {
final Complex[] roots = solver.solveAllComplex(derivative.getCoefficients(), initialGuess, getMaxEvaluations()); if (roots == null) return null;
&& aNew[leadIndex].getCoefficients()[0] == 0)) { for (int j = n - 1; j < leadIndex - n; ++j) { aNew[j] = aNew[j].multiply(bPolys[n]); && aNew[leadIndex].getCoefficients()[0] == 0)) { for (int j = leadIndex - n; j < leadIndex; ++j) { aNew[j] = aNew[j].multiply(bPolys[n]) aNew[leadIndex - n + j].getCoefficients()); double reduceFactor = 1; for (int j = 0; j < n; ++j) { for (int k = 0; k < mat[i][j].getCoefficients().length; ++k) { largestCoeff = Math.max( Math.abs(mat[i][j].getCoefficients()[k]), largestCoeff); double[] roots = det.getCoefficients();