gslcpp
Modern-C++ Wrapper for GSL
include
gslcpp
wrap
element.hpp
Go to the documentation of this file.
1
/// \file include/gslcpp/wrap/element.hpp
2
/// \copyright 2022 Thomas E. Vaughan, all rights reserved.
3
/// \brief Definition for gsl::element, gsl::element_t.
4
5
#
pragma
once
6
#
include
"complex.hpp"
7
8
namespace
gsl
{
9
10
11
/// Via specialization, define fundamental, atomic element for type E of each
12
/// (possibly complex) element in vector or matrix.
13
///
14
/// If `E` be not complex, then define fundamental type as `E`, so that each of
15
/// v_iface::real(), v_iface::imag(), m_iface::real(), and m_iface::imag() has
16
/// a well defined return-type.
17
///
18
/// - Any attempt in client-code to ask for the imaginary part of a real vector
19
/// or a real matrix will result in a compile-time error.
20
///
21
/// - However, a call to v_iface::real() or m_iface::real() should compile and
22
/// work properly for any type of vector.
23
///
24
/// \tparam E Possibly complex type of each element in vector or matrix.
25
template
<
typename
E>
struct
element
{
26
/// Allow each of v_iface::real(), v_iface::imag(), m_iface::real(), or
27
/// m_iface::imag() to compile without error, so long as client-code does not
28
/// request the imaginary part of a real vector or a real matrix.
29
using
type= E;
30
};
31
32
33
/// Specialization of \ref element for gsl::complex<double>.
34
template
<>
struct
element
<
gsl
::complex<
double
>> {
35
/// Type of element in view returned by v_iface::real(), etc.
36
using
type=
double
;
37
};
38
39
40
/// Specialization of \ref element for gsl::complex<float>.
41
template
<>
struct
element
<
gsl
::complex<
float
>> {
42
/// Type of element in view returned by v_iface::real(), etc.
43
using
type=
float
;
44
};
45
46
47
/// Specialization of \ref element for gsl::complex<long double>.
48
template
<>
struct
element
<
gsl
::complex<
long
double
>> {
49
/// Type of element in view returned by v_iface::real(), etc.
50
using
type=
long
double
;
51
};
52
53
54
/// Specialization of \ref element for `gsl::complex<double> const`
55
template
<>
struct
element
<
gsl
::complex<
double
>
const
> {
56
/// Type of element in view returned by v_iface::real(), etc.
57
using
type=
double
const
;
58
};
59
60
61
/// Specialization of \ref element for `gsl::complex<float> const`.
62
template
<>
struct
element
<
gsl
::complex<
float
>
const
> {
63
/// Type of element in view returned by v_iface::real(), etc.
64
using
type=
float
const
;
65
};
66
67
68
/// Specialization of \ref element for `gsl::complex<long double> const`.
69
template
<>
struct
element
<
gsl
::complex<
long
double
>
const
> {
70
/// Type of element in view returned by v_iface::real(), etc.
71
using
type=
long
double
const
;
72
};
73
74
75
/// Via specialization, define fundamental, atomic element for type E of each
76
/// (possibly complex) element in vector or matrix.
77
///
78
/// If `E` be not complex, then define fundamental type as `E`, so that each of
79
/// v_iface::real(), v_iface::imag(), m_iface::real(), and m_iface::imag() has
80
/// a well defined return-type.
81
///
82
/// - Any attempt in client-code to ask for the imaginary part of a real vector
83
/// or a real matrix will result in a compile-time error.
84
///
85
/// - However, a call to v_iface::real() or m_iface::real() should compile and
86
/// work properly for any type of vector.
87
///
88
/// \sa gsl::element<E>
89
///
90
/// \tparam E Possibly complex type of each element in vector or matrix.
91
template
<
typename
E>
using
element_t=
typename
element
<E>::type;
92
93
94
}
// namespace gsl
95
96
// EOF
gsl::element
Via specialization, define fundamental, atomic element for type E of each (possibly complex) element ...
Definition:
element.hpp:25
gsl
Namespace for C++-interface to GSL.
Definition:
v-iface.hpp:51
Generated on Mon Mar 14 2022 00:01:35 for gslcpp by
1.8.17