Created
July 22, 2015 12:22
-
-
Save yt-siden/81943eda303f309ea467 to your computer and use it in GitHub Desktop.
MAGMA type wrapper for converting complex type (std::complex -> magmaComplex)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UUID_6DBD3348_8ECE_4541_A1E1_3D5EBF9C3BD8 | |
#define UUID_6DBD3348_8ECE_4541_A1E1_3D5EBF9C3BD8 | |
#include <complex> | |
#include <magma.h> | |
// MAGMA type wrapper for using std::complex | |
/* | |
* T -> magma_type_wrapper<T>::type | |
* --------------------------------------------------- | |
* std::complex<float> -> magmaFloatComplex | |
* std::complex<double> -> magmaDoubleComplex | |
* T (not listed above) -> T | |
*/ | |
template <typename T> | |
struct magma_type_wrapper | |
{ | |
typedef T type; | |
}; | |
template<> | |
struct magma_type_wrapper<std::complex<float>> | |
{ | |
typedef magmaFloatComplex type; | |
}; | |
template<> | |
struct magma_type_wrapper<std::complex<double>> | |
{ | |
typedef magmaDoubleComplex type; | |
}; | |
// example use -- magma_setvector | |
template <typename T> | |
void setvector(int const n, T const * const hx_src, int const incx, T * const dy_dst, int const incy) | |
{ | |
return magma_setvector(const_cast<int&>(n), sizeof(T), | |
reinterpret_cast<magma_type_wrapper<T>::type *>(const_cast<T const *>(hx_src)), | |
const_cast<int&>(incx), | |
reinterpret_cast<magma_type_wrapper<T>::type *>(const_cast<T *>(dy_dst)), | |
const_cast<int&>(incy)); | |
} | |
#endif //UUID_6DBD3348_8ECE_4541_A1E1_3D5EBF9C3BD8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment