1 package JSci.maths.polynomials; 2 3 import JSci.maths.fields.Field; 4 5 import java.lang.UnsupportedOperationException ; 6 7 11 public class RealMonomialBasis implements PolynomialBasis { 12 private RealPolynomial[] _basis; 13 private int _dim; 14 15 16 public RealMonomialBasis( int dim ) { 17 _dim = dim; 18 _basis = new RealPolynomial[dim]; 19 } 20 21 27 public Polynomial getBasisVector( int k ) { 28 if ( k >= _dim ) { 29 throw new ArrayIndexOutOfBoundsException (); 30 } else { 31 double[] db = new double[_dim]; 32 db[k] = 1.0; 33 _basis[k] = new RealPolynomial( db ); 34 return _basis[k]; 35 } 36 } 37 38 42 public int dimension() { 43 return _dim; 44 } 45 46 49 public Field.Member[] getSamplingPoints() { 50 throw new UnsupportedOperationException ("Not implemented."); 51 } 52 53 58 public Polynomial superposition(Field.Member[] coeff) { 59 return superposition( RealPolynomialRing.toDouble( coeff ) ); 60 } 61 62 66 public RealPolynomial superposition( double[] d ) { 67 if ( d == null ) { 68 throw new NullPointerException (); 69 } 70 if ( d.length != _dim ) { 71 throw new IllegalArgumentException ( "Dimension of basis is " + _dim + ". Got " 72 + d.length + " coefficients" ); 73 } 74 75 return new RealPolynomial( d ); 76 } 77 } 78 | Popular Tags |