4
4
#:set RHS_SYMBOL = [ranksuffix(r) for r in [1,2]]
5
5
#:set RHS_EMPTY = [emptyranksuffix(r) for r in [1,2]]
6
6
#:set ALL_RHS = list(zip(RHS_SYMBOL,RHS_SUFFIX,RHS_EMPTY))
7
- module stdlib_linalg_solve
7
+ submodule (stdlib_linalg) stdlib_linalg_solve
8
+ !! Solve linear system Ax=b
8
9
use stdlib_linalg_constants
9
10
use stdlib_linalg_lapack, only: gesv
10
11
use stdlib_linalg_state, only: linalg_state_type, linalg_error_handling, LINALG_ERROR, &
11
12
LINALG_INTERNAL_ERROR, LINALG_VALUE_ERROR
12
13
implicit none(type,external)
13
-
14
- !> Solve a linear system
15
- public :: solve
16
-
17
- ! NumPy: solve(a, b)
18
- ! Scipy: solve(a, b, lower=False, overwrite_a=False, overwrite_b=False, check_finite=True, assume_a='gen', transposed=False)[source]#
19
- ! IMSL: lu_solve(a, b, transpose=False)
20
-
21
- interface solve
22
- #:for nd,ndsuf,nde in ALL_RHS
23
- #:for rk,rt,ri in RC_KINDS_TYPES
24
- #:if rk!="xdp"
25
- module procedure stdlib_linalg_${ri}$_solve_${ndsuf}$
26
- module procedure stdlib_linalg_${ri}$_pure_solve_${ndsuf}$
27
- #:endif
28
- #:endfor
29
- #:endfor
30
- end interface solve
31
-
32
14
33
15
character(*), parameter :: this = 'solve'
34
16
@@ -62,7 +44,7 @@ module stdlib_linalg_solve
62
44
#:for rk,rt,ri in RC_KINDS_TYPES
63
45
#:if rk!="xdp"
64
46
! Compute the solution to a real system of linear equations A * X = B
65
- function stdlib_linalg_${ri}$_solve_${ndsuf}$(a,b,overwrite_a,err) result(x)
47
+ module function stdlib_linalg_${ri}$_solve_${ndsuf}$(a,b,overwrite_a,err) result(x)
66
48
!> Input matrix a[n,n]
67
49
${rt}$, intent(inout), target :: a(:,:)
68
50
!> Right hand side vector or array, b[n] or b[n,nrhs]
@@ -74,14 +56,14 @@ module stdlib_linalg_solve
74
56
!> Result array/matrix x[n] or x[n,nrhs]
75
57
${rt}$, allocatable, target :: x${nd}$
76
58
77
- !> Local variables
59
+ ! Local variables
78
60
type(linalg_state_type) :: err0
79
61
integer(ilp) :: lda,n,ldb,nrhs,info
80
62
integer(ilp), allocatable :: ipiv(:)
81
63
logical(lk) :: copy_a
82
64
${rt}$, pointer :: xmat(:,:),amat(:,:)
83
65
84
- !> Problem sizes
66
+ ! Problem sizes
85
67
lda = size(a,1,kind=ilp)
86
68
n = size(a,2,kind=ilp)
87
69
ldb = size(b,1,kind=ilp)
@@ -130,22 +112,22 @@ module stdlib_linalg_solve
130
112
end function stdlib_linalg_${ri}$_solve_${ndsuf}$
131
113
132
114
! Compute the solution to a real system of linear equations A * X = B (pure interface)
133
- pure function stdlib_linalg_${ri}$_pure_solve_${ndsuf}$(a,b) result(x)
115
+ pure module function stdlib_linalg_${ri}$_pure_solve_${ndsuf}$(a,b) result(x)
134
116
!> Input matrix a[n,n]
135
117
${rt}$, intent(in), target :: a(:,:)
136
118
!> Right hand side vector or array, b[n] or b[n,nrhs]
137
119
${rt}$, intent(in) :: b${nd}$
138
120
!> Result array/matrix x[n] or x[n,nrhs]
139
121
${rt}$, allocatable, target :: x${nd}$
140
122
141
- !> Local variables
123
+ ! Local variables
142
124
type(linalg_state_type) :: err0
143
125
integer(ilp) :: lda,n,ldb,nrhs,info
144
126
integer(ilp), allocatable :: ipiv(:)
145
127
${rt}$, pointer :: xmat(:,:)
146
128
${rt}$, allocatable :: amat(:,:)
147
129
148
- !> Problem sizes
130
+ ! Problem sizes
149
131
lda = size(a,1,kind=ilp)
150
132
n = size(a,2,kind=ilp)
151
133
ldb = size(b,1,kind=ilp)
@@ -185,4 +167,4 @@ module stdlib_linalg_solve
185
167
#:endfor
186
168
#:endfor
187
169
188
- end module stdlib_linalg_solve
170
+ end submodule stdlib_linalg_solve
0 commit comments