Package com.polytechnik.utils
Class RecurrenceABWithMultiplicationCached
java.lang.Object
com.polytechnik.utils.RecurrenceAB
com.polytechnik.utils.RecurrenceABWithMultiplicationCached
- All Implemented Interfaces:
BasisFunctionsCalculatable
,BasisFunctionsMultipliable
,BasisPolynomials
,ConfederateMatrixCalculatable
,SimpleBasisPolynomials
,ThreeTermRecurrenceCalculatable
The same as
RecurrenceAB
, but the multiplication setQlQmExpansionCoefs
is
cached using BasisFunctionsMultiplicationCache
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BasisFunctionsMultiplicationCache
private final double[][]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double[][]
getBasisFunctionsDifferentiated
(int numQl) Calculate the derivative of basis functions.double[]
getPQkMomentsFromQkMoments
(double[] P, double[] moments) Calculate <P(x) Q_k(x)> moments from <Q_k(x)> moments.static void
Unit test a general 3 term recurrence basis with cached multiplication.double[]
mult2Pol
(double[] p1, double[] p2) Multiply two polynomials in basis usingBasisFunctionsMultipliable.setQlQmExpansionCoefs(int,int,double [])
operator.void
setQlQmExpansionCoefs
(int l, int m, double[] s) CallsgetBasisFunctionsMultipliedByPolynomial
, theBasisPolynomials#setQlQmExpansionCoefs
typically uses analytic expression; this implementation instead uses three term recurrence implemented ingetBasisFunctionsMultipliedByPolynomial
.Methods inherited from class com.polytechnik.utils.RecurrenceAB
calculate, getAk, getAllAk, getAllBk, getaxbP, getBasisFunctionsMultipliedByPolynomial, getBasisFunctionsMultipliedByPolynomial, getBasisFunctionsOnPolynomialArgument, getBk, getConfederateMatrix, getD0, getD1, getD2, getDifferentiated, getIntegrated, getMomentsFromSample, getNext, getNext, numAk, sdiv1
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.polytechnik.utils.BasisFunctionsCalculatable
convertFunctionTo_Basis_from_Monomials, convertFunctionTo_Basis_from_PBASIS, convertFunctionTo_Monomials_from_Basis, getMomentsFromSample, getMomentsFromSample, getONE, getX0Moments, getXQkMomentsFromQkMoments
Methods inherited from interface com.polytechnik.utils.BasisFunctionsMultipliable
getKK, getMomentsOfMeasureProducingPolynomialInKK, getMomentsOfMeasureProducingPolynomialInKK_MQQM, getQQMatr, getTwoQuadraticFormsProductAsQuadraticForm, sdiv
Methods inherited from interface com.polytechnik.utils.BasisPolynomials
setNewtonBinomialLikeCoefs
Methods inherited from interface com.polytechnik.utils.SimpleBasisPolynomials
convertBasisToPBASIS, convertFunctionTo_PBASIS_from_Basis, getBasisFunctionsOnPolynomialArgument
-
Field Details
-
bmulcache
-
dPol
private final double[][] dPol
-
-
Constructor Details
-
RecurrenceABWithMultiplicationCached
public RecurrenceABWithMultiplicationCached(double[] a, double[] b)
-
-
Method Details
-
getBasisFunctionsDifferentiated
protected double[][] getBasisFunctionsDifferentiated(int numQl) Description copied from class:RecurrenceAB
Calculate the derivative of basis functions. Used bygetDifferentiated
andgetIntegrated
.- Overrides:
getBasisFunctionsDifferentiated
in classRecurrenceAB
- Parameters:
numQl
- The number of basis functions to calculate the derivative.- Returns:
- An array of Q'_0, Q'_1,... Q'_{numQl-1}. For an implementation with internal caching the method may return more functions than the numQl.
-
setQlQmExpansionCoefs
public void setQlQmExpansionCoefs(int l, int m, double[] s) Description copied from class:RecurrenceAB
CallsgetBasisFunctionsMultipliedByPolynomial
, theBasisPolynomials#setQlQmExpansionCoefs
typically uses analytic expression; this implementation instead uses three term recurrence implemented ingetBasisFunctionsMultipliedByPolynomial
.- Specified by:
setQlQmExpansionCoefs
in interfaceBasisFunctionsMultipliable
- Overrides:
setQlQmExpansionCoefs
in classRecurrenceAB
- Parameters:
l
- l.m
- m.s
- A buffer of dimension at leastl+m+1
to save the expansion coeficients.
-
getPQkMomentsFromQkMoments
public double[] getPQkMomentsFromQkMoments(double[] P, double[] moments) Description copied from interface:BasisFunctionsMultipliable
Calculate <P(x) Q_k(x)> moments from <Q_k(x)> moments.- Specified by:
getPQkMomentsFromQkMoments
in interfaceBasisFunctionsMultipliable
- Overrides:
getPQkMomentsFromQkMoments
in classRecurrenceAB
- Parameters:
moments
- <F|Qk>.- Returns:
- <F|P(x)Qk>.
-
mult2Pol
public double[] mult2Pol(double[] p1, double[] p2) Description copied from interface:BasisFunctionsMultipliable
Multiply two polynomials in basis usingBasisFunctionsMultipliable.setQlQmExpansionCoefs(int,int,double [])
operator.- Specified by:
mult2Pol
in interfaceBasisFunctionsMultipliable
- Overrides:
mult2Pol
in classRecurrenceAB
- Parameters:
p1
- Firts polynomial.p2
- Second polynomial.- Returns:
- p*q. For example:
.new Chebyshev().mult2Pol(new double[]{0,0,1},new double[]{0,0,0,0,0,1}) ={ 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 }
-
main
Unit test a general 3 term recurrence basis with cached multiplication.
-