|
|
|
|
@ -7,15 +7,26 @@
|
|
|
|
|
|
|
|
|
|
namespace sdr {
|
|
|
|
|
|
|
|
|
|
/** Forward declaration of type tratis template. */
|
|
|
|
|
template <class T> class Traits;
|
|
|
|
|
/** Forward declaration of type tratis template.
|
|
|
|
|
* For each supported type, @c uint8_t, @c std::comple<uint8_t>, @c int8_t,
|
|
|
|
|
* @c std::complex<uint8_t>, @c uint16_t, @c std::complex<uint16_t>, @c int16_t,
|
|
|
|
|
* @c std::complex<int16_t>, @c float, @c std::complex<float>, @c double and
|
|
|
|
|
* @c std::complex<double>, the Traits template povides the @c Scalar type (the template argument
|
|
|
|
|
* type), its real type (i.e. for the type @c std::complex<int16_t> it would be @c int16_t),
|
|
|
|
|
* its super scalar (i.e. for the @c int16_t, it would be @c int32_t but for @c float it is
|
|
|
|
|
* @c flaot again) which allows for safe multiplications of these values, the scale mapping
|
|
|
|
|
* the interval [-1,1] to the values of the scalar type, the bit shift from the scalar type to the
|
|
|
|
|
* super scalar type and the type id for the scalar. */
|
|
|
|
|
template <class Scalar> class Traits;
|
|
|
|
|
|
|
|
|
|
/** Template specialization of type tratis for uint8_t scalar. */
|
|
|
|
|
template <>
|
|
|
|
|
class Traits<uint8_t> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef uint8_t Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef uint8_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef uint16_t SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -30,8 +41,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<uint8_t> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<uint8_t> Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef uint8_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef std::complex<uint16_t> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -46,8 +59,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits<int8_t> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef int8_t Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef int8_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef int16_t SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -62,8 +77,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<int8_t> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<int8_t> Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef int8_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef std::complex<int16_t> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -78,8 +95,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits<uint16_t> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef uint16_t Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef uint16_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef uint32_t SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -94,8 +113,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<uint16_t> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<uint16_t> Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef uint16_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef std::complex<uint32_t> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -110,8 +131,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits<int16_t> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef int16_t Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef int16_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef int32_t SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -126,8 +149,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<int16_t> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<int16_t> Scalar;
|
|
|
|
|
/** The real Scalar type. */
|
|
|
|
|
typedef int16_t RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef std::complex<int32_t> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -144,6 +169,8 @@ class Traits<float> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
typedef float Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef float RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef float SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -158,8 +185,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<float> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<float> Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef float RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef std::complex<float> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -174,8 +203,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits<double> {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef double Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef double RScalar;
|
|
|
|
|
/** The compute scalar type. */
|
|
|
|
|
typedef double SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -190,8 +221,10 @@ public:
|
|
|
|
|
template <>
|
|
|
|
|
class Traits< std::complex<double> > {
|
|
|
|
|
public:
|
|
|
|
|
/** The Scalar type. */
|
|
|
|
|
/** The scalar type. */
|
|
|
|
|
typedef std::complex<double> Scalar;
|
|
|
|
|
/** The real scalar type. */
|
|
|
|
|
typedef double RScalar;
|
|
|
|
|
/** The compute (super) scalar type. */
|
|
|
|
|
typedef std::complex<double> SScalar;
|
|
|
|
|
/** The scaleing factor from floating point to integer. */
|
|
|
|
|
@ -205,4 +238,4 @@ public:
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // TRAITS_HH
|
|
|
|
|
#endif
|
|
|
|
|
|