Octopus
lalg_adv.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module lalg_adv_oct_m
23 use blacs_oct_m
24 use debug_oct_m
25 use global_oct_m
26 use, intrinsic :: iso_fortran_env
27 use lapack_oct_m
28 use math_oct_m
30 use mpi_oct_m
33 use sort_oct_m
34 use utils_oct_m
35#ifdef HAVE_ELPA
36 use elpa
37#endif
38
39 implicit none
40
41 private
42 public :: &
55 zlalg_exp, &
56 zlalg_phi, &
62 lalg_zdni, &
64 lalg_zd2ni, &
68
69
70
71 interface lalg_cholesky
72 module procedure dcholesky, zcholesky
73 end interface lalg_cholesky
74
75 interface lalg_geneigensolve
76 module procedure dgeneigensolve, zgeneigensolve
77 end interface lalg_geneigensolve
78
79 interface lalg_eigensolve_nonh
80 module procedure zeigensolve_nonh, deigensolve_nonh
81 end interface lalg_eigensolve_nonh
82
83 interface lalg_eigensolve
84 module procedure deigensolve, zeigensolve
85 end interface lalg_eigensolve
86
89 end interface lalg_eigensolve_parallel
90
93
94 interface lalg_determinant
95 module procedure ddeterminant, zdeterminant
96 end interface lalg_determinant
97
98 interface lalg_inverse
99 module procedure dinverse, zinverse
100 end interface lalg_inverse
101
102 interface lalg_linsyssolve
103 module procedure dlinsyssolve, zlinsyssolve
104 end interface lalg_linsyssolve
105
108 end interface lalg_singular_value_decomp
109
110 interface lalg_svd_inverse
111 module procedure dsvd_inverse, zsvd_inverse
112 end interface lalg_svd_inverse
113
117 end interface lalg_lowest_geneigensolve
118
119 interface lalg_lowest_eigensolve
120 module procedure dlowest_eigensolve, zlowest_eigensolve
121 end interface lalg_lowest_eigensolve
122
123 interface lapack_geev
124 module procedure lalg_dgeev, lalg_zgeev
125 end interface lapack_geev
126
127 interface lalg_least_squares
128 module procedure dleast_squares_vec, zleast_squares_vec
129 end interface lalg_least_squares
130
131 interface lalg_matrix_norm2
132 module procedure dmatrix_norm2, zmatrix_norm2
133 end interface lalg_matrix_norm2
134
135 interface lalg_matrix_function
137 end interface lalg_matrix_function
138
139contains
140
141 ! ---------------------------------------------------------
143 real(real64) function sfmin()
144 interface
145 real(real64) function dlamch(cmach)
146 import real64
147 implicit none
148 character(1), intent(in) :: cmach
149 end function dlamch
150 end interface
151
152 sfmin = dlamch('S')
153 end function sfmin
154
155 subroutine lalg_dgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
156 character(1), intent(in) :: jobvl, jobvr
157 integer, intent(in) :: n, lda, ldvl, ldvr, lwork
158 real(real64), intent(inout) :: a(:,:)
159 complex(real64), intent(out) :: w(:)
160 real(real64), intent(out) :: vl(:,:), vr(:,:)
161 real(real64), intent(out) :: rwork(:)
162 real(real64), intent(out) :: work(:)
163 integer, intent(out) :: info
165 real(real64), allocatable :: wr(:), wi(:)
166
167 push_sub(lalg_dgeev)
169 safe_allocate(wr(1:n))
170 safe_allocate(wi(1:n))
171
172 call dgeev(jobvl, jobvr, n, a(1, 1), lda, wr(1), wi(1), vl(1, 1), ldvl, vr(1, 1), ldvr, work(1), lwork, rwork(1), info)
173
174 w(1:n) = cmplx(wr(1:n), wi(1:n), real64)
175
176 safe_deallocate_a(wr)
177 safe_deallocate_a(wi)
178
179 pop_sub(lalg_dgeev)
180 end subroutine lalg_dgeev
181
182 subroutine lalg_zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
183 character(1), intent(in) :: jobvl, jobvr
184 integer, intent(in) :: n, lda, ldvl, ldvr, lwork
185 complex(real64), intent(inout) :: a(:,:)
186 complex(real64), intent(out) :: w(:)
187 complex(real64), intent(out) :: vl(:,:), vr(:,:)
188 real(real64), intent(out) :: rwork(:)
189 complex(real64), intent(out) :: work(:)
190 integer, intent(out) :: info
192 push_sub(lalg_zgeev)
193
194 call zgeev(jobvl, jobvr, n, a(1, 1), lda, w(1), vl(1, 1), ldvl, vr(1, 1), ldvr, work(1), lwork, rwork(1), info)
196 pop_sub(lalg_zgeev)
197 end subroutine lalg_zgeev
198
216 subroutine zlalg_exp(nn, pp, aa, ex, hermitian)
217 integer, intent(in) :: nn
218 complex(real64), intent(in) :: pp
219 complex(real64), intent(in) :: aa(:, :)
220 complex(real64), intent(inout) :: ex(:, :)
221 logical, intent(in) :: hermitian
222
223 complex(real64), allocatable :: evectors(:, :), zevalues(:)
224 real(real64), allocatable :: evalues(:)
225
226 integer :: ii
227
228 push_sub(zlalg_exp)
229
230 safe_allocate(evectors(1:nn, 1:nn))
231
232 if (hermitian) then
233 safe_allocate(evalues(1:nn))
234 safe_allocate(zevalues(1:nn))
235
236 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
237
238 call lalg_eigensolve(nn, evectors, evalues)
239
240 zevalues(1:nn) = exp(pp*evalues(1:nn))
241
242 do ii = 1, nn
243 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
244 end do
245
246 ex(1:nn, 1:nn) = matmul(evectors(1:nn, 1:nn), ex(1:nn, 1:nn))
247
248 safe_deallocate_a(evalues)
249 safe_deallocate_a(zevalues)
250 else
251 safe_allocate(zevalues(1:nn))
252
253 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
254
255 call lalg_eigensolve_nonh(nn, evectors, zevalues)
256
257 zevalues(1:nn) = exp(pp*zevalues(1:nn))
258
259 ex(1:nn, 1:nn) = evectors(1:nn, 1:nn)
260
261 call lalg_inverse(nn, evectors, 'dir')
262
263 do ii = 1, nn
264 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
265 end do
266
267 ex(1:nn, 1:nn) = matmul(ex(1:nn, 1:nn), evectors(1:nn, 1:nn))
268
269 safe_deallocate_a(zevalues)
270 end if
271
272 safe_deallocate_a(evectors)
273
274 pop_sub(zlalg_exp)
275 end subroutine zlalg_exp
276
277
294 subroutine zlalg_phi(nn, pp, aa, ex, hermitian)
295 integer, intent(in) :: nn
296 complex(real64), intent(in) :: pp
297 complex(real64), intent(in) :: aa(:, :)
298 complex(real64), intent(inout) :: ex(:, :)
299 logical, intent(in) :: hermitian
300
301 complex(real64), allocatable :: evectors(:, :), zevalues(:)
302 real(real64), allocatable :: evalues(:)
303
304 integer :: ii
305
306 push_sub(zlalg_phi)
307
308 safe_allocate(evectors(1:nn, 1:nn))
310 if (hermitian) then
311 safe_allocate(evalues(1:nn))
312 safe_allocate(zevalues(1:nn))
313
314 evectors = aa
315
316 call lalg_eigensolve(nn, evectors, evalues)
317
318 do ii = 1, nn
319 zevalues(ii) = (exp(pp*evalues(ii)) - m_z1) / (pp*evalues(ii))
320 end do
321
322 do ii = 1, nn
323 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
324 end do
325
326 ex(1:nn, 1:nn) = matmul(evectors(1:nn, 1:nn), ex(1:nn, 1:nn))
327
328 safe_deallocate_a(evalues)
329 safe_deallocate_a(zevalues)
330 else
331 safe_allocate(zevalues(1:nn))
332
333 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
334
335 call lalg_eigensolve_nonh(nn, evectors, zevalues)
336
337 do ii = 1, nn
338 zevalues(ii) = (exp(pp*zevalues(ii)) - m_z1) / (pp*zevalues(ii))
339 end do
340
341 ex(1:nn, 1:nn) = evectors(1:nn, 1:nn)
342
343 call lalg_inverse(nn, evectors, 'dir')
344
345 do ii = 1, nn
346 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
347 end do
348
349 ex(1:nn, 1:nn) = matmul(ex(1:nn, 1:nn), evectors(1:nn, 1:nn))
350
351 safe_deallocate_a(zevalues)
352 end if
353
354 pop_sub(zlalg_phi)
355 end subroutine zlalg_phi
356
357
369 subroutine lalg_zeigenderivatives(n, mat, zeigenvec, zeigenval, zmat)
370 integer, intent(in) :: n
371 complex(real64), intent(in) :: mat(:, :)
372 complex(real64), intent(out) :: zeigenvec(:, :)
373 complex(real64), intent(out) :: zeigenval(:)
374 complex(real64), intent(out) :: zmat(:, :, :)
375
376 integer :: i, alpha, beta
377 complex(real64), allocatable :: knaught(:, :)
378 complex(real64), allocatable :: lambdaminusdm(:, :)
379 complex(real64), allocatable :: ilambdaminusdm(:, :)
380 complex(real64), allocatable :: unit(:, :)
381
382 push_sub(lalg_zeigenderivatives)
383
384 safe_allocate(unit(1:n, 1:n))
385 safe_allocate(knaught(1:n, 1:n))
386 safe_allocate(lambdaminusdm(1:n, 1:n))
387 safe_allocate(ilambdaminusdm(1:n, 1:n))
388
389 zeigenvec = mat
390 call lalg_eigensolve_nonh(n, zeigenvec, zeigenval)
391
392 unit = m_z0
393 do i = 1, n
394 unit(i, i) = m_z1
395 end do
396
397 do i = 1, n
398 do alpha = 1, n
399 do beta = 1, n
400 knaught(alpha, beta) = - zeigenvec(alpha, i)*conjg(zeigenvec(beta, i))
401 end do
402 end do
403 knaught = knaught + unit
404 lambdaminusdm = zeigenval(i)*unit - mat
405 call lalg_zpseudoinverse(n, lambdaminusdm, ilambdaminusdm)
406 zmat(:, :, i) = matmul(ilambdaminusdm, knaught)
407 end do
408
409 safe_deallocate_a(unit)
410 safe_deallocate_a(knaught)
411 safe_deallocate_a(lambdaminusdm)
412 safe_deallocate_a(ilambdaminusdm)
414 end subroutine lalg_zeigenderivatives
415
416
421 subroutine lalg_zpseudoinverse(n, mat, imat)
422 integer, intent(in) :: n
423 complex(real64), intent(in) :: mat(:, :)
424 complex(real64), intent(out) :: imat(:, :)
425
426 integer :: i
427 complex(real64), allocatable :: u(:, :), vt(:, :), sigma(:, :)
428 real(real64), allocatable :: sg_values(:)
429
430 push_sub(lalg_zpseudoinverse)
431
432 safe_allocate(u(1:n, 1:n))
433 safe_allocate(vt(1:n, 1:n))
434 safe_allocate(sigma(1:n, 1:n))
435 safe_allocate(sg_values(1:n))
436
437 imat = mat
438 call lalg_singular_value_decomp(n, n, imat, u, vt, sg_values)
439
440 sigma = m_z0
441 do i = 1, n
442 if (abs(sg_values(i)) <= 1.0e-12_real64 * maxval(abs(sg_values))) then
443 sigma(i, i) = m_z0
444 else
445 sigma(i, i) = m_z1 / sg_values(i)
446 end if
447 end do
448
449 vt = conjg(transpose(vt))
450 u = conjg(transpose(u))
451 imat = matmul(vt, matmul(sigma, u))
452
453 ! Check if we truly have a pseudoinverse
454 vt = matmul(mat, matmul(imat, mat)) - mat
455 if (maxval(abs(vt)) > 1.0e-10_real64 * maxval(abs(mat))) then
456 write(*, *) maxval(abs(vt))
457 write(*, *) vt
458 write(*, *)
459 write(*, *) 1.0e-10_real64 * maxval(abs(mat))
460 write(*, *) maxval(abs(vt)) > 1.0e-10_real64 * maxval(abs(mat))
461 write(*, *) mat
462 write(message(1), '(a)') 'Pseudoinverse failed.'
463 call messages_fatal(1)
464 end if
465
466 safe_deallocate_a(u)
467 safe_deallocate_a(vt)
468 safe_deallocate_a(sigma)
469 safe_deallocate_a(sg_values)
470 pop_sub(lalg_zpseudoinverse)
471 end subroutine lalg_zpseudoinverse
472
473
480 subroutine lalg_check_zeigenderivatives(n, mat)
481 integer, intent(in) :: n
482 complex(real64), intent(in) :: mat(:, :)
483
484 integer :: alpha, beta, gamma, delta
485 complex(real64) :: deltah, zuder_direct, zder_direct, zuder_directplus, zuder_directminus
486 complex(real64), allocatable :: zeigenvec(:, :), dm(:, :), zeigref_(:, :), zeigenval(:), mmatrix(:, :, :)
487 complex(real64), allocatable :: zeigplus(:), zeigminus(:), zeig0(:), zeigplusminus(:), zeigminusplus(:)
488
490
491 safe_allocate(zeigenvec(1:n, 1:n))
492 safe_allocate(dm(1:n, 1:n))
493 safe_allocate(zeigref_(1:n, 1:n))
494 safe_allocate(zeigenval(1:n))
495 safe_allocate(mmatrix(1:n, 1:n, 1:n))
496 safe_allocate(zeigplus(1:n))
497 safe_allocate(zeigminus(1:n))
498 safe_allocate(zeig0(1:n))
499 safe_allocate(zeigplusminus(1:n))
500 safe_allocate(zeigminusplus(1:n))
501
502 assert(n == 2)
503
504 dm = mat
505 call lalg_zeigenderivatives(2, dm, zeigref_, zeigenval, mmatrix)
506
507
508 deltah = (0.000001_real64, 0.000_real64)
509 !deltah = M_z1 * maxval(abs(dm)) * 0.001_real64
510 do alpha = 1, n
511 do beta = 1, n
512 zder_direct = lalg_zdni(zeigref_(:, 2), alpha, beta)
513 zuder_direct = lalg_zduialpha(zeigref_(:, 2), mmatrix(:, :, 2), 2, alpha, beta)
515 zeigenvec = dm
516 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) + deltah
517 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigplus)
518 zeigenvec(:, 1) = zeigenvec(:, 1)/sum(conjg(zeigref_(1:2, 1))*zeigenvec(1:2, 1))
519 zeigenvec(:, 2) = zeigenvec(:, 2)/sum(conjg(zeigref_(1:2, 2))*zeigenvec(1:2, 2))
520 zuder_directplus = zeigenvec(2, 2)
521
522 zeigenvec = dm
523 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) - deltah
524 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigminus)
525 zeigenvec(:, 1) = zeigenvec(:, 1)/sum(conjg(zeigref_(1:2, 1))*zeigenvec(1:2, 1))
526 zeigenvec(:, 2) = zeigenvec(:, 2)/sum(conjg(zeigref_(1:2, 2))*zeigenvec(1:2, 2))
527 zuder_directminus = zeigenvec(2, 2)
528
529 write(*, '(2i1,4f24.12)') alpha, beta, zder_direct, (zeigplus(2) - zeigminus(2))/(m_two * deltah)
530 write(*, '(2i1,4f24.12)') alpha, beta, &
531 zuder_direct, (zuder_directplus - zuder_directminus) / (m_two * deltah)
532
533 do gamma = 1, n
534 do delta = 1, n
535 if (alpha == gamma .and. beta == delta) then
536 zder_direct = lalg_zd2ni(zeigref_(:, 1), mmatrix(:, :, 1), alpha, beta, gamma, delta)
537
538 zeigenvec = dm
539 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeig0)
540
541 zeigenvec = dm
542 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) + deltah
543 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigplus)
544
545 zeigenvec = dm
546 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) - deltah
547 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigminus)
548
549 write(*, '(4i1,4f24.12)') alpha, beta, gamma, delta, &
550 zder_direct, (zeigplus(1) + zeigminus(1) - m_two*zeig0(1))/(deltah**2)
551 else
552 zder_direct = lalg_zd2ni(zeigref_(:, 1), mmatrix(:, :, 1), alpha, beta, gamma, delta)
553
554 zeigenvec = dm
555 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) + deltah
556 zeigenvec(gamma, delta) = zeigenvec(gamma, delta) + deltah
557 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigplus)
558
559 zeigenvec = dm
560 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) - deltah
561 zeigenvec(gamma, delta) = zeigenvec(gamma, delta) - deltah
562 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigminus)
563
564 zeigenvec = dm
565 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) + deltah
566 zeigenvec(gamma, delta) = zeigenvec(gamma, delta) - deltah
567 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigplusminus)
568
569 zeigenvec = dm
570 zeigenvec(alpha, beta) = zeigenvec(alpha, beta) - deltah
571 zeigenvec(gamma, delta) = zeigenvec(gamma, delta) + deltah
572 call lalg_eigensolve_nonh(2, zeigenvec(:, :), zeigminusplus)
574 write(*, '(4i1,4f24.12)') alpha, beta, gamma, delta, &
575 zder_direct, (zeigplus(1) + zeigminus(1) - zeigplusminus(1) - zeigminusplus(1))/(m_four*deltah**2)
576
577
578 end if
579 end do
580 end do
581
582 end do
583 end do
584
585 safe_deallocate_a(zeigenval)
586 safe_deallocate_a(mmatrix)
587 safe_deallocate_a(zeigenvec)
588 safe_deallocate_a(dm)
589 safe_deallocate_a(zeigref_)
590 safe_deallocate_a(zeigplus)
591 safe_deallocate_a(zeigminus)
592 safe_deallocate_a(zeig0)
593 safe_deallocate_a(zeigplusminus)
594 safe_deallocate_a(zeigminusplus)
596 end subroutine lalg_check_zeigenderivatives
597
598 complex(real64) function lalg_zdni(eigenvec, alpha, beta)
599 integer, intent(in) :: alpha, beta
600 complex(real64) :: eigenvec(2)
601 lalg_zdni = conjg(eigenvec(alpha)) * eigenvec(beta)
602 end function lalg_zdni
603
604 complex(real64) function lalg_zduialpha(eigenvec, mmatrix, alpha, gamma, delta)
605 integer, intent(in) :: alpha, gamma, delta
606 complex(real64) :: eigenvec(2), mmatrix(2, 2)
607 lalg_zduialpha = mmatrix(alpha, gamma) * eigenvec(delta)
608 end function lalg_zduialpha
609
610 complex(real64) function lalg_zd2ni(eigenvec, mmatrix, alpha, beta, gamma, delta)
611 integer, intent(in) :: alpha, beta, gamma, delta
612 complex(real64) :: eigenvec(2), mmatrix(2, 2)
613 lalg_zd2ni = conjg(mmatrix(alpha, delta) * eigenvec(gamma)) * eigenvec(beta) + &
614 conjg(eigenvec(alpha)) * mmatrix(beta, gamma) * eigenvec(delta)
615 end function lalg_zd2ni
616
617 ! ---------------------------------------------------------
622 pure real(real64) function pseudoinverse_default_tolerance(m, n, sg_values) result(tol)
623 integer, intent(in) :: m, n
624 real(real64), intent(in) :: sg_values(:)
625 tol = m_epsilon * m * n * maxval(sg_values)
627
628
634 function lalg_remove_rotation(n, A) result(P)
635 integer, intent(in) :: n
636 real(real64), intent(in) :: a(1:n, 1:n)
637 real(real64) :: p(1:n, 1:n)
638
639 real(real64) :: ata(1:n, 1:n)
640
641 push_sub(lalg_remove_rotation)
642
643 ata = matmul(transpose(a), a)
644 call lalg_matrix_function(n, m_one, ata, p, square_root, .true.)
645
646 pop_sub(lalg_remove_rotation)
647 end function lalg_remove_rotation
648
649#include "undef.F90"
650#include "complex.F90"
651#include "lalg_adv_lapack_inc.F90"
652
653#include "undef.F90"
654#include "real.F90"
655#include "lalg_adv_lapack_inc.F90"
656
657end module lalg_adv_oct_m
658
659!! Local Variables:
660!! mode: f90
661!! coding: utf-8
662!! End:
Note that lalg_determinant and lalg_inverse are just wrappers over the same routine.
Definition: lalg_adv.F90:187
double exp(double __x) __attribute__((__nothrow__
This module contains interfaces for BLACS routines Interfaces are from http:
Definition: blacs.F90:27
This module provides the BLACS processor grid.
subroutine zmatrix_norm2(m, n, a, norm_l2, preserve_mat)
Norm of a 2D matrix.
Definition: lalg_adv.F90:1484
complex(real64) function, public lalg_zd2ni(eigenvec, mmatrix, alpha, beta, gamma, delta)
Definition: lalg_adv.F90:704
subroutine zlowest_geneigensolve(k, n, a, b, e, v, preserve_mat, bof, err_code)
Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian gener...
Definition: lalg_adv.F90:1087
complex(real64) function zdeterminant(n, a, preserve_mat)
Invert a real symmetric or complex Hermitian square matrix a.
Definition: lalg_adv.F90:1369
subroutine zeigensolve_nonh(n, a, e, err_code, side, sort_eigenvectors)
Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) e...
Definition: lalg_adv.F90:968
subroutine zlinsyssolve(n, nrhs, a, b, x)
compute the solution to a complex system of linear equations A*X = B, where A is an N-by-N matrix and...
Definition: lalg_adv.F90:1569
subroutine, public zlalg_exp(nn, pp, aa, ex, hermitian)
Definition: lalg_adv.F90:310
subroutine deigensolve_parallel(n, a, e, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenprobl...
Definition: lalg_adv.F90:3335
subroutine dgeneigensolve(n, a, b, e, preserve_mat, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalize...
Definition: lalg_adv.F90:2302
subroutine zeigensolve(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.
Definition: lalg_adv.F90:1206
subroutine dsingular_value_decomp(m, n, a, u, vt, sg_values, preserve_mat)
computes the singular value decomposition of a real NxN matrix a(:,:)
Definition: lalg_adv.F90:3083
subroutine deigensolve_nonh(n, a, e, err_code, side, sort_eigenvectors)
Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) e...
Definition: lalg_adv.F90:2404
subroutine zinverse(n, a, method, det, threshold, uplo)
An interface to different method to invert a matrix.
Definition: lalg_adv.F90:2041
subroutine, public lalg_zpseudoinverse(n, mat, imat)
Definition: lalg_adv.F90:515
real(real64) function sfmin()
Auxiliary function.
Definition: lalg_adv.F90:237
subroutine dlinsyssolve(n, nrhs, a, b, x)
compute the solution to a real system of linear equations A*X = B, where A is an N-by-N matrix and X ...
Definition: lalg_adv.F90:3004
subroutine zsingular_value_decomp(m, n, a, u, vt, sg_values, preserve_mat)
computes the singular value decomposition of a complex MxN matrix a(:,:)
Definition: lalg_adv.F90:1648
subroutine dcholesky(n, a, bof, err_code)
Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a,...
Definition: lalg_adv.F90:2249
subroutine deigensolve(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.
Definition: lalg_adv.F90:2643
subroutine, public lalg_zeigenderivatives(n, mat, zeigenvec, zeigenval, zmat)
Definition: lalg_adv.F90:463
subroutine dmatrix_norm2(m, n, a, norm_l2, preserve_mat)
Norm of a 2D matrix.
Definition: lalg_adv.F90:2919
subroutine zlowest_eigensolve(k, n, a, e, v, preserve_mat)
Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem,...
Definition: lalg_adv.F90:1278
complex(real64) function, public lalg_zduialpha(eigenvec, mmatrix, alpha, gamma, delta)
Definition: lalg_adv.F90:698
subroutine zgeneigensolve(n, a, b, e, preserve_mat, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalize...
Definition: lalg_adv.F90:866
subroutine dleast_squares_vec(nn, aa, bb, xx, preserve_mat)
Definition: lalg_adv.F90:3263
subroutine dlowest_geneigensolve(k, n, a, b, e, v, preserve_mat, bof, err_code)
Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian gener...
Definition: lalg_adv.F90:2523
subroutine zcholesky(n, a, bof, err_code)
Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a,...
Definition: lalg_adv.F90:813
subroutine, public lalg_check_zeigenderivatives(n, mat)
Definition: lalg_adv.F90:574
complex(real64) function, public lalg_zdni(eigenvec, alpha, beta)
Definition: lalg_adv.F90:692
pure real(real64) function pseudoinverse_default_tolerance(m, n, sg_values)
Computes the default Moore-Penrose pseudoinverse tolerance for zeroing.
Definition: lalg_adv.F90:716
subroutine zleast_squares_vec(nn, aa, bb, xx, preserve_mat)
Definition: lalg_adv.F90:1833
real(real64) function, dimension(1:n, 1:n), public lalg_remove_rotation(n, A)
Remove rotation from affine transformation A by computing the polar decomposition and discarding the ...
Definition: lalg_adv.F90:728
subroutine lalg_zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
Definition: lalg_adv.F90:276
subroutine dlalg_matrix_function(n, factor, a, fun_a, fun, hermitian)
This routine calculates a function of a matrix by using an eigenvalue decomposition.
Definition: lalg_adv.F90:3516
subroutine dinverse(n, a, method, det, threshold, uplo)
An interface to different method to invert a matrix.
Definition: lalg_adv.F90:3468
subroutine zeigensolve_parallel(n, a, e, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenprobl...
Definition: lalg_adv.F90:1908
real(real64) function ddeterminant(n, a, preserve_mat)
Invert a real symmetric or complex Hermitian square matrix a.
Definition: lalg_adv.F90:2804
subroutine lalg_dgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
Definition: lalg_adv.F90:249
subroutine, public zlalg_matrix_function(n, factor, a, fun_a, fun, hermitian)
This routine calculates a function of a matrix by using an eigenvalue decomposition.
Definition: lalg_adv.F90:2089
subroutine dlowest_eigensolve(k, n, a, e, v, preserve_mat)
Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem,...
Definition: lalg_adv.F90:2715
subroutine dsvd_inverse(m, n, a, threshold)
computes inverse of a real NxN matrix a(:,:) using the SVD decomposition
Definition: lalg_adv.F90:3161
subroutine, public zlalg_phi(nn, pp, aa, ex, hermitian)
Definition: lalg_adv.F90:388
subroutine zsvd_inverse(m, n, a, threshold)
computes inverse of a complex MxN matrix a(:,:) using the SVD decomposition
Definition: lalg_adv.F90:1730
This module contains interfaces for LAPACK routines.
Definition: lapack.F90:118
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
This module contains interfaces for ScaLAPACK routines Interfaces are from http:
Definition: scalapack.F90:131
This module is intended to contain "only mathematical" functions and procedures.
Definition: sort.F90:117
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:118
int true(void)