ergo
template_blas_copy.h
Go to the documentation of this file.
1 /* Ergo, version 3.7, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2018 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_COPY_HEADER
38 #define TEMPLATE_BLAS_COPY_HEADER
39 
40 
41 template<class Treal>
42 int template_blas_copy(const integer *n, const Treal *dx, const integer *incx,
43  Treal *dy, const integer *incy)
44 {
45  /* System generated locals */
46  integer i__1;
47  /* Local variables */
48  integer i__, m, ix, iy, mp1;
49 /* copies a vector, x, to a vector, y.
50  uses unrolled loops for increments equal to one.
51  jack dongarra, linpack, 3/11/78.
52  modified 12/3/93, array(1) declarations changed to array(*)
53  Parameter adjustments */
54  --dy;
55  --dx;
56  /* Function Body */
57  if (*n <= 0) {
58  return 0;
59  }
60  if (*incx == 1 && *incy == 1) {
61  goto L20;
62  }
63 /* code for unequal increments or equal increments
64  not equal to 1 */
65  ix = 1;
66  iy = 1;
67  if (*incx < 0) {
68  ix = (-(*n) + 1) * *incx + 1;
69  }
70  if (*incy < 0) {
71  iy = (-(*n) + 1) * *incy + 1;
72  }
73  i__1 = *n;
74  for (i__ = 1; i__ <= i__1; ++i__) {
75  dy[iy] = dx[ix];
76  ix += *incx;
77  iy += *incy;
78 /* L10: */
79  }
80  return 0;
81 /* code for both increments equal to 1
82  clean-up loop */
83 L20:
84  m = *n % 7;
85  if (m == 0) {
86  goto L40;
87  }
88  i__1 = m;
89  for (i__ = 1; i__ <= i__1; ++i__) {
90  dy[i__] = dx[i__];
91 /* L30: */
92  }
93  if (*n < 7) {
94  return 0;
95  }
96 L40:
97  mp1 = m + 1;
98  i__1 = *n;
99  for (i__ = mp1; i__ <= i__1; i__ += 7) {
100  dy[i__] = dx[i__];
101  dy[i__ + 1] = dx[i__ + 1];
102  dy[i__ + 2] = dx[i__ + 2];
103  dy[i__ + 3] = dx[i__ + 3];
104  dy[i__ + 4] = dx[i__ + 4];
105  dy[i__ + 5] = dx[i__ + 5];
106  dy[i__ + 6] = dx[i__ + 6];
107 /* L50: */
108  }
109  return 0;
110 } /* dcopy_ */
111 
112 #endif
int integer
Definition: template_blas_common.h:40
int template_blas_copy(const integer *n, const Treal *dx, const integer *incx, Treal *dy, const integer *incy)
Definition: template_blas_copy.h:42