forked from STEllAR-GROUP/hpxla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_complex_cblas_compatibility.cpp
45 lines (33 loc) · 1.07 KB
/
std_complex_cblas_compatibility.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2012 Bryce Adelstein-Lelbach
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
////////////////////////////////////////////////////////////////////////////////
#include <hpx/util/lightweight_test.hpp>
#include <complex>
/// The C interface for BLAS require complex numbers to be represented by
/// two floating point numbers of the same type that reside in a contiguous
/// block of memory, with the real part first and the imaginary second. This
/// test verifies that std::complex<> fulfills those requirements.
template <
typename T
>
void test()
{
std::complex<T> x(17.0, 42.0);
T* real = (T*) &x;
T* imag = ((T*) &x) + 1;
HPX_SANITY(real);
if (real)
HPX_TEST_EQ(17.0, *real);
HPX_SANITY(imag);
if (imag)
HPX_TEST_EQ(42.0, *imag);
}
int main()
{
test<float>();
test<double>();
return hpx::util::report_errors();
}