template_lapack_lacpy.h

Go to the documentation of this file.
00001 /* Ergo, version 3.2, a program for linear scaling electronic structure
00002  * calculations.
00003  * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  * 
00018  * Primary academic reference:
00019  * Kohn−Sham Density Functional Theory Electronic Structure Calculations 
00020  * with Linearly Scaling Computational Time and Memory Usage,
00021  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
00022  * J. Chem. Theory Comput. 7, 340 (2011),
00023  * <http://dx.doi.org/10.1021/ct100611z>
00024  * 
00025  * For further information about Ergo, see <http://www.ergoscf.org>.
00026  */
00027  
00028  /* This file belongs to the template_lapack part of the Ergo source 
00029   * code. The source files in the template_lapack directory are modified
00030   * versions of files originally distributed as CLAPACK, see the
00031   * Copyright/license notice in the file template_lapack/COPYING.
00032   */
00033  
00034 
00035 #ifndef TEMPLATE_LAPACK_LACPY_HEADER
00036 #define TEMPLATE_LAPACK_LACPY_HEADER
00037 
00038 
00039 template<class Treal>
00040 int template_lapack_lacpy(const char *uplo, const integer *m, const integer *n, const Treal *
00041         a, const integer *lda, Treal *b, const integer *ldb)
00042 {
00043 /*  -- LAPACK auxiliary routine (version 3.0) --   
00044        Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
00045        Courant Institute, Argonne National Lab, and Rice University   
00046        February 29, 1992   
00047 
00048 
00049     Purpose   
00050     =======   
00051 
00052     DLACPY copies all or part of a two-dimensional matrix A to another   
00053     matrix B.   
00054 
00055     Arguments   
00056     =========   
00057 
00058     UPLO    (input) CHARACTER*1   
00059             Specifies the part of the matrix A to be copied to B.   
00060             = 'U':      Upper triangular part   
00061             = 'L':      Lower triangular part   
00062             Otherwise:  All of the matrix A   
00063 
00064     M       (input) INTEGER   
00065             The number of rows of the matrix A.  M >= 0.   
00066 
00067     N       (input) INTEGER   
00068             The number of columns of the matrix A.  N >= 0.   
00069 
00070     A       (input) DOUBLE PRECISION array, dimension (LDA,N)   
00071             The m by n matrix A.  If UPLO = 'U', only the upper triangle   
00072             or trapezoid is accessed; if UPLO = 'L', only the lower   
00073             triangle or trapezoid is accessed.   
00074 
00075     LDA     (input) INTEGER   
00076             The leading dimension of the array A.  LDA >= max(1,M).   
00077 
00078     B       (output) DOUBLE PRECISION array, dimension (LDB,N)   
00079             On exit, B = A in the locations specified by UPLO.   
00080 
00081     LDB     (input) INTEGER   
00082             The leading dimension of the array B.  LDB >= max(1,M).   
00083 
00084     =====================================================================   
00085 
00086 
00087        Parameter adjustments */
00088     /* System generated locals */
00089     integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00090     /* Local variables */
00091      integer i__, j;
00092 #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1]
00093 #define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1]
00094 
00095     a_dim1 = *lda;
00096     a_offset = 1 + a_dim1 * 1;
00097     a -= a_offset;
00098     b_dim1 = *ldb;
00099     b_offset = 1 + b_dim1 * 1;
00100     b -= b_offset;
00101 
00102     /* Function Body */
00103     if (template_blas_lsame(uplo, "U")) {
00104         i__1 = *n;
00105         for (j = 1; j <= i__1; ++j) {
00106             i__2 = minMACRO(j,*m);
00107             for (i__ = 1; i__ <= i__2; ++i__) {
00108                 b_ref(i__, j) = a_ref(i__, j);
00109 /* L10: */
00110             }
00111 /* L20: */
00112         }
00113     } else if (template_blas_lsame(uplo, "L")) {
00114         i__1 = *n;
00115         for (j = 1; j <= i__1; ++j) {
00116             i__2 = *m;
00117             for (i__ = j; i__ <= i__2; ++i__) {
00118                 b_ref(i__, j) = a_ref(i__, j);
00119 /* L30: */
00120             }
00121 /* L40: */
00122         }
00123     } else {
00124         i__1 = *n;
00125         for (j = 1; j <= i__1; ++j) {
00126             i__2 = *m;
00127             for (i__ = 1; i__ <= i__2; ++i__) {
00128                 b_ref(i__, j) = a_ref(i__, j);
00129 /* L50: */
00130             }
00131 /* L60: */
00132         }
00133     }
00134     return 0;
00135 
00136 /*     End of DLACPY */
00137 
00138 } /* dlacpy_ */
00139 
00140 #undef b_ref
00141 #undef a_ref
00142 
00143 
00144 #endif

Generated on Wed Nov 21 09:32:11 2012 for ergo by  doxygen 1.4.7