ergo
template_lapack_lacpy.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 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_LAPACK_LACPY_HEADER
38 #define TEMPLATE_LAPACK_LACPY_HEADER
39 
40 
41 template<class Treal>
42 int template_lapack_lacpy(const char *uplo, const integer *m, const integer *n, const Treal *
43  a, const integer *lda, Treal *b, const integer *ldb)
44 {
45 /* -- LAPACK auxiliary routine (version 3.0) --
46  Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
47  Courant Institute, Argonne National Lab, and Rice University
48  February 29, 1992
49 
50 
51  Purpose
52  =======
53 
54  DLACPY copies all or part of a two-dimensional matrix A to another
55  matrix B.
56 
57  Arguments
58  =========
59 
60  UPLO (input) CHARACTER*1
61  Specifies the part of the matrix A to be copied to B.
62  = 'U': Upper triangular part
63  = 'L': Lower triangular part
64  Otherwise: All of the matrix A
65 
66  M (input) INTEGER
67  The number of rows of the matrix A. M >= 0.
68 
69  N (input) INTEGER
70  The number of columns of the matrix A. N >= 0.
71 
72  A (input) DOUBLE PRECISION array, dimension (LDA,N)
73  The m by n matrix A. If UPLO = 'U', only the upper triangle
74  or trapezoid is accessed; if UPLO = 'L', only the lower
75  triangle or trapezoid is accessed.
76 
77  LDA (input) INTEGER
78  The leading dimension of the array A. LDA >= max(1,M).
79 
80  B (output) DOUBLE PRECISION array, dimension (LDB,N)
81  On exit, B = A in the locations specified by UPLO.
82 
83  LDB (input) INTEGER
84  The leading dimension of the array B. LDB >= max(1,M).
85 
86  =====================================================================
87 
88 
89  Parameter adjustments */
90  /* System generated locals */
91  integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
92  /* Local variables */
93  integer i__, j;
94 #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1]
95 #define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1]
96 
97  a_dim1 = *lda;
98  a_offset = 1 + a_dim1 * 1;
99  a -= a_offset;
100  b_dim1 = *ldb;
101  b_offset = 1 + b_dim1 * 1;
102  b -= b_offset;
103 
104  /* Function Body */
105  if (template_blas_lsame(uplo, "U")) {
106  i__1 = *n;
107  for (j = 1; j <= i__1; ++j) {
108  i__2 = minMACRO(j,*m);
109  for (i__ = 1; i__ <= i__2; ++i__) {
110  b_ref(i__, j) = a_ref(i__, j);
111 /* L10: */
112  }
113 /* L20: */
114  }
115  } else if (template_blas_lsame(uplo, "L")) {
116  i__1 = *n;
117  for (j = 1; j <= i__1; ++j) {
118  i__2 = *m;
119  for (i__ = j; i__ <= i__2; ++i__) {
120  b_ref(i__, j) = a_ref(i__, j);
121 /* L30: */
122  }
123 /* L40: */
124  }
125  } else {
126  i__1 = *n;
127  for (j = 1; j <= i__1; ++j) {
128  i__2 = *m;
129  for (i__ = 1; i__ <= i__2; ++i__) {
130  b_ref(i__, j) = a_ref(i__, j);
131 /* L50: */
132  }
133 /* L60: */
134  }
135  }
136  return 0;
137 
138 /* End of DLACPY */
139 
140 } /* dlacpy_ */
141 
142 #undef b_ref
143 #undef a_ref
144 
145 
146 #endif
a_ref
#define a_ref(a_1, a_2)
minMACRO
#define minMACRO(a, b)
Definition: template_blas_common.h:46
template_lapack_lacpy
int template_lapack_lacpy(const char *uplo, const integer *m, const integer *n, const Treal *a, const integer *lda, Treal *b, const integer *ldb)
Definition: template_lapack_lacpy.h:42
b_ref
#define b_ref(a_1, a_2)
template_blas_lsame
logical template_blas_lsame(const char *ca, const char *cb)
Definition: template_blas_common.cc:46
integer
int integer
Definition: template_blas_common.h:40