FE-Project
Loading...
Searching...
No Matches
scale_linalgebra::linalgebra_solvelineq Interface Reference

Solve a linear equation Ax=b using a direct solver. More...

Public Member Functions

subroutine linalgebra_solvelineq_b1d (a, b, x)
 Solve a linear equation Ax=b using a direct solver.
subroutine linalgebra_solvelineq_b2d (a, b, x)
 Solve a linear equation Ax=b using a direct solver where b is a matrix.

Detailed Description

Solve a linear equation Ax=b using a direct solver.

Definition at line 33 of file scale_linalgebra.F90.

Member Function/Subroutine Documentation

◆ linalgebra_solvelineq_b1d()

subroutine scale_linalgebra::linalgebra_solvelineq::linalgebra_solvelineq_b1d ( real(rp), dimension(:,:), intent(in) a,
real(rp), dimension(:), intent(in) b,
real(rp), dimension(size(b)), intent(out) x )

Solve a linear equation Ax=b using a direct solver.

Parameters
[in]aCoefficient matrix
[in]bVector in the right-hand side
[out]xSolution vector of linear equation Ax=b

Definition at line 107 of file scale_linalgebra.F90.

108 implicit none
109 real(RP), intent(in) :: A(:,:) !< Coefficient matrix
110 real(RP), intent(in) :: b(:) !< Vector in the right-hand side
111 real(RP), intent(out) :: x(size(b)) !< Solution vector of linear equation Ax=b
112
113 real(RP) :: A_lu(size(A,1),size(A,2))
114 integer :: ipiv(size(A,1))
115 integer :: n, info
116
117 !---------------------------------------------------------------------------
118
119 a_lu = a
120 n = size(a,1)
121
122 call dgetrf(n, n, a_lu, n, ipiv, info)
123 if (info /=0 ) then
124 log_error("linalgebra_SolveLinEq",*) "Matrix is singular"
125 call prc_abort
126 end if
127
128 x(:) = b
129 call dgetrs('N', n, 1, a_lu, n, ipiv, x, n, info)
130 if (info /=0 ) then
131 log_error("linalgebra_SolveLinEq",*) "Matrix inversion is failed"
132 call prc_abort
133 end if
134
135 return

◆ linalgebra_solvelineq_b2d()

subroutine scale_linalgebra::linalgebra_solvelineq::linalgebra_solvelineq_b2d ( real(rp), dimension(:,:), intent(in) a,
real(rp), dimension(:,:), intent(in) b,
real(rp), dimension(size(b,1),size(b,2)), intent(out) x )

Solve a linear equation Ax=b using a direct solver where b is a matrix.

Parameters
[in]aCoefficient matrix
[in]bMatrix in the right-hand side
[out]xMatrix storing solution of linear equation Ax=b

Definition at line 140 of file scale_linalgebra.F90.

141 implicit none
142 real(RP), intent(in) :: A(:,:) !< Coefficient matrix
143 real(RP), intent(in) :: b(:,:) !< Matrix in the right-hand side
144 real(RP), intent(out) :: x(size(b,1),size(b,2)) !< Matrix storing solution of linear equation Ax=b
145
146 real(RP) :: A_lu(size(A,1),size(A,2))
147 integer :: ipiv(size(A,1))
148 integer :: n, info
149
150 !---------------------------------------------------------------------------
151
152 a_lu = a
153 n = size(a,1)
154
155 call dgetrf(n, n, a_lu, n, ipiv, info)
156 if (info /=0 ) then
157 log_error("linalgebra_SolveLinEq",*) "Matrix is singular"
158 call prc_abort
159 end if
160
161 x(:,:) = b
162 call dgetrs('N', n, size(b,2), a_lu, n, ipiv, x, n, info)
163 if (info /=0 ) then
164 log_error("linalgebra_SolveLinEq",*) "Matrix inversion is failed"
165 call prc_abort
166 end if
167
168 return

The documentation for this interface was generated from the following file: