51 integer(kind=kint),
intent(in) :: n, lda
52 real(kind=
kreal),
intent(inout) :: a(lda,*)
53 real(kind=
kreal),
intent(in) :: zero
54 integer(kind=kint),
intent(out) :: info
55 integer(kind=kint) :: i, j, k
56 real(kind=
kreal) :: d, l
61 if (.not. (abs(d) > zero))
then
68 a(i,j) = a(i,j) - a(i,k)*l
80 integer(kind=kint),
intent(in) :: m, n, ldl, lda
81 real(kind=
kreal),
intent(in) :: l(ldl,*)
82 real(kind=
kreal),
intent(inout) :: a(lda,*)
83 integer(kind=kint) :: i, j
84 #ifdef HECMW_WITH_LAPACK
87 call dtrsm(
'R',
'L',
'T',
'U', m, n, 1.0d0, l, ldl, a, lda)
90 a(i,j) = a(i,j) / l(j,j)
94 integer(kind=kint) :: k
100 a(i,j) = a(i,j) - a(i,k)*l(j,k)
106 a(i,j) = a(i,j) / l(j,j)
117 integer(kind=kint),
intent(in) :: m, n, lda
118 real(kind=
kreal),
intent(inout) :: a(lda,*)
119 real(kind=
kreal),
intent(in) :: u, zero
120 integer(kind=kint),
intent(out) :: info
121 integer(kind=kint) :: i, j
122 real(kind=
kreal) :: uinv
125 if (info /= 0)
return
130 if (.not. (abs(a(i,j)) <= uinv))
then
146 subroutine hecmw_mf_kernel_panel_piv(m, n, lda, a, blk, u, alpha, zero, allow_delay, wk, &
147 npiv, perm, ptype, dsub, nswap, n2x2, info)
149 integer(kind=kint),
intent(in) :: m, n, lda
150 real(kind=
kreal),
intent(inout) :: a(lda,*)
151 integer(kind=kint),
intent(inout) :: blk(n)
152 real(kind=
kreal),
intent(in) :: u, alpha, zero
153 logical,
intent(in) :: allow_delay
154 real(kind=
kreal),
intent(inout) :: wk(2*m)
155 integer(kind=kint),
intent(out) :: npiv, perm(n), ptype(n), nswap, n2x2, info
156 real(kind=
kreal),
intent(out) :: dsub(n)
157 integer(kind=kint) :: p, nrem, i, r, pass
158 real(kind=
kreal) :: lam, app, best, uinv
159 logical :: accepted, same
175 lam = max(lam, abs(a(i,p)))
178 if (app > zero .and. app >= u*lam)
then
188 same = (blk(i) == blk(p))
189 if (same .neqv. (pass == 1)) cycle
190 if (abs(a(i,p)) > best)
then
196 call try_partner(r, accepted)
201 if (.not. allow_delay)
then
207 call try_partner(r, accepted)
214 if (nrem > p)
call swap(p, nrem)
222 subroutine try_partner(r, accepted)
223 integer(kind=kint),
intent(in) :: r
224 logical,
intent(out) :: accepted
225 integer(kind=kint) :: i
226 real(kind=
kreal) :: sig, arr, aa, bb, cc, det, cp, cr, g1, g2
231 sig = max(sig, abs(a(r,i)))
234 sig = max(sig, abs(a(i,r)))
237 if (arr > zero .and. arr >= alpha*sig)
then
244 if (r /= p+1)
call swap(p+1, r)
249 if (abs(det) > zero*zero)
then
253 cp = max(cp, abs(a(i,p)))
254 cr = max(cr, abs(a(i,p+1)))
256 g1 = (abs(cc)*cp + abs(bb)*cr) / abs(det)
257 g2 = (abs(bb)*cp + abs(aa)*cr) / abs(det)
258 if (g1 <= uinv .and. g2 <= uinv)
then
259 if (r /= p+1) nswap = nswap + 1
266 if (r /= p+1)
call swap(p+1, r)
267 end subroutine try_partner
270 subroutine pivot_1x1()
271 integer(kind=kint) :: i, j
272 real(kind=
kreal) :: d, l
278 a(i,j) = a(i,j) - a(i,p)*l
286 end subroutine pivot_1x1
289 subroutine pivot_2x2()
290 integer(kind=kint) :: i, j
291 real(kind=
kreal) :: aa, bb, cc, det
298 wk(i) = (cc*a(i,p) - bb*a(i,p+1)) / det
299 wk(m+i) = (aa*a(i,p+1) - bb*a(i,p)) / det
303 a(i,j) = a(i,j) - wk(i)*a(j,p) - wk(m+i)*a(j,p+1)
315 end subroutine pivot_2x2
318 subroutine swap(x, y)
319 integer(kind=kint),
intent(in) :: x, y
320 integer(kind=kint) :: i, t
321 real(kind=
kreal) :: v
354 integer(kind=kint),
intent(in) :: m, n, ldl, lda
355 real(kind=
kreal),
intent(in) :: l(ldl,*)
356 integer(kind=kint),
intent(in) :: ptype(n)
357 real(kind=
kreal),
intent(in) :: dsub(n)
358 real(kind=
kreal),
intent(in) :: a(lda,*)
359 real(kind=
kreal),
intent(out) :: w(m,n)
360 integer(kind=kint) :: i, j
361 real(kind=
kreal) :: d11, d21, d22
364 if (ptype(j) == 1)
then
366 w(i,j) = a(i,j) * l(j,j)
368 else if (ptype(j) == 2)
then
373 w(i,j) = a(i,j)*d11 + a(i,j+1)*d21
374 w(i,j+1) = a(i,j)*d21 + a(i,j+1)*d22
383 integer(kind=kint),
intent(in) :: m, n, k, ldw, ldb, ldc
384 real(kind=
kreal),
intent(in) :: w(ldw,*)
385 real(kind=
kreal),
intent(in) :: b(ldb,*)
386 real(kind=
kreal),
intent(inout) :: c(ldc,*)
387 #ifdef HECMW_WITH_LAPACK
390 call dgemm(
'N',
'T', m, n, k, -1.0d0, w, ldw, b, ldb, 1.0d0, c, ldc)
392 integer(kind=kint) :: i, j, p
397 c(i,j) = c(i,j) - w(i,p)*b(j,p)
407 integer(kind=kint),
intent(in) :: n, ldl
408 real(kind=
kreal),
intent(in) :: l(ldl,*)
409 real(kind=
kreal),
intent(inout) :: x(n)
410 integer(kind=kint) :: i, j
414 x(i) = x(i) - l(i,j)*x(j)
422 integer(kind=kint),
intent(in) :: n, ldl
423 real(kind=
kreal),
intent(in) :: l(ldl,*)
424 real(kind=
kreal),
intent(inout) :: x(n)
425 integer(kind=kint) :: i, j
429 x(j) = x(j) - l(i,j)*x(i)
437 integer(kind=kint),
intent(in) :: n, ldl
438 real(kind=
kreal),
intent(in) :: l(ldl,*)
439 integer(kind=kint),
intent(in) :: ptype(n)
440 real(kind=
kreal),
intent(in) :: dsub(n)
441 real(kind=
kreal),
intent(inout) :: x(n)
442 integer(kind=kint) :: j
443 real(kind=
kreal) :: d11, d21, d22, det, x1, x2
446 if (ptype(j) == 1)
then
448 else if (ptype(j) == 2)
then
452 det = d11*d22 - d21*d21
455 x(j) = (d22*x1 - d21*x2) / det
456 x(j+1) = (d11*x2 - d21*x1) / det
464 integer(kind=kint),
intent(in) :: m, n, lda
465 real(kind=
kreal),
intent(in) :: a(lda,*)
466 real(kind=
kreal),
intent(in) :: x(n)
467 real(kind=
kreal),
intent(inout) :: y(m)
468 integer(kind=kint) :: i, j
472 y(i) = y(i) - a(i,j)*x(j)
480 integer(kind=kint),
intent(in) :: m, n, lda
481 real(kind=
kreal),
intent(in) :: a(lda,*)
482 real(kind=
kreal),
intent(in) :: x(m)
483 real(kind=
kreal),
intent(inout) :: y(n)
484 integer(kind=kint) :: i, j
488 y(j) = y(j) - a(i,j)*x(i)
498 integer(kind=kint),
intent(in) :: n, lda, ldb
499 real(kind=
kreal),
intent(inout) :: a(lda,*), b(ldb,*)
500 real(kind=
kreal),
intent(in) :: zero
501 integer(kind=kint),
intent(out) :: info
502 integer(kind=kint) :: i, j, k
503 real(kind=
kreal) :: d, l, u
508 if (.not. (abs(d) > zero))
then
518 a(i,j) = a(i,j) - a(i,k)*u
522 b(i,j) = b(i,j) - b(i,k)*l
531 integer(kind=kint),
intent(in) :: m, n, ldt, lda
532 real(kind=
kreal),
intent(in) :: t(ldt,*)
533 logical,
intent(in) :: unit
534 real(kind=
kreal),
intent(inout) :: a(lda,*)
535 #ifdef HECMW_WITH_LAPACK
539 call dtrsm(
'R',
'L',
'T',
'U', m, n, 1.0d0, t, ldt, a, lda)
541 call dtrsm(
'R',
'L',
'T',
'N', m, n, 1.0d0, t, ldt, a, lda)
544 integer(kind=kint) :: i, j, k
549 a(i,j) = a(i,j) - a(i,k)*t(j,k)
554 a(i,j) = a(i,j) / t(j,j)
566 integer(kind=kint),
intent(in) :: m, n, lda, ldb
567 real(kind=
kreal),
intent(inout) :: a(lda,*), b(ldb,*)
568 real(kind=
kreal),
intent(in) :: u, zero
569 integer(kind=kint),
intent(out) :: info
570 integer(kind=kint) :: i, j
571 real(kind=
kreal) :: uinv
574 if (info /= 0)
return
585 if (.not. (abs(a(i,j)) <= uinv))
then
600 subroutine hecmw_mf_kernel_panel_lu_piv(m, n, lda, a, ldb, b, blk, blkr, u, zero, allow_delay, &
601 npiv, permc, permr, nswap, info)
603 integer(kind=kint),
intent(in) :: m, n, lda, ldb
604 real(kind=
kreal),
intent(inout) :: a(lda,*), b(ldb,*)
605 integer(kind=kint),
intent(inout) :: blk(n), blkr(n)
606 real(kind=
kreal),
intent(in) :: u, zero
607 logical,
intent(in) :: allow_delay
608 integer(kind=kint),
intent(out) :: npiv, permc(n), permr(n), nswap, info
609 integer(kind=kint) :: p, nrem, i, r, pass
610 real(kind=
kreal) :: lam, best
624 lam = max(lam, abs(a(i,p)))
631 same = (blkr(i) == blk(p))
632 if (same .neqv. (pass == 1)) cycle
633 if (abs(a(i,p)) > best)
then
639 if (best >= u*lam)
exit
645 if (.not. allow_delay)
then
649 if (nrem > p)
call swap_sym(p, nrem)
665 integer(kind=kint) :: i, j
666 real(kind=
kreal) :: d, l, uu
675 a(i,j) = a(i,j) - a(i,p)*uu
679 b(i,j) = b(i,j) - b(i,p)*l
686 subroutine swap_row(x, y)
687 integer(kind=kint),
intent(in) :: x, y
688 integer(kind=kint) :: c, t
689 real(kind=
kreal) :: v
715 end subroutine swap_row
718 subroutine swap_sym(x, y)
719 integer(kind=kint),
intent(in) :: x, y
720 integer(kind=kint) :: i, t
721 real(kind=
kreal) :: v
765 end subroutine swap_sym
773 integer(kind=kint),
intent(in) :: n, ldl, ldu
774 real(kind=
kreal),
intent(in) :: l(ldl,*), ut(ldu,*)
775 real(kind=
kreal),
intent(inout) :: x(n)
776 integer(kind=kint) :: i, j
780 x(j) = x(j) - ut(i,j)*x(i)
791 #ifdef HECMW_WITH_LAPACK
842 integer(kind=kint),
intent(in) :: m, n, lda, ldv
843 real(kind=
kreal),
intent(inout) :: a(lda,*)
844 real(kind=
kreal),
intent(in) :: eps
845 real(kind=
kreal),
intent(out) :: v(ldv,*)
846 integer(kind=kint),
intent(out) :: rank
847 integer(kind=kint),
intent(in),
optional :: rcap
848 #ifdef HECMW_WITH_LAPACK
849 integer(kind=kint),
allocatable :: jpvt(:)
850 real(kind=
kreal),
allocatable :: tau(:), vn1(:), vn2(:), wk(:)
851 integer(kind=kint) :: i, j, k, p, r, rlim, itmp
852 real(kind=
kreal) :: r11, rkk, akk, tol3z, tmp, tmp2, dtmp
853 real(kind=
kreal),
external :: dnrm2, dlamch
854 external :: dlarfg, dgemv, dger
858 rlim = int((int(m, 8)*n - 1)/(int(m, 8) + n), kind=
kint)
859 if (
present(rcap)) rlim = min(rlim, max(rcap, 0))
860 tol3z = sqrt(dlamch(
'Epsilon'))
861 allocate(jpvt(n), tau(rlim + 1), vn1(n), vn2(n), wk(n))
864 vn1(j) = dnrm2(m, a(1,j), 1)
872 if (vn1(j) > vn1(p)) p = j
890 rkk = dnrm2(m - k + 1, a(k,k), 1)
891 if (k == 1) r11 = rkk
892 if (.not. (rkk > eps*r11))
then
897 deallocate(jpvt, tau, vn1, vn2, wk)
900 call dlarfg(m - k + 1, a(k,k), a(k+1,k), 1, tau(k))
903 call dgemv(
'T', m - k + 1, n - k, 1.0d0, a(k,k+1), lda, a(k,k), 1, 0.0d0, wk, 1)
904 call dger(m - k + 1, n - k, -tau(k), a(k,k), 1, wk, 1, a(k,k+1), lda)
907 if (vn1(j) /= 0.0d0)
then
908 tmp = max(1.0d0 - (abs(a(k,j))/vn1(j))**2, 0.0d0)
909 tmp2 = tmp*(vn1(j)/vn2(j))**2
910 if (tmp2 <= tol3z)
then
911 vn1(j) = dnrm2(m - k, a(k+1,j), 1)
914 vn1(j) = vn1(j)*sqrt(tmp)
922 v(jpvt(j), k) = a(k, j)
924 v(jpvt(j), k) = 0.0d0
931 call dgemv(
'T', m - k + 1, r - k, 1.0d0, a(k,k+1), lda, a(k,k), 1, 0.0d0, wk, 1)
932 call dger(m - k + 1, r - k, -tau(k), a(k,k), 1, wk, 1, a(k,k+1), lda)
935 a(i,k) = -tau(k)*a(i,k)
937 a(k,k) = 1.0d0 - tau(k)
943 deallocate(jpvt, tau, vn1, vn2, wk)
952 integer(kind=kint),
intent(in) :: m, n, k, lda, ldb, ldc
953 real(kind=
kreal),
intent(in) :: a(lda,*), b(ldb,*)
954 real(kind=
kreal),
intent(out) :: c(ldc,*)
955 #ifdef HECMW_WITH_LAPACK
958 call dgemm(
'N',
'N', m, n, k, 1.0d0, a, lda, b, ldb, 0.0d0, c, ldc)
960 integer(kind=kint) :: i, j, p
968 c(i,j) = c(i,j) + a(i,p)*b(p,j)
978 integer(kind=kint),
intent(in) :: m, n, k, lda, ldb, ldc
979 real(kind=
kreal),
intent(in) :: a(lda,*), b(ldb,*)
980 real(kind=
kreal),
intent(out) :: c(ldc,*)
981 #ifdef HECMW_WITH_LAPACK
984 call dgemm(
'T',
'N', m, n, k, 1.0d0, a, lda, b, ldb, 0.0d0, c, ldc)
986 integer(kind=kint) :: i, j, p
992 c(i,j) = c(i,j) + a(p,i)*b(p,j)
1002 integer(kind=kint),
intent(in) :: m, n, lda
1003 real(kind=
kreal),
intent(in) :: a(lda,*)
1004 real(kind=
kreal),
intent(in) :: x(m)
1005 real(kind=
kreal),
intent(out) :: y(n)
1006 integer(kind=kint) :: i, j
1011 y(j) = y(j) + a(i,j)*x(i)
1019 integer(kind=kint),
intent(in) :: n, r, ldl, ldv, ldw
1020 real(kind=
kreal),
intent(in) :: l(ldl,*)
1021 integer(kind=kint),
intent(in) :: ptype(n)
1022 real(kind=
kreal),
intent(in) :: dsub(n)
1023 real(kind=
kreal),
intent(in) :: v(ldv,*)
1024 real(kind=
kreal),
intent(out) :: w(ldw,*)
1025 integer(kind=kint) :: q, c
1026 real(kind=
kreal) :: d11, d21, d22
1030 if (ptype(q) == 1)
then
1032 w(q,c) = v(q,c) * l(q,q)
1040 w(q,c) = v(q,c)*d11 + v(q+1,c)*d21
1041 w(q+1,c) = v(q,c)*d21 + v(q+1,c)*d22
Dense kernels of the multifrontal solver, symmetric (LDLt) and unsymmetric (LU) mode.
subroutine, public hecmw_mf_kernel_gemm(m, n, k, ldw, w, ldb, b, ldc, c)
c(m,n) <- c - w(m,k) * b(n,k)^T
subroutine, public hecmw_mf_kernel_scale(m, n, ldl, l, ptype, dsub, lda, a, w)
w(m,n) <- a * D with the block diagonal D of the factored tile l(n,n).
subroutine, public hecmw_mf_kernel_compress(m, n, lda, a, eps, ldv, v, rank, rcap)
Truncated rank revealing QR of a(m,n) with the truncation |R(k,k)| <= eps |R(1,1)|: on success the le...
subroutine, public hecmw_mf_kernel_panel_lu_piv(m, n, lda, a, ldb, b, blk, blkr, u, zero, allow_delay, npiv, permc, permr, nswap, info)
LU of the panel a(m,n), b(m,n) with threshold partial pivoting among its n rows: column p takes the r...
subroutine, public hecmw_mf_kernel_gemv(m, n, lda, a, x, y)
y(m) <- y - a(m,n) * x(n)
subroutine, public hecmw_mf_kernel_panel_nopiv(m, n, lda, a, u, zero, info)
Factor the panel a(m,n) (leading n x n block LDLt, rows below by the panel solve) without pivoting an...
logical function, public hecmw_mf_kernel_blr_available()
Whether the BLR compression is available (LAPACK build).
subroutine, public hecmw_mf_kernel_dsolve(n, ldl, l, ptype, dsub, x)
x <- D^-1 x with the block diagonal D of the factored tile l(n,n).
subroutine, public hecmw_mf_kernel_trsv(n, ldl, l, x)
x <- L^-1 x with the unit lower triangle of the tile l(n,n).
subroutine, public hecmw_mf_kernel_trsm_rt(m, n, ldt, t, unit, lda, a)
a(m,n) <- a * T^-T with the lower triangle of t(n,n), unit diagonal when unit.
subroutine, public hecmw_mf_kernel_mult_nn(m, n, k, lda, a, ldb, b, ldc, c)
c(m,n) <- a(m,k) * b(k,n)
subroutine, public hecmw_mf_kernel_usolve(n, ldl, l, ldu, ut, x)
x <- U^-1 x with the diagonal of U on the diagonal of l(n,n) and its strictly upper part transposed i...
subroutine, public hecmw_mf_kernel_mult_tv(m, n, lda, a, x, y)
y(n) <- a(m,n)^T * x(m)
subroutine, public hecmw_mf_kernel_gemv_t(m, n, lda, a, x, y)
y(n) <- y - a(m,n)^T * x(m)
subroutine, public hecmw_mf_kernel_trsm(m, n, ldl, l, lda, a)
a(m,n) <- a * L^-T * D^-1 with L, D taken from the factored tile l(n,n) (1x1 pivots only).
subroutine, public hecmw_mf_kernel_panel_lu_nopiv(m, n, lda, a, ldb, b, u, zero, info)
LU of the panel a(m,n), b(m,n) (leading n x n block, rows below by the panel solves) without pivoting...
subroutine, public hecmw_mf_kernel_scale_rows(n, r, ldl, l, ptype, dsub, ldv, v, ldw, w)
w(n,r) <- D * v(n,r) with the block diagonal D of the factored tile l(n,n).
subroutine, public hecmw_mf_kernel_ldlt(n, lda, a, zero, info)
In place LDLt of the lower triangle of a(n,n) without pivoting; info is the index of the first pivot ...
subroutine, public hecmw_mf_kernel_mult_tn(m, n, k, lda, a, ldb, b, ldc, c)
c(m,n) <- a(k,m)^T * b(k,n)
subroutine, public hecmw_mf_kernel_lu(n, lda, a, ldb, b, zero, info)
In place LU of the n x n block held in a (diagonal and below) and b (above, transposed) without pivot...
subroutine, public hecmw_mf_kernel_panel_piv(m, n, lda, a, blk, u, alpha, zero, allow_delay, wk, npiv, perm, ptype, dsub, nswap, n2x2, info)
Factor the panel a(m,n) with 1x1 and 2x2 pivots chosen among its n columns. A column is accepted as a...
subroutine, public hecmw_mf_kernel_trsv_t(n, ldl, l, x)
x <- L^-T x with the unit lower triangle of the tile l(n,n).
integer(kind=4), parameter kint
integer(kind=4), parameter kreal