SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.polynomial.root
Class Roots

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.polynomial.root.Roots

public class Roots
extends java.lang.Object

This class provides utility functions to access the roots returned by Solver.

This design separately the algorithms for finding roots and the algorithms for reading/accessing the results.


Constructor Summary
Roots(NumberList roots)
          Construct a Roots instance to collect all the roots of a polynomial equation.
 
Method Summary
 NumberList allRoots()
          Get a copy of all the roots of the polynomial.
 java.util.List<Complex> complexRoots()
          Get a copy of all the Complex but not real roots of the polynomial.
 java.lang.Number get(int i)
          Get the i-th root of the polynomial.
 double[] realRoots()
          Get a copy of all the real roots of the polynomial.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Roots

public Roots(NumberList roots)
Construct a Roots instance to collect all the roots of a polynomial equation.

Parameters:
roots - the roots of a polynomial equation
Method Detail

get

public java.lang.Number get(int i)
Get the i-th root of the polynomial.

Parameters:
i - the index, counting from 1
Returns:
the i-th root
Throws:
Solver.RootFindingException - if i exceeds the number of roots (the polynomial degree)

allRoots

public NumberList allRoots()
Get a copy of all the roots of the polynomial.

Returns:
a double array of the real roots

realRoots

public double[] realRoots()
Get a copy of all the real roots of the polynomial.

The union of these and complexRoots() equal to those of allRoots().

Returns:
a copy of the double array of the real roots

complexRoots

public java.util.List<Complex> complexRoots()
Get a copy of all the Complex but not real roots of the polynomial.

The union of these and realRoots() equal to those of allRoots().

Returns:
a copy of the list of Complex roots

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.