Package com.polytechnik.freemoney
Class MatricesFromPI
java.lang.Object
com.polytechnik.freemoney.MatricesFromPI
A helper class to calculate commonly used matrices from volume-weighted sampled moments
using integration by parts.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static double[]
getbQQdpdtDivI2FromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{1}{I^2}\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).private static double[]
getbQQdpdtDivIFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{1}{I}\frac{dp}{dt} \Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).static double[]
getbQQdpdtFromQQp_withLastP
(double[] QQp, EVXData I, Function<double[], double[]> getEDPsi, double[] QQt, double p_last) Obtain regular \(\left<\psi^{[j]}\Big|\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|p|Q_k\right>\) using integration by parts.private static double[]
getbQQdpdtFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) Obtain \(\left<\psi^{[j]}\Big|\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\), similar toVolMatrix.getDiffMatrix(int, double[])
but the original moments are calculated with \( I\) weigth.private static double[]
getbQQdpdtIpowFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, MatricesFromPI.GetPsiDpsiFactor factor, boolean flagDivide) static double[]
getbQQDtpDivIFromQQpi_withLastP
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double p_last, double Ifuture) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{d}{dt}\frac{p}{I}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\) using integration by parts.private static double[]
getbQQI2dpdtFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|I^2\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).private static double[]
getbQQIdpdtFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) Obtain \(\left<\psi^{[j]}\Big|I\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).static double[]
getbQQIpowdpdtFromQQpi_withLastP
(double Ipow, double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double[] QQi, double p_last) A helper method to obtain actual \( \left<\psi^{[j]}\Big|I^{\mathrm{Ipow}}\frac{dp}{dt}\Big|\psi^{[j]}\right> \), including out of integral term, using integration by parts.static double[]
getbQQpdIdtFromQQp
(double[] QQp, EVXData I, Function<double[], double[]> getEDPsi, double Ifuture) A helper method to obtain something like \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right> \), exact meaning is not clear: when \(p=const\) we get an exact \( dI/dt \), and when \( I=const \) we get all zero.private static double[]
getbQQpdIdtFromQQp
(double[] QQp, EVXData I, Function<double[], double[]> getEDPsi, double Ifuture, boolean flagDivI) static double[]
getbQQpdIdtFromQQpi
(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double Ifuture) A helper method to obtain something like \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right> \), exact meaning is not clear: when \(p=const\) we get an exact \( dI/dt \), and when \( I=const \) we get all zero.static double[]
getbQQpFrombQQpi
(double[] bQQpi, EVXData I) A helper function to obtain \(|p|\) operator from \(|pI|\) as \(|I^{-1/2}|pI|I^{-1/2}|\), crude and simple approach.static double[]
getbQQpiFrombQQp
(double[] bQQp, EVXData I) A helper function to obtain \(|pI|\) operator from \(|p|\) as \(|I^{1/2}|p|I^{1/2}|\).private static double[]
getbQQpIpowFrombQQp
(double[] bQQp, EVXData I, boolean flagDivide) TransformbQQp
matrix either to \(|I^{-1/2}|p|I^{-1/2}|\) ifflagDivide=true
or to \(|I^{1/2}|p|I^{1/2}|\) ifflagDivide=false
.
-
Constructor Details
-
MatricesFromPI
public MatricesFromPI()
-
-
Method Details
-
getbQQpFrombQQpi
A helper function to obtain \(|p|\) operator from \(|pI|\) as \(|I^{-1/2}|pI|I^{-1/2}|\), crude and simple approach. The main advantage of the approach is that the eigenvalues \(\left|p|\psi\right>=\lambda\left|\psi\right>\) of obtained matrix are the same as of the problem \(\left|pI|\psi\right>=\lambda\left|I|\psi\right>\). The method is not a good one for derivatives. ThegetbQQIpowdpdtFromQQpi_withLastP(double, double[], com.polytechnik.utils.EVXData, java.util.function.Function<double[], double[]>, double[], double)
typically gives a much better result for derivatives.- Parameters:
bQQpi
- The matrix \( \left<\psi^{[j]}|pI|\psi^{[k]}\right> \) where \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \). The matrixQQpi
=\( \left<Q_j|pI|Q_k\right>\) in original basis \(Q_k\) can be converted to \( \left|\psi^{[i]}\right> \) -basisbQQpi
using
.EVXData.convertMatrFromQtoB_Basis(n,QQpi,I.ev)
I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.- Returns:
bQQp
matrix.
-
getbQQpiFrombQQp
A helper function to obtain \(|pI|\) operator from \(|p|\) as \(|I^{1/2}|p|I^{1/2}|\).- Parameters:
bQQp
- The matrix \( \left<\psi^{[j]}|p|\psi^{[k]}\right> \) where \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \). The matrixQQp
=\( \left<Q_j|p|Q_k\right>\) in original basis \(Q_k\) can be converted to \( \left|\psi^{[i]}\right> \) -basisbQQp
using
.EVXData.convertMatrFromQtoB_Basis(n,QQp,I.ev)
I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.- Returns:
bQQpi
matrix.
-
getbQQpIpowFrombQQp
TransformbQQp
matrix either to \(|I^{-1/2}|p|I^{-1/2}|\) ifflagDivide=true
or to \(|I^{1/2}|p|I^{1/2}|\) ifflagDivide=false
.- Parameters:
bQQp
- The matrix in I-basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.flagDivide
- Iftrue
constructbQQp[j,k]/sqrt(I.ev[j]*I.ev[k])
, iffalse
constructbQQp[j,k]*sqrt(I.ev[j]*I.ev[k])
.
-
getbQQdpdtFromQQp_withLastP
public static double[] getbQQdpdtFromQQp_withLastP(double[] QQp, EVXData I, Function<double[], double[]> getEDPsi, double[] QQt, double p_last) Obtain regular \(\left<\psi^{[j]}\Big|\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|p|Q_k\right>\) using integration by parts. The method can also be used for the calculation of \(\left<\psi^{[j]}\Big|\frac{dpI}{dt}\Big|\psi^{[k]}\right> \): just putQQpi
instead ofQQp
andIfuture*p_last
instead ofp_last
.- Parameters:
QQp
- The matrix \( \left<Q_j|p|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \), corresponds toCommonBasisOperations.getEDPsi(double[])
that is a one ofWIntegratorLegendreShifted.getEDPsi(double[])
,WIntegratorLaguerre.getEDPsi(double[])
, orWIntegratorMonomials.getEDPsi(double[])
depending on basis used.QQt
- The matrix \( \left<Q_j|Q_k\right>\) in original basis.p_last
- Edge (at \(x_0\)) value of \( p \) to calculate \( dp/dt \), denoted \( P^{last} \).- Returns:
- The matrix \( P^{last}\psi^{[j]}(x_0)\psi^{[k]}(x_0)\omega(x_0)- \left<\mathrm{getEDPsi}(\psi^{[j]})\Big|p\Big|\psi^{[k]}\right> -\left<\psi^{[j]}\Big|p\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \).
- See Also:
-
getbQQdpdtFromQQpi
private static double[] getbQQdpdtFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) Obtain \(\left<\psi^{[j]}\Big|\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\), similar toVolMatrix.getDiffMatrix(int, double[])
but the original moments are calculated with \( I\) weigth. The approximation is \begin{align} \left<\psi^{[j]}\Big|\frac{dp}{dt}\Big|\psi^{[k]}\right>&\approx p(x_0)\psi^{[j]}(x_0)\psi^{[k]}(x_0)\omega(x_0)- \frac{1}{\lambda^{[k]}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> -\frac{1}{\lambda^{[j]}}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \end{align}- Parameters:
QQpi
- The matrix \( \left<Q_j|pI|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \) with weight; corresponds toCommonBasisOperations.getEDPsi(double[])
andVolMatrix.getDPsi(double[])
.- Returns:
- The matrix \(
\frac{1}{\lambda^{[k]}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right>
+\frac{1}{\lambda^{[j]}}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right>
\). Out of integral term is not included and the sign is the same as in
VolMatrix.getDiffMatrix(int, double[])
. - See Also:
-
getbQQIdpdtFromQQpi
private static double[] getbQQIdpdtFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) Obtain \(\left<\psi^{[j]}\Big|I\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).- Returns:
- The matrix \( \frac{\sqrt{\lambda^{[j]}}}{\sqrt{\lambda^{[k]}}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> +\frac{\sqrt{\lambda^{[k]}}}{\sqrt{\lambda^{[j]}}}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \). Out of integral term is not included.
-
getbQQI2dpdtFromQQpi
private static double[] getbQQI2dpdtFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|I^2\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).- Returns:
- The matrix \( \lambda^{[j]}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> +\lambda^{[k]}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \). Out of integral term is not included.
-
getbQQdpdtDivIFromQQpi
private static double[] getbQQdpdtDivIFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{1}{I}\frac{dp}{dt} \Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).- Returns:
- The matrix \( \frac{1}{{\lambda^{[k]}}^{3/2}\sqrt{\lambda^{[j]}}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> +\frac{1}{{\lambda^{[j]}}^{3/2}\sqrt{\lambda^{[k]}}}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \). Out of integral term is not included.
-
getbQQdpdtDivI2FromQQpi
private static double[] getbQQdpdtDivI2FromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{1}{I^2}\frac{dp}{dt}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\).- Returns:
- The matrix \( \frac{1}{{\lambda^{[k]}}^{2}\lambda^{[j]}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> +\frac{1}{{\lambda^{[j]}}^{2}\lambda^{[k]}}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \). Out of integral term is not included.
-
getbQQdpdtIpowFromQQpi
private static double[] getbQQdpdtIpowFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, MatricesFromPI.GetPsiDpsiFactor factor, boolean flagDivide) -
getbQQIpowdpdtFromQQpi_withLastP
public static double[] getbQQIpowdpdtFromQQpi_withLastP(double Ipow, double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double[] QQi, double p_last) A helper method to obtain actual \( \left<\psi^{[j]}\Big|I^{\mathrm{Ipow}}\frac{dp}{dt}\Big|\psi^{[j]}\right> \), including out of integral term, using integration by parts. The method adjusts last value to 0 to compensate out of integral term, then callsgetbQQdpdtIpowFromQQpi(double[], com.polytechnik.utils.EVXData, java.util.function.Function<double[], double[]>, com.polytechnik.freemoney.MatricesFromPI.GetPsiDpsiFactor, boolean)
.- Parameters:
Ipow
- the power of \( I \) in the result.QQpi
- The matrix \( \left<Q_j|pI|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \), corresponds toCommonBasisOperations.getEDPsi(double[])
that is a one ofWIntegratorLegendreShifted.getEDPsi(double[])
,WIntegratorLaguerre.getEDPsi(double[])
, orWIntegratorMonomials.getEDPsi(double[])
depending on basis used.QQi
- The matrix \( \left<Q_j|I|Q_k\right>\) in original basis.p_last
- The last value of p.- Returns:
- The matrix \( \frac{\left(\lambda^{[j]}\lambda^{[k]}\right)^{\mathrm{Ipow}/2}}{\lambda^{[k]}}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|(\mathrm{p\_last}-p)I\Big|\psi^{[k]}\right> +\frac{\left(\lambda^{[j]}\lambda^{[k]}\right)^{\mathrm{Ipow}/2}}{\lambda^{[j]}}\left<\psi^{[j]}\Big|(\mathrm{p\_last}-p)I\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \).
-
getbQQpdIdtFromQQp
public static double[] getbQQpdIdtFromQQp(double[] QQp, EVXData I, Function<double[], double[]> getEDPsi, double Ifuture) A helper method to obtain something like \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right> \), exact meaning is not clear: when \(p=const\) we get an exact \( dI/dt \), and when \( I=const \) we get all zero. Typical usage: call withQQpi=QQt
to obtain \(\left<\psi^{[j]}\Big|\frac{dI}{dt}\Big|\psi^{[k]}\right>\).- Parameters:
QQp
- The matrix \( \left<Q_j|p|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \).Ifuture
- Future value of \( I \) to calculate \( dI/dt \), denoted \(I^F\), typically the maximal eigenvalue ofI
.- Returns:
- The matrix \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right>= \left(I^F-\lambda^{[k]}\right) \left<\mathrm{getEDPsi}(\psi^{[j]})\Big|p\Big|\psi^{[k]}\right> + \left(I^F-\lambda^{[j]}\right) \left<\psi^{[j]}\Big|p\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \).
-
getbQQpdIdtFromQQpi
public static double[] getbQQpdIdtFromQQpi(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double Ifuture) A helper method to obtain something like \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right> \), exact meaning is not clear: when \(p=const\) we get an exact \( dI/dt \), and when \( I=const \) we get all zero. Typical usage: call withQQpi=QQi
to obtain \(\left<\psi^{[j]}\Big|\frac{dI}{dt}\Big|\psi^{[k]}\right>\).- Parameters:
QQpi
- The matrix \( \left<Q_j|pI|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \).Ifuture
- Future value of \( I \) to calculate \( dI/dt \), denoted \(I^F\), typically the maximal eigenvalue ofI
.- Returns:
- The matrix \( \left<\psi^{[j]}\Big|p\frac{dI}{dt}\Big|\psi^{[k]}\right>= \left(\frac{I^F}{\lambda^{[k]}}-1\right) \left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> + \left(\frac{I^F}{\lambda^{[j]}}-1\right) \left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \).
-
getbQQpdIdtFromQQp
-
getbQQDtpDivIFromQQpi_withLastP
public static double[] getbQQDtpDivIFromQQpi_withLastP(double[] QQpi, EVXData I, Function<double[], double[]> getEDPsi, double p_last, double Ifuture) An attempt to obtain \(\left<\psi^{[j]}\Big|\frac{d}{dt}\frac{p}{I}\Big|\psi^{[k]}\right> \) from \( \left<Q_j|pI|Q_k\right>\) using integration by parts.- Parameters:
QQpi
- The matrix \( \left<Q_j|pI|Q_k\right>\) in original basis.I
- Eigenproblem \( \left|I|\psi^{[i]}\right>=\lambda^{[i]}\left|\psi^{[i]}\right> \) solution.getEDPsi
- Time-variation of \( \left|\psi\right> \), corresponds toCommonBasisOperations.getEDPsi(double[])
that is a one ofWIntegratorLegendreShifted.getEDPsi(double[])
,WIntegratorLaguerre.getEDPsi(double[])
, orWIntegratorMonomials.getEDPsi(double[])
depending on basis used.p_last
- Edge (at \(x_0\)) value of \(p\), denoted \( P^{last} \).Ifuture
- Future value of \( I \) to calculate \( dI/dt \), denoted \(I^F\).- Returns:
- The matrix \( \frac{P^{last}}{I^F}\psi^{[j]}(x_0)\psi^{[k]}(x_0)\omega(x_0)- \frac{1}{{\lambda^{[k]}}^2}\left<\mathrm{getEDPsi}(\psi^{[j]})\Big|pI\Big|\psi^{[k]}\right> -\frac{1}{{\lambda^{[j]}}^2}\left<\psi^{[j]}\Big|pI\Big|\mathrm{getEDPsi}(\psi^{[k]})\right> \).
- See Also:
-