Interface BasisFunctionsCalculatable

All Superinterfaces:
BasisFunctionsMultipliable, ConfederateMatrixCalculatable
All Known Subinterfaces:
BasisPolynomials, SimpleBasisPolynomials
All Known Implementing Classes:
Chebyshev, HermiteE, Laguerre, Legendre, LegendreShifted, Monomials, RecurrenceAB, RecurrenceABWithMultiplicationCached

public interface BasisFunctionsCalculatable extends BasisFunctionsMultipliable, ConfederateMatrixCalculatable
Polynomial basis functions calculatable at x. The most important one --- multiply p*(ma*x+mb). This interface is typically a part of BasisPolynomials functionality, however it can be used to representa a more general than three term recurrence type of polynomials.
  • Method Details

    • getaxbP

      double[] getaxbP(double[] p, double ma, double mb)
      Multiply p*(ma*x+mb) in the basis. Do not mistake with a and b recurrence coefficients of getAB().
      Parameters:
      p - Input polynomial.
      Returns:
      p*(ma*x+mb), an array of the length 1+p.length.
    • getONE

      default double[] getONE()
      Calculate 1 in basis.
      Returns:
      An array of 1 length such that getD0(getONE(),x)=1.
    • calculate

      double calculate(int n, double x)
      Calculation basis polynomial value.
      Parameters:
      n - T index.
      x - Argument.
      Returns:
      The value of the polynomial Tn at x.
    • getD0

      double getD0(double[] Qcoefs, double x)
      Calculates \( \sum_k Q_k(x) Qcoefs[k] \).
      Parameters:
      Qcoefs - Coefficients.
      x - Point to estimate the sum.
      Returns:
      The sum.
    • getD1

      double getD1(double[] Qcoefs, double x)
      Calculates \( d/dx \sum_k Q_k(x) Qcoefs[k] \).
      Parameters:
      Qcoefs - Coefficients.
      x - Point to estimate the sum.
      Returns:
      The derivative.
    • getD2

      double getD2(double[] Qcoefs, double x)
      Calculates \( d^2/dx^2 \sum_k Q_k(x) Qcoefs[k] \).
      Parameters:
      Qcoefs - Coefficients.
      x - Point to estimate the sum.
      Returns:
      The second derivative.
    • getDifferentiated

      double[] getDifferentiated(double[] Qcoefs)
      Differentiate a function in basis,
      Parameters:
      Qcoefs - : \( F(x)=\sum_k Q_k(x) Qcoefs[k] \).
      Returns:
      \( dF/dx=\sum_k Q'_k(x) Qcoefs[k] \).
    • getIntegrated

      double[] getIntegrated(double[] Qcoefs)
      Integrate a function in basis.
      Parameters:
      Qcoefs - : \( F(x)=\sum_k Q_k(x) Qcoefs[k] \).
      Returns:
      \( \int F(x)dx=\sum_k Qcoefs[k] \int Q_k(x) dx \). The integral is typically normalized as I(0)=0.
    • getMomentsFromSample

      double[] getMomentsFromSample(int nmoms, double[] x, double[] w, int nelsinsample)
      Given observations x and weights w calculate the 0..nmoms-1 moments in the basis.
      Parameters:
      nmoms - The number of moments to calculate.
      x - observation samples.
      w - weights.
      nelsinsample - How many elements to sample.
      Returns:
      nelsinsample generalzied moments, \( k=0\dots nmoms-1 \): \( \sum_{j=0}^{nelsinsample-1} Q_k(x[j])*w[j] \).
    • getMomentsFromSample

      default double[] getMomentsFromSample(int nmoms, double[] x, double[] w)
    • getMomentsFromSample

      default double[] getMomentsFromSample(int nmoms, double[] x)
      All weights are taken=1.
    • getX0Moments

      default double[] getX0Moments(int nmoms, double x0)
      Calcuate \( Q_k(x0) \) moments (single value calculation (at x0) of all basis functions).
      Parameters:
      nmoms - The number of moments, k=0...nmoms-1.
      x0 - At what point to calculate.
      Returns:
      \( Q_k(x0) \) array.
    • sdiv1

      default SDivRes sdiv1(double[] p, double x0)
      Synthetically divide p by (x-x0). Calculations in basis.
      Parameters:
      p - Input polynomial;
      x0 - To divide on (x-x0)
      Returns:
      Quotient q and remainder r in class SDivRes.
    • getXQkMomentsFromQkMoments

      default double[] getXQkMomentsFromQkMoments(double[] moments)
      Calculate <F|xQk> moments from <F|Qk> The method should be overloaded if optimal implementation is required.
      Parameters:
      moments - <F|Qk>.
      Returns:
      <F|xQk>.
    • convertBasisToPBASIS

      double[][] convertBasisToPBASIS(int num, BasisFunctionsCalculatable PBASIS)
      A helper method to convert this basis to PBASIS. Usage example:
      
      new Chebyshev().convertBasisToPBASIS(7,new Monomials())
      ={ { 1.0 },
         { 0.0, 1.0 },
         { -1.0, 0.0, 2.0 },
         { 0.0, -3.0, 0.0, 4.0 },
         { 1.0, 0.0, -8.0, 0.0, 8.0 },
         { 0.0, 5.0, 0.0, -20.0, 0.0, 16.0 },
         { -1.0, 0.0, 18.0, 0.0, -48.0, 0.0, 32.0 }
       }
      
      are Chebyshev polynomials. Or convert Chebyshev to Laguerre basis and back:
      
      new Chebyshev().convertBasisToPBASIS(7,new Laguerre())
      ={ { 1.0 },
         { 1.0, -1.0 },
         { 3.0, -8.0, 4.0 },
         { 21.0, -69.0, 72.0, -24.0 },
         { 177.0, -736.0, 1136.0, -768.0, 192.0 },
         { 1805.0, -9245.0, 18840.0, -19080.0, 9600.0, -1920.0 },
         { 21923.0, -133704.0, 338724.0, -456192.0, 344448.0, -138240.0, 23040.0 }
      }
      
      new Laguerre().convertBasisToPBASIS(7,new Chebyshev())
      ={ { 1.0 },
         { 1.0, -1.0 },
         { 1.25, -2.0, 0.25 },
         { 1.7500000000000002, -3.125, 0.75, -0.041666666666666664 },
         { 2.5156250000000004, -4.5, 1.5208333333333333, -0.16666666666666666, 0.005208333333333333 },
         { 3.578125000000001, -6.255208333333334, 2.6041666666666665, -0.41927083333333337, 0.026041666666666664, -5.208333333333333E-4 },
         { 4.9848090277777795, -8.53125, 4.063151041666666, -0.8489583333333333, 0.07838541666666667, -0.0031249999999999997, 4.340277777777777E-5 }
      }
      
      Parameters:
      PBASIS - The basis in which we obtain this basis polynomials.
      Returns:
      expansion coefficients.
    • convertFunctionTo_PBASIS_from_Basis

      double[] convertFunctionTo_PBASIS_from_Basis(double[] Qcoefs, BasisFunctionsCalculatable PBASIS)
      Convert from basis to PBASIS basis.
      Parameters:
      Qcoefs - Coefficients.
      PBASIS - The basis to convert to.
      Returns:
      Polynomial in PBASIS.
    • convertFunctionTo_Basis_from_PBASIS

      default double[] convertFunctionTo_Basis_from_PBASIS(double[] coefs, BasisFunctionsCalculatable PBASIS)
      Convert from PBASIS to this basis. Equivalent to PBASIS.convertFunctionTo_PBASIS_from_Basis(coefs,this).
      Parameters:
      coefs - Polynomial coefficients.
      Returns:
      Polynomial in basis.
    • convertFunctionTo_Monomials_from_Basis

      default double[] convertFunctionTo_Monomials_from_Basis(double[] Qcoefs)
      Convert from basis to polynomial basis. Used for testing. Equivalent to convertFunctionTo_PBASIS_from_Basis(Qcoefs,new Monomials()).
      Parameters:
      Qcoefs - Coefficients.
      Returns:
      Polynomial in regular basis.
    • convertFunctionTo_Basis_from_Monomials

      default double[] convertFunctionTo_Basis_from_Monomials(double[] coefs)
      Convert from polynomials to basis. Used for testing. Equivalent to convertFunctionTo_Basis_from_PBASIS(coefs,new Monomials()).
      Parameters:
      coefs - Polynomial coefficients.
      Returns:
      Polynomial in basis.