Package ca.nengo.math.impl

Source Code of ca.nengo.math.impl.PolynomialTest

/*
* Created on 22-May-2007
*/
package ca.nengo.math.impl;

import ca.nengo.TestUtil;
import ca.nengo.math.impl.Polynomial;
import junit.framework.TestCase;

public class PolynomialTest extends TestCase {

  /*
   * Test method for 'ca.nengo.math.impl.Polynomial.getDimension()'
   */
  public void testGetDimension() {
    Polynomial f = new Polynomial(new float[]{-1,0,1,2});
    assertEquals(1, f.getDimension());
  }

  /*
   * Test method for 'ca.nengo.math.impl.Polynomial.map(float[])'
   */
  public void testMap() {
    Polynomial f = new Polynomial(new float[]{-1,0,2,1});
    TestUtil.assertClose(2, f.map(new float[]{1}), .00001f);
    TestUtil.assertClose(15, f.map(new float[]{2}), .00001f);
    TestUtil.assertClose(-1, f.map(new float[]{-2}), .00001f);
    TestUtil.assertClose(-1, f.map(new float[]{0}), .00001f);
  }

  /*
   * Test method for 'ca.nengo.math.impl.Polynomial.multiMap(float[][])'
   */
  public void testMultiMap() {
    Polynomial f = new Polynomial(new float[]{-1,0,2,-1});

    float[] values = f.multiMap(new float[][]{new float[]{3}, new float[]{-2}});
    TestUtil.assertClose(-10, values[0], .00001f);
    TestUtil.assertClose(15, values[1], .00001f);
  }

}
TOP

Related Classes of ca.nengo.math.impl.PolynomialTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.