KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > polynomials > ChebychevBasis


1 package JSci.maths.polynomials;
2
3 /** The famous Chebychev basis for interpolating polynomials
4  * with minimal variation
5  * @author b.dietrich
6  */

7 public class ChebychevBasis extends RealLagrangeBasis
8     implements PolynomialBasis {
9     /** Creates a new instance of ChebychevBase for a given dimension
10      * @param dim dimension
11      */

12     public ChebychevBasis( int dim ) {
13         super();
14         if ( dim <= 0 ) {
15             throw new IllegalArgumentException JavaDoc();
16         }
17         super._dim = dim;
18         _samplingsX = new double[_dim];
19
20         int n = _dim - 1;
21         for ( int k = 0; k < _dim; k++ ) {
22             _samplingsX[k] = Math.cos( ( (double) ( 2 * k + 1 ) * Math.PI ) / (double) ( 2 * n + 2 ) );
23         }
24         buildBasis();
25     }
26 }
27
28
Popular Tags