Expression Templates Library (ETL)
imag.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_Cimag
29 static constexpr bool has_cimag = true;
30 #else
31 static constexpr bool has_cimag = false;
32 #endif
33 
43 inline void imag([[maybe_unused]] size_t n,
44  [[maybe_unused]] float alpha,
45  [[maybe_unused]] std::complex<float>* A,
46  [[maybe_unused]] size_t lda,
47  [[maybe_unused]] float* B,
48  [[maybe_unused]] size_t ldb) {
49 #ifdef EGBLAS_HAS_Cimag
50  inc_counter("egblas");
51  egblas_cimag(n, alpha, reinterpret_cast<cuComplex*>(A), lda, (B), ldb);
52 #else
53  cpp_unreachable("Invalid call to egblas::imag");
54 #endif
55 }
56 
66 inline void imag([[maybe_unused]] size_t n,
67  [[maybe_unused]] float alpha,
68  [[maybe_unused]] etl::complex<float>* A,
69  [[maybe_unused]] size_t lda,
70  [[maybe_unused]] float* B,
71  [[maybe_unused]] size_t ldb) {
72 #ifdef EGBLAS_HAS_Cimag
73  inc_counter("egblas");
74  egblas_cimag(n, alpha, reinterpret_cast<cuComplex*>(A), lda, (B), ldb);
75 #else
76  cpp_unreachable("Invalid call to egblas::imag");
77 #endif
78 }
79 
83 #ifdef EGBLAS_HAS_Zimag
84 static constexpr bool has_zimag = true;
85 #else
86 static constexpr bool has_zimag = false;
87 #endif
88 
98 inline void imag([[maybe_unused]] size_t n,
99  [[maybe_unused]] double alpha,
100  [[maybe_unused]] std::complex<double>* A,
101  [[maybe_unused]] size_t lda,
102  [[maybe_unused]] double* B,
103  [[maybe_unused]] size_t ldb) {
104 #ifdef EGBLAS_HAS_Zimag
105  inc_counter("egblas");
106  egblas_zimag(n, alpha, reinterpret_cast<cuDoubleComplex*>(A), lda, (B), ldb);
107 #else
108  cpp_unreachable("Invalid call to egblas::imag");
109 #endif
110 }
111 
121 inline void imag([[maybe_unused]] size_t n,
122  [[maybe_unused]] double alpha,
123  [[maybe_unused]] etl::complex<double>* A,
124  [[maybe_unused]] size_t lda,
125  [[maybe_unused]] double* B,
126  [[maybe_unused]] size_t ldb) {
127 #ifdef EGBLAS_HAS_Zimag
128  inc_counter("egblas");
129  egblas_zimag(n, alpha, reinterpret_cast<cuDoubleComplex*>(A), lda, (B), ldb);
130 #else
131  cpp_unreachable("Invalid call to egblas::imag");
132 #endif
133 }
134 
135 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
auto imag(E &&value)
Extract the imag part of each complex value of the given expression.
Definition: expression_builder.hpp:196
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25