ergo
template_blas_axpy.h
Go to the documentation of this file.
1/* Ergo, version 3.8.2, a program for linear scaling electronic structure
2 * calculations.
3 * Copyright (C) 2023 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4 * and Anastasia Kruchinina.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Primary academic reference:
20 * Ergo: An open-source program for linear-scaling electronic structure
21 * calculations,
22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23 * Kruchinina,
24 * SoftwareX 7, 107 (2018),
25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26 *
27 * For further information about Ergo, see <http://www.ergoscf.org>.
28 */
29
30 /* This file belongs to the template_lapack part of the Ergo source
31 * code. The source files in the template_lapack directory are modified
32 * versions of files originally distributed as CLAPACK, see the
33 * Copyright/license notice in the file template_lapack/COPYING.
34 */
35
36
37#ifndef TEMPLATE_BLAS_AXPY_HEADER
38#define TEMPLATE_BLAS_AXPY_HEADER
39
41
42template<class Treal>
43int template_blas_axpy(const integer *n, const Treal *da, const Treal *dx,
44 const integer *incx, Treal *dy, const integer *incy)
45{
46 /* System generated locals */
47 integer i__1;
48 /* Local variables */
49 integer i__, m, ix, iy, mp1;
50/* constant times a vector plus a vector.
51 uses unrolled loops for increments equal to one.
52 jack dongarra, linpack, 3/11/78.
53 modified 12/3/93, array(1) declarations changed to array(*)
54 Parameter adjustments */
55 --dy;
56 --dx;
57 /* Function Body */
58 if (*n <= 0) {
59 return 0;
60 }
61 if (*da == 0.) {
62 return 0;
63 }
64 if (*incx == 1 && *incy == 1) {
65 goto L20;
66 }
67/* code for unequal increments or equal increments
68 not equal to 1 */
69 ix = 1;
70 iy = 1;
71 if (*incx < 0) {
72 ix = (-(*n) + 1) * *incx + 1;
73 }
74 if (*incy < 0) {
75 iy = (-(*n) + 1) * *incy + 1;
76 }
77 i__1 = *n;
78 for (i__ = 1; i__ <= i__1; ++i__) {
79 dy[iy] += *da * dx[ix];
80 ix += *incx;
81 iy += *incy;
82/* L10: */
83 }
84 return 0;
85/* code for both increments equal to 1
86 clean-up loop */
87L20:
88 m = *n % 4;
89 if (m == 0) {
90 goto L40;
91 }
92 i__1 = m;
93 for (i__ = 1; i__ <= i__1; ++i__) {
94 dy[i__] += *da * dx[i__];
95/* L30: */
96 }
97 if (*n < 4) {
98 return 0;
99 }
100L40:
101 mp1 = m + 1;
102 i__1 = *n;
103 for (i__ = mp1; i__ <= i__1; i__ += 4) {
104 dy[i__] += *da * dx[i__];
105 dy[i__ + 1] += *da * dx[i__ + 1];
106 dy[i__ + 2] += *da * dx[i__ + 2];
107 dy[i__ + 3] += *da * dx[i__ + 3];
108/* L50: */
109 }
110 return 0;
111} /* daxpy_ */
112
113#endif
int template_blas_axpy(const integer *n, const Treal *da, const Treal *dx, const integer *incx, Treal *dy, const integer *incy)
Definition template_blas_axpy.h:43
int integer
Definition template_blas_common.h:40