@Test public void testAdjustDegree() { assertCoefficientsEquals(new double[]{A, B, C}, valueOf(A, B, C).adjustDegree()); assertCoefficientsEquals(new double[]{A, B}, valueOf(A, B, 0).adjustDegree()); assertCoefficientsEquals(new double[]{0}, valueOf(0).adjustDegree()); assertCoefficientsEquals(new double[]{A}, valueOf(A, EPS).adjustDegree()); assertCoefficientsEquals(new double[]{A, EPS * 2}, valueOf(A, EPS * 2).adjustDegree()); assertCoefficientsEquals(new double[]{A, 666 + EPS}, valueOf(A, 666 + EPS).adjustDegree()); }
public Polynomial adjustDegree() { int n = degree; while ((n >= 0) && Doubles.equals(0, get(n), EPSILON)) { --n; } if (n < 0) { return Polynomial.ZERO; } if (n == degree) { return this; } return new Polynomial(m_c, n); }
Polynomial implements IReadDataBlock { public Polynomial adjustDegree() { int n = degree; while ((n >= 0) && Doubles.equals(0, get(n), EPSILON)) { --n; } if (n < 0) { return Polynomial.ZERO; } if (n == degree) { return this; } return new Polynomial(m_c, n); } }
Polynomial implements IReadDataBlock { public Polynomial adjustDegree() { int n = degree; while ((n >= 0) && Doubles.equals(0, get(n), EPSILON)) { --n; } if (n < 0) { return Polynomial.ZERO; } if (n == degree) { return this; } return new Polynomial(m_c, n); } private  Polynomial(final double[] coefficients, final int degree); }
Polynomial implements IReadDataBlock { public Polynomial adjustDegree() { int n = degree; while ((n >= 0) && Doubles.equals(0, get(n), EPSILON)) { --n; } if (n < 0) { return Polynomial.ZERO; } if (n == degree) { return this; } return new Polynomial(m_c, n); } private  Polynomial(final double[] coefficients, final int degree); static Division divide(final Polynomial num, final Polynomial denom); @Override void copyTo(double[] buffer, int start); @Override int getLength(); @Override IReadDataBlock rextract(int start, int length); static Complex[] checkRoots(final Complex[] roots); static double getEpsilon(); static Polynomial of(double[] coefficients); static Polynomial copyOf(double[] coefficients); static Polynomial copyOf(double[] coefficients, int start, int end); static Polynomial valueOf(double firstCoefficient, double... nextCoefficients); static Polynomial fromComplexRoots(Complex[] roots); static Polynomial fromComplexRoots(final Complex[] roots, final double c); static Polynomial fromData(IReadDataBlock data); static Polynomial factor(double c, int n); static void setEpsilon(final double value); static IRootsSolver getDefRootsSearcher(); static void setDefRootsSearcher(final IRootsSolver value); Polynomial adjustDegree(); Polynomial derivate(); Polynomial divide(final double d); Polynomial divide(final Polynomial r); @Override boolean equals(final Object obj); boolean equals(Polynomial other, double epsilon); Complex evaluateAt(final Complex x); double evaluateAt(final double x); static double revaluate(final double[] c, final double x); static double evaluate(final double[] c, final double x); static double evaluate(final int degree, IntToDoubleFunction fn, final double x); Complex evaluateAtFrequency(final double w); @Override double get(final int idx); double[] getCoefficients(); int getDegree(); @Override int hashCode(); boolean isZero(); boolean isIdentity(); Polynomial minus(double d); Polynomial minus(final Polynomial r); Polynomial mirror(); Polynomial negate(); Polynomial plus(final double d); Polynomial plus(final Polynomial r); Complex[] roots(); Complex[] roots(IRootsSolver searcher); Polynomial smooth(); Polynomial times(final double d); Polynomial times(final Polynomial r); Polynomial times(final Polynomial r, boolean computeroots); @Override String toString(); String toString(final char var, final boolean bSmooth); String toString(final String fmt, final char var,
            final boolean bSmooth); }
Polynomial implements IReadDataBlock { public Polynomial adjustDegree() { int n = degree; while ((n >= 0) && Doubles.equals(0, get(n), EPSILON)) { --n; } if (n < 0) { return Polynomial.ZERO; } if (n == degree) { return this; } return new Polynomial(m_c, n); } private  Polynomial(final double[] coefficients, final int degree); static Division divide(final Polynomial num, final Polynomial denom); @Override void copyTo(double[] buffer, int start); @Override int getLength(); @Override IReadDataBlock rextract(int start, int length); static Complex[] checkRoots(final Complex[] roots); static double getEpsilon(); static Polynomial of(double[] coefficients); static Polynomial copyOf(double[] coefficients); static Polynomial copyOf(double[] coefficients, int start, int end); static Polynomial valueOf(double firstCoefficient, double... nextCoefficients); static Polynomial fromComplexRoots(Complex[] roots); static Polynomial fromComplexRoots(final Complex[] roots, final double c); static Polynomial fromData(IReadDataBlock data); static Polynomial factor(double c, int n); static void setEpsilon(final double value); static IRootsSolver getDefRootsSearcher(); static void setDefRootsSearcher(final IRootsSolver value); Polynomial adjustDegree(); Polynomial derivate(); Polynomial divide(final double d); Polynomial divide(final Polynomial r); @Override boolean equals(final Object obj); boolean equals(Polynomial other, double epsilon); Complex evaluateAt(final Complex x); double evaluateAt(final double x); static double revaluate(final double[] c, final double x); static double evaluate(final double[] c, final double x); static double evaluate(final int degree, IntToDoubleFunction fn, final double x); Complex evaluateAtFrequency(final double w); @Override double get(final int idx); double[] getCoefficients(); int getDegree(); @Override int hashCode(); boolean isZero(); boolean isIdentity(); Polynomial minus(double d); Polynomial minus(final Polynomial r); Polynomial mirror(); Polynomial negate(); Polynomial plus(final double d); Polynomial plus(final Polynomial r); Complex[] roots(); Complex[] roots(IRootsSolver searcher); Polynomial smooth(); Polynomial times(final double d); Polynomial times(final Polynomial r); Polynomial times(final Polynomial r, boolean computeroots); @Override String toString(); String toString(final char var, final boolean bSmooth); String toString(final String fmt, final char var,
            final boolean bSmooth); static final Polynomial ZERO; static final Polynomial ONE; }