Package com.polytechnik.utils
Interface BasisFunctionsMultipliable
- All Known Subinterfaces:
BasisFunctionsCalculatable
,BasisPolynomials
,SimpleBasisPolynomials
- All Known Implementing Classes:
BasisFunctionsMultiplicationCache
,Chebyshev
,HermiteE
,Laguerre
,Legendre
,LegendreShifted
,Monomials
,RecurrenceAB
,RecurrenceABWithMultiplicationCached
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Multiplication--related basis functions.
-
Method Summary
Modifier and TypeMethodDescriptionprivate SDivRes
_sdiv
(double[] p, int np, double[] d, int nd) Divide p by d, such that p=q*d+r.default double[][]
getBasisFunctionsMultipliedByPolynomial
(int numQl, double[] pol) Multiply Q_l, l=0..numQl-1, by a polynomial.default double[]
getKK
(int n, double[] MM) Calculate Q(x) MM Q(x) polynomial of 2*(n-1) degree.default double[]
getMomentsOfMeasureProducingPolynomialInKK
(int n, double[] P_toproduce) Generate a measure, that, whengetKK(n,QQmu)
is applied, produce given polynomial P_toproduce.default double[]
getMomentsOfMeasureProducingPolynomialInKK_MQQM
(int n, double[] P_toproduce, double[] M) Generate a measure, that, whengetKK(n,M*QQmu*M)
is applied, produce given polynomial P_toproduce.default double[]
getPQkMomentsFromQkMoments
(double[] P, double[] moments) Calculate <P(x) Q_k(x)> moments from <Q_k(x)> moments.default double[]
getQQMatr
(int n, double[] moments) Calculate <Qj|Qk> matrix from <Qm> moments usingsetQlQmExpansionCoefs
basis functions multiplication operator.default double[]
getTwoQuadraticFormsProductAsQuadraticForm
(int nA, double[] A, int nB, double[] B) A conversion of two quadratic forms product.default double[]
mult2Pol
(double[] p1, double[] p2) Multiply two polynomials in basis usingsetQlQmExpansionCoefs(int,int,double [])
operator.default SDivRes
sdiv
(double[] p, double[] d) Synthetically divide p by d, such that p=q*d+r.void
setQlQmExpansionCoefs
(int l, int m, double[] s) Multiply basis functions: expand \( Q_l(x)Q_m(x)=\sum_{k=0}^{l+m} s_k Q_k(x) \).
-
Method Details
-
setQlQmExpansionCoefs
void setQlQmExpansionCoefs(int l, int m, double[] s) Multiply basis functions: expand \( Q_l(x)Q_m(x)=\sum_{k=0}^{l+m} s_k Q_k(x) \).- Parameters:
l
- l.m
- m.s
- A buffer of dimension at leastl+m+1
to save the expansion coeficients.
-
mult2Pol
default double[] mult2Pol(double[] p1, double[] p2) Multiply two polynomials in basis usingsetQlQmExpansionCoefs(int,int,double [])
operator.- 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 }
-
getBasisFunctionsMultipliedByPolynomial
default double[][] getBasisFunctionsMultipliedByPolynomial(int numQl, double[] pol) Multiply Q_l, l=0..numQl-1, by a polynomial.- Parameters:
numQl
- The number of Ql*P to calculate.pol
- Polynomial to multiply.- Returns:
- An array of numQl dimension, elements: Q0*pol, Q1*pol, ... Q_{numQl-1}*pol. For example
new Chebyshev().getBasisFunctionsMultipliedByPolynomial(3,new double[]{0,0,0,0,0,1}) ={ { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5 }, { 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 } }
-
getPQkMomentsFromQkMoments
default double[] getPQkMomentsFromQkMoments(double[] P, double[] moments) Calculate <P(x) Q_k(x)> moments from <Q_k(x)> moments.- Parameters:
moments
- <F|Qk>.- Returns:
- <F|P(x)Qk>.
-
sdiv
Synthetically divide p by d, such that p=q*d+r. Calculations in basis. This implementation requires p.length>=d.length.- Parameters:
p
- Polynomial to divide.d
- Divider.- Returns:
- Quotient q and remainder r in class SDivRes.
-
_sdiv
Divide p by d, such that p=q*d+r. Calculations in basis.- Parameters:
p
- Polynomial to divide.np
- Max index of p, dim=np+1.d
- Divider.nd
- Max index of d, dim=nd+1. Note: in contrast with class Polynomials, where the size of p & d is passed, here we pass max index (1 less than the number of elements).
-
getQQMatr
default double[] getQQMatr(int n, double[] moments) Calculate <Qj|Qk> matrix from <Qm> moments usingsetQlQmExpansionCoefs
basis functions multiplication operator.- Parameters:
n
- Matrix dimension.moments
- <Qk> Moments, at least 2n-1 elements should present (0..2n-2 moments).- Returns:
- <Q_i|Q_j> matrix. For example
new Chebyshev().getQQMatr(5,new double []{1,0,0,0,0,0,0,0,0}) ={ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 }
-
getKK
default double[] getKK(int n, double[] MM) Calculate Q(x) MM Q(x) polynomial of 2*(n-1) degree.- Parameters:
n
- the dimension, MM.length=n*n.MM
- The MM matrix, dim=n*n.- Returns:
- Q(x) MM Q(x) polynomial, an array of dim=2*n-1.
-
getMomentsOfMeasureProducingPolynomialInKK
default double[] getMomentsOfMeasureProducingPolynomialInKK(int n, double[] P_toproduce) Generate a measure, that, whengetKK(n,QQmu)
is applied, produce given polynomial P_toproduce. The moments are obtained solving linear system problem.- Parameters:
n
- the dimension.P_toproduce
- a polynomial to produce, must have 0..2n-2, total 2n-1 elements.- Returns:
- Measure moments
mu
0..2n-2.
-
getMomentsOfMeasureProducingPolynomialInKK_MQQM
default double[] getMomentsOfMeasureProducingPolynomialInKK_MQQM(int n, double[] P_toproduce, double[] M) Generate a measure, that, whengetKK(n,M*QQmu*M)
is applied, produce given polynomial P_toproduce. The moments are obtained solving linear system problem.- Parameters:
n
- the dimension.P_toproduce
- a polynomial to produce, must have 0..2n-2, total 2n-1 elements.M
- a symmetric matrix to multiply QQmu (typically G^{-1} is used).- Returns:
- Measure moments
mu
0..2n-2.
-
getTwoQuadraticFormsProductAsQuadraticForm
default double[] getTwoQuadraticFormsProductAsQuadraticForm(int nA, double[] A, int nB, double[] B) A conversion of two quadratic forms product. Given two quadratic forms \(Q_j(x) A_{jk} Q_k(x) \) ; \(j,k=0\dots \mathtt{nA}-1\) and \(Q_u(x) B_{uv} Q_v(x) \) ; \(u,v=0\dots \mathtt{nB}-1\) construct a matrix \( C_{gh} \) such that \[ \begin{align} \sum_{g,h=0}^{\mathtt{nA}+\mathtt{nB}-2} Q_g(x) C_{gh} Q_h(x) &= \sum_{j,k=0}^{\mathtt{nA}-1} Q_j(x) A_{jk} Q_k(x) \cdot \sum_{u,v=0}^{\mathtt{nB}-1} Q_u(x) B_{uv} Q_v(x) \end{align} \] The conversion is performed by applying multiplication operatorsetQlQmExpansionCoefs(int, int, double[])
. While the polynomialgetKK(nA+nB-1,C)
=\(\sum_{g,h=0}^{\mathtt{nA}+\mathtt{nB}-2} Q_g(x) C_{gh} Q_h(x)\) is unique, obtained solution (the matrix \( C_{gh} \) ) is non-inique. It is often advantageous to use the matrix generated by the measure fromgetMomentsOfMeasureProducingPolynomialInKK_MQQM(int, double[], double[])
.- Returns:
- The matrix
C
of the dimension(nA+nB-1)*(nA+nB-1)
.
-