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