Package com.irurueta.numerical
Class ExponentialMatrixEstimator
java.lang.Object
com.irurueta.numerical.ExponentialMatrixEstimator
Estimates exponential of a square matrix.
This is based on Gene H. Golub and Charles F. Van Loan. Matrix Computations. 3rd ed. 1996. p. 572
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.irurueta.algebra.Matrix
Scaled version of provided input matrix.private com.irurueta.algebra.Matrix
Internal matrix reused for efficiency while provided input matrices keep the same size.private com.irurueta.algebra.Matrix
Denominator of Padé approximant.private com.irurueta.algebra.Matrix
Contains copy of estimated result.private final DoubleFactorialEstimator
Estimates factorial values.private com.irurueta.algebra.Matrix
Numerator of Padé approximant.private int
Number of rows of matrix to be estimated.private com.irurueta.algebra.Matrix
Internal matrix reused for efficiency while provided input matrices keep the same size.static final double
Default error tolerance of estimated result element-wise.private com.irurueta.algebra.Matrix
Internal matrix reused for efficiency while provided input matrices keep the same size. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.irurueta.algebra.Matrix
exponential
(com.irurueta.algebra.Matrix a) Estimates exponential of provided matrix with default error tolerance.com.irurueta.algebra.Matrix
exponential
(com.irurueta.algebra.Matrix a, double tolerance) Estimates exponential of provided matrix.void
exponential
(com.irurueta.algebra.Matrix a, com.irurueta.algebra.Matrix result) Estimates exponential of provided matrix with default error tolerance.void
exponential
(com.irurueta.algebra.Matrix a, com.irurueta.algebra.Matrix result, double tolerance) Estimates exponential of provided matrix.private int
findQForRelativeError
(double maxRelativeError) Finds required order of Padé approximant for provided maximum allowed relative error to be achieved.private int
findQForTolerance
(double tolerance, double normA) Finds required order of Padé approximant for provided absolute error tolerance to be achieved.private void
initialize
(int rows) Initializes matrices being reused as long as number of rows is preserved for multiple provided input matrices for efficiency purposes.private static double
normmax
(com.irurueta.algebra.Matrix a) Estimates infinite norm of provided matrix.private double
relativeError
(int p, int q) Estimates relative error achieved by this algorithm for provided input values.
-
Field Details
-
TOLERANCE
public static final double TOLERANCEDefault error tolerance of estimated result element-wise. When this tolerance is used, algorithm achieves an error close to machine precision, but might be slightly larger than this value (which is about 1.1e-16). -
factorialEstimator
Estimates factorial values. -
rows
private int rowsNumber of rows of matrix to be estimated. Every time the number of rows change, reused matrices are re-instantiated for computational efficiency. -
as
private com.irurueta.algebra.Matrix asScaled version of provided input matrix. This instance is reused as long as provided input matrices keep the same size. -
d
private com.irurueta.algebra.Matrix dDenominator of Padé approximant. This is reused for efficiency while provided input matrices keep the same size. -
n
private com.irurueta.algebra.Matrix nNumerator of Padé approximant. This is reused for efficiency while provided input matrices keep the same size. -
x
private com.irurueta.algebra.Matrix xInternal matrix reused for efficiency while provided input matrices keep the same size. -
tmp
private com.irurueta.algebra.Matrix tmpInternal matrix reused for efficiency while provided input matrices keep the same size. -
cX
private com.irurueta.algebra.Matrix cXInternal matrix reused for efficiency while provided input matrices keep the same size. -
f
private com.irurueta.algebra.Matrix fContains copy of estimated result. This is reused for efficiency while provided input matrices keep the same size.
-
-
Constructor Details
-
ExponentialMatrixEstimator
public ExponentialMatrixEstimator()
-
-
Method Details
-
exponential
public com.irurueta.algebra.Matrix exponential(com.irurueta.algebra.Matrix a) throws com.irurueta.algebra.AlgebraException Estimates exponential of provided matrix with default error tolerance. When this tolerance is used, algorithm achieves an error close to machine precision, but might be slightly larger than this value (which is about 1.1e-6).- Parameters:
a
- matrix to be used for exponential estimation.- Returns:
- estimated exponential matrix.
- Throws:
com.irurueta.algebra.AlgebraException
- if there are numerical errors.
-
exponential
public com.irurueta.algebra.Matrix exponential(com.irurueta.algebra.Matrix a, double tolerance) throws com.irurueta.algebra.AlgebraException Estimates exponential of provided matrix. Larger tolerance than default one can be used to reduce computational complexity if less accuracy is required.- Parameters:
a
- matrix to be used for exponential estimation.tolerance
- maximum allowed absolute error tolerance element-wise.- Returns:
- estimated exponential matrix.
- Throws:
com.irurueta.algebra.AlgebraException
- if there are numerical errors.
-
exponential
public void exponential(com.irurueta.algebra.Matrix a, com.irurueta.algebra.Matrix result) throws com.irurueta.algebra.AlgebraException Estimates exponential of provided matrix with default error tolerance. When this tolerance is used, algorithm achieves an error close to machine precision, but might be slightly larger than this value (which is about 1.1e-6).- Parameters:
a
- matrix to be used for exponential estimation.result
- instance where result will be stored.- Throws:
com.irurueta.algebra.AlgebraException
- if there are numerical errors.
-
exponential
public void exponential(com.irurueta.algebra.Matrix a, com.irurueta.algebra.Matrix result, double tolerance) throws com.irurueta.algebra.AlgebraException Estimates exponential of provided matrix. Larger tolerance than default one can be used to reduce computational complexity if less accuracy is required.- Parameters:
a
- matrix to be used for exponential estimation.result
- instance where result will be stored.tolerance
- maximum allowed absolute error tolerance element-wise.- Throws:
com.irurueta.algebra.AlgebraException
- if there are numerical errors.
-
initialize
private void initialize(int rows) throws com.irurueta.algebra.AlgebraException Initializes matrices being reused as long as number of rows is preserved for multiple provided input matrices for efficiency purposes.- Parameters:
rows
- number of rows.- Throws:
com.irurueta.algebra.AlgebraException
- if an error occurs during instantiation.
-
relativeError
private double relativeError(int p, int q) Estimates relative error achieved by this algorithm for provided input values.- Parameters:
p
- Padé approximant order of numerator.q
- Padé approximant order of denominator.- Returns:
- estimated relative error.
-
findQForRelativeError
private int findQForRelativeError(double maxRelativeError) Finds required order of Padé approximant for provided maximum allowed relative error to be achieved.- Parameters:
maxRelativeError
- maximum allowed relative error.- Returns:
- Padé approximant order.
-
findQForTolerance
private int findQForTolerance(double tolerance, double normA) Finds required order of Padé approximant for provided absolute error tolerance to be achieved.- Parameters:
tolerance
- maximum allowed absolute error tolerance.normA
- infinite norm (maximum absolute value) of provided matrix.- Returns:
- Padé approximant order.
-
normmax
private static double normmax(com.irurueta.algebra.Matrix a) Estimates infinite norm of provided matrix. Infinite norm is equivalent to the maximum absolute value of all matrix elements.- Parameters:
a
- matrix to compute infinite norm for.- Returns:
- estimated infinite norm.
-