22 V compute(
size_t n,
size_t i,
size_t j) {
26 return i == 0 && j == 0 ? 1 : i == 0 && j == 1 ? 3 : i == 1 && j == 0 ? 4 : 2;
29 return n * (((i + 1) + (j + 1) - 1 + n / 2) % n) + (((i + 1) + 2 * (j + 1) - 2) % n) + 1;
47 static constexpr
bool gpu_computable =
false;
60 return detail::compute<value_type>(n, i / n, i % n);
69 return detail::compute<value_type>(n, i / n, i % n);
79 return detail::compute<value_type>(n, i / n, i % n);
89 return detail::compute<value_type>(n, i, j);
99 return detail::compute<value_type>(n, i, j);
107 template <
typename E>
108 constexpr
bool alias(
const E& rhs)
const noexcept {
109 return (
void)rhs,
false;
118 template <
typename Visitor>
119 void visit([[maybe_unused]] Visitor&& visitor)
const {}
141 template <
typename V,
size_t N>
145 static constexpr
bool gpu_computable =
false;
153 return detail::compute<value_type>(N, i / N, i % N);
162 return detail::compute<value_type>(N, i / N, i % N);
172 return detail::compute<value_type>(N, i / N, i % N);
182 return detail::compute<value_type>(N, i, j);
192 return detail::compute<value_type>(N, i, j);
200 template <
typename E>
201 constexpr
bool alias(
const E& rhs)
const noexcept {
202 return (
void)rhs,
false;
211 template <
typename Visitor>
212 void visit([[maybe_unused]] Visitor&& visitor)
const {}
234 template <
typename V>
239 static constexpr
bool is_etl =
true;
244 static constexpr
bool is_linear =
false;
246 static constexpr
bool is_value =
false;
247 static constexpr
bool is_direct =
false;
248 static constexpr
bool is_generator =
false;
249 static constexpr
bool is_temporary =
false;
250 static constexpr
bool is_padded =
false;
251 static constexpr
bool is_aligned =
false;
252 static constexpr
bool gpu_computable =
false;
260 template <vector_mode_t VV>
261 static constexpr
bool vectorizable =
false;
278 static size_t dim(
const expr_t& v, [[maybe_unused]]
size_t d) {
302 template <
size_t N,
typename V>
307 static constexpr
bool is_etl =
true;
312 static constexpr
bool is_linear =
false;
314 static constexpr
bool is_value =
false;
315 static constexpr
bool is_direct =
false;
316 static constexpr
bool is_generator =
false;
317 static constexpr
bool is_temporary =
false;
318 static constexpr
bool is_padded =
false;
319 static constexpr
bool is_aligned =
false;
320 static constexpr
bool gpu_computable =
false;
328 template <vector_mode_t VV>
329 static constexpr
bool vectorizable =
false;
335 static constexpr
size_t size() {
345 return (
void)v, N * N;
354 static constexpr
size_t dim() {
364 static constexpr
size_t dim(
const expr_t& e,
size_t d) {
365 return (
void)e, (void)d, N;
void ensure_cpu_up_to_date() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: virtual_views.hpp:125
value_type operator[](size_t i)
Returns the element at the given index.
Definition: virtual_views.hpp:59
V value_type
The value type in the matrix.
Definition: virtual_views.hpp:43
value_type operator[](size_t i) const
Returns the element at the given index.
Definition: virtual_views.hpp:161
static constexpr size_t dim(const expr_t &e, size_t d)
Returns the dth dimension of the given expression.
Definition: virtual_views.hpp:364
constexpr bool alias(const E &rhs) const noexcept
Test if this expression aliases with the given expression.
Definition: virtual_views.hpp:108
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
static size_t dim(const expr_t &v, [[maybe_unused]] size_t d)
Returns the dth dimension of the given expression.
Definition: virtual_views.hpp:278
A view (virtual) of a dynamic magic matrix.
Definition: virtual_views.hpp:42
value_type operator()(size_t i, size_t j)
Access to the value at the given (i, j) position.
Definition: virtual_views.hpp:181
void visit([[maybe_unused]] Visitor &&visitor) const
Apply the given visitor to this expression and its descendants.
Definition: virtual_views.hpp:212
V value_type
The value type of the expression.
Definition: virtual_views.hpp:305
order
Storage order of a matrix.
Definition: order.hpp:15
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: virtual_views.hpp:294
V value_type
The value type.
Definition: virtual_views.hpp:143
static constexpr size_t dimensions()
Returns the number of expressions for this type.
Definition: virtual_views.hpp:372
value_type operator()(size_t i, size_t j) const
Access to the value at the given (i, j) position.
Definition: virtual_views.hpp:191
void ensure_gpu_up_to_date() const
Copy back from the GPU to the expression memory if necessary.
Definition: virtual_views.hpp:133
constexpr bool is_fast
Traits to test if the given ETL expresion type is fast (sizes known at compile-time) ...
Definition: traits.hpp:588
value_type operator[](size_t i)
Returns the element at the given index.
Definition: virtual_views.hpp:152
static constexpr size_t dim()
Returns the D2th dimension of an expression of this type.
Definition: virtual_views.hpp:354
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
const size_t n
The dimensions of the magic matrix.
Definition: virtual_views.hpp:45
V value_type
The value type of the expression.
Definition: virtual_views.hpp:237
constexpr bool alias(const E &rhs) const noexcept
Test if this expression aliases with the given expression.
Definition: virtual_views.hpp:201
static constexpr size_t dimensions()
Returns the number of expressions for this type.
Definition: virtual_views.hpp:286
value_type operator[](size_t i) const
Returns the element at the given index.
Definition: virtual_views.hpp:68
void visit([[maybe_unused]] Visitor &&visitor) const
Apply the given visitor to this expression and its descendants.
Definition: virtual_views.hpp:119
static size_t size(const expr_t &v)
Returns the size of the given expression.
Definition: virtual_views.hpp:268
A view (virtual) of a static magic matrix.
Definition: virtual_views.hpp:142
static constexpr size_t size()
Returns the size of an expression of this fast type.
Definition: virtual_views.hpp:335
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
magic_view(size_t n)
Construct a new magic_view with the given dimension.
Definition: virtual_views.hpp:52
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
static constexpr size_t size(const expr_t &v)
Returns the size of the given expression.
Definition: virtual_views.hpp:344
value_type operator()(size_t i, size_t j) const
Access to the value at the given (i, j) position.
Definition: virtual_views.hpp:98
value_type read_flat(size_t i) const
Returns the value at the given index This function never has side effects.
Definition: virtual_views.hpp:78
value_type operator()(size_t i, size_t j)
Access to the value at the given (i, j) position.
Definition: virtual_views.hpp:88
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
void ensure_cpu_up_to_date() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: virtual_views.hpp:218
void ensure_gpu_up_to_date() const
Copy back from the GPU to the expression memory if necessary.
Definition: virtual_views.hpp:226
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: virtual_views.hpp:380
value_type read_flat(size_t i) const
Returns the value at the given index This function never has side effects.
Definition: virtual_views.hpp:171