8template <
typename T =
double>
struct scalar {
9 using base_type = hila::arithmetic_type<T>;
10 using argument_type = T;
24 template <
typename scalar_t,
25 std::enable_if_t<std::is_arithmetic<scalar_t>::value,
int> = 0>
26 constexpr scalar<T>(
const scalar_t val) : value(
static_cast<T
>(val)) {}
32 template <
typename A>
operator scalar<A>()
const {
33 return scalar<A>({
static_cast<A
>(value)});
37 operator T() {
return value; }
39 template <
typename scalar_t,
40 std::enable_if_t<std::is_arithmetic<scalar_t>::value,
int> = 0>
42 value =
static_cast<T
>(s);
46 T real()
const {
return value; }
47 T imag()
const {
return 0; }
49 T squarenorm()
const {
return value * value; }
53 double abs()
const {
return sqrt(
static_cast<double>(squarenorm())); }
58 scalar<T> operator+()
const {
return *
this; }
67 template <typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
69 value +=
static_cast<T
>(a);
79 template <typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
81 value -=
static_cast<T
>(a);
86 value = value * lhs.value;
91 template <typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
93 value *=
static_cast<T
>(a);
99 value = value / lhs.value;
104 template <typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
106 value /=
static_cast<T
>(a);
116template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
121template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
132template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
137template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
148template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
153template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
164template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>
170template <typename T, typename A, std::enable_if_t<std::is_arithmetic<A>::value,
int> = 0>