hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
device_matrix.hpp
Go to the documentation of this file.
1#pragma once
8
9#include <memory>
10
11#include "hpfem/core/types.hpp"
12
13struct hpfem_gpu_matrix; // the GPU library's object (gpu/include/hpfem_gpu.h)
14
15namespace hpfem::solvers {
16
18 public:
22 explicit DeviceMatrix(const SparseMatrix& matrix);
24 DeviceMatrix(const DeviceMatrix&) = delete;
27 DeviceMatrix& operator=(DeviceMatrix&&) noexcept;
28
30 [[nodiscard]] Vector apply(const Vector& x) const;
32 [[nodiscard]] Matrix apply_many(const Matrix& x) const;
33 [[nodiscard]] Index rows() const noexcept { return rows_; }
34 [[nodiscard]] Index cols() const noexcept { return cols_; }
35
37 [[nodiscard]] static bool available() noexcept;
38
40 [[nodiscard]] ::hpfem_gpu_matrix* handle() const noexcept;
41
42 private:
43 struct Impl;
44 std::unique_ptr<Impl> impl_;
45 Index rows_ = 0;
46 Index cols_ = 0;
47};
48
49} // namespace hpfem::solvers
Definition device_matrix.hpp:17
DeviceMatrix(const SparseMatrix &matrix)
DeviceMatrix & operator=(const DeviceMatrix &)=delete
::hpfem_gpu_matrix * handle() const noexcept
Raw handle of the GPU library (for DeviceStepper; no meaning elsewhere).
Index rows() const noexcept
Definition device_matrix.hpp:33
DeviceMatrix(DeviceMatrix &&) noexcept
Index cols() const noexcept
Definition device_matrix.hpp:34
DeviceMatrix(const DeviceMatrix &)=delete
Vector apply(const Vector &x) const
(one vector: uploaded, multiplied, downloaded).
Matrix apply_many(const Matrix &x) const
One product per column (one transfer for all).
static bool available() noexcept
True if the GPU library is loaded with API version 3 or later and a device is present.
Definition device_arnoldi.hpp:23
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition types.hpp:22
Eigen::SparseMatrix< Complex, Eigen::RowMajor, Index > SparseMatrix
Definition types.hpp:24
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > Vector
Definition types.hpp:20