Expression Templates Library (ETL)
conj.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
13 #pragma once
14 
15 #ifdef ETL_EGBLAS_MODE
16 
17 #include "etl/impl/cublas/cuda.hpp"
18 
19 #include <egblas.hpp>
20 
21 #endif
22 
23 namespace etl::impl::egblas {
24 
28 #ifdef EGBLAS_HAS_CCONJ
29 static constexpr bool has_cconj = true;
30 #else
31 static constexpr bool has_cconj = false;
32 #endif
33 
43 inline void conj([[maybe_unused]] size_t n,
44  [[maybe_unused]] std::complex<float> alpha,
45  [[maybe_unused]] std::complex<float>* A,
46  [[maybe_unused]] size_t lda,
47  [[maybe_unused]] std::complex<float>* B,
48  [[maybe_unused]] size_t ldb) {
49 #ifdef EGBLAS_HAS_CCONJ
50  inc_counter("egblas");
51  egblas_cconj(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
52 #else
53  cpp_unreachable("Invalid call to egblas::conj");
54 #endif
55 }
56 
66 inline void conj([[maybe_unused]] size_t n,
67  [[maybe_unused]] etl::complex<float> alpha,
68  [[maybe_unused]] etl::complex<float>* A,
69  [[maybe_unused]] size_t lda,
70  [[maybe_unused]] etl::complex<float>* B,
71  [[maybe_unused]] size_t ldb) {
72 #ifdef EGBLAS_HAS_CCONJ
73  inc_counter("egblas");
74  egblas_cconj(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
75 #else
76  cpp_unreachable("Invalid call to egblas::conj");
77 #endif
78 }
79 
83 #ifdef EGBLAS_HAS_Zconj
84 static constexpr bool has_zconj = true;
85 #else
86 static constexpr bool has_zconj = false;
87 #endif
88 
98 inline void conj([[maybe_unused]] size_t n,
99  [[maybe_unused]] std::complex<double> alpha,
100  [[maybe_unused]] std::complex<double>* A,
101  [[maybe_unused]] size_t lda,
102  [[maybe_unused]] std::complex<double>* B,
103  [[maybe_unused]] size_t ldb) {
104 #ifdef EGBLAS_HAS_Zconj
105  inc_counter("egblas");
106  egblas_zconj(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
107 #else
108  cpp_unreachable("Invalid call to egblas::conj");
109 #endif
110 }
111 
121 inline void conj([[maybe_unused]] size_t n,
122  [[maybe_unused]] etl::complex<double> alpha,
123  [[maybe_unused]] etl::complex<double>* A,
124  [[maybe_unused]] size_t lda,
125  [[maybe_unused]] etl::complex<double>* B,
126  [[maybe_unused]] size_t ldb) {
127 #ifdef EGBLAS_HAS_Zconj
128  inc_counter("egblas");
129  egblas_zconj(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
130 #else
131  cpp_unreachable("Invalid call to egblas::conj");
132 #endif
133 }
134 
135 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
auto conj(E &&value)
Apply the conjugate operation on each complex value of the given expression.
Definition: expression_builder.hpp:206
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25