xtensor
Toggle main menu visibility
Loading...
Searching...
No Matches
xlayout.hpp
1
/***************************************************************************
2
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
3
* Copyright (c) QuantStack *
4
* *
5
* Distributed under the terms of the BSD 3-Clause License. *
6
* *
7
* The full license is in the file LICENSE, distributed with this software. *
8
****************************************************************************/
9
10
#ifndef XTENSOR_LAYOUT_HPP
11
#define XTENSOR_LAYOUT_HPP
12
13
#include <type_traits>
14
15
// Do not include anything else here.
16
// xlayout.hpp is included in xtensor_forward.hpp
17
// and we don't want to bring other headers to it.
18
#include "../core/xtensor_config.hpp"
19
20
namespace
xt
21
{
23
enum class
layout_type
24
{
26
dynamic
= 0x00,
28
any
= 0xFF,
30
row_major
= 0x01,
32
column_major
= 0x02
33
};
34
51
template
<
class
... Args>
52
constexpr
layout_type
compute_layout
(Args... args)
noexcept
;
53
54
constexpr
layout_type
default_assignable_layout(
layout_type
l)
noexcept
;
55
56
constexpr
layout_type
layout_remove_any(
const
layout_type
layout)
noexcept
;
57
58
/******************
59
* Implementation *
60
******************/
61
62
namespace
detail
63
{
64
constexpr
layout_type
compute_layout_impl()
noexcept
65
{
66
return
layout_type::any
;
67
}
68
69
constexpr
layout_type
compute_layout_impl(
layout_type
l)
noexcept
70
{
71
return
l;
72
}
73
74
constexpr
layout_type
compute_layout_impl(
layout_type
lhs,
layout_type
rhs)
noexcept
75
{
76
using
type = std::underlying_type_t<layout_type>;
77
return
layout_type
(
static_cast<
type
>
(lhs) &
static_cast<
type
>
(rhs));
78
}
79
80
template
<
class
... Args>
81
constexpr
layout_type
compute_layout_impl(
layout_type
lhs, Args... args)
noexcept
82
{
83
return
compute_layout_impl(lhs, compute_layout_impl(args...));
84
}
85
}
86
87
template
<
class
... Args>
88
constexpr
layout_type
compute_layout
(Args... args)
noexcept
89
{
90
return
detail::compute_layout_impl(args...);
91
}
92
93
constexpr
layout_type
default_assignable_layout(
layout_type
l)
noexcept
94
{
95
return
(l ==
layout_type::row_major
|| l ==
layout_type::column_major
) ? l : XTENSOR_DEFAULT_LAYOUT;
96
}
97
98
constexpr
layout_type
layout_remove_any(
const
layout_type
layout)
noexcept
99
{
100
return
layout ==
layout_type::any
? XTENSOR_DEFAULT_LAYOUT : layout;
101
}
102
}
103
104
#endif
xt::any
bool any(E &&e)
Any.
Definition
xoperation.hpp:935
xt
standard mathematical functions for xexpressions
Definition
xchunked_array.hpp:20
xt::compute_layout
constexpr layout_type compute_layout(Args... args) noexcept
Implementation of the following logical table:
Definition
xlayout.hpp:88
xt::layout_type
layout_type
Definition
xlayout.hpp:24
xt::layout_type::any
@ any
Definition
xlayout.hpp:28
xt::layout_type::row_major
@ row_major
Definition
xlayout.hpp:30
xt::layout_type::column_major
@ column_major
Definition
xlayout.hpp:32
xt::layout_type::dynamic
@ dynamic
Definition
xlayout.hpp:26
include
xtensor
core
xlayout.hpp
Generated by
1.17.0