Ginkgo
Generated from branch based on main. Ginkgo version 1.11.0
A numerical linear algebra library targeting many-core architectures
Toggle main menu visibility
Loading...
Searching...
No Matches
type_traits.hpp
1
// SPDX-FileCopyrightText: 2025 The Ginkgo authors
2
//
3
// SPDX-License-Identifier: BSD-3-Clause
4
5
#ifndef GKO_PUBLIC_CORE_BASE_TYPE_TRAITS_HPP_
6
#define GKO_PUBLIC_CORE_BASE_TYPE_TRAITS_HPP_
7
8
#include <type_traits>
9
10
#include <ginkgo/core/base/lin_op.hpp>
11
12
namespace
gko
{
13
namespace
detail {
14
15
16
template
<
typename
Type>
17
constexpr
bool
is_ginkgo_linop = std::is_base_of_v<LinOp, Type>;
18
19
20
// helper to get factory type of concrete type or LinOp
21
template
<
typename
Type>
22
struct
factory_type_impl {
23
using
type =
typename
Type::Factory;
24
};
25
26
// It requires LinOp to be complete type
27
template
<>
28
struct
factory_type_impl<LinOp> {
29
using
type = LinOpFactory;
30
};
31
32
33
template
<
typename
Type>
34
using
factory_type =
typename
factory_type_impl<Type>::type;
35
36
37
// helper for handle the transposed type of concrete type and LinOp
38
template
<
typename
Type,
typename
=
void
>
39
struct
transposed_type_impl {
40
using
type =
typename
Type::transposed_type;
41
};
42
43
// It requires LinOp to be complete type
44
template
<>
45
struct
transposed_type_impl<LinOp, void> {
46
using
type = LinOp;
47
};
48
49
// return the same type when Type is the precision format.
50
// it is used in ILU.
51
template
<
typename
Type>
52
struct
transposed_type_impl<Type, std::enable_if_t<!is_ginkgo_linop<Type>>> {
53
using
type = Type;
54
};
55
56
57
template
<
typename
Type>
58
using
transposed_type =
typename
transposed_type_impl<Type>::type;
59
60
61
// helper to get value_type of concrete type or void for LinOp
62
template
<
typename
Type,
typename
=
void
>
63
struct
get_value_type_impl {
64
using
type =
typename
Type::value_type;
65
};
66
67
// We need to use SFINAE not conditional_t because both type needs to be
68
// valid in conditional_t
69
template
<
typename
Type>
70
struct
get_value_type_impl<Type, std::enable_if_t<!is_ginkgo_linop<Type>>> {
71
using
type = Type;
72
};
73
74
75
template
<
typename
Type>
76
using
get_value_type =
typename
get_value_type_impl<Type>::type;
77
78
79
}
// namespace detail
80
}
// namespace gko
81
82
#endif
// GKO_PUBLIC_CORE_BASE_TYPE_TRAITS_HPP_
gko
The Ginkgo namespace.
Definition
abstract_factory.hpp:20
ginkgo
core
base
type_traits.hpp
Generated by
1.18.0