Skip to content

Commit

Permalink
to_complex/real and remove_complex only
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Sep 17, 2020
1 parent 42c26f9 commit cc13408
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 39 deletions.
47 changes: 15 additions & 32 deletions include/ginkgo/core/base/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct remove_complex_impl<std::complex<T>> {
* @tparam T the type being made complex
*/
template <typename T>
struct add_complex_impl {
struct to_complex_impl {
using type = std::complex<T>;
};

Expand All @@ -149,7 +149,7 @@ struct add_complex_impl {
* @tparam T the type being made complex
*/
template <typename T>
struct add_complex_impl<std::complex<T>> {
struct to_complex_impl<std::complex<T>> {
using type = std::complex<T>;
};

Expand Down Expand Up @@ -226,7 +226,7 @@ struct remove_complex_s<


template <typename T, typename = void>
struct add_complex_s {};
struct to_complex_s {};

/**
* Obtains a complex counterpart of a real type, and leaves the type
Expand All @@ -235,9 +235,9 @@ struct add_complex_s {};
* @tparam T complex or scalar type
*/
template <typename T>
struct add_complex_s<
struct to_complex_s<
T, xstd::void_t<std::enable_if_t<is_complex_or_scalar_impl<T>::value>>> {
using type = typename detail::add_complex_impl<T>::type;
using type = typename detail::to_complex_impl<T>::type;
};

/**
Expand All @@ -247,10 +247,10 @@ struct add_complex_s<
* @tparam T class with template parameters
*/
template <typename T>
struct add_complex_s<
struct to_complex_s<
T, xstd::void_t<std::enable_if_t<!is_complex_or_scalar_impl<T>::value>>> {
using type =
typename detail::template_convertor<detail::add_complex_impl, T>::type;
typename detail::template_convertor<detail::to_complex_impl, T>::type;
};


Expand Down Expand Up @@ -353,27 +353,27 @@ using remove_complex = typename remove_complex_s<T>::type;
* Add the complex of complex/scalar type or the template parameter of class
* by accessing the `type` attribute of this struct.
*
* @tparam T type to add complex
* @tparam T type to complex_type
*/
using detail::add_complex_s;
using detail::to_complex_s;

/**
* Obtain the type which adds the complex of complex/scalar type or the
* template parameter of class by accessing the `type` attribute of this struct.
*
* @tparam T type to add complex
* @tparam T type to complex_type
*
* @note add_complex<class> can not be used in friend class declaration.
* @note to_complex<class> can not be used in friend class declaration.
* the followings are the error message from different combination.
* friend add_complex<Csr>;
* friend to_complex<Csr>;
* error: can not recognize it is class correctly.
* friend class add_complex<Csr>;
* friend class to_complex<Csr>;
* error: using alias template specialization
* friend class add_complex_s<Csr<ValueType,IndexType>>::type;
* friend class to_complex_s<Csr<ValueType,IndexType>>::type;
* error: can not recognize it is class correctly.
*/
template <typename T>
using add_complex = typename add_complex_s<T>::type;
using to_complex = typename to_complex_s<T>::type;


/**
Expand All @@ -393,23 +393,6 @@ template <typename T>
using to_real = remove_complex<T>;


/**
* to_complex_s is alias of add_complex_s
*
* @tparam T type to complex
*/
template <typename T>
using to_complex_s = add_complex_s<T>;

/**
* to_complex is alias of add_complex
*
* @tparam T type to complex
*/
template <typename T>
using to_complex = add_complex<T>;


namespace detail {


Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/coo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Coo : public EnableLinOp<Coo<ValueType, IndexType>>,
friend class Csr<ValueType, IndexType>;
friend class Dense<ValueType>;
friend class CooBuilder<ValueType, IndexType>;
friend class Coo<add_complex<ValueType>, IndexType>;
friend class Coo<to_complex<ValueType>, IndexType>;

public:
using EnableLinOp<Coo>::convert_to;
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
friend class Sellp<ValueType, IndexType>;
friend class SparsityCsr<ValueType, IndexType>;
friend class CsrBuilder<ValueType, IndexType>;
friend class Csr<add_complex<ValueType>, IndexType>;
friend class Csr<to_complex<ValueType>, IndexType>;

public:
using value_type = ValueType;
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Dense
friend class Sellp<ValueType, int64>;
friend class SparsityCsr<ValueType, int32>;
friend class SparsityCsr<ValueType, int64>;
friend class Dense<add_complex<ValueType>>;
friend class Dense<to_complex<ValueType>>;

public:
using EnableLinOp<Dense>::convert_to;
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/diagonal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Diagonal
friend class EnableCreateMethod<Diagonal>;
friend class Csr<ValueType, int32>;
friend class Csr<ValueType, int64>;
friend class Diagonal<add_complex<ValueType>>;
friend class Diagonal<to_complex<ValueType>>;

public:
using EnableLinOp<Diagonal>::convert_to;
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/ell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Ell : public EnableLinOp<Ell<ValueType, IndexType>>,
friend class EnablePolymorphicObject<Ell, LinOp>;
friend class Dense<ValueType>;
friend class Csr<ValueType, IndexType>;
friend class Ell<add_complex<ValueType>, IndexType>;
friend class Ell<to_complex<ValueType>, IndexType>;

public:
using EnableLinOp<Ell>::convert_to;
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/hybrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Hybrid
friend class EnablePolymorphicObject<Hybrid, LinOp>;
friend class Dense<ValueType>;
friend class Csr<ValueType, IndexType>;
friend class Hybrid<add_complex<ValueType>, IndexType>;
friend class Hybrid<to_complex<ValueType>, IndexType>;


public:
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/matrix/sellp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Sellp : public EnableLinOp<Sellp<ValueType, IndexType>>,
friend class EnablePolymorphicObject<Sellp, LinOp>;
friend class Dense<ValueType>;
friend class Csr<ValueType, IndexType>;
friend class Sellp<add_complex<ValueType>, IndexType>;
friend class Sellp<to_complex<ValueType>, IndexType>;

public:
using EnableLinOp<Sellp>::convert_to;
Expand Down

0 comments on commit cc13408

Please sign in to comment.