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// some BLAS libraries define their own types for complex data
41#ifndef HAVE_INTEL_MKL
42#ifndef blas_complex_float
43# define blas_complex_float std::complex<float>
44#else
45static_assert(sizeof(std::complex<float>)==sizeof(blas_complex_float), "sizes of blas_complex_float and std::complex<float> do not match");
46#endif
47#ifndef blas_complex_double
48# define blas_complex_double std::complex<double>
49#else
50static_assert(sizeof(std::complex<double>)==sizeof(blas_complex_double), "sizes of blas_complex_double and std::complex<double> do not match");
51#endif
52#else
53// if calling direct need to cast to the MKL complex types
54# ifdef MKL_DIRECT_CALL
55# include <mkl_types.h>
56# ifndef blas_complex_float
57# define blas_complex_float MKL_Complex8
58# endif
59# ifndef blas_complex_double
60# define blas_complex_double MKL_Complex16
61# endif
62// else can call via F77 prototypes which don't need type conversion
63# else
64# ifndef blas_complex_float
65# define blas_complex_float std::complex<float>
66# endif
67# ifndef blas_complex_double
68# define blas_complex_double std::complex<double>
69# endif
70# endif
71#endif
72
73namespace madness {
74namespace cblas {
75
76 /// Matrix operations for BLAS function calls
77 typedef enum {
80 ConjTrans=2
82
83 /////////// legalized conversions between C++ and CBLAS types //////////
84 template <typename T>
86 to_cptr(const T* ptr) {
87 static_assert(sizeof(T)==sizeof(blas_complex_float), "sizes of blas_complex_float and T given to madness::cblas::to_cptr do not match");
88 return reinterpret_cast<const blas_complex_float*>(ptr);
89 }
90 template <typename T>
91 typename std::enable_if<!std::is_const<T>::value, blas_complex_float*>::type
92 to_cptr(T* ptr) {
93 static_assert(sizeof(T)==sizeof(blas_complex_float), "sizes of blas_complex_float and T given to madness::cblas::to_cptr do not match");
94 return reinterpret_cast<blas_complex_float*>(ptr);
95 }
96
97 template <typename T>
99 to_zptr(const T* ptr) {
100 static_assert(sizeof(T)==sizeof(blas_complex_double), "sizes of blas_complex_double and T given to madness::cblas::to_zptr do not match");
101 return reinterpret_cast<const blas_complex_double*>(ptr);
102 }
103 template <typename T>
104 typename std::enable_if<!std::is_const<T>::value, blas_complex_double*>::type
105 to_zptr(T* ptr) {
106 static_assert(sizeof(T)==sizeof(blas_complex_double), "sizes of blas_complex_double and T given to madness::cblas::to_zptr do not match");
107 return reinterpret_cast<blas_complex_double*>(ptr);
108 }
109
110} // namespace cblas
111} // namespace madness
112
113#endif // MADNESS_LINALG_CBLAS_TYPES_H__INCLUDED
114
#define blas_complex_double
Definition cblas_types.h:48
#define blas_complex_float
Definition cblas_types.h:43
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
Macros and tools pertaining to the configuration of MADNESS.
const blas_complex_double * to_zptr(const T *ptr)
Definition cblas_types.h:99
const blas_complex_float * to_cptr(const T *ptr)
Definition cblas_types.h:86
CBLAS_TRANSPOSE
Matrix operations for BLAS function calls.
Definition cblas_types.h:77
@ NoTrans
Definition cblas_types.h:78
@ ConjTrans
Definition cblas_types.h:80
@ Trans
Definition cblas_types.h:79
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
std::string type(const PairType &n)
Definition PNOParameters.h:18