ergo
template_blas_scal.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_SCAL_HEADER
36 #define TEMPLATE_BLAS_SCAL_HEADER
37 
38 #include "template_blas_common.h"
39 
40 template<class Treal>
41 int template_blas_scal(const integer *n, const Treal *da, Treal *dx,
42  const integer *incx)
43 {
44  /* System generated locals */
45  integer i__1, i__2;
46  /* Local variables */
47  integer i__, m, nincx, mp1;
48 /* scales a vector by a constant.
49  uses unrolled loops for increment equal to one.
50  jack dongarra, linpack, 3/11/78.
51  modified 3/93 to return if incx .le. 0.
52  modified 12/3/93, array(1) declarations changed to array(*)
53  Parameter adjustments */
54  --dx;
55  /* Function Body */
56  if (*n <= 0 || *incx <= 0) {
57  return 0;
58  }
59  if (*incx == 1) {
60  goto L20;
61  }
62 /* code for increment not equal to 1 */
63  nincx = *n * *incx;
64  i__1 = nincx;
65  i__2 = *incx;
66  for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
67  dx[i__] = *da * dx[i__];
68 /* L10: */
69  }
70  return 0;
71 /* code for increment equal to 1
72  clean-up loop */
73 L20:
74  m = *n % 5;
75  if (m == 0) {
76  goto L40;
77  }
78  i__2 = m;
79  for (i__ = 1; i__ <= i__2; ++i__) {
80  dx[i__] = *da * dx[i__];
81 /* L30: */
82  }
83  if (*n < 5) {
84  return 0;
85  }
86 L40:
87  mp1 = m + 1;
88  i__2 = *n;
89  for (i__ = mp1; i__ <= i__2; i__ += 5) {
90  dx[i__] = *da * dx[i__];
91  dx[i__ + 1] = *da * dx[i__ + 1];
92  dx[i__ + 2] = *da * dx[i__ + 2];
93  dx[i__ + 3] = *da * dx[i__ + 3];
94  dx[i__ + 4] = *da * dx[i__ + 4];
95 /* L50: */
96  }
97  return 0;
98 } /* dscal_ */
99 
100 #endif
int template_blas_scal(const integer *n, const Treal *da, Treal *dx, const integer *incx)
Definition: template_blas_scal.h:41
int integer
Definition: template_blas_common.h:38