1 //////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source
3 // License.  See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by:
8 //    Lawrence Livermore National Laboratory
9 //
10 // File created by:
11 // Miguel A. Morales, moralessilva2@llnl.gov
12 //    Lawrence Livermore National Laboratory
13 ////////////////////////////////////////////////////////////////////////////////
14 
15 #ifndef AFQMC_MA_UTILITIES_HPP
16 #define AFQMC_MA_UTILITIES_HPP
17 
18 #include <complex>
19 #include "AFQMC/config.0.h"
20 #include "AFQMC/Memory/raw_pointers.hpp"
21 #include "AFQMC/Memory/SharedMemory/shm_ptr_with_raw_ptr_dispatch.hpp"
22 
23 namespace ma
24 {
25 using qmcplusplus::afqmc::to_address;
26 
27 enum TENSOR_OPERATIONS
28 {
29   TOp_PLUS,
30   TOp_MINUS,
31   TOp_MUL,
32   TOp_DIV
33 };
34 
35 static const int INCX                   = 1;
36 static const int INCY                   = 1;
37 static const char UPLO                  = 'L';
38 static const char TRANS                 = 'T';
39 static const char NOTRANS               = 'N';
40 static const float sone                 = 1.0;
41 static const float szero                = 0.0;
42 static const double done                = 1.0;
43 static const double dzero               = 0.0;
44 static const std::complex<float> cone   = std::complex<float>(1.0, 0.0);
45 static const std::complex<float> czero  = std::complex<float>(0.0, 0.0);
46 static const std::complex<double> zone  = std::complex<double>(1.0, 0.0);
47 static const std::complex<double> zzero = std::complex<double>(0.0, 0.0);
48 
49 /*
50 #if defined(HAVE_MKL)
51 typedef enum {CblasRowMajor=101, CblasColMajor=102} CBLAS_LAYOUT;
52 typedef enum {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113} CBLAS_TRANSPOSE;
53 #endif
54 */
55 
real(double const & d)56 inline double const& real(double const& d) { return d; }
real(float const & f)57 inline float const& real(float const& f) { return f; }
58 
conj(double const & d)59 inline double conj(double const& d) { return d; }
conj(float const & f)60 inline float conj(float const& f) { return f; }
61 
conj(std::complex<double> const & d)62 inline std::complex<double> conj(std::complex<double> const& d) { return std::conj(d); }
conj(std::complex<float> const & f)63 inline std::complex<float> conj(std::complex<float> const& f) { return std::conj(f); }
64 //template<typename T>
65 //T conj(T const& v) { return v; }
66 //template<typename T>
67 //std::complex<T> conj(std::complex<T> const& v) { return std::conj(v); }
68 
69 template<class Ptr>
pointer_dispatch(Ptr p)70 auto pointer_dispatch(Ptr p)
71 {
72   return p;
73 }
74 
75 template<typename T>
pointer_dispatch(shm::shm_ptr_with_raw_ptr_dispatch<T> p)76 T* pointer_dispatch(shm::shm_ptr_with_raw_ptr_dispatch<T> p)
77 {
78   return to_address(p);
79 }
80 
81 
82 } // namespace ma
83 
84 #endif
85