Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5eb5273

Browse files
Added matrix_exp to specs.
1 parent 551ecf5 commit 5eb5273

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

‎doc/specs/stdlib_linalg.md‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,24 +1896,60 @@ Given a matrix \(A\), this function computes its matrix exponential \(E = \exp(A
18961896

18971897
### Syntax
18981898

1899-
`E = ` [[stdlib_linalg(module):expm(interface)]] `(a [, order, err])`
1899+
`E = ` [[stdlib_linalg(module):expm(interface)]] `(a [, order])`
19001900

19011901
### Arguments
19021902

19031903
`a`: Shall be a rank-2 `real` or `complex` array containing the data. It is an `intent(in)` argument.
19041904

19051905
`order` (optional): Shall be a non-negative `integer` value specifying the order of the Pade approximation. By default `order=10`. It is an `intent(in)` argument.
19061906

1907+
### Return value
1908+
1909+
The returned array `E` contains the Pade approximation of \(\exp(A)\).
1910+
1911+
If `A` is non-square or `order` is negative, it raises a `LINALG_VALUE_ERROR`.
1912+
1913+
### Example
1914+
1915+
```fortran
1916+
{!example/linalg/example_expm.f90!}
1917+
```
1918+
1919+
## `matrix_exp` - Computes the matrix exponential {#matrix_exp}
1920+
1921+
### Status
1922+
1923+
Experimental
1924+
1925+
### Description
1926+
1927+
Given a matrix \(A\), this function computes its matrix exponential \(E = \exp(A)\) using a Pade approximation.
1928+
1929+
### Syntax
1930+
1931+
`call ` [[stdlib_linalg(module):matrix_exp(interface)]] `(a [, e, order, err])`
1932+
1933+
### Arguments
1934+
1935+
`a`: Shall be a rank-2 `real` or `complex` array containing the data. If `e` is not passed, it is an `intent(inout)` argument and is overwritten on exit by the matrix exponential. If `e` is passed, it is an `intent(in)` argument and is left unchanged.
1936+
1937+
`e` (optional): Shall be a rank-2 `real` or `complex` array with the same dimensions as `a`. It is an `intent(out)` argument. On exit, it contains the matrix exponential of `a`.
1938+
1939+
`order` (optional): Shall be a non-negative `integer` value specifying the order of the Pade approximation. By default `order=10`. It is an `intent(in)` argument.
1940+
19071941
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
19081942

19091943
### Return value
19101944

1911-
The returned array `E` contains the Pade approximation of \(\exp(A)\).
1945+
The returned array `A` (in-place) or `E` (out-of-place) contains the Pade approximation of \(\exp(A)\).
19121946

19131947
If `A` is non-square or `order` is negative, it raises a `LINALG_VALUE_ERROR`.
19141948
If `err` is not present, exceptions trigger an `error stop`.
19151949

19161950
### Example
19171951

19181952
```fortran
1919-
{!example/linalg/example_expm.f90!}
1953+
{!example/linalg/example_matrix_exp.f90!}
1954+
```
1955+

‎example/linalg/example_expm.f90‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ program example_expm
22
use stdlib_linalg, only: expm
33
implicit none
44
real :: A(3, 3), E(3, 3)
5+
integer :: i
56
A = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3])
67
E = expm(A)
8+
9+
print *, "Matrix A :"
10+
do i = 1, 3
11+
print *, A(i, :)
12+
end do
13+
14+
print *, "Matrix exponential E = exp(A):"
15+
do i = 1, 3
16+
print *, E(i, :)
17+
end do
718
end program example_expm
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
program example_expm
2+
use stdlib_linalg, only: matrix_exp
3+
implicit none
4+
real :: A(3, 3), E(3, 3)
5+
integer :: i
6+
7+
print *, "Matrix A :"
8+
do i = 1, 3
9+
print *, A(i, :)
10+
end do
11+
12+
A = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3])
13+
call matrix_exp(A) ! In-place computation.
14+
! For out-of-place, use call matrix_exp(A, E).
15+
16+
print *, "Matrix exponential E = exp(A):"
17+
do i = 1, 3
18+
print *, E(i, :)
19+
end do
20+
end program example_expm

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /