7submodule(
linalg) linalg_factor
15 module subroutine lu_factor_dbl(a, ipvt, err)
17 real(real64),
intent(inout),
dimension(:,:) :: a
18 integer(int32),
intent(out),
dimension(:) :: ipvt
19 class(errors),
intent(inout),
optional,
target :: err
22 integer(int32) :: m, n, mn, flag
23 class(errors),
pointer :: errmgr
24 type(errors),
target :: deferr
25 character(len = :),
allocatable :: errmsg
31 if (
present(err))
then
39 if (
size(ipvt) /= mn)
then
41 call errmgr%report_error(
"lu_factor_dbl", &
42 "Incorrectly sized input array IPVT, argument 2.", &
48 call dgetrf(m, n, a, m, ipvt, flag)
55 allocate(
character(len = 256) :: errmsg)
57 "Singular matrix encountered (row ", flag,
")"
58 call errmgr%report_warning(
"lu_factor_dbl", trim(errmsg), &
59 la_singular_matrix_error)
67 module subroutine lu_factor_cmplx(a, ipvt, err)
69 complex(real64),
intent(inout),
dimension(:,:) :: a
70 integer(int32),
intent(out),
dimension(:) :: ipvt
71 class(errors),
intent(inout),
optional,
target :: err
74 integer(int32) :: m, n, mn, flag
75 class(errors),
pointer :: errmgr
76 type(errors),
target :: deferr
77 character(len = :),
allocatable :: errmsg
83 if (
present(err))
then
91 if (
size(ipvt) /= mn)
then
93 call errmgr%report_error(
"lu_factor_cmplx", &
94 "Incorrectly sized input array IPVT, argument 2.", &
100 call zgetrf(m, n, a, m, ipvt, flag)
107 allocate(
character(len = 256) :: errmsg)
109 "Singular matrix encountered (row ", flag,
")"
110 call errmgr%report_warning(
"lu_factor_cmplx", trim(errmsg), &
111 la_singular_matrix_error)
119 module subroutine form_lu_all(lu, ipvt, u, p, err)
121 real(real64),
intent(inout),
dimension(:,:) :: lu
122 integer(int32),
intent(in),
dimension(:) :: ipvt
123 real(real64),
intent(out),
dimension(:,:) :: u, p
124 class(errors),
intent(inout),
optional,
target :: err
127 integer(int32) :: j, jp, n, flag
128 class(errors),
pointer :: errmgr
129 type(errors),
target :: deferr
130 character(len = :),
allocatable :: errmsg
133 real(real64),
parameter :: zero = 0.0d0
134 real(real64),
parameter :: one = 1.0d0
138 if (
present(err))
then
146 if (
size(lu, 2) /= n)
then
148 else if (
size(ipvt) /= n)
then
150 else if (
size(u, 1) /= n .or.
size(u, 2) /= n)
then
152 else if (
size(p, 1) /= n .or.
size(p, 2) /= n)
then
157 allocate(
character(len = 256) :: errmsg)
158 write(errmsg, 100)
"Input number ", flag, &
159 " is not sized correctly."
160 call errmgr%report_error(
"form_lu_all", trim(errmsg), &
166 call dlaset(
'A', n, n, zero, one, p, n)
172 if (j /= jp)
call swap(p(j,1:n), p(jp,1:n))
178 if (j > 1) lu(1:j-1,j) = zero
187 module subroutine form_lu_all_cmplx(lu, ipvt, u, p, err)
189 complex(real64),
intent(inout),
dimension(:,:) :: lu
190 integer(int32),
intent(in),
dimension(:) :: ipvt
191 complex(real64),
intent(out),
dimension(:,:) :: u
192 real(real64),
intent(out),
dimension(:,:) :: p
193 class(errors),
intent(inout),
optional,
target :: err
196 integer(int32) :: j, jp, n, flag
197 class(errors),
pointer :: errmgr
198 type(errors),
target :: deferr
199 character(len = :),
allocatable :: errmsg
202 real(real64),
parameter :: zero = 0.0d0
203 real(real64),
parameter :: one = 1.0d0
204 complex(real64),
parameter :: c_zero = (0.0d0, 0.0d0)
205 complex(real64),
parameter :: c_one = (1.0d0, 0.0d0)
209 if (
present(err))
then
217 if (
size(lu, 2) /= n)
then
219 else if (
size(ipvt) /= n)
then
221 else if (
size(u, 1) /= n .or.
size(u, 2) /= n)
then
223 else if (
size(p, 1) /= n .or.
size(p, 2) /= n)
then
228 allocate(
character(len = 256) :: errmsg)
229 write(errmsg, 100)
"Input number ", flag, &
230 " is not sized correctly."
231 call errmgr%report_error(
"form_lu_all_cmplx", trim(errmsg), &
237 call dlaset(
'A', n, n, zero, one, p, n)
243 if (j /= jp)
call swap(p(j,1:n), p(jp,1:n))
249 if (j > 1) lu(1:j-1,j) = c_zero
258 module subroutine form_lu_only(lu, u, err)
260 real(real64),
intent(inout),
dimension(:,:) :: lu
261 real(real64),
intent(out),
dimension(:,:) :: u
262 class(errors),
intent(inout),
optional,
target :: err
265 integer(int32) :: j, n, flag
266 class(errors),
pointer :: errmgr
267 type(errors),
target :: deferr
268 character(len = :),
allocatable :: errmsg
271 real(real64),
parameter :: zero = 0.0d0
272 real(real64),
parameter :: one = 1.0d0
276 if (
present(err))
then
284 if (
size(lu, 2) /= n)
then
286 else if (
size(u, 1) /= n .or.
size(u, 2) /= n)
then
291 allocate(
character(len = 256) :: errmsg)
292 write(errmsg, 100)
"Input number ", flag, &
293 " is not sized correctly."
294 call errmgr%report_error(
"form_lu_only", trim(errmsg), &
305 if (j > 1) lu(1:j-1,j) = zero
314 module subroutine form_lu_only_cmplx(lu, u, err)
316 complex(real64),
intent(inout),
dimension(:,:) :: lu
317 complex(real64),
intent(out),
dimension(:,:) :: u
318 class(errors),
intent(inout),
optional,
target :: err
321 integer(int32) :: j, n, flag
322 class(errors),
pointer :: errmgr
323 type(errors),
target :: deferr
324 character(len = :),
allocatable :: errmsg
327 complex(real64),
parameter :: zero = (0.0d0, 0.0d0)
328 complex(real64),
parameter :: one = (1.0d0, 0.0d0)
332 if (
present(err))
then
340 if (
size(lu, 2) /= n)
then
342 else if (
size(u, 1) /= n .or.
size(u, 2) /= n)
then
347 allocate(
character(len = 256) :: errmsg)
348 write(errmsg, 100)
"Input number ", flag, &
349 " is not sized correctly."
350 call errmgr%report_error(
"form_lu_only_cmplx", trim(errmsg), &
361 if (j > 1) lu(1:j-1,j) = zero
372 module subroutine qr_factor_no_pivot(a, tau, work, olwork, err)
374 real(real64),
intent(inout),
dimension(:,:) :: a
375 real(real64),
intent(out),
dimension(:) :: tau
376 real(real64),
intent(out),
target,
dimension(:),
optional :: work
377 integer(int32),
intent(out),
optional :: olwork
378 class(errors),
intent(inout),
optional,
target :: err
381 integer(int32) :: m, n, mn, istat, lwork, flag
382 real(real64),
dimension(1) :: temp
383 real(real64),
pointer,
dimension(:) :: wptr
384 real(real64),
allocatable,
target,
dimension(:) :: wrk
385 class(errors),
pointer :: errmgr
386 type(errors),
target :: deferr
392 if (
present(err))
then
399 if (
size(tau) /= mn)
then
401 call errmgr%report_error(
"qr_factor_no_pivot", &
402 "Incorrectly sized input array TAU, argument 2.", &
408 call dgeqrf(m, n, a, m, tau, temp, -1, flag)
409 lwork = int(temp(1), int32)
410 if (
present(olwork))
then
416 if (
present(work))
then
417 if (
size(work) < lwork)
then
419 call errmgr%report_error(
"qr_factor_no_pivot", &
420 "Incorrectly sized input array WORK, argument 3.", &
424 wptr => work(1:lwork)
426 allocate(wrk(lwork), stat = istat)
429 call errmgr%report_error(
"qr_factor_no_pivot", &
430 "Insufficient memory available.", &
431 la_out_of_memory_error)
438 call dgeqrf(m, n, a, m, tau, wptr, lwork, flag)
442 module subroutine qr_factor_no_pivot_cmplx(a, tau, work, olwork, err)
444 complex(real64),
intent(inout),
dimension(:,:) :: a
445 complex(real64),
intent(out),
dimension(:) :: tau
446 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
447 integer(int32),
intent(out),
optional :: olwork
448 class(errors),
intent(inout),
optional,
target :: err
451 integer(int32) :: m, n, mn, istat, lwork, flag
452 complex(real64),
dimension(1) :: temp
453 complex(real64),
pointer,
dimension(:) :: wptr
454 complex(real64),
allocatable,
target,
dimension(:) :: wrk
455 class(errors),
pointer :: errmgr
456 type(errors),
target :: deferr
462 if (
present(err))
then
469 if (
size(tau) /= mn)
then
471 call errmgr%report_error(
"qr_factor_no_pivot_cmplx", &
472 "Incorrectly sized input array TAU, argument 2.", &
478 call zgeqrf(m, n, a, m, tau, temp, -1, flag)
479 lwork = int(temp(1), int32)
480 if (
present(olwork))
then
486 if (
present(work))
then
487 if (
size(work) < lwork)
then
489 call errmgr%report_error(
"qr_factor_no_pivot_cmplx", &
490 "Incorrectly sized input array WORK, argument 3.", &
494 wptr => work(1:lwork)
496 allocate(wrk(lwork), stat = istat)
499 call errmgr%report_error(
"qr_factor_no_pivot_cmplx", &
500 "Insufficient memory available.", &
501 la_out_of_memory_error)
508 call zgeqrf(m, n, a, m, tau, wptr, lwork, flag)
512 module subroutine qr_factor_pivot(a, tau, jpvt, work, olwork, err)
514 real(real64),
intent(inout),
dimension(:,:) :: a
515 real(real64),
intent(out),
dimension(:) :: tau
516 integer(int32),
intent(inout),
dimension(:) :: jpvt
517 real(real64),
intent(out),
target,
dimension(:),
optional :: work
518 integer(int32),
intent(out),
optional :: olwork
519 class(errors),
intent(inout),
optional,
target :: err
522 integer(int32) :: m, n, mn, istat, lwork, flag
523 real(real64),
dimension(1) :: temp
524 real(real64),
pointer,
dimension(:) :: wptr
525 real(real64),
allocatable,
target,
dimension(:) :: wrk
526 class(errors),
pointer :: errmgr
527 type(errors),
target :: deferr
528 character(len = :),
allocatable :: errmsg
534 if (
present(err))
then
542 if (
size(tau) /= mn)
then
544 else if (
size(jpvt) /= n)
then
549 allocate(
character(len = 256) :: errmsg)
550 write(errmsg, 100)
"Input number ", flag, &
551 " is not sized correctly."
552 call errmgr%report_error(
"qr_factor_pivot", trim(errmsg), &
558 call dgeqp3(m, n, a, m, jpvt, tau, temp, -1, flag)
559 lwork = int(temp(1), int32)
560 if (
present(olwork))
then
566 if (
present(work))
then
567 if (
size(work) < lwork)
then
569 call errmgr%report_error(
"qr_factor_pivot", &
570 "Incorrectly sized input array WORK, argument 4.", &
574 wptr => work(1:lwork)
576 allocate(wrk(lwork), stat = istat)
579 call errmgr%report_error(
"qr_factor_pivot", &
580 "Insufficient memory available.", &
581 la_out_of_memory_error)
588 call dgeqp3(m, n, a, m, jpvt, tau, wptr, lwork, flag)
591 if (
allocated(wrk))
deallocate(wrk)
598 module subroutine qr_factor_pivot_cmplx(a, tau, jpvt, work, olwork, rwork, &
601 complex(real64),
intent(inout),
dimension(:,:) :: a
602 complex(real64),
intent(out),
dimension(:) :: tau
603 integer(int32),
intent(inout),
dimension(:) :: jpvt
604 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
605 integer(int32),
intent(out),
optional :: olwork
606 real(real64),
intent(out),
target,
dimension(:),
optional :: rwork
607 class(errors),
intent(inout),
optional,
target :: err
610 integer(int32) :: m, n, mn, istat, lwork, flag
611 complex(real64),
dimension(1) :: temp
612 complex(real64),
pointer,
dimension(:) :: wptr
613 complex(real64),
allocatable,
target,
dimension(:) :: wrk
614 real(real64),
pointer,
dimension(:) :: rptr
615 real(real64),
allocatable,
target,
dimension(:) :: rwrk
616 class(errors),
pointer :: errmgr
617 type(errors),
target :: deferr
618 character(len = :),
allocatable :: errmsg
624 if (
present(err))
then
632 if (
size(tau) /= mn)
then
634 else if (
size(jpvt) /= n)
then
639 allocate(
character(len = 256) :: errmsg)
640 write(errmsg, 100)
"Input number ", flag, &
641 " is not sized correctly."
642 call errmgr%report_error(
"qr_factor_pivot_cmplx", trim(errmsg), &
646 if (
present(rwork))
then
647 if (
size(rwork) < 2 * n)
then
648 call errmgr%report_error(
"qr_factor_pivot_cmplx", &
649 "Incorrectly sized input array RWORK, argument 6.", &
655 allocate(rwrk(2 * n), stat = flag)
657 call errmgr%report_error(
"qr_factor_pivot_cmplx", &
658 "Insufficient memory available.", &
659 la_out_of_memory_error)
666 call zgeqp3(m, n, a, m, jpvt, tau, temp, -1, rptr, flag)
667 lwork = int(temp(1), int32)
668 if (
present(olwork))
then
674 if (
present(work))
then
675 if (
size(work) < lwork)
then
677 call errmgr%report_error(
"qr_factor_pivot_cmplx", &
678 "Incorrectly sized input array WORK, argument 4.", &
682 wptr => work(1:lwork)
684 allocate(wrk(lwork), stat = istat)
687 call errmgr%report_error(
"qr_factor_pivot_cmplx", &
688 "Insufficient memory available.", &
689 la_out_of_memory_error)
696 call zgeqp3(m, n, a, m, jpvt, tau, wptr, lwork, rptr, flag)
699 if (
allocated(wrk))
deallocate(wrk)
706 module subroutine form_qr_no_pivot(r, tau, q, work, olwork, err)
708 real(real64),
intent(inout),
dimension(:,:) :: r
709 real(real64),
intent(in),
dimension(:) :: tau
710 real(real64),
intent(out),
dimension(:,:) :: q
711 real(real64),
intent(out),
target,
dimension(:),
optional :: work
712 integer(int32),
intent(out),
optional :: olwork
713 class(errors),
intent(inout),
optional,
target :: err
716 real(real64),
parameter :: zero = 0.0d0
719 integer(int32) :: j, m, n, mn, qcol, istat, flag, lwork
720 real(real64),
pointer,
dimension(:) :: wptr
721 real(real64),
allocatable,
target,
dimension(:) :: wrk
722 real(real64),
dimension(1) :: temp
723 class(errors),
pointer :: errmgr
724 type(errors),
target :: deferr
725 character(len = :),
allocatable :: errmsg
732 if (
present(err))
then
740 if (
size(tau) /= mn)
then
742 else if (
size(q, 1) /= m .or. (qcol /= m .and. qcol /= n))
then
744 else if (qcol == n .and. m < n)
then
749 allocate(
character(len = 256) :: errmsg)
750 write(errmsg, 100)
"Input number ", flag, &
751 " is not sized correctly."
752 call errmgr%report_error(
"form_qr_no_pivot", trim(errmsg), &
758 call dorgqr(m, qcol, mn, q, m, tau, temp, -1, flag)
759 lwork = int(temp(1), int32)
760 if (
present(olwork))
then
766 if (
present(work))
then
767 if (
size(work) < lwork)
then
769 call errmgr%report_error(
"form_qr_no_pivot", &
770 "Incorrectly sized input array WORK, argument 4.", &
774 wptr => work(1:lwork)
776 allocate(wrk(lwork), stat = istat)
779 call errmgr%report_error(
"form_qr_no_pivot", &
780 "Insufficient memory available.", &
781 la_out_of_memory_error)
790 q(j+1:m,j) = r(j+1:m,j)
795 call dorgqr(m, qcol, mn, q, m, tau, wptr, lwork, flag)
798 if (
allocated(wrk))
deallocate(wrk)
805 module subroutine form_qr_no_pivot_cmplx(r, tau, q, work, olwork, err)
807 complex(real64),
intent(inout),
dimension(:,:) :: r
808 complex(real64),
intent(in),
dimension(:) :: tau
809 complex(real64),
intent(out),
dimension(:,:) :: q
810 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
811 integer(int32),
intent(out),
optional :: olwork
812 class(errors),
intent(inout),
optional,
target :: err
815 complex(real64),
parameter :: zero = (0.0d0, 0.0d0)
818 integer(int32) :: j, m, n, mn, qcol, istat, flag, lwork
819 complex(real64),
pointer,
dimension(:) :: wptr
820 complex(real64),
allocatable,
target,
dimension(:) :: wrk
821 complex(real64),
dimension(1) :: temp
822 class(errors),
pointer :: errmgr
823 type(errors),
target :: deferr
824 character(len = :),
allocatable :: errmsg
831 if (
present(err))
then
839 if (
size(tau) /= mn)
then
841 else if (
size(q, 1) /= m .or. (qcol /= m .and. qcol /= n))
then
843 else if (qcol == n .and. m < n)
then
848 allocate(
character(len = 256) :: errmsg)
849 write(errmsg, 100)
"Input number ", flag, &
850 " is not sized correctly."
851 call errmgr%report_error(
"form_qr_no_pivot_cmplx", trim(errmsg), &
857 call zungqr(m, qcol, mn, q, m, tau, temp, -1, flag)
858 lwork = int(temp(1), int32)
859 if (
present(olwork))
then
865 if (
present(work))
then
866 if (
size(work) < lwork)
then
868 call errmgr%report_error(
"form_qr_no_pivot_cmplx", &
869 "Incorrectly sized input array WORK, argument 4.", &
873 wptr => work(1:lwork)
875 allocate(wrk(lwork), stat = istat)
878 call errmgr%report_error(
"form_qr_no_pivot_cmplx", &
879 "Insufficient memory available.", &
880 la_out_of_memory_error)
889 q(j+1:m,j) = r(j+1:m,j)
894 call zungqr(m, qcol, mn, q, m, tau, wptr, lwork, flag)
897 if (
allocated(wrk))
deallocate(wrk)
904 module subroutine form_qr_pivot(r, tau, pvt, q, p, work, olwork, err)
906 real(real64),
intent(inout),
dimension(:,:) :: r
907 real(real64),
intent(in),
dimension(:) :: tau
908 integer(int32),
intent(in),
dimension(:) :: pvt
909 real(real64),
intent(out),
dimension(:,:) :: q, p
910 real(real64),
intent(out),
target,
dimension(:),
optional :: work
911 integer(int32),
intent(out),
optional :: olwork
912 class(errors),
intent(inout),
optional,
target :: err
915 real(real64),
parameter :: zero = 0.0d0
916 real(real64),
parameter :: one = 1.0d0
919 integer(int32) :: j, jp, m, n, mn, flag
920 class(errors),
pointer :: errmgr
921 type(errors),
target :: deferr
922 character(len = :),
allocatable :: errmsg
928 if (
present(err))
then
936 if (
size(tau) /= mn)
then
938 else if (
size(pvt) /= n)
then
940 else if (
size(q, 1) /= m .or. &
941 (
size(q, 2) /= m .and.
size(q, 2) /= n))
then
943 else if (
size(q, 2) == n .and. m < n)
then
945 else if (
size(p, 1) /= n .or.
size(p, 2) /= n)
then
950 allocate(
character(len = 256) :: errmsg)
951 write(errmsg, 100)
"Input number ", flag, &
952 " is not sized correctly."
953 call errmgr%report_error(
"form_qr_pivot", trim(errmsg), &
959 call form_qr_no_pivot(r, tau, q, work = work, olwork = olwork, &
961 if (
present(olwork))
return
962 if (errmgr%has_error_occurred())
return
976 module subroutine form_qr_pivot_cmplx(r, tau, pvt, q, p, work, olwork, err)
978 complex(real64),
intent(inout),
dimension(:,:) :: r
979 complex(real64),
intent(in),
dimension(:) :: tau
980 integer(int32),
intent(in),
dimension(:) :: pvt
981 complex(real64),
intent(out),
dimension(:,:) :: q, p
982 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
983 integer(int32),
intent(out),
optional :: olwork
984 class(errors),
intent(inout),
optional,
target :: err
987 complex(real64),
parameter :: zero = (0.0d0, 0.0d0)
988 complex(real64),
parameter :: one = (1.0d0, 0.0d0)
991 integer(int32) :: j, jp, m, n, mn, flag
992 class(errors),
pointer :: errmgr
993 type(errors),
target :: deferr
994 character(len = :),
allocatable :: errmsg
1000 if (
present(err))
then
1008 if (
size(tau) /= mn)
then
1010 else if (
size(pvt) /= n)
then
1012 else if (
size(q, 1) /= m .or. &
1013 (
size(q, 2) /= m .and.
size(q, 2) /= n))
then
1015 else if (
size(q, 2) == n .and. m < n)
then
1017 else if (
size(p, 1) /= n .or.
size(p, 2) /= n)
then
1022 allocate(
character(len = 256) :: errmsg)
1023 write(errmsg, 100)
"Input number ", flag, &
1024 " is not sized correctly."
1025 call errmgr%report_error(
"form_qr_pivot_cmplx", trim(errmsg), &
1026 la_array_size_error)
1031 call form_qr_no_pivot_cmplx(r, tau, q, work = work, olwork = olwork, &
1033 if (
present(olwork))
return
1034 if (errmgr%has_error_occurred())
return
1048 module subroutine mult_qr_mtx(lside, trans, a, tau, c, work, olwork, err)
1050 logical,
intent(in) :: lside, trans
1051 real(real64),
intent(in),
dimension(:) :: tau
1052 real(real64),
intent(inout),
dimension(:,:) :: a, c
1053 real(real64),
intent(out),
target,
dimension(:),
optional :: work
1054 integer(int32),
intent(out),
optional :: olwork
1055 class(errors),
intent(inout),
optional,
target :: err
1058 real(real64),
parameter :: one = 1.0d0
1061 character :: side, t
1062 integer(int32) :: m, n, k, nrowa, istat, flag, lwork
1063 real(real64),
pointer,
dimension(:) :: wptr
1064 real(real64),
allocatable,
target,
dimension(:) :: wrk
1065 real(real64),
dimension(1) :: temp
1066 class(errors),
pointer :: errmgr
1067 type(errors),
target :: deferr
1068 character(len = :),
allocatable :: errmsg
1086 if (
present(err))
then
1096 if (
size(a, 1) /= m .or.
size(a, 2) < k) flag = 3
1099 if (
size(a, 1) /= n .or.
size(a, 2) < k) flag = 3
1103 allocate(
character(len = 256) :: errmsg)
1104 write(errmsg, 100)
"Input number ", flag, &
1105 " is not sized correctly."
1106 call errmgr%report_error(
"mult_qr_mtx", trim(errmsg), &
1107 la_array_size_error)
1112 call dormqr(side, t, m, n, k, a, nrowa, tau, c, m, temp, -1, flag)
1113 lwork = int(temp(1), int32)
1114 if (
present(olwork))
then
1120 if (
present(work))
then
1121 if (
size(work) < lwork)
then
1123 call errmgr%report_error(
"mult_qr_mtx", &
1124 "Incorrectly sized input array WORK, argument 6.", &
1125 la_array_size_error)
1128 wptr => work(1:lwork)
1130 allocate(wrk(lwork), stat = istat)
1131 if (istat /= 0)
then
1133 call errmgr%report_error(
"mult_qr_mtx", &
1134 "Insufficient memory available.", &
1135 la_out_of_memory_error)
1142 call dormqr(side, t, m, n, k, a, nrowa, tau, c, m, wptr, lwork, flag)
1149 module subroutine mult_qr_mtx_cmplx(lside, trans, a, tau, c, work, olwork, err)
1151 logical,
intent(in) :: lside, trans
1152 complex(real64),
intent(in),
dimension(:) :: tau
1153 complex(real64),
intent(inout),
dimension(:,:) :: a, c
1154 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
1155 integer(int32),
intent(out),
optional :: olwork
1156 class(errors),
intent(inout),
optional,
target :: err
1159 complex(real64),
parameter :: one = (1.0d0, 0.0d0)
1162 character :: side, t
1163 integer(int32) :: m, n, k, nrowa, istat, flag, lwork
1164 complex(real64),
pointer,
dimension(:) :: wptr
1165 complex(real64),
allocatable,
target,
dimension(:) :: wrk
1166 complex(real64),
dimension(1) :: temp
1167 class(errors),
pointer :: errmgr
1168 type(errors),
target :: deferr
1169 character(len = :),
allocatable :: errmsg
1187 if (
present(err))
then
1197 if (
size(a, 1) /= m .or.
size(a, 2) < k) flag = 3
1200 if (
size(a, 1) /= n .or.
size(a, 2) < k) flag = 3
1204 allocate(
character(len = 256) :: errmsg)
1205 write(errmsg, 100)
"Input number ", flag, &
1206 " is not sized correctly."
1207 call errmgr%report_error(
"mult_qr_mtx_cmplx", trim(errmsg), &
1208 la_array_size_error)
1213 call zunmqr(side, t, m, n, k, a, nrowa, tau, c, m, temp, -1, flag)
1214 lwork = int(temp(1), int32)
1215 if (
present(olwork))
then
1221 if (
present(work))
then
1222 if (
size(work) < lwork)
then
1224 call errmgr%report_error(
"mult_qr_mtx_cmplx", &
1225 "Incorrectly sized input array WORK, argument 6.", &
1226 la_array_size_error)
1229 wptr => work(1:lwork)
1231 allocate(wrk(lwork), stat = istat)
1232 if (istat /= 0)
then
1234 call errmgr%report_error(
"mult_qr_mtx_cmplx", &
1235 "Insufficient memory available.", &
1236 la_out_of_memory_error)
1243 call zunmqr(side, t, m, n, k, a, nrowa, tau, c, m, wptr, lwork, flag)
1250 module subroutine mult_qr_vec(trans, a, tau, c, work, olwork, err)
1252 logical,
intent(in) :: trans
1253 real(real64),
intent(inout),
dimension(:,:) :: a
1254 real(real64),
intent(in),
dimension(:) :: tau
1255 real(real64),
intent(inout),
dimension(:) :: c
1256 real(real64),
intent(out),
target,
dimension(:),
optional :: work
1257 integer(int32),
intent(out),
optional :: olwork
1258 class(errors),
intent(inout),
optional,
target :: err
1261 real(real64),
parameter :: one = 1.0d0
1264 character :: side, t
1265 integer(int32) :: m, k, nrowa, istat, flag, lwork
1266 real(real64),
pointer,
dimension(:) :: wptr
1267 real(real64),
allocatable,
target,
dimension(:) :: wrk
1268 real(real64),
dimension(1) :: temp
1269 class(errors),
pointer :: errmgr
1270 type(errors),
target :: deferr
1271 character(len = :),
allocatable :: errmsg
1283 if (
present(err))
then
1291 if (
size(a, 1) /= m .or.
size(a, 2) < k) flag = 3
1294 allocate(
character(len = 256) :: errmsg)
1295 write(errmsg, 100)
"Input number ", flag, &
1296 " is not sized correctly."
1297 call errmgr%report_error(
"mult_qr_vec", trim(errmsg), &
1298 la_array_size_error)
1303 call dormqr(side, t, m, 1, k, a, nrowa, tau, c, m, temp, -1, flag)
1304 lwork = int(temp(1), int32)
1305 if (
present(olwork))
then
1311 if (
present(work))
then
1312 if (
size(work) < lwork)
then
1314 call errmgr%report_error(
"mult_qr_vec", &
1315 "Incorrectly sized input array WORK, argument 6.", &
1316 la_array_size_error)
1319 wptr => work(1:lwork)
1321 allocate(wrk(lwork), stat = istat)
1322 if (istat /= 0)
then
1324 call errmgr%report_error(
"mult_qr_vec", &
1325 "Insufficient memory available.", &
1326 la_out_of_memory_error)
1333 call dormqr(side, t, m, 1, k, a, nrowa, tau, c, m, wptr, lwork, flag)
1340 module subroutine mult_qr_vec_cmplx(trans, a, tau, c, work, olwork, err)
1342 logical,
intent(in) :: trans
1343 complex(real64),
intent(inout),
dimension(:,:) :: a
1344 complex(real64),
intent(in),
dimension(:) :: tau
1345 complex(real64),
intent(inout),
dimension(:) :: c
1346 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
1347 integer(int32),
intent(out),
optional :: olwork
1348 class(errors),
intent(inout),
optional,
target :: err
1351 complex(real64),
parameter :: one = (1.0d0, 0.0d0)
1354 character :: side, t
1355 integer(int32) :: m, k, nrowa, istat, flag, lwork
1356 complex(real64),
pointer,
dimension(:) :: wptr
1357 complex(real64),
allocatable,
target,
dimension(:) :: wrk
1358 complex(real64),
dimension(1) :: temp
1359 class(errors),
pointer :: errmgr
1360 type(errors),
target :: deferr
1361 character(len = :),
allocatable :: errmsg
1373 if (
present(err))
then
1381 if (
size(a, 1) /= m .or.
size(a, 2) < k) flag = 3
1384 allocate(
character(len = 256) :: errmsg)
1385 write(errmsg, 100)
"Input number ", flag, &
1386 " is not sized correctly."
1387 call errmgr%report_error(
"mult_qr_vec", trim(errmsg), &
1388 la_array_size_error)
1393 call zunmqr(side, t, m, 1, k, a, nrowa, tau, c, m, temp, -1, flag)
1394 lwork = int(temp(1), int32)
1395 if (
present(olwork))
then
1401 if (
present(work))
then
1402 if (
size(work) < lwork)
then
1404 call errmgr%report_error(
"mult_qr_vec", &
1405 "Incorrectly sized input array WORK, argument 6.", &
1406 la_array_size_error)
1409 wptr => work(1:lwork)
1411 allocate(wrk(lwork), stat = istat)
1412 if (istat /= 0)
then
1414 call errmgr%report_error(
"mult_qr_vec", &
1415 "Insufficient memory available.", &
1416 la_out_of_memory_error)
1423 call zunmqr(side, t, m, 1, k, a, nrowa, tau, c, m, wptr, lwork, flag)
1430 module subroutine qr_rank1_update_dbl(q, r, u, v, work, err)
1432 real(real64),
intent(inout),
dimension(:,:) :: q, r
1433 real(real64),
intent(inout),
dimension(:) :: u, v
1434 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
1435 class(errors),
intent(inout),
optional,
target :: err
1439 integer(int32) :: m, n, k, lwork, istat, flag
1440 real(real64),
pointer,
dimension(:) :: wptr
1441 real(real64),
allocatable,
target,
dimension(:) :: wrk
1442 class(errors),
pointer :: errmgr
1443 type(errors),
target :: deferr
1444 character(len = :),
allocatable :: errmsg
1450 full =
size(q, 2) == m
1452 if (
present(err))
then
1462 else if (.not.full .and.
size(q, 2) /= k)
then
1464 else if (
size(r, 1) /= m)
then
1466 else if (
size(u) /= m)
then
1468 else if (
size(v) /= n)
then
1473 allocate(
character(len = 256) :: errmsg)
1474 write(errmsg, 100)
"Input number ", flag, &
1475 " is not sized correctly."
1476 call errmgr%report_error(
"qr_rank1_update", trim(errmsg), &
1477 la_array_size_error)
1482 if (
present(work))
then
1483 if (
size(work) < lwork)
then
1485 call errmgr%report_error(
"qr_rank1_update", &
1486 "Incorrectly sized input array WORK, argument 5.", &
1487 la_array_size_error)
1490 wptr => work(1:lwork)
1492 allocate(wrk(lwork), stat = istat)
1493 if (istat /= 0)
then
1495 call errmgr%report_error(
"qr_rank1_update", &
1496 "Insufficient memory available.", &
1497 la_out_of_memory_error)
1504 call dqr1up(m, n, k, q, m, r, m, u, v, wptr)
1511 module subroutine qr_rank1_update_cmplx(q, r, u, v, work, rwork, err)
1513 complex(real64),
intent(inout),
dimension(:,:) :: q, r
1514 complex(real64),
intent(inout),
dimension(:) :: u, v
1515 complex(real64),
intent(out),
target,
optional,
dimension(:) :: work
1516 real(real64),
intent(out),
target,
optional,
dimension(:) :: rwork
1517 class(errors),
intent(inout),
optional,
target :: err
1521 integer(int32) :: m, n, k, lwork, istat, flag, lrwork
1522 complex(real64),
pointer,
dimension(:) :: wptr
1523 complex(real64),
allocatable,
target,
dimension(:) :: wrk
1524 real(real64),
pointer,
dimension(:) :: rwptr
1525 real(real64),
allocatable,
target,
dimension(:) :: rwrk
1526 class(errors),
pointer :: errmgr
1527 type(errors),
target :: deferr
1528 character(len = :),
allocatable :: errmsg
1534 full =
size(q, 2) == m
1537 if (
present(err))
then
1547 else if (.not.full .and.
size(q, 2) /= k)
then
1549 else if (
size(r, 1) /= m)
then
1551 else if (
size(u) /= m)
then
1553 else if (
size(v) /= n)
then
1558 allocate(
character(len = 256) :: errmsg)
1559 write(errmsg, 100)
"Input number ", flag, &
1560 " is not sized correctly."
1561 call errmgr%report_error(
"qr_rank1_update_cmplx", trim(errmsg), &
1562 la_array_size_error)
1567 if (
present(work))
then
1568 if (
size(work) < lwork)
then
1570 call errmgr%report_error(
"qr_rank1_update_cmplx", &
1571 "Incorrectly sized input array WORK, argument 5.", &
1572 la_array_size_error)
1575 wptr => work(1:lwork)
1577 allocate(wrk(lwork), stat = istat)
1578 if (istat /= 0)
then
1580 call errmgr%report_error(
"qr_rank1_update_cmplx", &
1581 "Insufficient memory available.", &
1582 la_out_of_memory_error)
1588 if (
present(rwork))
then
1589 if (
size(rwork) < lrwork)
then
1591 call errmgr%report_error(
"qr_rank1_update_cmplx", &
1592 "Incorrectly sized input array RWORK, argument 6.", &
1593 la_array_size_error)
1596 wptr => work(1:lrwork)
1598 allocate(rwrk(lrwork), stat = istat)
1599 if (istat /= 0)
then
1601 call errmgr%report_error(
"qr_rank1_update_cmplx", &
1602 "Insufficient memory available.", &
1603 la_out_of_memory_error)
1610 call zqr1up(m, n, k, q, m, r, m, u, v, wptr, rwptr)
1619 module subroutine cholesky_factor_dbl(a, upper, err)
1621 real(real64),
intent(inout),
dimension(:,:) :: a
1622 logical,
intent(in),
optional :: upper
1623 class(errors),
intent(inout),
optional,
target :: err
1626 real(real64),
parameter :: zero = 0.0d0
1630 integer(int32) :: i, n, flag
1631 class(errors),
pointer :: errmgr
1632 type(errors),
target :: deferr
1633 character(len = :),
allocatable :: errmsg
1637 if (
present(upper))
then
1646 if (
present(err))
then
1653 if (
size(a, 2) /= n)
then
1655 call errmgr%report_error(
"cholesky_factor", &
1656 "The input matrix must be square.", la_array_size_error)
1661 call dpotrf(uplo, n, a, n, flag)
1664 allocate(
character(len = 256) :: errmsg)
1665 write(errmsg, 100)
"The leading minor of order ", flag, &
1666 " is not positive definite."
1667 call errmgr%report_error(
"cholesky_factor", trim(errmsg), &
1668 la_matrix_format_error)
1672 if (uplo ==
'U')
then
1689 module subroutine cholesky_factor_cmplx(a, upper, err)
1691 complex(real64),
intent(inout),
dimension(:,:) :: a
1692 logical,
intent(in),
optional :: upper
1693 class(errors),
intent(inout),
optional,
target :: err
1696 complex(real64),
parameter :: zero = (0.0d0, 0.0d0)
1700 integer(int32) :: i, n, flag
1701 class(errors),
pointer :: errmgr
1702 type(errors),
target :: deferr
1703 character(len = :),
allocatable :: errmsg
1707 if (
present(upper))
then
1716 if (
present(err))
then
1723 if (
size(a, 2) /= n)
then
1725 call errmgr%report_error(
"cholesky_factor_cmplx", &
1726 "The input matrix must be square.", la_array_size_error)
1731 call zpotrf(uplo, n, a, n, flag)
1734 allocate(
character(len = 256) :: errmsg)
1735 write(errmsg, 100)
"The leading minor of order ", flag, &
1736 " is not positive definite."
1737 call errmgr%report_error(
"cholesky_factor_cmplx", trim(errmsg), &
1738 la_matrix_format_error)
1742 if (uplo ==
'U')
then
1759 module subroutine cholesky_rank1_update_dbl(r, u, work, err)
1761 real(real64),
intent(inout),
dimension(:,:) :: r
1762 real(real64),
intent(inout),
dimension(:) :: u
1763 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
1764 class(errors),
intent(inout),
optional,
target :: err
1767 integer(int32) :: n, lwork, istat, flag
1768 real(real64),
pointer,
dimension(:) :: wptr
1769 real(real64),
allocatable,
target,
dimension(:) :: wrk
1770 class(errors),
pointer :: errmgr
1771 type(errors),
target :: deferr
1772 character(len = :),
allocatable :: errmsg
1777 if (
present(err))
then
1785 if (
size(r, 2) /= n)
then
1787 else if (
size(u) /= n)
then
1791 allocate(
character(len = 256) :: errmsg)
1792 write(errmsg, 100)
"Input number ", flag, &
1793 " is not sized correctly."
1794 call errmgr%report_error(
"cholesky_rank1_update", trim(errmsg), &
1795 la_array_size_error)
1800 if (
present(work))
then
1801 if (
size(work) < lwork)
then
1803 call errmgr%report_error(
"cholesky_rank1_update", &
1804 "The workspace array is too short.", &
1805 la_array_size_error)
1808 wptr => work(1:lwork)
1810 allocate(wrk(lwork), stat = istat)
1811 if (istat /= 0)
then
1812 call errmgr%report_error(
"cholesky_rank1_update", &
1813 "Insufficient memory available.", &
1814 la_out_of_memory_error)
1821 call dch1up(n, r, n, u, wptr)
1828 module subroutine cholesky_rank1_update_cmplx(r, u, work, err)
1830 complex(real64),
intent(inout),
dimension(:,:) :: r
1831 complex(real64),
intent(inout),
dimension(:) :: u
1832 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
1833 class(errors),
intent(inout),
optional,
target :: err
1836 integer(int32) :: n, lwork, istat, flag
1837 real(real64),
pointer,
dimension(:) :: wptr
1838 real(real64),
allocatable,
target,
dimension(:) :: wrk
1839 class(errors),
pointer :: errmgr
1840 type(errors),
target :: deferr
1841 character(len = :),
allocatable :: errmsg
1846 if (
present(err))
then
1854 if (
size(r, 2) /= n)
then
1856 else if (
size(u) /= n)
then
1860 allocate(
character(len = 256) :: errmsg)
1861 write(errmsg, 100)
"Input number ", flag, &
1862 " is not sized correctly."
1863 call errmgr%report_error(
"cholesky_rank1_update_cmplx", &
1865 la_array_size_error)
1870 if (
present(work))
then
1871 if (
size(work) < lwork)
then
1873 call errmgr%report_error(
"cholesky_rank1_update_cmplx", &
1874 "The workspace array is too short.", &
1875 la_array_size_error)
1878 wptr => work(1:lwork)
1880 allocate(wrk(lwork), stat = istat)
1881 if (istat /= 0)
then
1882 call errmgr%report_error(
"cholesky_rank1_update", &
1883 "Insufficient memory available.", &
1884 la_out_of_memory_error)
1891 call zch1up(n, r, n, u, wptr)
1898 module subroutine cholesky_rank1_downdate_dbl(r, u, work, err)
1900 real(real64),
intent(inout),
dimension(:,:) :: r
1901 real(real64),
intent(inout),
dimension(:) :: u
1902 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
1903 class(errors),
intent(inout),
optional,
target :: err
1906 integer(int32) :: n, lwork, istat, flag
1907 real(real64),
pointer,
dimension(:) :: wptr
1908 real(real64),
allocatable,
target,
dimension(:) :: wrk
1909 class(errors),
pointer :: errmgr
1910 type(errors),
target :: deferr
1911 character(len = :),
allocatable :: errmsg
1916 if (
present(err))
then
1924 if (
size(r, 2) /= n)
then
1926 else if (
size(u) /= n)
then
1930 allocate(
character(len = 256) :: errmsg)
1931 write(errmsg, 100)
"Input number ", flag, &
1932 " is not sized correctly."
1933 call errmgr%report_error(
"cholesky_rank1_downdate", trim(errmsg), &
1934 la_array_size_error)
1939 if (
present(work))
then
1940 if (
size(work) < lwork)
then
1942 call errmgr%report_error(
"cholesky_rank1_downdate", &
1943 "The workspace array is too short.", &
1944 la_array_size_error)
1947 wptr => work(1:lwork)
1949 allocate(wrk(lwork), stat = istat)
1950 if (istat /= 0)
then
1951 call errmgr%report_error(
"cholesky_rank1_downdate", &
1952 "Insufficient memory available.", &
1953 la_out_of_memory_error)
1960 call dch1dn(n, r, n, u, wptr, flag)
1963 call errmgr%report_error(
"cholesky_rank1_downdate", &
1964 "The downdated matrix is not positive definite.", &
1965 la_matrix_format_error)
1966 else if (flag == 2)
then
1968 call errmgr%report_error(
"cholesky_rank1_downdate", &
1969 "The input matrix is singular.", la_singular_matrix_error)
1977 module subroutine cholesky_rank1_downdate_cmplx(r, u, work, err)
1979 complex(real64),
intent(inout),
dimension(:,:) :: r
1980 complex(real64),
intent(inout),
dimension(:) :: u
1981 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
1982 class(errors),
intent(inout),
optional,
target :: err
1985 integer(int32) :: n, lwork, istat, flag
1986 real(real64),
pointer,
dimension(:) :: wptr
1987 real(real64),
allocatable,
target,
dimension(:) :: wrk
1988 class(errors),
pointer :: errmgr
1989 type(errors),
target :: deferr
1990 character(len = :),
allocatable :: errmsg
1995 if (
present(err))
then
2003 if (
size(r, 2) /= n)
then
2005 else if (
size(u) /= n)
then
2009 allocate(
character(len = 256) :: errmsg)
2010 write(errmsg, 100)
"Input number ", flag, &
2011 " is not sized correctly."
2012 call errmgr%report_error(
"cholesky_rank1_downdate_cmplx", &
2014 la_array_size_error)
2019 if (
present(work))
then
2020 if (
size(work) < lwork)
then
2022 call errmgr%report_error(
"cholesky_rank1_downdate_cmplx", &
2023 "The workspace array is too short.", &
2024 la_array_size_error)
2027 wptr => work(1:lwork)
2029 allocate(wrk(lwork), stat = istat)
2030 if (istat /= 0)
then
2031 call errmgr%report_error(
"cholesky_rank1_downdate_cmplx", &
2032 "Insufficient memory available.", &
2033 la_out_of_memory_error)
2040 call zch1dn(n, r, n, u, wptr, flag)
2043 call errmgr%report_error(
"cholesky_rank1_downdate_cmplx", &
2044 "The downdated matrix is not positive definite.", &
2045 la_matrix_format_error)
2046 else if (flag == 2)
then
2048 call errmgr%report_error(
"cholesky_rank1_downdate_cmplx", &
2049 "The input matrix is singular.", la_singular_matrix_error)
2059 module subroutine rz_factor_dbl(a, tau, work, olwork, err)
2061 real(real64),
intent(inout),
dimension(:,:) :: a
2062 real(real64),
intent(out),
dimension(:) :: tau
2063 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
2064 integer(int32),
intent(out),
optional :: olwork
2065 class(errors),
intent(inout),
optional,
target :: err
2068 integer(int32) :: m, n, lwork, flag, istat
2069 real(real64),
pointer,
dimension(:) :: wptr
2070 real(real64),
allocatable,
target,
dimension(:) :: wrk
2071 real(real64),
dimension(1) :: temp
2072 class(errors),
pointer :: errmgr
2073 type(errors),
target :: deferr
2074 character(len = :),
allocatable :: errmsg
2079 if (
present(err))
then
2087 if (
size(tau) /= m)
then
2092 allocate(
character(len = 256) :: errmsg)
2093 write(errmsg, 100)
"Input number ", flag, &
2094 " is not sized correctly."
2095 call errmgr%report_error(
"rz_factor", trim(errmsg), &
2096 la_array_size_error)
2101 call dtzrzf(m, n, a, m, tau, temp, -1, flag)
2102 lwork = int(temp(1), int32)
2103 if (
present(olwork))
then
2109 if (
present(work))
then
2110 if (
size(work) < lwork)
then
2112 call errmgr%report_error(
"rz_factor", &
2113 "Incorrectly sized input array WORK, argument 3.", &
2114 la_array_size_error)
2117 wptr => work(1:lwork)
2119 allocate(wrk(lwork), stat = istat)
2120 if (istat /= 0)
then
2122 call errmgr%report_error(
"rz_factor", &
2123 "Insufficient memory available.", &
2124 la_out_of_memory_error)
2131 call dtzrzf(m, n, a, m, tau, wptr, lwork, flag)
2138 module subroutine rz_factor_cmplx(a, tau, work, olwork, err)
2140 complex(real64),
intent(inout),
dimension(:,:) :: a
2141 complex(real64),
intent(out),
dimension(:) :: tau
2142 complex(real64),
intent(out),
target,
optional,
dimension(:) :: work
2143 integer(int32),
intent(out),
optional :: olwork
2144 class(errors),
intent(inout),
optional,
target :: err
2147 integer(int32) :: m, n, lwork, flag, istat
2148 complex(real64),
pointer,
dimension(:) :: wptr
2149 complex(real64),
allocatable,
target,
dimension(:) :: wrk
2150 complex(real64),
dimension(1) :: temp
2151 class(errors),
pointer :: errmgr
2152 type(errors),
target :: deferr
2153 character(len = :),
allocatable :: errmsg
2158 if (
present(err))
then
2166 if (
size(tau) /= m)
then
2171 allocate(
character(len = 256) :: errmsg)
2172 write(errmsg, 100)
"Input number ", flag, &
2173 " is not sized correctly."
2174 call errmgr%report_error(
"rz_factor_cmplx", trim(errmsg), &
2175 la_array_size_error)
2180 call ztzrzf(m, n, a, m, tau, temp, -1, flag)
2181 lwork = int(temp(1), int32)
2182 if (
present(olwork))
then
2188 if (
present(work))
then
2189 if (
size(work) < lwork)
then
2191 call errmgr%report_error(
"rz_factor_cmplx", &
2192 "Incorrectly sized input array WORK, argument 3.", &
2193 la_array_size_error)
2196 wptr => work(1:lwork)
2198 allocate(wrk(lwork), stat = istat)
2199 if (istat /= 0)
then
2201 call errmgr%report_error(
"rz_factor_cmplx", &
2202 "Insufficient memory available.", &
2203 la_out_of_memory_error)
2210 call ztzrzf(m, n, a, m, tau, wptr, lwork, flag)
2217 module subroutine mult_rz_mtx(lside, trans, l, a, tau, c, work, olwork, err)
2219 logical,
intent(in) :: lside, trans
2220 integer(int32),
intent(in) :: l
2221 real(real64),
intent(inout),
dimension(:,:) :: a, c
2222 real(real64),
intent(in),
dimension(:) :: tau
2223 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
2224 integer(int32),
intent(out),
optional :: olwork
2225 class(errors),
intent(inout),
optional,
target :: err
2228 character :: side, t
2229 integer(int32) :: m, n, k, lwork, flag, istat, lda
2230 real(real64),
pointer,
dimension(:) :: wptr
2231 real(real64),
allocatable,
target,
dimension(:) :: wrk
2232 real(real64),
dimension(1) :: temp
2233 class(errors),
pointer :: errmgr
2234 type(errors),
target :: deferr
2235 character(len = :),
allocatable :: errmsg
2252 if (
present(err))
then
2261 if (l > m .or. l < 0)
then
2263 else if (k > m)
then
2265 else if (
size(a, 1) < k .or.
size(a, 2) /= m)
then
2269 if (l > n .or. l < 0)
then
2271 else if (k > n)
then
2273 else if (
size(a, 1) < k .or.
size(a, 2) /= n)
then
2279 allocate(
character(len = 256) :: errmsg)
2280 write(errmsg, 100)
"Input number ", flag, &
2281 " is not sized correctly."
2282 call errmgr%report_error(
"mult_rz_mtx", trim(errmsg), &
2283 la_array_size_error)
2288 call dormrz(side, t, m, n, k, l, a, lda, tau, c, m, temp, -1, flag)
2289 lwork = int(temp(1), int32)
2290 if (
present(olwork))
then
2296 if (
present(work))
then
2297 if (
size(work) < lwork)
then
2299 call errmgr%report_error(
"mult_rz_mtx", &
2300 "Incorrectly sized input array WORK, argument 7.", &
2301 la_array_size_error)
2304 wptr => work(1:lwork)
2306 allocate(wrk(lwork), stat = istat)
2307 if (istat /= 0)
then
2309 call errmgr%report_error(
"mult_rz_mtx", &
2310 "Insufficient memory available.", &
2311 la_out_of_memory_error)
2318 call dormrz(side, t, m, n, k, l, a, lda, tau, c, m, wptr, lwork, flag)
2325 module subroutine mult_rz_mtx_cmplx(lside, trans, l, a, tau, c, work, olwork, err)
2327 logical,
intent(in) :: lside, trans
2328 integer(int32),
intent(in) :: l
2329 complex(real64),
intent(inout),
dimension(:,:) :: a, c
2330 complex(real64),
intent(in),
dimension(:) :: tau
2331 complex(real64),
intent(out),
target,
optional,
dimension(:) :: work
2332 integer(int32),
intent(out),
optional :: olwork
2333 class(errors),
intent(inout),
optional,
target :: err
2336 character :: side, t
2337 integer(int32) :: m, n, k, lwork, flag, istat, lda
2338 complex(real64),
pointer,
dimension(:) :: wptr
2339 complex(real64),
allocatable,
target,
dimension(:) :: wrk
2340 complex(real64),
dimension(1) :: temp
2341 class(errors),
pointer :: errmgr
2342 type(errors),
target :: deferr
2343 character(len = :),
allocatable :: errmsg
2360 if (
present(err))
then
2369 if (l > m .or. l < 0)
then
2371 else if (k > m)
then
2373 else if (
size(a, 1) < k .or.
size(a, 2) /= m)
then
2377 if (l > n .or. l < 0)
then
2379 else if (k > n)
then
2381 else if (
size(a, 1) < k .or.
size(a, 2) /= n)
then
2387 allocate(
character(len = 256) :: errmsg)
2388 write(errmsg, 100)
"Input number ", flag, &
2389 " is not sized correctly."
2390 call errmgr%report_error(
"mult_rz_mtx_cmplx", trim(errmsg), &
2391 la_array_size_error)
2396 call zunmrz(side, t, m, n, k, l, a, lda, tau, c, m, temp, -1, flag)
2397 lwork = int(temp(1), int32)
2398 if (
present(olwork))
then
2404 if (
present(work))
then
2405 if (
size(work) < lwork)
then
2407 call errmgr%report_error(
"mult_rz_mtx_cmplx", &
2408 "Incorrectly sized input array WORK, argument 7.", &
2409 la_array_size_error)
2412 wptr => work(1:lwork)
2414 allocate(wrk(lwork), stat = istat)
2415 if (istat /= 0)
then
2417 call errmgr%report_error(
"mult_rz_mtx_cmplx", &
2418 "Insufficient memory available.", &
2419 la_out_of_memory_error)
2426 call zunmrz(side, t, m, n, k, l, a, lda, tau, c, m, wptr, lwork, flag)
2433 module subroutine mult_rz_vec(trans, l, a, tau, c, work, olwork, err)
2435 logical,
intent(in) :: trans
2436 integer(int32),
intent(in) :: l
2437 real(real64),
intent(inout),
dimension(:,:) :: a
2438 real(real64),
intent(in),
dimension(:) :: tau
2439 real(real64),
intent(inout),
dimension(:) :: c
2440 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
2441 integer(int32),
intent(out),
optional :: olwork
2442 class(errors),
intent(inout),
optional,
target :: err
2445 character :: side, t
2446 integer(int32) :: m, k, lwork, flag, istat, lda
2447 real(real64),
pointer,
dimension(:) :: wptr
2448 real(real64),
allocatable,
target,
dimension(:) :: wrk
2449 real(real64),
dimension(1) :: temp
2450 class(errors),
pointer :: errmgr
2451 type(errors),
target :: deferr
2452 character(len = :),
allocatable :: errmsg
2464 if (
present(err))
then
2472 if (l > m .or. l < 0)
then
2474 else if (k > m)
then
2476 else if (
size(a, 1) < k .or.
size(a, 2) /= m)
then
2481 allocate(
character(len = 256) :: errmsg)
2482 write(errmsg, 100)
"Input number ", flag, &
2483 " is not sized correctly."
2484 call errmgr%report_error(
"mult_rz_vec", trim(errmsg), &
2485 la_array_size_error)
2490 call dormrz(side, t, m, 1, k, l, a, lda, tau, c, m, temp, -1, flag)
2491 lwork = int(temp(1), int32)
2492 if (
present(olwork))
then
2498 if (
present(work))
then
2499 if (
size(work) < lwork)
then
2501 call errmgr%report_error(
"mult_rz_vec", &
2502 "Incorrectly sized input array WORK, argument 6.", &
2503 la_array_size_error)
2506 wptr => work(1:lwork)
2508 allocate(wrk(lwork), stat = istat)
2509 if (istat /= 0)
then
2511 call errmgr%report_error(
"mult_rz_vec", &
2512 "Insufficient memory available.", &
2513 la_out_of_memory_error)
2520 call dormrz(side, t, m, 1, k, l, a, lda, tau, c, m, wptr, lwork, flag)
2527 module subroutine mult_rz_vec_cmplx(trans, l, a, tau, c, work, olwork, err)
2529 logical,
intent(in) :: trans
2530 integer(int32),
intent(in) :: l
2531 complex(real64),
intent(inout),
dimension(:,:) :: a
2532 complex(real64),
intent(in),
dimension(:) :: tau
2533 complex(real64),
intent(inout),
dimension(:) :: c
2534 complex(real64),
intent(out),
target,
optional,
dimension(:) :: work
2535 integer(int32),
intent(out),
optional :: olwork
2536 class(errors),
intent(inout),
optional,
target :: err
2539 character :: side, t
2540 integer(int32) :: m, k, lwork, flag, istat, lda
2541 complex(real64),
pointer,
dimension(:) :: wptr
2542 complex(real64),
allocatable,
target,
dimension(:) :: wrk
2543 complex(real64),
dimension(1) :: temp
2544 class(errors),
pointer :: errmgr
2545 type(errors),
target :: deferr
2546 character(len = :),
allocatable :: errmsg
2558 if (
present(err))
then
2566 if (l > m .or. l < 0)
then
2568 else if (k > m)
then
2570 else if (
size(a, 1) < k .or.
size(a, 2) /= m)
then
2575 allocate(
character(len = 256) :: errmsg)
2576 write(errmsg, 100)
"Input number ", flag, &
2577 " is not sized correctly."
2578 call errmgr%report_error(
"mult_rz_vec_cmplx", trim(errmsg), &
2579 la_array_size_error)
2584 call zunmrz(side, t, m, 1, k, l, a, lda, tau, c, m, temp, -1, flag)
2585 lwork = int(temp(1), int32)
2586 if (
present(olwork))
then
2592 if (
present(work))
then
2593 if (
size(work) < lwork)
then
2595 call errmgr%report_error(
"mult_rz_vec_cmplx", &
2596 "Incorrectly sized input array WORK, argument 6.", &
2597 la_array_size_error)
2600 wptr => work(1:lwork)
2602 allocate(wrk(lwork), stat = istat)
2603 if (istat /= 0)
then
2605 call errmgr%report_error(
"mult_rz_vec_cmplx", &
2606 "Insufficient memory available.", &
2607 la_out_of_memory_error)
2614 call zunmrz(side, t, m, 1, k, l, a, lda, tau, c, m, wptr, lwork, flag)
2623 module subroutine svd_dbl(a, s, u, vt, work, olwork, err)
2625 real(real64),
intent(inout),
dimension(:,:) :: a
2626 real(real64),
intent(out),
dimension(:) :: s
2627 real(real64),
intent(out),
optional,
dimension(:,:) :: u, vt
2628 real(real64),
intent(out),
target,
optional,
dimension(:) :: work
2629 integer(int32),
intent(out),
optional :: olwork
2630 class(errors),
intent(inout),
optional,
target :: err
2633 character :: jobu, jobvt
2634 integer(int32) :: m, n, mn, istat, lwork, flag
2635 real(real64),
pointer,
dimension(:) :: wptr
2636 real(real64),
allocatable,
target,
dimension(:) :: wrk
2637 real(real64),
dimension(1) :: temp
2638 class(errors),
pointer :: errmgr
2639 type(errors),
target :: deferr
2640 character(len = :),
allocatable :: errmsg
2646 if (
present(u))
then
2647 if (
size(u, 2) == m)
then
2649 else if (
size(u, 2) == mn)
then
2655 if (
present(vt))
then
2660 if (
present(err))
then
2668 if (
size(s) /= mn)
then
2670 else if (
present(u))
then
2671 if (
size(u, 1) /= m) flag = 3
2672 if (
size(u, 2) /= m .and.
size(u, 2) /= mn) flag = 3
2673 else if (
present(vt))
then
2674 if (
size(vt, 1) /= n .or.
size(vt, 2) /= n) flag = 4
2678 allocate(
character(len = 256) :: errmsg)
2679 write(errmsg, 100)
"Input number ", flag, &
2680 " is not sized correctly."
2681 call errmgr%report_error(
"svd", trim(errmsg), &
2682 la_array_size_error)
2687 call dgesvd(jobu, jobvt, m, n, a, m, s, temp, m, temp, n, temp, -1, &
2689 lwork = int(temp(1), int32)
2690 if (
present(olwork))
then
2696 if (
present(work))
then
2697 if (
size(work) < lwork)
then
2699 call errmgr%report_error(
"svd", &
2700 "Incorrectly sized input array WORK, argument 5.", &
2701 la_array_size_error)
2704 wptr => work(1:lwork)
2706 allocate(wrk(lwork), stat = istat)
2707 if (istat /= 0)
then
2709 call errmgr%report_error(
"svd", &
2710 "Insufficient memory available.", &
2711 la_out_of_memory_error)
2718 if (
present(u) .and.
present(vt))
then
2719 call dgesvd(jobu, jobvt, m, n, a, m, s, u, m, vt, n, wptr, lwork, &
2721 else if (
present(u) .and. .not.
present(vt))
then
2722 call dgesvd(jobu, jobvt, m, n, a, m, s, u, m, temp, n, wptr, &
2724 else if (.not.
present(u) .and.
present(vt))
then
2725 call dgesvd(jobu, jobvt, m, n, a, m, s, temp, m, vt, n, wptr, &
2728 call dgesvd(jobu, jobvt, m, n, a, m, s, temp, m, temp, n, wptr, &
2734 allocate(
character(len = 256) :: errmsg)
2735 write(errmsg, 101) flag,
" superdiagonals could not " // &
2736 "converge to zero as part of the QR iteration process."
2737 call errmgr%report_warning(
"svd", errmsg, la_convergence_error)
2746 module subroutine svd_cmplx(a, s, u, vt, work, olwork, rwork, err)
2748 complex(real64),
intent(inout),
dimension(:,:) :: a
2749 real(real64),
intent(out),
dimension(:) :: s
2750 complex(real64),
intent(out),
optional,
dimension(:,:) :: u, vt
2751 complex(real64),
intent(out),
target,
optional,
dimension(:) :: work
2752 integer(int32),
intent(out),
optional :: olwork
2753 real(real64),
intent(out),
target,
optional,
dimension(:) :: rwork
2754 class(errors),
intent(inout),
optional,
target :: err
2757 character :: jobu, jobvt
2758 integer(int32) :: m, n, mn, istat, lwork, flag, lrwork
2759 complex(real64),
pointer,
dimension(:) :: wptr
2760 complex(real64),
allocatable,
target,
dimension(:) :: wrk
2761 complex(real64),
dimension(1) :: temp
2762 real(real64),
dimension(1) :: rtemp
2763 real(real64),
pointer,
dimension(:) :: rwptr
2764 real(real64),
allocatable,
target,
dimension(:) :: rwrk
2765 class(errors),
pointer :: errmgr
2766 type(errors),
target :: deferr
2767 character(len = :),
allocatable :: errmsg
2774 if (
present(u))
then
2775 if (
size(u, 2) == m)
then
2777 else if (
size(u, 2) == mn)
then
2783 if (
present(vt))
then
2788 if (
present(err))
then
2796 if (
size(s) /= mn)
then
2798 else if (
present(u))
then
2799 if (
size(u, 1) /= m) flag = 3
2800 if (
size(u, 2) /= m .and.
size(u, 2) /= mn) flag = 3
2801 else if (
present(vt))
then
2802 if (
size(vt, 1) /= n .or.
size(vt, 2) /= n) flag = 4
2806 allocate(
character(len = 256) :: errmsg)
2807 write(errmsg, 100)
"Input number ", flag, &
2808 " is not sized correctly."
2809 call errmgr%report_error(
"svd_cmplx", trim(errmsg), &
2810 la_array_size_error)
2815 call zgesvd(jobu, jobvt, m, n, a, m, s, temp, m, temp, n, temp, -1, &
2817 lwork = int(temp(1), int32)
2818 if (
present(olwork))
then
2824 if (
present(work))
then
2825 if (
size(work) < lwork)
then
2827 call errmgr%report_error(
"svd_cmplx", &
2828 "Incorrectly sized input array WORK, argument 5.", &
2829 la_array_size_error)
2832 wptr => work(1:lwork)
2834 allocate(wrk(lwork), stat = istat)
2835 if (istat /= 0)
then
2837 call errmgr%report_error(
"svd_cmplx", &
2838 "Insufficient memory available.", &
2839 la_out_of_memory_error)
2845 if (
present(rwork))
then
2846 if (
size(rwork) < lrwork)
then
2848 call errmgr%report_error(
"svd_cmplx", &
2849 "Incorrectly sized input array RWORK, argument 7.", &
2850 la_array_size_error)
2852 rwptr => rwork(1:lrwork)
2854 allocate(rwrk(lrwork), stat = istat)
2855 if (istat /= 0)
then
2857 call errmgr%report_error(
"svd_cmplx", &
2858 "Insufficient memory available.", &
2859 la_out_of_memory_error)
2866 if (
present(u) .and.
present(vt))
then
2867 call zgesvd(jobu, jobvt, m, n, a, m, s, u, m, vt, n, wptr, lwork, &
2869 else if (
present(u) .and. .not.
present(vt))
then
2870 call zgesvd(jobu, jobvt, m, n, a, m, s, u, m, temp, n, wptr, &
2872 else if (.not.
present(u) .and.
present(vt))
then
2873 call zgesvd(jobu, jobvt, m, n, a, m, s, temp, m, vt, n, wptr, &
2876 call zgesvd(jobu, jobvt, m, n, a, m, s, temp, m, temp, n, wptr, &
2882 allocate(
character(len = 256) :: errmsg)
2883 write(errmsg, 101) flag,
" superdiagonals could not " // &
2884 "converge to zero as part of the QR iteration process."
2885 call errmgr%report_warning(
"svd_cmplx", errmsg, &
2886 la_convergence_error)
2897 module subroutine lq_factor_no_pivot(a, tau, work, olwork, err)
2899 real(real64),
intent(inout),
dimension(:,:) :: a
2900 real(real64),
intent(out),
dimension(:) :: tau
2901 real(real64),
intent(out),
target,
dimension(:),
optional :: work
2902 integer(int32),
intent(out),
optional :: olwork
2903 class(errors),
intent(inout),
optional,
target :: err
2906 integer(int32) :: m, n, mn, istat, lwork, flag
2907 real(real64),
dimension(1) :: temp
2908 real(real64),
pointer,
dimension(:) :: wptr
2909 real(real64),
allocatable,
target,
dimension(:) :: wrk
2910 class(errors),
pointer :: errmgr
2911 type(errors),
target :: deferr
2917 if (
present(err))
then
2924 if (
size(tau) /= mn)
then
2926 call errmgr%report_error(
"lq_factor_no_pivot", &
2927 "Incorrectly sized input array TAU, argument 2.", &
2928 la_array_size_error)
2933 call dgelqf(m, n, a, m, tau, temp, -1, flag)
2934 lwork = int(temp(1), int32)
2935 if (
present(olwork))
then
2941 if (
present(work))
then
2942 if (
size(work) < lwork)
then
2944 call errmgr%report_error(
"lq_factor_no_pivot", &
2945 "Incorrectly sized input array WORK, argument 3.", &
2946 la_array_size_error)
2949 wptr => work(1:lwork)
2951 allocate(wrk(lwork), stat = istat)
2952 if (istat /= 0)
then
2954 call errmgr%report_error(
"lq_factor_no_pivot", &
2955 "Insufficient memory available.", &
2956 la_out_of_memory_error)
2963 call dgelqf(m, n, a, m, tau, wptr, lwork, flag)
2967 module subroutine lq_factor_no_pivot_cmplx(a, tau, work, olwork, err)
2969 complex(real64),
intent(inout),
dimension(:,:) :: a
2970 complex(real64),
intent(out),
dimension(:) :: tau
2971 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
2972 integer(int32),
intent(out),
optional :: olwork
2973 class(errors),
intent(inout),
optional,
target :: err
2976 integer(int32) :: m, n, mn, istat, lwork, flag
2977 complex(real64),
dimension(1) :: temp
2978 complex(real64),
pointer,
dimension(:) :: wptr
2979 complex(real64),
allocatable,
target,
dimension(:) :: wrk
2980 class(errors),
pointer :: errmgr
2981 type(errors),
target :: deferr
2987 if (
present(err))
then
2994 if (
size(tau) /= mn)
then
2996 call errmgr%report_error(
"lq_factor_no_pivot_cmplx", &
2997 "Incorrectly sized input array TAU, argument 2.", &
2998 la_array_size_error)
3003 call zgelqf(m, n, a, m, tau, temp, -1, flag)
3004 lwork = int(temp(1), int32)
3005 if (
present(olwork))
then
3011 if (
present(work))
then
3012 if (
size(work) < lwork)
then
3014 call errmgr%report_error(
"lq_factor_no_pivot_cmplx", &
3015 "Incorrectly sized input array WORK, argument 3.", &
3016 la_array_size_error)
3019 wptr => work(1:lwork)
3021 allocate(wrk(lwork), stat = istat)
3022 if (istat /= 0)
then
3024 call errmgr%report_error(
"lq_factor_no_pivot_cmplx", &
3025 "Insufficient memory available.", &
3026 la_out_of_memory_error)
3033 call zgelqf(m, n, a, m, tau, wptr, lwork, flag)
3037 module subroutine form_lq_no_pivot(l, tau, q, work, olwork, err)
3039 real(real64),
intent(inout),
dimension(:,:) :: l
3040 real(real64),
intent(in),
dimension(:) :: tau
3041 real(real64),
intent(out),
dimension(:,:) :: q
3042 real(real64),
intent(out),
target,
dimension(:),
optional :: work
3043 integer(int32),
intent(out),
optional :: olwork
3044 class(errors),
intent(inout),
optional,
target :: err
3047 real(real64),
parameter :: zero = 0.0d0
3050 integer(int32) :: i, j, m, n, mn, k, istat, flag, lwork
3051 real(real64),
pointer,
dimension(:) :: wptr
3052 real(real64),
allocatable,
target,
dimension(:) :: wrk
3053 real(real64),
dimension(1) :: temp
3054 class(errors),
pointer :: errmgr
3055 type(errors),
target :: deferr
3056 character(len = :),
allocatable :: errmsg
3062 if (
present(err))
then
3072 else if (
size(tau) /= mn)
then
3074 else if (
size(q, 1) /= n .or.
size(q, 2) /= n)
then
3079 allocate(
character(len = 256) :: errmsg)
3080 write(errmsg, 100)
"Input number ", flag, &
3081 " is not sized correctly."
3082 call errmgr%report_error(
"form_lq_no_pivot", trim(errmsg), &
3083 la_array_size_error)
3088 call dorglq(n, n, mn, q, n, tau, temp, -1, flag)
3089 lwork = int(temp(1), int32)
3090 if (
present(olwork))
then
3096 if (
present(work))
then
3097 if (
size(work) < lwork)
then
3099 call errmgr%report_error(
"form_lq_no_pivot", &
3100 "Incorrectly sized input array WORK, argument 4.", &
3101 la_array_size_error)
3104 wptr => work(1:lwork)
3106 allocate(wrk(lwork), stat = istat)
3107 if (istat /= 0)
then
3109 call errmgr%report_error(
"form_lq_no_pivot", &
3110 "Insufficient memory available.", &
3111 la_out_of_memory_error)
3125 call dorglq(n, n, mn, q, n, tau, wptr, lwork, flag)
3132 module subroutine form_lq_no_pivot_cmplx(l, tau, q, work, olwork, err)
3134 complex(real64),
intent(inout),
dimension(:,:) :: l
3135 complex(real64),
intent(in),
dimension(:) :: tau
3136 complex(real64),
intent(out),
dimension(:,:) :: q
3137 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
3138 integer(int32),
intent(out),
optional :: olwork
3139 class(errors),
intent(inout),
optional,
target :: err
3142 complex(real64),
parameter :: zero = (0.0d0, 0.0d0)
3145 integer(int32) :: i, j, m, n, mn, k, istat, flag, lwork
3146 complex(real64),
pointer,
dimension(:) :: wptr
3147 complex(real64),
allocatable,
target,
dimension(:) :: wrk
3148 complex(real64),
dimension(1) :: temp
3149 class(errors),
pointer :: errmgr
3150 type(errors),
target :: deferr
3151 character(len = :),
allocatable :: errmsg
3157 if (
present(err))
then
3167 else if (
size(tau) /= mn)
then
3169 else if (
size(q, 1) /= n .or.
size(q, 2) /= n)
then
3174 allocate(
character(len = 256) :: errmsg)
3175 write(errmsg, 100)
"Input number ", flag, &
3176 " is not sized correctly."
3177 call errmgr%report_error(
"form_lq_no_pivot_cmplx", trim(errmsg), &
3178 la_array_size_error)
3183 call zunglq(n, n, mn, q, n, tau, temp, -1, flag)
3184 lwork = int(temp(1), int32)
3185 if (
present(olwork))
then
3191 if (
present(work))
then
3192 if (
size(work) < lwork)
then
3194 call errmgr%report_error(
"form_lq_no_pivot_cmplx", &
3195 "Incorrectly sized input array WORK, argument 4.", &
3196 la_array_size_error)
3199 wptr => work(1:lwork)
3201 allocate(wrk(lwork), stat = istat)
3202 if (istat /= 0)
then
3204 call errmgr%report_error(
"form_lq_no_pivot_cmplx", &
3205 "Insufficient memory available.", &
3206 la_out_of_memory_error)
3220 call zunglq(n, n, mn, q, n, tau, wptr, lwork, flag)
3227 module subroutine mult_lq_mtx(lside, trans, a, tau, c, work, olwork, err)
3229 logical,
intent(in) :: lside, trans
3230 real(real64),
intent(in),
dimension(:,:) :: a
3231 real(real64),
intent(in),
dimension(:) :: tau
3232 real(real64),
intent(inout),
dimension(:,:) :: c
3233 real(real64),
intent(out),
target,
dimension(:),
optional :: work
3234 integer(int32),
intent(out),
optional :: olwork
3235 class(errors),
intent(inout),
optional,
target :: err
3238 character :: side, t
3239 integer(int32) :: m, n, k, ncola, istat, flag, lwork
3240 real(real64),
pointer,
dimension(:) :: wptr
3241 real(real64),
allocatable,
target,
dimension(:) :: wrk
3242 real(real64),
dimension(1) :: temp
3243 class(errors),
pointer :: errmgr
3244 type(errors),
target :: deferr
3245 character(len = :),
allocatable :: errmsg
3263 if (
present(err))
then
3271 if (
size(a, 1) /= k .or.
size(a, 2) /= ncola)
then
3276 allocate(
character(len = 256) :: errmsg)
3277 write(errmsg, 100)
"Input number ", flag, &
3278 " is not sized correctly."
3279 call errmgr%report_error(
"mult_lq_mtx", trim(errmsg), &
3280 la_array_size_error)
3285 call dormlq(side, t, m, n, k, a, k, tau, c, m, temp, -1, flag)
3286 lwork = int(temp(1), int32)
3287 if (
present(olwork))
then
3293 if (
present(work))
then
3294 if (
size(work) < lwork)
then
3296 call errmgr%report_error(
"mult_lq_mtx", &
3297 "Incorrectly sized input array WORK, argument 6.", &
3298 la_array_size_error)
3301 wptr => work(1:lwork)
3303 allocate(wrk(lwork), stat = istat)
3304 if (istat /= 0)
then
3306 call errmgr%report_error(
"mult_lq_mtx", &
3307 "Insufficient memory available.", &
3308 la_out_of_memory_error)
3315 call dormlq(side, t, m, n, k, a, k, tau, c, m, wptr, lwork, flag)
3322 module subroutine mult_lq_mtx_cmplx(lside, trans, a, tau, c, work, olwork, err)
3324 logical,
intent(in) :: lside, trans
3325 complex(real64),
intent(in),
dimension(:,:) :: a
3326 complex(real64),
intent(in),
dimension(:) :: tau
3327 complex(real64),
intent(inout),
dimension(:,:) :: c
3328 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
3329 integer(int32),
intent(out),
optional :: olwork
3330 class(errors),
intent(inout),
optional,
target :: err
3333 character :: side, t
3334 integer(int32) :: m, n, k, ncola, istat, flag, lwork
3335 complex(real64),
pointer,
dimension(:) :: wptr
3336 complex(real64),
allocatable,
target,
dimension(:) :: wrk
3337 complex(real64),
dimension(1) :: temp
3338 class(errors),
pointer :: errmgr
3339 type(errors),
target :: deferr
3340 character(len = :),
allocatable :: errmsg
3358 if (
present(err))
then
3366 if (
size(a, 1) /= k .or.
size(a, 2) /= ncola)
then
3371 allocate(
character(len = 256) :: errmsg)
3372 write(errmsg, 100)
"Input number ", flag, &
3373 " is not sized correctly."
3374 call errmgr%report_error(
"mult_lq_mtx_cmplx", trim(errmsg), &
3375 la_array_size_error)
3380 call zunmlq(side, t, m, n, k, a, k, tau, c, m, temp, -1, flag)
3381 lwork = int(temp(1), int32)
3382 if (
present(olwork))
then
3388 if (
present(work))
then
3389 if (
size(work) < lwork)
then
3391 call errmgr%report_error(
"mult_lq_mtx_cmplx", &
3392 "Incorrectly sized input array WORK, argument 6.", &
3393 la_array_size_error)
3396 wptr => work(1:lwork)
3398 allocate(wrk(lwork), stat = istat)
3399 if (istat /= 0)
then
3401 call errmgr%report_error(
"mult_lq_mtx_cmplx", &
3402 "Insufficient memory available.", &
3403 la_out_of_memory_error)
3410 call zunmlq(side, t, m, n, k, a, k, tau, c, m, wptr, lwork, flag)
3417 module subroutine mult_lq_vec(trans, a, tau, c, work, olwork, err)
3419 logical,
intent(in) :: trans
3420 real(real64),
intent(in),
dimension(:,:) :: a
3421 real(real64),
intent(in),
dimension(:) :: tau
3422 real(real64),
intent(inout),
dimension(:) :: c
3423 real(real64),
intent(out),
target,
dimension(:),
optional :: work
3424 integer(int32),
intent(out),
optional :: olwork
3425 class(errors),
intent(inout),
optional,
target :: err
3428 character :: side, t
3429 integer(int32) :: m, n, k, istat, flag, lwork
3430 real(real64),
pointer,
dimension(:) :: wptr
3431 real(real64),
allocatable,
target,
dimension(:) :: wrk
3432 real(real64),
dimension(1) :: temp
3433 class(errors),
pointer :: errmgr
3434 type(errors),
target :: deferr
3435 character(len = :),
allocatable :: errmsg
3447 if (
present(err))
then
3455 if (
size(a, 1) /= k .or.
size(a, 2) /= m)
then
3460 allocate(
character(len = 256) :: errmsg)
3461 write(errmsg, 100)
"Input number ", flag, &
3462 " is not sized correctly."
3463 call errmgr%report_error(
"mult_lq_vec", trim(errmsg), &
3464 la_array_size_error)
3469 call dormlq(side, t, m, n, k, a, k, tau, c, m, temp, -1, flag)
3470 lwork = int(temp(1), int32)
3471 if (
present(olwork))
then
3477 if (
present(work))
then
3478 if (
size(work) < lwork)
then
3480 call errmgr%report_error(
"mult_lq_vec", &
3481 "Incorrectly sized input array WORK, argument 6.", &
3482 la_array_size_error)
3485 wptr => work(1:lwork)
3487 allocate(wrk(lwork), stat = istat)
3488 if (istat /= 0)
then
3490 call errmgr%report_error(
"mult_lq_vec", &
3491 "Insufficient memory available.", &
3492 la_out_of_memory_error)
3499 call dormlq(side, t, m, n, k, a, k, tau, c, m, wptr, lwork, flag)
3506 module subroutine mult_lq_vec_cmplx(trans, a, tau, c, work, olwork, err)
3508 logical,
intent(in) :: trans
3509 complex(real64),
intent(in),
dimension(:,:) :: a
3510 complex(real64),
intent(in),
dimension(:) :: tau
3511 complex(real64),
intent(inout),
dimension(:) :: c
3512 complex(real64),
intent(out),
target,
dimension(:),
optional :: work
3513 integer(int32),
intent(out),
optional :: olwork
3514 class(errors),
intent(inout),
optional,
target :: err
3517 character :: side, t
3518 integer(int32) :: m, n, k, istat, flag, lwork
3519 complex(real64),
pointer,
dimension(:) :: wptr
3520 complex(real64),
allocatable,
target,
dimension(:) :: wrk
3521 complex(real64),
dimension(1) :: temp
3522 class(errors),
pointer :: errmgr
3523 type(errors),
target :: deferr
3524 character(len = :),
allocatable :: errmsg
3536 if (
present(err))
then
3544 if (
size(a, 1) /= k .or.
size(a, 2) /= m)
then
3549 allocate(
character(len = 256) :: errmsg)
3550 write(errmsg, 100)
"Input number ", flag, &
3551 " is not sized correctly."
3552 call errmgr%report_error(
"mult_lq_vec_cmplx", trim(errmsg), &
3553 la_array_size_error)
3558 call zunmlq(side, t, m, n, k, a, k, tau, c, m, temp, -1, flag)
3559 lwork = int(temp(1), int32)
3560 if (
present(olwork))
then
3566 if (
present(work))
then
3567 if (
size(work) < lwork)
then
3569 call errmgr%report_error(
"mult_lq_vec_cmplx", &
3570 "Incorrectly sized input array WORK, argument 6.", &
3571 la_array_size_error)
3574 wptr => work(1:lwork)
3576 allocate(wrk(lwork), stat = istat)
3577 if (istat /= 0)
then
3579 call errmgr%report_error(
"mult_lq_vec_cmplx", &
3580 "Insufficient memory available.", &
3581 la_out_of_memory_error)
3588 call zunmlq(side, t, m, n, k, a, k, tau, c, m, wptr, lwork, flag)
Provides a set of common linear algebra routines.
A module providing explicit interfaces for the QRUPDATE library.