MADNESS 0.10.1
cblas_types.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2019 Virginia Tech
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 2 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, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30*/
31
32
33#ifndef MADNESS_LINALG_CBLAS_TYPES_H__INCLUDED
34#define MADNESS_LINALG_CBLAS_TYPES_H__INCLUDED
35
36/// \file cblas_types.h
37/// \brief Define types used by CBLAS API
38
40#include <complex>
41#if defined(HAVE_INTEL_MKL) && defined(MKL_DIRECT_CALL)
42// calling MKL directly needs its complex types; via the F77 prototypes no conversion is needed
43# include <mkl_types.h>
44#endif
45
46namespace madness {
47namespace cblas {
48
49 /// The complex types of the BLAS being called. These used to be the macros
50 /// blas_complex_float/double, in the LAPACKE style; blaspp declares typedefs of
51 /// those names and does not tolerate a pre-existing macro, so any translation
52 /// unit that included MADNESS before TiledArray failed to compile.
53#if defined(HAVE_INTEL_MKL) && defined(MKL_DIRECT_CALL)
54 using complex_float = MKL_Complex8;
55 using complex_double = MKL_Complex16;
56#else
57 using complex_float = std::complex<float>;
58 using complex_double = std::complex<double>;
59#endif
60 static_assert(sizeof(complex_float) == sizeof(std::complex<float>), "the BLAS single-precision complex type must match std::complex<float>");
61 static_assert(sizeof(complex_double) == sizeof(std::complex<double>), "the BLAS double-precision complex type must match std::complex<double>");
62
63 /// Matrix operations for BLAS function calls
64 typedef enum {
67 ConjTrans=2
69
70 /////////// legalized conversions between C++ and CBLAS types //////////
71 template <typename T>
72 const complex_float*
73 to_cptr(const T* ptr) {
74 static_assert(sizeof(T)==sizeof(complex_float), "sizes of complex_float and T given to madness::cblas::to_cptr do not match");
75 return reinterpret_cast<const complex_float*>(ptr);
76 }
77 template <typename T>
78 typename std::enable_if<!std::is_const<T>::value, complex_float*>::type
79 to_cptr(T* ptr) {
80 static_assert(sizeof(T)==sizeof(complex_float), "sizes of complex_float and T given to madness::cblas::to_cptr do not match");
81 return reinterpret_cast<complex_float*>(ptr);
82 }
83
84 template <typename T>
85 const complex_double*
86 to_zptr(const T* ptr) {
87 static_assert(sizeof(T)==sizeof(complex_double), "sizes of complex_double and T given to madness::cblas::to_zptr do not match");
88 return reinterpret_cast<const complex_double*>(ptr);
89 }
90 template <typename T>
91 typename std::enable_if<!std::is_const<T>::value, complex_double*>::type
92 to_zptr(T* ptr) {
93 static_assert(sizeof(T)==sizeof(complex_double), "sizes of complex_double and T given to madness::cblas::to_zptr do not match");
94 return reinterpret_cast<complex_double*>(ptr);
95 }
96
97} // namespace cblas
98} // namespace madness
99
100#endif // MADNESS_LINALG_CBLAS_TYPES_H__INCLUDED
101
Macros and tools pertaining to the configuration of MADNESS.
std::complex< float > complex_float
Definition cblas_types.h:57
const complex_float * to_cptr(const T *ptr)
Definition cblas_types.h:73
const complex_double * to_zptr(const T *ptr)
Definition cblas_types.h:86
std::complex< double > complex_double
Definition cblas_types.h:58
CBLAS_TRANSPOSE
Matrix operations for BLAS function calls.
Definition cblas_types.h:64
@ NoTrans
Definition cblas_types.h:65
@ ConjTrans
Definition cblas_types.h:67
@ Trans
Definition cblas_types.h:66
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
std::string type(const PairType &n)
Definition PNOParameters.h:18