Example usage for org.jfree.data.function PolynomialFunction2D PolynomialFunction2D

List of usage examples for org.jfree.data.function PolynomialFunction2D PolynomialFunction2D

Introduction

In this page you can find the example usage for org.jfree.data.function PolynomialFunction2D PolynomialFunction2D.

Prototype

public PolynomialFunction2D(double[] coefficients) 

Source Link

Document

Constructs a new polynomial function y = a0 + a1 * x + a2 * x^2 + ...

Usage

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * Some tests for the constructor./*from w w w  .  j av  a  2s . c  om*/
 */
@Test
public void testConstructor() {
    PolynomialFunction2D f = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    assertTrue(Arrays.equals(new double[] { 1.0, 2.0 }, f.getCoefficients()));

    boolean pass = false;
    try {
        f = new PolynomialFunction2D(null);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * Some checks for the getCoefficients() method.
 *///from   w  w w.  j  a v  a2 s  .c  o  m
@Test
public void testGetCoefficients() {
    PolynomialFunction2D f = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    double[] c = f.getCoefficients();
    assertTrue(Arrays.equals(new double[] { 1.0, 2.0 }, c));

    // make sure that modifying the returned array doesn't change the
    // function
    c[0] = 99.9;
    assertTrue(Arrays.equals(new double[] { 1.0, 2.0 }, f.getCoefficients()));
}

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * Some checks for the getOrder() method.
 *///from w  w w. j ava  2  s.  c  om
@Test
public void testGetOrder() {
    PolynomialFunction2D f = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    assertEquals(1, f.getOrder());
}

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * For datasets, the equals() method just checks keys and values.
 *//*from  w w  w .j  a v  a2 s .  c  o m*/
@Test
public void testEquals() {
    PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    PolynomialFunction2D f2 = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    assertTrue(f1.equals(f2));
    f1 = new PolynomialFunction2D(new double[] { 2.0, 3.0 });
    assertFalse(f1.equals(f2));
    f2 = new PolynomialFunction2D(new double[] { 2.0, 3.0 });
    assertTrue(f1.equals(f2));
}

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//*  w w w. ja va2s .c  o m*/
@Test
public void testSerialization() {
    PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    PolynomialFunction2D f2 = (PolynomialFunction2D) TestUtilities.serialised(f1);
    assertEquals(f1, f2);
}

From source file:org.jfree.data.function.PolynomialFunction2DTest.java

/**
 * Objects that are equal should have the same hash code otherwise FindBugs
 * will tell on us.../*from  w w  w  . j a v a2  s. c  om*/
 */
@Test
public void testHashCode() {
    PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    PolynomialFunction2D f2 = new PolynomialFunction2D(new double[] { 1.0, 2.0 });
    assertEquals(f1.hashCode(), f2.hashCode());

}