qrupdate-ng 1.2.0
Loading...
Searching...
No Matches
cdotc.f90
Go to the documentation of this file.
1! Copyright (C) 2026 Martin Köhler <koehlerm(AT)mpi-magdeburg.mpg.de>
2!
3! This file is part of qrupdate-ng.
4!
5! qrupdate is free software; you can redistribute it and/or modify
6! it under the terms of the GNU General Public License as published by
7! the Free Software Foundation; either version 3 of the License, or
8! (at your option) any later version.
9!
10! This program is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13! GNU General Public License for more details.
14!
15! You should have received a copy of the GNU General Public License
16! along with this software; see the file COPYING. If not, see
17! <http://www.gnu.org/licenses/>.
18!
19!> \brief CDOTC Complex dot product (x**H y version)
20!
21!> \par Definition:
22! ===========
23!> \verbatim
24!> SUBROUTINE QRUPDATE_CDOTC(RET, N,CX,INCX,CY,INCY)
25!>
26!> .. Scalar Arguments ..
27!> INTEGER INCX,INCY,N
28!> COMPLEX(real32) ret
29!> ..
30!> .. Array Arguments ..
31!> COMPLEX(real32) CX(*),CY(*)
32!> ..
33!> \endverbatim
34!
35!> \par Purpose:
36! =============
37!>
38!> \verbatim
39!>
40!> CDOTC forms the dot product of two complex vectors
41!> CDOTC = X^H * Y
42!>
43!> \endverbatim
44!
45! Arguments:
46! ==========
47!
48!> \param[out] RET
49!> \verbatim
50!> RET is COMPLEX(real32)
51!> RET contains the dot product.
52!> \endverbatim
53!>
54!> \param[in] N
55!> \verbatim
56!> N is INTEGER
57!> number of elements in input vector(s)
58!> \endverbatim
59!>
60!> \param[in] CX
61!> \verbatim
62!> CX is COMPLEX(real32) array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
63!> \endverbatim
64!>
65!> \param[in] INCX
66!> \verbatim
67!> INCX is INTEGER
68!> storage spacing between elements of CX
69!> \endverbatim
70!>
71!> \param[in] CY
72!> \verbatim
73!> CY is COMPLEX(real32) array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
74!> \endverbatim
75!>
76!> \param[in] INCY
77!> \verbatim
78!> INCY is INTEGER
79!> storage spacing between elements of CY
80!> \endverbatim
81!
82!> \remark This routine is equivalent to cdotc from BLAS but invariant with the compiler's Fortran ABI
83!
84!> \ingroup aux
85! =====================================================================
86subroutine qrupdate_cdotc(ret,n,cx,incx,cy,incy)
87 use iso_fortran_env
88 implicit none
89
90 ! .. scalar arguments ..
91 integer, intent(in) :: incx,incy,n
92 ! ..
93 ! .. array arguments ..
94 complex(real32), intent(in) :: cx(*),cy(*)
95 complex(real32), intent(out) :: ret
96 ! ..
97 !
98 ! .. local scalars ..
99 complex(real32) ctemp
100 integer i,ix,iy
101 ! ..
102 ctemp = (0.0,0.0)
103 ret = (0.0,0.0)
104 if (n.le.0) return
105 if (incx.eq.1 .and. incy.eq.1) then
106 !
107 ! code for both increments equal to 1
108 !
109 do i = 1,n
110 ctemp = ctemp + conjg(cx(i))*cy(i)
111 end do
112 else
113 !
114 ! code for unequal increments or equal increments
115 ! not equal to 1
116 !
117 ix = 1
118 iy = 1
119 if (incx.lt.0) ix = (-n+1)*incx + 1
120 if (incy.lt.0) iy = (-n+1)*incy + 1
121 do i = 1,n
122 ctemp = ctemp + conjg(cx(ix))*cy(iy)
123 ix = ix + incx
124 iy = iy + incy
125 end do
126 end if
127 ret = ctemp
128 return
129 !
130 ! end of cdotc
131 !
132end subroutine
subroutine qrupdate_cdotc(ret, n, cx, incx, cy, incy)
CDOTC Complex dot product (x**H y version).
Definition cdotc.f90:87