29 template <RealOrComplex To, RealOrComplex From>
33 require_precision<To>(
p);
36 throw std::invalid_argument(
"Krylov transfer requires matching vector dimensions");
37 for (std::size_t i = 0; i < input.
values.size(); ++i)
38 output.
values[i] = gmres_detail::convert_scalar<To>(input.
values[i],
p);
47 [[nodiscard]] std::size_t
dimension() const noexcept {
return dimension_; }
51 return x.values.size();
62 template <
class Element, std::
size_t Extent>
63 requires std::same_as<std::remove_const_t<Element>,
Scalar>
64 [[nodiscard]]
auto prototype_view(std::span<Element, Extent> x)
const -> std::span<Scalar const>
69 [[nodiscard]] std::size_t
vector_dimension(std::span<Scalar const> x)
const noexcept {
return x.size(); }
72 [[nodiscard]]
int copy_count() const noexcept {
return copy_count_; }
73 [[nodiscard]]
int axpy_count() const noexcept {
return axpy_count_; }
74 [[nodiscard]]
int scal_count() const noexcept {
return scal_count_; }
75 [[nodiscard]]
int set_zero_count() const noexcept {
return set_zero_count_; }
77 [[nodiscard]]
int norm_count() const noexcept {
return norm_count_; }
93 require_same_size(dst, src);
100 require_same_size(y, x);
102 for (std::size_t i = 0; i < y.
values.size(); ++i)
128 require_same_size(x, y);
129 ++inner_product_count_;
131 auto x_span = make_span(x);
132 auto y_span = make_span(y);
140 auto x_span = make_span(x);
149 throw std::invalid_argument(
"dense Krylov vectors have different sizes");
153 [[nodiscard]]
static auto make_span(DenseHostVector<Scalar>
const& vector)
155 using extents_type = stdex::dextents<uni20::index_type, 1>;
156 return stdex::mdspan<Scalar const, extents_type>(
157 vector.values.data(), extents_type{static_cast<uni20::index_type>(vector.values.size())});
160 std::size_t dimension_ = 0;
161 int allocation_count_ = 0;
165 int set_zero_count_ = 0;
166 int inner_product_count_ = 0;
177 throw std::invalid_argument(
"dense Krylov operator matrix has the wrong size");
180 [[nodiscard]]
int matvec_count() const noexcept {
return matvec_count_; }
184 if (x.
values.size() != this->problem_dimension() || y.
values.size() != this->problem_dimension())
186 throw std::invalid_argument(
"dense Krylov matvec vector has the wrong size");
202 std::vector<Scalar> matrix_;
203 int matvec_count_ = 0;
206static_assert(KrylovMatrixFreeOperator<DenseHostVectorOps<float>, DenseHostVector<float>,
float>);
207static_assert(KrylovMatrixFreeOperator<DenseHostVectorOps<double>, DenseHostVector<double>,
double>);
208static_assert(KrylovMatrixFreeOperator<DenseHostVectorOps<uni20::complex<float>>,
210static_assert(KrylovMatrixFreeOperator<DenseHostVectorOps<uni20::complex<double>>,
Exact arithmetic or an explicit binary working precision.
Definition core/precision.hpp:13
Dense host vector algebra without an assembled operator.
Definition dense_host_vector.hpp:43
void scal(DenseHostVector< Scalar > &x, Scalar alpha)
Definition dense_host_vector.hpp:108
int set_zero_count() const noexcept
Definition dense_host_vector.hpp:75
uni20::make_real_t< Scalar > norm(DenseHostVector< Scalar > const &x)
Definition dense_host_vector.hpp:136
auto prototype_view(DenseHostVector< Scalar > const &&) const =delete
auto prototype_view(std::span< Element, Extent > x) const -> std::span< Scalar const >
Copy a borrowed span descriptor, including a temporary span.
Definition dense_host_vector.hpp:64
int axpy_count() const noexcept
Definition dense_host_vector.hpp:73
int inner_product_count() const noexcept
Definition dense_host_vector.hpp:76
DenseHostVector< Scalar > allocate_like(std::span< Scalar const > x)
Allocate independent owning storage from a retained span's extent.
Definition dense_host_vector.hpp:85
Scalar inner_product(DenseHostVector< Scalar > const &x, DenseHostVector< Scalar > const &y)
Definition dense_host_vector.hpp:126
int copy_count() const noexcept
Definition dense_host_vector.hpp:72
int allocation_count() const noexcept
Definition dense_host_vector.hpp:71
int scal_count() const noexcept
Definition dense_host_vector.hpp:74
void set_zero(DenseHostVector< Scalar > &x)
Definition dense_host_vector.hpp:117
std::size_t vector_dimension(std::span< Scalar const > x) const noexcept
Definition dense_host_vector.hpp:69
std::size_t problem_dimension() const noexcept
Definition dense_host_vector.hpp:48
std::size_t dimension() const noexcept
Definition dense_host_vector.hpp:47
int norm_count() const noexcept
Definition dense_host_vector.hpp:77
std::size_t vector_dimension(DenseHostVector< Scalar > const &x) const noexcept
Definition dense_host_vector.hpp:49
void axpy(DenseHostVector< Scalar > &y, Scalar alpha, DenseHostVector< Scalar > const &x)
Definition dense_host_vector.hpp:98
auto prototype_view(DenseHostVector< Scalar > const &x) const -> std::span< Scalar const >
Retain a read-only allocation descriptor without copying vector elements.
Definition dense_host_vector.hpp:55
DenseHostVectorAlgebra(std::size_t dimension)
Definition dense_host_vector.hpp:45
void copy(DenseHostVector< Scalar > &dst, DenseHostVector< Scalar > const &src)
Definition dense_host_vector.hpp:91
DenseHostVector< Scalar > allocate_like(DenseHostVector< Scalar > const &x)
Definition dense_host_vector.hpp:79
Dense reference operator combined with host vector algebra for prototypes.
Definition dense_host_vector.hpp:171
void matvec(DenseHostVector< Scalar > &y, DenseHostVector< Scalar > const &x)
Definition dense_host_vector.hpp:182
DenseHostVectorOps(std::size_t dimension, std::vector< Scalar > matrix)
Definition dense_host_vector.hpp:173
int matvec_count() const noexcept
Definition dense_host_vector.hpp:180
Concept for complex scalar types.
Definition scalar_concepts.hpp:75
Concept for numeric scalar types (integer, real, or complex).
Definition scalar_concepts.hpp:81
locale_t value
Definition data_table.cpp:49
typename detail::complex_type< Real >::type complex
Project-level complex scalar spelling.
Definition types.hpp:66
typename make_real< T >::type make_real_t
Alias for the underlying real-valued type of T.
Definition scalar_traits.hpp:168
Definition block_tensor_vector.hpp:23
Definition data_table.cpp:8
auto inner_product_host(BackendSelector selector, async::Async< LhsTensor > const &lhs, async::Async< RhsTensor > const &rhs)
Return a nonblocking async host C++ scalar inner product through an explicit selector.
Definition linalg/async/reductions.hpp:496
auto norm_host(BackendSelector selector, async::Async< InputTensor > const &input)
Return a nonblocking async host C++ scalar norm through an explicit selector.
Definition linalg/async/reductions.hpp:554
Explicit precision conversion between dense prototype vector spaces.
Definition dense_host_vector.hpp:28
Prototype host vector used by matrix-free Krylov tests and adapters.
Definition dense_host_vector.hpp:20
std::vector< Scalar > values
Definition dense_host_vector.hpp:21
Backend value for the reference host CPU dense linalg oracle.
Definition backend_selector.hpp:55
Tensor sums, inner products, and Euclidean norms with explicit result residency.