@@ -1679,16 +1679,49 @@ module stdlib_linalg
1679
1679
#:endfor
1680
1680
end interface mnorm
1681
1681
1682
- !> Matrix exponential: function interface
1682
+ !> Matrix exponential: function interface
1683
1683
interface expm
1684
+ !! version : experimental
1685
+ !!
1686
+ !! Computes the exponential of a matrix using a rational Pade approximation.
1687
+ !!
1688
+ !! ### Description
1689
+ !!
1690
+ !! This interface provides methods for computing the exponential of a matrix
1691
+ !! represented as a standard Fortran rank-2 array. Supported data types include
1692
+ !! `real` and `complex`.
1693
+ !!
1694
+ !! By default, the order of the Pade approximation is set to 10. It can be changed
1695
+ !! via the `order` argument which must be non-negative.
1696
+ !!
1697
+ !! If the input matrix is non-square or the order of the Pade approximation is
1698
+ !! negative, the function returns an error state.
1699
+ !!
1700
+ !! ### Example
1701
+ !!
1702
+ !! ```fortran
1703
+ !! real(dp) :: A(3, 3), E(3, 3)
1704
+ !!
1705
+ !! A = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3])
1706
+ !!
1707
+ !! ! Default Pade approximation of the matrix exponential.
1708
+ !! E = expm(A)
1709
+ !!
1710
+ !! ! Pade approximation with specified order.
1711
+ !! E = expm(A, order=12)
1712
+ !! ```
1713
+ !!
1684
1714
#:for rk,rt,ri in RC_KINDS_TYPES
1685
- module function expm_${ri}$(A, order) result(E)
1715
+ module function stdlib_expm_${ri}$(A, order, err) result(E)
1716
+ !> Input matrix a(n, n).
1686
1717
${rt}$, intent(in) :: A(:, :)
1687
- !! On entry, the original matrix. On exit, its exponential.
1718
+ !> [optional] Order of the Pade approximation (default `order=10`)
1688
1719
integer(ilp), optional, intent(in) :: order
1689
- !! Order of the rational approximation.
1720
+ !> [optional] State return flag. On error, if not requested, the code will stop.
1721
+ type(linalg_state_type), optional, intent(out) :: err
1722
+ !> Exponential of the input matrix E = exp(A).
1690
1723
${rt}$, allocatable :: E(:, :)
1691
- end function expm_ ${ri}$
1724
+ end function stdlib_expm_ ${ri}$
1692
1725
#:endfor
1693
1726
end interface expm
1694
1727
0 commit comments