Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
ops/matrix_set.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include <utility>
15
16namespace uni20::linalg
17{
18
25template <class BackendSelector, uni20::MutableRankedTensorView<2> MatrixTensor, class Scalar>
26void set_matrix(BackendSelector&& selector, MatrixTensor&& matrix, Scalar diagonal, Scalar off_diagonal,
28{
29 auto matrix_descriptor = uni20::mdspec_of(matrix);
30 dispatch_kernel(std::forward<BackendSelector>(selector), matrix_set_op{.region = region}, matrix_descriptor, diagonal,
31 off_diagonal);
32}
33
35template <uni20::MutableRankedTensorView<2> MatrixTensor, class Scalar>
36void set_matrix(MatrixTensor&& matrix, Scalar diagonal, Scalar off_diagonal, MatrixRegion region = MatrixRegion::All)
37{
38 auto selector = select_backend(matrix_set_op{.region = region}, matrix);
39 set_matrix(selector, std::forward<MatrixTensor>(matrix), diagonal, off_diagonal, region);
40}
41
42} // namespace uni20::linalg
Reference CPU backend for structured dense matrix initialization.
Concept for numeric scalar types (integer, real, or complex).
Definition scalar_concepts.hpp:81
Operation-tag backend dispatch over tensor-view operands.
Definition linalg/async.hpp:28
void set_matrix(BackendSelector selector, async::Async< MatrixTensor > &matrix, Diagonal &&diagonal, OffDiagonal &&off_diagonal, MatrixRegion region=MatrixRegion::All)
Schedule structured matrix initialization through an explicit selector.
Definition async/matrix_set.hpp:58
constexpr auto select_backend(Operation const &operation, FirstTensor const &, RestTensors const &...)
Select the default backend list for an operation on Tensor operands.
Definition backend_selector.hpp:252
void dispatch_kernel(BackendSelector &&selector, Op op, Args &&... args)
Normalize a selector and dispatch or report that every eligible backend declined.
Definition dispatch.hpp:374
MatrixRegion
Matrix region selected by structured initialization operations.
Definition operation_tags.hpp:208
@ All
All entries, including rectangular portions of the matrix.
constexpr decltype(auto) mdspec_of(Tensor &tensor) noexcept(noexcept(tensor.mdspec()))
Return a tensor's immediate or descriptor-backed multidimensional metadata.
Definition tensor/concepts.hpp:50
Backend-independent operation values used with normalized kernel operands.
Structured dense matrix initialization operation tag.
Definition operation_tags.hpp:219
MatrixRegion region
Definition operation_tags.hpp:221
Concepts for tensor-level objects that resolve mdspan kernel operands.