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