Octopus
blas.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
21! -----------------------------------------------------------------------
24! -----------------------------------------------------------------------
25module blas_oct_m
26
27 implicit none
28
29 public ! interfaces, plus the wrappers below, in this module
30
31 ! ---------------------------------------------------------------------
32 ! BLAS level I
33 ! ---------------------------------------------------------------------
34
37 interface blas_swap
38 subroutine dswap(n, dx, incx, dy, incy)
39 use, intrinsic :: iso_fortran_env
40 implicit none
41 integer, intent(in) :: n, incx, incy
42 real(real64), intent(inout) :: dx, dy
43 end subroutine dswap
44
45 subroutine zswap(n, dx, incx, dy, incy)
46 use, intrinsic :: iso_fortran_env
47 implicit none
48 integer, intent(in) :: n, incx, incy
49 complex(real64), intent(inout) :: dx, dy
50 end subroutine zswap
51 end interface blas_swap
52
55 interface blas_scal
56 subroutine dscal(n, da, dx, incx)
57 use, intrinsic :: iso_fortran_env
58 implicit none
59 integer, intent(in) :: n, incx
60 real(real64), intent(in) :: da
61 real(real64), intent(inout) :: dx
62 end subroutine dscal
63
64 subroutine zscal(n, da, dx, incx)
65 use, intrinsic :: iso_fortran_env
66 implicit none
67 integer, intent(in) :: n, incx
68 complex(real64), intent(in) :: da
69 complex(real64), intent(inout) :: dx
70 end subroutine zscal
71
72 subroutine zdscal(n, da, dx, incx)
73 use, intrinsic :: iso_fortran_env
74 implicit none
75 integer, intent(in) :: n, incx
76 real(real64), intent(in) :: da
77 complex(real64), intent(inout) :: dx
78 end subroutine zdscal
79 end interface blas_scal
80
83 interface blas_axpy
84 subroutine daxpy (n, da, dx, incx, dy, incy)
85 use, intrinsic :: iso_fortran_env
86 implicit none
87 integer, intent(in) :: n, incx, incy
88 real(real64), intent(in) :: da, dx
89 real(real64), intent(inout) :: dy
90 end subroutine daxpy
91
92 subroutine zaxpy (n, da, dx, incx, dy, incy)
93 use, intrinsic :: iso_fortran_env
94 implicit none
95 integer, intent(in) :: n, incx, incy
96 complex(real64), intent(in) :: da, dx
97 complex(real64), intent(inout) :: dy
98 end subroutine zaxpy
99
100 module procedure dazaxpy
101 end interface blas_axpy
102
105 interface blas_copy
106 subroutine dcopy(n, dx, incx, dy, incy)
107 use, intrinsic :: iso_fortran_env
108 implicit none
109 integer, intent(in) :: n, incx, incy
110 real(real64), intent(in) :: dx
111 real(real64), intent(out) :: dy
112 end subroutine dcopy
113
114 subroutine zcopy(n, dx, incx, dy, incy)
115 use, intrinsic :: iso_fortran_env
116 implicit none
117 integer, intent(in) :: n, incx, incy
118 complex(real64), intent(in) :: dx
119 complex(real64), intent(out) :: dy
120 end subroutine zcopy
121 end interface blas_copy
122
125 interface blas_dot
126 real(real64) function ddot(n, dx, incx, dy, incy)
127 use, intrinsic :: iso_fortran_env
128 implicit none
129 integer, intent(in) :: n, incx, incy
130 real(real64), intent(in) :: dx, dy
131 end function ddot
133#if defined(HAVE_ACCELERATE)
134 module procedure zdotc
135#else
136 complex(real64) function zdotc(n, dx, incx, dy, incy)
137 use, intrinsic :: iso_fortran_env
138 implicit none
139 integer, intent(in) :: n, incx, incy
140 complex(real64), intent(in) :: dx, dy
141 end function zdotc
142#endif
143 end interface blas_dot
144
145 interface blas_dotu
146#if defined(HAVE_ACCELERATE)
147 module procedure zdotu
148#else
149 complex(real64) function zdotu(n, dx, incx, dy, incy)
150 use, intrinsic :: iso_fortran_env
151 implicit none
152 integer, intent(in) :: n, incx, incy
153 complex(real64), intent(in) :: dx, dy
154 end function zdotu
155#endif
156 end interface blas_dotu
157
164 interface blas_nrm2
165 real(real64) function dnrm2(n, dx, incx)
166 use, intrinsic :: iso_fortran_env
167 implicit none
168 integer, intent(in) :: n, incx
169 real(real64), intent(in) :: dx
170 end function dnrm2
171
172 real(real64) function dznrm2(n, dx, incx)
173 use, intrinsic :: iso_fortran_env
174 implicit none
175 integer, intent(in) :: n, incx
176 complex(real64), intent(in) :: dx
177 end function dznrm2
178 end interface blas_nrm2
180
181 ! ------------------------------------------------------------------
182 ! BLAS level II
183 ! ------------------------------------------------------------------
184
194 interface blas_symv
195 subroutine dsymv(uplo, n, alpha, a, lda, x, incx, beta, y, incy)
196 use, intrinsic :: iso_fortran_env
197 implicit none
198 character(1), intent(in) :: uplo
199 integer, intent(in) :: n, lda, incx, incy
200 real(real64), intent(in) :: alpha, beta
201 real(real64), intent(in) :: a
202 real(real64), intent(in) :: x
203 real(real64), intent(inout) :: y
204 end subroutine dsymv
205
206 subroutine zsymv(uplo, n, alpha, a, lda, x, incx, beta, y, incy)
207 use, intrinsic :: iso_fortran_env
208 implicit none
209 character(1), intent(in) :: uplo
210 integer, intent(in) :: n, lda, incx, incy
211 complex(real64), intent(in) :: alpha, beta
212 complex(real64), intent(in) :: a
213 complex(real64), intent(in) :: x
214 complex(real64), intent(inout) :: y
215 end subroutine zsymv
216 end interface blas_symv
217
231 interface blas_gemv
232 subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
233 use, intrinsic :: iso_fortran_env
234 implicit none
235 character(1), intent(in) :: trans
236 integer, intent(in) :: m, n, lda, incx, incy
237 real(real64), intent(in) :: alpha, beta
238 real(real64), intent(in) :: a
239 real(real64), intent(in) :: x
240 real(real64), intent(inout) :: y
241 end subroutine dgemv
242
243 subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
244 use, intrinsic :: iso_fortran_env
245 implicit none
246 character(1), intent(in) :: trans
247 integer, intent(in) :: m, n, lda, incx, incy
248 complex(real64), intent(in) :: alpha, beta
249 complex(real64), intent(in) :: a
250 complex(real64), intent(in) :: x
251 complex(real64), intent(inout) :: y
252 end subroutine zgemv
253 end interface blas_gemv
254
255
256 ! ------------------------------------------------------------------
257 ! BLAS level III
258 ! ------------------------------------------------------------------
276 interface blas_gemm
277 subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
278 use, intrinsic :: iso_fortran_env
279 implicit none
280 character(1), intent(in) :: transa, transb
281 integer, intent(in) :: m, n, k, lda, ldb, ldc
282 real(real64), intent(in) :: alpha, beta
283 real(real64), intent(in) :: a
284 real(real64), intent(in) :: b
285 real(real64), intent(inout) :: c
286 end subroutine dgemm
287
288 subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
289 use, intrinsic :: iso_fortran_env
290 implicit none
291 character(1), intent(in) :: transa, transb
292 integer, intent(in) :: m, n, k, lda, ldb, ldc
293 complex(real64), intent(in) :: alpha, beta
294 complex(real64), intent(in) :: a
295 complex(real64), intent(in) :: b
296 complex(real64), intent(inout) :: c
297 end subroutine zgemm
298
299 module procedure zdgemm
300 end interface
316 interface blas_trmm
317 subroutine dtrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
318 use, intrinsic :: iso_fortran_env
319 implicit none
320 character(1), intent(in) :: side, uplo, transa, diag
321 integer, intent(in) :: m, n, lda, ldb
322 real(real64), intent(in) :: a, alpha
323 real(real64), intent(inout) :: b
324 end subroutine dtrmm
325
326 subroutine ztrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
327 use, intrinsic :: iso_fortran_env
328 implicit none
329 character(1), intent(in) :: side, uplo, transa, diag
330 integer, intent(in) :: m, n, lda, ldb
331 complex(real64), intent(in) :: a, alpha
332 complex(real64), intent(inout) :: b
333 end subroutine ztrmm
334 end interface blas_trmm
335
351 interface blas_symm
352 subroutine dsymm(side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc)
353 use, intrinsic :: iso_fortran_env
354 implicit none
355 character(1), intent(in) :: side, uplo
356 integer, intent(in) :: m, n, lda, ldb, ldc
357 real(real64), intent(in) :: alpha, beta, a, b
358 real(real64), intent(inout) :: c
359 end subroutine dsymm
360
361 subroutine zsymm(side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc)
362 use, intrinsic :: iso_fortran_env
363 implicit none
364 character(1), intent(in) :: side, uplo
365 integer, intent(in) :: m, n, lda, ldb, ldc
366 complex(real64), intent(in) :: alpha, beta, a, b
367 complex(real64), intent(inout) :: c
368 end subroutine zsymm
369 end interface blas_symm
370
387 interface blas_herk
388 subroutine dsyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
389 use, intrinsic :: iso_fortran_env
390 implicit none
391 character(1), intent(in) :: uplo, trans
392 integer, intent(in) :: n, k, lda, ldc
393 real(real64), intent(in) :: alpha, beta, a
394 real(real64), intent(inout) :: c
395 end subroutine dsyrk
396
397 subroutine zherk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
398 use, intrinsic :: iso_fortran_env
399 implicit none
400 character(1), intent(in) :: uplo, trans
401 integer, intent(in) :: n, k, lda, ldc
402 real(real64), intent(in) :: alpha, beta
403 complex(real64), intent(in) :: a
404 complex(real64), intent(inout) :: c
405 end subroutine zherk
406 end interface blas_herk
407
428 interface blas_trsm
429 subroutine dtrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
430 use, intrinsic :: iso_fortran_env
431 implicit none
432 character(1), intent(in) :: side
433 character(1), intent(in) :: uplo
434 character(1), intent(in) :: transa
435 character(1), intent(in) :: diag
436 integer, intent(in) :: m
437 integer, intent(in) :: n
438 real(real64), intent(in) :: alpha
439 real(real64), intent(in) :: a
440 integer, intent(in) :: lda
441 real(real64), intent(inout) :: b
442 integer, intent(in) :: ldb
443 end subroutine dtrsm
444
445 subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
446 use, intrinsic :: iso_fortran_env
447 implicit none
448 character(1), intent(in) :: side
449 character(1), intent(in) :: uplo
450 character(1), intent(in) :: transa
451 character(1), intent(in) :: diag
452 integer, intent(in) :: m
453 integer, intent(in) :: n
454 complex(real64), intent(in) :: alpha
455 complex(real64), intent(in) :: a
456 integer, intent(in) :: lda
457 complex(real64), intent(inout) :: b
458 integer, intent(in) :: ldb
459 end subroutine ztrsm
460 end interface blas_trsm
461
462contains
463
464#if defined(HAVE_ACCELERATE)
465
472 complex(real64) function zdotc(n, dx, incx, dy, incy)
473 use, intrinsic :: iso_c_binding
474 use, intrinsic :: iso_fortran_env
475 implicit none
476 integer, intent(in) :: n, incx, incy
477 complex(real64), intent(in) :: dx, dy
478
479 interface
480 subroutine cblas_zdotc_sub(n, x, incx, y, incy, dotc) bind(c, name="cblas_zdotc_sub")
481 use, intrinsic :: iso_c_binding
482 implicit none
483 integer(c_int), intent(in), value :: n, incx, incy
484 complex(c_double_complex), intent(in) :: x, y
485 complex(c_double_complex), intent(out) :: dotc
486 end subroutine cblas_zdotc_sub
487 end interface
488
489 ! no PUSH_SUB, called too often
490
491 call cblas_zdotc_sub(n, dx, incx, dy, incy, zdotc)
493 end function zdotc
494
498 complex(real64) function zdotu(n, dx, incx, dy, incy)
499 use, intrinsic :: iso_c_binding
500 use, intrinsic :: iso_fortran_env
501 implicit none
502 integer, intent(in) :: n, incx, incy
503 complex(real64), intent(in) :: dx, dy
504
505 interface
506 subroutine cblas_zdotu_sub(n, x, incx, y, incy, dotu) bind(c, name="cblas_zdotu_sub")
507 use, intrinsic :: iso_c_binding
508 implicit none
509 integer(c_int), intent(in), value :: n, incx, incy
510 complex(c_double_complex), intent(in) :: x, y
511 complex(c_double_complex), intent(out) :: dotu
512 end subroutine cblas_zdotu_sub
513 end interface
514
515 ! no PUSH_SUB, called too often
516
517 call cblas_zdotu_sub(n, dx, incx, dy, incy, zdotu)
518
519 end function zdotu
520#endif
521
526 subroutine dazaxpy(n, da, dx, dy)
527 use, intrinsic :: iso_c_binding
528 use, intrinsic :: iso_fortran_env
529 implicit none
530 integer, intent(in) :: n
531 real(real64), intent(in) :: da
532 complex(real64), intent(in), target :: dx
533 complex(real64), intent(inout), target :: dy
534
535 real(real64), pointer :: rx, ry
536
537 ! no PUSH_SUB, called too often
538
539 call c_f_pointer(c_loc(dx), rx)
540 call c_f_pointer(c_loc(dy), ry)
541
542 call blas_axpy(2*n, da, rx, 1, ry, 1)
543
544 end subroutine dazaxpy
545
551 subroutine zdgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
552 use, intrinsic :: iso_c_binding
553 use, intrinsic :: iso_fortran_env
554 implicit none
555 character(1), intent(in) :: transa, transb
556 integer, intent(in) :: m, n, k, lda, ldb, ldc
557 real(real64), intent(in) :: alpha, beta
558 complex(real64), intent(in), target :: a
559 real(real64), intent(in) :: b
560 complex(real64), intent(inout), target :: c
561
562 real(real64), pointer :: ra, rc
564 ! no PUSH_SUB, called too often
565
566 call c_f_pointer(c_loc(a), ra)
567 call c_f_pointer(c_loc(c), rc)
568
569 call blas_gemm(transa, transb, m, n, k, alpha, ra, lda, b, ldb, beta, rc, ldc)
570
571 end subroutine zdgemm
572
573end module blas_oct_m
574
575
576!! Local Variables:
577!! mode: f90
578!! coding: utf-8
579!! End:
--------------— axpy ---------------— Constant times a vector plus a vector.
Definition: blas.F90:178
--------------— copy ---------------— Copies a vector, x, to a vector, y.
Definition: blas.F90:200
--------------— dot ---------------— Forms the dot product of two vectors.
Definition: blas.F90:220
--------------— gemm ---------------— performs one of the matrix-matrix operations
Definition: blas.F90:371
--------------— gemv ---------------— SGEMV performs one of the matrix-vector operations
Definition: blas.F90:326
--------------— syrk, herk ---------------— performs one of the symmetric rank k operations
Definition: blas.F90:482
--------------— nrm2 ---------------— Returns the euclidean norm of a vector via the function name,...
Definition: blas.F90:259
--------------— scal ---------------— Scales a vector by a constant.
Definition: blas.F90:150
--------------— swap ---------------— Interchanges two vectors.
Definition: blas.F90:132
--------------— symm, hemm ---------------— performs one of the matrix-matrix operations
Definition: blas.F90:446
--------------— symv ---------------— performs the matrix-vector operation
Definition: blas.F90:289
--------------— trmm ---------------— Performs one of the matrix-matrix operations
Definition: blas.F90:411
--------------------—trsm----------------------— Solves one of the matrix equations
Definition: blas.F90:523
void cblas_zdotc_sub(const int N, const void *X, const int incX, const void *Y, const int incY, void *dotc)
void cblas_zdotu_sub(const int N, const void *X, const int incX, const void *Y, const int incY, void *dotu)
This module contains interfaces for BLAS routines You should not use these routines directly....
Definition: blas.F90:120
subroutine zdgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
A real matrix multiplying a complex one, added to a complex matrix.
Definition: blas.F90:589
subroutine dazaxpy(n, da, dx, dy)
A real constant times a complex vector plus a complex vector.
Definition: blas.F90:564