Skip to content

Commit

Permalink
bug fix for gcc-4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
titaschanda committed May 21, 2017
1 parent 963c1e9 commit a5b54f3
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 106 deletions.
219 changes: 132 additions & 87 deletions include/QIClib_bits/basic/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,11 @@ template <typename T1> using RR = typename std::remove_reference<T1>::type;

template <typename T1> using RCV = typename std::remove_cv<T1>::type;

template <typename T1>
using pT2 = typename T1::pod_type;
template <typename T1> using pT2 = typename T1::pod_type;

template <typename T1>
using eT2 = typename T1::elem_type;
template <typename T1> using eT2 = typename T1::elem_type;

template <typename T1>
using GPT = typename arma::get_pod_type<T1>::result;
template <typename T1> using GPT = typename arma::get_pod_type<T1>::result;

template <typename T1>
using pT = typename conditional_arma<trait::RR<T1> >::type::pod_type;
Expand All @@ -76,116 +73,154 @@ using eT = typename conditional_arma<trait::RR<T1> >::type::elem_type;

//****************************************************************************

template <typename T1, typename... T2>
struct is_arma_type_var : std::false_type {};
template <typename T1, typename... T2> struct is_arma_type_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_arma_type_var<T1> : arma::is_arma_type<trait::RR<T1> > {};
template <typename T1> struct is_arma_type_var<T1> {
static constexpr bool value = arma::is_arma_type<trait::RR<T1> >::value;
};

template <typename T1, typename T2, typename... T3>
struct is_arma_type_var<T1, T2, T3...>
: std::integral_constant<bool, is_arma_type_var<T1>::value &&
is_arma_type_var<T2, T3...>::value> {};
struct is_arma_type_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_arma_type_var<T1>::value
&&is_arma_type_var<T2, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_arma_sparse_type_var : std::false_type {};
template <typename T1, typename... T2> struct is_arma_sparse_type_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_arma_sparse_type_var<T1> : arma::is_arma_sparse_type<trait::RR<T1> > {
template <typename T1> struct is_arma_sparse_type_var<T1> {
static constexpr bool value =
arma::is_arma_sparse_type<trait::RR<T1> >::value;
};

template <typename T1, typename T2, typename... T3>
struct is_arma_sparse_type_var<T1, T2, T3...>
: std::integral_constant<bool, is_arma_sparse_type_var<T1>::value &&
is_arma_sparse_type_var<T2, T3...>::value> {
struct is_arma_sparse_type_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_arma_sparse_type_var<T1>::value &&
is_arma_sparse_type_var<T2, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_floating_point_var : std::false_type {};
template <typename T1, typename... T2> struct is_floating_point_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_floating_point_var<T1> : std::is_floating_point<T1> {};
template <typename T1> struct is_floating_point_var<T1> {
static constexpr bool value = std::is_floating_point<T1>::value;
};

template <typename T1, typename T2, typename... T3>
struct is_floating_point_var<T1, T2, T3...>
: std::integral_constant<bool, is_floating_point_var<T1>::value &&
is_floating_point_var<T2, T3...>::value> {};
struct is_floating_point_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_floating_point_var<T1>::value
&&is_floating_point_var<T2, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1> struct is_complex : std::false_type {};
template <typename T1> struct is_complex {
static constexpr bool value = std::false_type::value;
};

template <typename T1> struct is_complex<std::complex<T1> > : std::true_type {};
template <typename T1> struct is_complex<std::complex<T1> > {
static constexpr bool value = std::true_type::value;
};

template <typename T1>
struct is_complex<const std::complex<T1> > : std::true_type {};
template <typename T1> struct is_complex<const std::complex<T1> > {
static constexpr bool value = std::true_type::value;
};

template <typename T1>
struct is_complex<volatile std::complex<T1> > : std::true_type {};
template <typename T1> struct is_complex<volatile std::complex<T1> > {
static constexpr bool value = std::true_type::value;
};

template <typename T1>
struct is_complex<const volatile std::complex<T1> > : std::true_type {};
template <typename T1> struct is_complex<const volatile std::complex<T1> > {
static constexpr bool value = std::true_type::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_complex_var : std::false_type {};
template <typename T1, typename... T2> struct is_complex_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1> struct is_complex_var<T1> : is_complex<T1> {};
template <typename T1> struct is_complex_var<T1> {
static constexpr bool value = is_complex<T1>::value;
};

template <typename T1, typename T2, typename... T3>
struct is_complex_var<T1, T2, T3...>
: std::integral_constant<bool, is_complex<T1>::value &&
is_complex_var<T2, T3...>::value> {};
struct is_complex_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_complex<T1>::value
&&is_complex_var<T2, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1> struct is_complex_fp : std::false_type {};
template <typename T1> struct is_complex_fp {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_complex_fp<std::complex<T1> >
: std::integral_constant<bool, is_floating_point_var<T1>::value> {};
template <typename T1> struct is_complex_fp<std::complex<T1> > {
static constexpr bool value =
std::integral_constant<bool, is_floating_point_var<T1>::value>::value;
};

template <typename T1>
struct is_complex_fp<const std::complex<T1> >
: std::integral_constant<bool, is_floating_point_var<T1>::value> {};
template <typename T1> struct is_complex_fp<const std::complex<T1> > {
static constexpr bool value =
std::integral_constant<bool, is_floating_point_var<T1>::value>::value;
};

template <typename T1>
struct is_complex_fp<volatile std::complex<T1> >
: std::integral_constant<bool, is_floating_point_var<T1>::value> {};
template <typename T1> struct is_complex_fp<volatile std::complex<T1> > {
static constexpr bool value =
std::integral_constant<bool, is_floating_point_var<T1>::value>::value;
};

template <typename T1>
struct is_complex_fp<const volatile std::complex<T1> >
: std::integral_constant<bool, is_floating_point_var<T1>::value> {};
template <typename T1> struct is_complex_fp<const volatile std::complex<T1> > {
static constexpr bool value =
std::integral_constant<bool, is_floating_point_var<T1>::value>::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_complex_fp_var : std::false_type {};
template <typename T1, typename... T2> struct is_complex_fp_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1> struct is_complex_fp_var<T1> : is_complex_fp<T1> {};
template <typename T1> struct is_complex_fp_var<T1> {
static constexpr bool value = is_complex_fp<T1>::value;
};

template <typename T1, typename T2, typename... T3>
struct is_complex_fp_var<T1, T2, T3...>
: std::integral_constant<bool, is_complex_fp<T1>::value &&
is_complex_fp_var<T2, T3...>::value> {};
struct is_complex_fp_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_complex_fp<T1>::value
&&is_complex_fp_var<T2, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_fp_arma_type_var : std::false_type {};
template <typename T1, typename... T2> struct is_fp_arma_type_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_fp_arma_type_var<T1> : std::is_floating_point<trait::pT<T1> > {};
template <typename T1> struct is_fp_arma_type_var<T1> {
static constexpr bool value = std::is_floating_point<trait::pT<T1> >::value;
};

template <typename T1, typename T2, typename... T3>
struct is_fp_arma_type_var<T1, T2, T3...>
: std::integral_constant<bool, is_fp_arma_type_var<T1>::value &&
is_fp_arma_type_var<T2, T3...>::value> {};
struct is_fp_arma_type_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_fp_arma_type_var<T1>::value
&&is_fp_arma_type_var<T2, T3...>::value > ::value;
};

//****************************************************************************

Expand Down Expand Up @@ -219,36 +254,46 @@ struct eT_promoter_var<T1, T2, T3...> {

//****************************************************************************

template <typename T1, typename... T2> struct is_all_same : std::true_type {};
template <typename T1, typename... T2> struct is_all_same {
static constexpr bool value = std::false_type::value;
};

template <typename T1, typename T2>
struct is_all_same<T1, T2> : std::is_same<trait::RR<T1>, trait::RR<T2> > {};
template <typename T1, typename T2> struct is_all_same<T1, T2> {
static constexpr bool value =
std::is_same<trait::RR<T1>, trait::RR<T2> >::value;
};

template <typename T1, typename T2, typename... T3>
struct is_all_same<T1, T2, T3...>
: std::integral_constant<bool,
std::is_same<trait::RR<T1>, trait::RR<T2> >::value &&
is_all_same<T1, T3...>::value> {};
struct is_all_same<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
std::is_same<trait::RR<T1>, trait::RR<T2> >::value
&&is_all_same<T1, T3...>::value > ::value;
};

//****************************************************************************

template <typename T1, typename... T2>
struct is_same_pT_var : std::false_type {};
template <typename T1, typename... T2> struct is_same_pT_var {
static constexpr bool value = std::false_type::value;
};

template <typename T1>
struct is_same_pT_var<T1>
: std::integral_constant<bool, arma::is_arma_type<T1>::value> {};
template <typename T1> struct is_same_pT_var<T1> {
static constexpr bool value =
std::integral_constant<bool, arma::is_arma_type<T1>::value>::value;
};

template <typename T1, typename T2>
struct is_same_pT_var<T1, T2>
: std::integral_constant<
bool, arma::is_arma_type<T1>::value && arma::is_arma_type<T2>::value &&
std::is_same<trait::pT<T1>, trait::pT<T2> >::value> {};
template <typename T1, typename T2> struct is_same_pT_var<T1, T2> {
static constexpr bool
value = std::integral_constant < bool,
arma::is_arma_type<T1>::value &&arma::is_arma_type<T2>::value
&&std::is_same<trait::pT<T1>, trait::pT<T2> >::value > ::value;
};

template <typename T1, typename T2, typename... T3>
struct is_same_pT_var<T1, T2, T3...>
: std::integral_constant<bool, is_same_pT_var<T1, T2>::value &&
is_same_pT_var<T1, T3...>::value> {};
struct is_same_pT_var<T1, T2, T3...> {
static constexpr bool value = std::integral_constant < bool,
is_same_pT_var<T1, T2>::value
&&is_same_pT_var<T1, T3...>::value > ::value;
};

//*****************************************************************************

Expand Down
27 changes: 8 additions & 19 deletions include/QIClib_bits/class/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,10 @@ class SPM final : public _internal::Singleton<const SPM<T1> > {
proj3{3, 4};

struct {
const typename arma::Col<T1>::template fixed<4> phim{
static_cast<T1>(std::sqrt(0.5)), static_cast<T1>(0.0),
static_cast<T1>(0.0), static_cast<T1>(-std::sqrt(0.5))};

const typename arma::Col<T1>::template fixed<4> phip{
static_cast<T1>(std::sqrt(0.5)), static_cast<T1>(0.0),
static_cast<T1>(0.0), static_cast<T1>(std::sqrt(0.5))};

const typename arma::Col<T1>::template fixed<4> psim{
static_cast<T1>(0.0), static_cast<T1>(std::sqrt(0.5)),
static_cast<T1>(-std::sqrt(0.5)), static_cast<T1>(0.0)};

const typename arma::Col<T1>::template fixed<4> psip{
static_cast<T1>(0.0), static_cast<T1>(std::sqrt(0.5)),
static_cast<T1>(std::sqrt(0.5)), static_cast<T1>(0.0)};
typename arma::Col<T1>::template fixed<4> phim { };
typename arma::Col<T1>::template fixed<4> phip { };
typename arma::Col<T1>::template fixed<4> psim { };
typename arma::Col<T1>::template fixed<4> psip { };
} bell;

private:
Expand Down Expand Up @@ -158,10 +147,10 @@ class SPM final : public _internal::Singleton<const SPM<T1> > {

//**************************************************************************

// bell.phim << std::sqrt(0.5) << 0.0 << 0.0 << -std::sqrt(0.5);
// bell.phip << std::sqrt(0.5) << 0.0 << 0.0 << std::sqrt(0.5);
// bell.psim << 0.0 << std::sqrt(0.5) << -std::sqrt(0.5) << 0.0;
// bell.psip << 0.0 << std::sqrt(0.5) << std::sqrt(0.5) << 0.0;
bell.phim << std::sqrt(0.5) << 0.0 << 0.0 << -std::sqrt(0.5);
bell.phip << std::sqrt(0.5) << 0.0 << 0.0 << std::sqrt(0.5);
bell.psim << 0.0 << std::sqrt(0.5) << -std::sqrt(0.5) << 0.0;
bell.psip << 0.0 << std::sqrt(0.5) << std::sqrt(0.5) << 0.0;
}
~SPM() = default;
};
Expand Down

0 comments on commit a5b54f3

Please sign in to comment.