ergo
template_blas_copy.h
Go to the documentation of this file.
1 /* Ergo, version 3.3, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2013 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
4  *
5  * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Primary academic reference:
19  * Kohn−Sham Density Functional Theory Electronic Structure Calculations
20  * with Linearly Scaling Computational Time and Memory Usage,
21  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
22  * J. Chem. Theory Comput. 7, 340 (2011),
23  * <http://dx.doi.org/10.1021/ct100611z>
24  *
25  * For further information about Ergo, see <http://www.ergoscf.org>.
26  */
27 
28  /* This file belongs to the template_lapack part of the Ergo source
29  * code. The source files in the template_lapack directory are modified
30  * versions of files originally distributed as CLAPACK, see the
31  * Copyright/license notice in the file template_lapack/COPYING.
32  */
33 
34 
35 #ifndef TEMPLATE_BLAS_COPY_HEADER
36 #define TEMPLATE_BLAS_COPY_HEADER
37 
38 
39 template<class Treal>
40 int template_blas_copy(const integer *n, const Treal *dx, const integer *incx,
41  Treal *dy, const integer *incy)
42 {
43  /* System generated locals */
44  integer i__1;
45  /* Local variables */
46  integer i__, m, ix, iy, mp1;
47 /* copies a vector, x, to a vector, y.
48  uses unrolled loops for increments equal to one.
49  jack dongarra, linpack, 3/11/78.
50  modified 12/3/93, array(1) declarations changed to array(*)
51  Parameter adjustments */
52  --dy;
53  --dx;
54  /* Function Body */
55  if (*n <= 0) {
56  return 0;
57  }
58  if (*incx == 1 && *incy == 1) {
59  goto L20;
60  }
61 /* code for unequal increments or equal increments
62  not equal to 1 */
63  ix = 1;
64  iy = 1;
65  if (*incx < 0) {
66  ix = (-(*n) + 1) * *incx + 1;
67  }
68  if (*incy < 0) {
69  iy = (-(*n) + 1) * *incy + 1;
70  }
71  i__1 = *n;
72  for (i__ = 1; i__ <= i__1; ++i__) {
73  dy[iy] = dx[ix];
74  ix += *incx;
75  iy += *incy;
76 /* L10: */
77  }
78  return 0;
79 /* code for both increments equal to 1
80  clean-up loop */
81 L20:
82  m = *n % 7;
83  if (m == 0) {
84  goto L40;
85  }
86  i__1 = m;
87  for (i__ = 1; i__ <= i__1; ++i__) {
88  dy[i__] = dx[i__];
89 /* L30: */
90  }
91  if (*n < 7) {
92  return 0;
93  }
94 L40:
95  mp1 = m + 1;
96  i__1 = *n;
97  for (i__ = mp1; i__ <= i__1; i__ += 7) {
98  dy[i__] = dx[i__];
99  dy[i__ + 1] = dx[i__ + 1];
100  dy[i__ + 2] = dx[i__ + 2];
101  dy[i__ + 3] = dx[i__ + 3];
102  dy[i__ + 4] = dx[i__ + 4];
103  dy[i__ + 5] = dx[i__ + 5];
104  dy[i__ + 6] = dx[i__ + 6];
105 /* L50: */
106  }
107  return 0;
108 } /* dcopy_ */
109 
110 #endif
int integer
Definition: template_blas_common.h:38
int template_blas_copy(const integer *n, const Treal *dx, const integer *incx, Treal *dy, const integer *incy)
Definition: template_blas_copy.h:40