Ginkgo  Generated from pipelines/3136675824 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
lin_op.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_BASE_LIN_OP_HPP_
6 #define GKO_PUBLIC_CORE_BASE_LIN_OP_HPP_
7 
8 
9 #include <memory>
10 #include <type_traits>
11 #include <utility>
12 
13 #include <ginkgo/core/base/abstract_factory.hpp>
14 #include <ginkgo/core/base/device_matrix_data.hpp>
15 #include <ginkgo/core/base/dim.hpp>
16 #include <ginkgo/core/base/exception_helpers.hpp>
17 #include <ginkgo/core/base/math.hpp>
18 #include <ginkgo/core/base/matrix_assembly_data.hpp>
19 #include <ginkgo/core/base/matrix_data.hpp>
20 #include <ginkgo/core/base/multivector.hpp>
21 #include <ginkgo/core/base/polymorphic_object.hpp>
22 #include <ginkgo/core/base/types.hpp>
23 #include <ginkgo/core/base/utils.hpp>
24 #include <ginkgo/core/log/logger.hpp>
25 
26 
27 namespace gko {
28 namespace matrix {
29 
30 
31 template <typename ValueType>
32 class Diagonal;
33 
34 template <typename ValueType>
35 class Dense;
36 
37 
38 } // namespace matrix
39 
40 
41 namespace detail {
42 
43 
44 template <typename T>
45 struct is_dense_ptr : std::false_type {};
46 
47 template <typename T>
48 struct is_dense_ptr<const T&> : is_dense_ptr<std::decay_t<T>> {};
49 
50 template <typename T>
51 struct is_dense_ptr<T&> : is_dense_ptr<std::decay_t<T>> {};
52 
53 template <typename ValueType>
54 struct is_dense_ptr<matrix::Dense<ValueType>*> : std::true_type {};
55 
56 template <typename ValueType>
57 struct is_dense_ptr<const matrix::Dense<ValueType>*> : std::true_type {};
58 
59 template <typename ValueType>
60 struct is_dense_ptr<std::shared_ptr<matrix::Dense<ValueType>>>
61  : std::true_type {};
62 
63 template <typename ValueType>
64 struct is_dense_ptr<std::shared_ptr<const matrix::Dense<ValueType>>>
65  : std::true_type {};
66 
67 template <typename ValueType>
68 struct is_dense_ptr<std::unique_ptr<matrix::Dense<ValueType>>>
69  : std::true_type {};
70 
71 template <typename ValueType>
72 struct is_dense_ptr<std::unique_ptr<const matrix::Dense<ValueType>>>
73  : std::true_type {};
74 
75 
76 } // namespace detail
77 
78 
79 template <typename T>
80 constexpr bool is_dense_ptr = detail::is_dense_ptr<T>::value;
81 
82 
163 class LinOp : public PolymorphicObject {
164 public:
178  {
179  this->template log<log::Logger::linop_apply_started>(this, b.get(),
180  x.get());
181  this->validate_application_parameters(b.get(), x.get());
182  auto exec = this->get_executor();
183  this->apply_impl(make_temporary_clone(exec, b).get(),
184  make_temporary_clone(exec, x).get());
185  this->template log<log::Logger::linop_apply_completed>(this, b.get(),
186  x.get());
187  }
188 
210  {
211  this->template log<log::Logger::linop_advanced_apply_started>(
212  this, alpha.get(), b.get(), beta.get(), x.get());
213  this->validate_application_parameters(alpha.get(), b.get(), beta.get(),
214  x.get());
215  auto exec = this->get_executor();
216  this->apply_impl(make_temporary_clone(exec, alpha).get(),
217  make_temporary_clone(exec, b).get(),
218  make_temporary_clone(exec, beta).get(),
219  make_temporary_clone(exec, x).get());
220  this->template log<log::Logger::linop_advanced_apply_completed>(
221  this, alpha.get(), b.get(), beta.get(), x.get());
222  }
223 
224  template <typename DenseIn, typename DenseOut,
225  typename = std::enable_if_t<is_dense_ptr<DenseIn> &&
226  is_dense_ptr<DenseOut>>>
227  [[deprecated(
228  "Use apply(ptr_param<const AbstractMultiVector> b, "
229  "ptr_param<AbstractMultiVector> x) by storing vectors as "
230  "matrix::MultiVector")]] void
231  apply(const DenseIn& b, DenseOut&& x) const
232  {
233  apply(b->as_const_multivector_view(), x->as_multivector_view());
234  }
235 
236  template <typename DenseAlpha, typename DenseIn, typename DenseBeta,
237  typename DenseOut,
238  typename = std::enable_if_t<
239  is_dense_ptr<DenseAlpha> && is_dense_ptr<DenseIn> &&
240  is_dense_ptr<DenseBeta> && is_dense_ptr<DenseOut>>>
241  [[deprecated(
242  "Use apply(ptr_param<const AbstractMultiVector> alpha, ptr_param<const "
243  "AbstractMultiVector> b, ptr_param<const AbstractMultiVector> beta, "
244  "ptr_param<AbstractMultiVector> x) by storing vectors as "
245  "matrix::MultiVector")]] void
246  apply(const DenseAlpha& alpha, const DenseIn& b, const DenseBeta& beta,
247  DenseOut&& x) const
248  {
249  apply(alpha->as_const_multivector_view(),
250  b->as_const_multivector_view(), beta->as_const_multivector_view(),
251  x->as_multivector_view());
252  }
253 
259  const dim<2>& get_size() const noexcept { return size_; }
260 
268  virtual bool apply_uses_initial_guess() const { return false; }
269 
271  LinOp& operator=(const LinOp&) = default;
272 
279  {
280  if (this != &other) {
281  PolymorphicObject::operator=(std::move(other));
282  this->set_size(other.get_size());
283  other.set_size({});
284  }
285  return *this;
286  }
287 
289  LinOp(const LinOp&) = default;
290 
295  LinOp(LinOp&& other)
296  : PolymorphicObject(std::move(other)),
297  size_{std::exchange(other.size_, dim<2>{})}
298  {}
299 
300 protected:
307  explicit LinOp(std::shared_ptr<const Executor> exec,
308  const dim<2>& size = dim<2>{})
309  : PolymorphicObject(exec), size_{size}
310  {}
311 
317  void set_size(const dim<2>& value) noexcept { size_ = value; }
318 
328  virtual void apply_impl(const AbstractMultiVector* b,
329  AbstractMultiVector* x) const = 0;
330 
344  virtual void apply_impl(const AbstractMultiVector* alpha,
345  const AbstractMultiVector* b,
346  const AbstractMultiVector* beta,
347  AbstractMultiVector* x) const;
348 
356  void validate_application_parameters(const AbstractMultiVector* b,
357  const AbstractMultiVector* x) const;
358 
362  void validate_application_parameters(const LinOp* b, const LinOp* x) const
363  {
364  GKO_ASSERT_CONFORMANT(this, b);
365  GKO_ASSERT_EQUAL_ROWS(this, x);
366  GKO_ASSERT_EQUAL_COLS(b, x);
367  }
368 
378  void validate_application_parameters(const AbstractMultiVector* alpha,
379  const AbstractMultiVector* b,
380  const AbstractMultiVector* beta,
381  const AbstractMultiVector* x) const
382  {
383  this->validate_application_parameters(b, x);
384  GKO_ASSERT_EQUAL_DIMENSIONS(alpha, dim<2>(1, 1));
385  GKO_ASSERT_EQUAL_DIMENSIONS(beta, dim<2>(1, 1));
386  }
387 
388 private:
389  dim<2> size_{};
390 };
391 
392 
448  : public AbstractFactory<LinOp, std::shared_ptr<const LinOp>> {
449 public:
450  using AbstractFactory::AbstractFactory;
451 
452  std::unique_ptr<LinOp> generate(std::shared_ptr<const LinOp> input) const
453  {
454  this->template log<log::Logger::linop_factory_generate_started>(
455  this, input.get());
456  const auto exec = this->get_executor();
457  std::unique_ptr<LinOp> generated;
458  if (input->get_executor() == exec) {
459  generated = this->AbstractFactory::generate(input);
460  } else {
461  generated =
462  this->AbstractFactory::generate(gko::clone(exec, input));
463  }
464  this->template log<log::Logger::linop_factory_generate_completed>(
465  this, input.get(), generated.get());
466  return generated;
467  }
468 
475  class ReuseData {
476  public:
477  ReuseData();
478 
479  virtual ~ReuseData();
480 
481  ReuseData(const ReuseData&) = delete;
482 
483  ReuseData(ReuseData&&) = delete;
484 
485  ReuseData& operator=(const ReuseData&) = delete;
486 
487  ReuseData& operator=(ReuseData&&) = delete;
488  };
489 
494  virtual std::unique_ptr<ReuseData> create_empty_reuse_data() const;
495 
536  std::unique_ptr<LinOp> generate_reuse(std::shared_ptr<const LinOp> input,
537  ReuseData& reuse_data) const;
538 
551  virtual void check_reuse_consistent(const LinOp* input,
552  const ReuseData& reuse_data) const;
553 
554 protected:
566  virtual std::unique_ptr<LinOp> generate_reuse_impl(
567  std::shared_ptr<const LinOp> input, ReuseData& reuse_data) const;
568 };
569 
570 
597 public:
598  virtual ~Transposable() = default;
599 
605  virtual std::unique_ptr<LinOp> transpose() const = 0;
606 
613  virtual std::unique_ptr<LinOp> conj_transpose() const = 0;
614 };
615 
616 
646 template <typename IndexType>
647 class Permutable {
648 public:
649  virtual ~Permutable() = default;
650 
665  virtual std::unique_ptr<LinOp> permute(
666  const array<IndexType>* permutation_indices) const
667  {
668  return as<Permutable>(this->row_permute(permutation_indices))
669  ->column_permute(permutation_indices);
670  }
671 
686  virtual std::unique_ptr<LinOp> inverse_permute(
687  const array<IndexType>* permutation_indices) const
688  {
689  return as<Permutable>(this->inverse_row_permute(permutation_indices))
690  ->inverse_column_permute(permutation_indices);
691  }
692 
706  virtual std::unique_ptr<LinOp> row_permute(
707  const array<IndexType>* permutation_indices) const = 0;
708 
723  virtual std::unique_ptr<LinOp> column_permute(
724  const array<IndexType>* permutation_indices) const = 0;
725 
739  virtual std::unique_ptr<LinOp> inverse_row_permute(
740  const array<IndexType>* permutation_indices) const = 0;
741 
756  virtual std::unique_ptr<LinOp> inverse_column_permute(
757  const array<IndexType>* permutation_indices) const = 0;
758 };
759 
760 
767 template <typename ValueType, typename IndexType>
769 public:
770  using value_type = ValueType;
771  using index_type = IndexType;
772 
773  virtual ~ReadableFromMatrixData() = default;
774 
780  virtual void read(const matrix_data<ValueType, IndexType>& data) = 0;
781 
788  {
789  this->read(data.get_ordered_data());
790  }
791 
798  {
799  this->read(data.copy_to_host());
800  }
801 
809  {
810  this->read(data.copy_to_host());
811  data.empty_out();
812  }
813 };
814 
815 
822 template <typename ValueType, typename IndexType>
824 public:
825  using value_type = ValueType;
826  using index_type = IndexType;
827 
828  virtual ~WritableToMatrixData() = default;
829 
835  virtual void write(matrix_data<ValueType, IndexType>& data) const = 0;
836 
847  {
849  this->write(host_data);
851  data.get_executor(), host_data);
852  }
853 };
854 
855 
863 public:
864  virtual ~Preconditionable() = default;
865 
871  virtual std::shared_ptr<const LinOp> get_preconditioner() const
872  {
873  return preconditioner_;
874  }
875 
882  virtual void set_preconditioner(std::shared_ptr<const LinOp> new_precond)
883  {
884  preconditioner_ = new_precond;
885  }
886 
887 private:
888  std::shared_ptr<const LinOp> preconditioner_{};
889 };
890 
891 
902 public:
903  virtual ~DiagonalLinOpExtractable() = default;
904 
910  virtual std::unique_ptr<LinOp> extract_diagonal_linop() const = 0;
911 };
912 
913 
921 template <typename ValueType>
923 public:
924  using value_type = ValueType;
925 
926  virtual ~DiagonalExtractable() = default;
927 
928  std::unique_ptr<LinOp> extract_diagonal_linop() const override;
929 
935  virtual std::unique_ptr<matrix::Diagonal<ValueType>> extract_diagonal()
936  const = 0;
937 };
938 
939 
946 public:
947  virtual ~AbsoluteComputable() = default;
948 
954  virtual std::unique_ptr<LinOp> compute_absolute_linop() const = 0;
955 
959  virtual void compute_absolute_inplace() = 0;
960 };
961 
962 
974 template <typename AbsoluteLinOp>
976 public:
977  using absolute_type = AbsoluteLinOp;
978 
979  virtual ~EnableAbsoluteComputation() = default;
980 
981  std::unique_ptr<LinOp> compute_absolute_linop() const override
982  {
983  return this->compute_absolute();
984  }
985 
991  virtual std::unique_ptr<absolute_type> compute_absolute() const = 0;
992 };
993 
994 
1000 public:
1001  virtual ~ScaledIdentityAddable() = default;
1002 
1012 
1013 private:
1014  virtual void add_scaled_identity_impl(const AbstractMultiVector* a,
1015  const AbstractMultiVector* b) = 0;
1016 };
1017 
1018 
1036 template <typename ConcreteFactory, typename ConcreteLinOp,
1037  typename ParametersType, typename PolymorphicBase = LinOpFactory>
1039  EnableDefaultFactory<ConcreteFactory, ConcreteLinOp, ParametersType,
1040  PolymorphicBase>;
1041 
1042 
1063 template <typename ConcreteFactory, typename ConcreteLinOp,
1064  typename ParametersType, typename ReuseDataType,
1065  typename PolymorphicBase = LinOpFactory>
1067  : public EnableDefaultLinOpFactory<ConcreteFactory, ConcreteLinOp,
1068  ParametersType, PolymorphicBase> {
1069  using base_type =
1070  EnableDefaultLinOpFactory<ConcreteFactory, ConcreteLinOp,
1071  ParametersType, PolymorphicBase>;
1072 
1073 public:
1075  std::unique_ptr<ConcreteLinOp> generate_reuse(
1076  std::shared_ptr<const LinOp> input,
1077  LinOpFactory::ReuseData& reuse_data) const
1078  {
1079  return std::unique_ptr<ConcreteLinOp>(static_cast<ConcreteLinOp*>(
1080  this->LinOpFactory::generate_reuse(std::move(input), reuse_data)
1081  .release()));
1082  }
1083 
1084  std::unique_ptr<LinOpFactory::ReuseData> create_empty_reuse_data()
1085  const override
1086  {
1087  return std::make_unique<ReuseDataType>();
1088  }
1089 
1090  void check_reuse_consistent(
1091  const LinOp* input,
1092  const LinOpFactory::ReuseData& reuse_data) const override
1093  {
1094  ConcreteLinOp::check_reuse_consistent(
1095  static_cast<const ConcreteFactory*>(this), input,
1096  *as<ReuseDataType>(&reuse_data));
1097  }
1098 
1099 protected:
1100  explicit EnableDefaultReusableLinOpFactory(
1101  std::shared_ptr<const Executor> exec,
1102  const ParametersType& parameters = {})
1103  : base_type(std::move(exec), parameters)
1104  {}
1105 
1106  std::unique_ptr<LinOp> generate_reuse_impl(
1107  std::shared_ptr<const LinOp> input,
1108  LinOpFactory::ReuseData& reuse_data) const override
1109  {
1110  return std::unique_ptr<LinOp>(new ConcreteLinOp(
1111  static_cast<const ConcreteFactory*>(this), std::move(input),
1112  *as<ReuseDataType>(&reuse_data)));
1113  }
1114 };
1115 
1116 
1192 #define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name) \
1193 public: \
1194  const _parameters_name##_type& get_##_parameters_name() const \
1195  { \
1196  return _parameters_name##_; \
1197  } \
1198  \
1199  class _factory_name \
1200  : public ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \
1201  _parameters_name##_type> { \
1202  friend class ::gko::enable_parameters_type<_parameters_name##_type, \
1203  _factory_name>; \
1204  explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
1205  : ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \
1206  _parameters_name##_type>( \
1207  std::move(exec)) \
1208  {} \
1209  explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
1210  const _parameters_name##_type& parameters) \
1211  : ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \
1212  _parameters_name##_type>( \
1213  std::move(exec), parameters) \
1214  {} \
1215  }; \
1216  friend ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \
1217  _parameters_name##_type>; \
1218  \
1219  \
1220 private: \
1221  _parameters_name##_type _parameters_name##_; \
1222  \
1223 public: \
1224  static_assert(true, \
1225  "This assert is used to counter the false positive extra " \
1226  "semi-colon warnings")
1227 
1228 
1265 #define GKO_ENABLE_LIN_OP_FACTORY_WITH_REUSE(_lin_op, _parameters_name, \
1266  _factory_name, _reuse_data_type) \
1267 public: \
1268  const _parameters_name##_type& get_##_parameters_name() const \
1269  { \
1270  return _parameters_name##_; \
1271  } \
1272  \
1273  class _factory_name : public ::gko::EnableDefaultReusableLinOpFactory< \
1274  _factory_name, _lin_op, _parameters_name##_type, \
1275  _reuse_data_type> { \
1276  friend class ::gko::enable_parameters_type<_parameters_name##_type, \
1277  _factory_name>; \
1278  explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
1279  : ::gko::EnableDefaultReusableLinOpFactory< \
1280  _factory_name, _lin_op, _parameters_name##_type, \
1281  _reuse_data_type>(std::move(exec)) \
1282  {} \
1283  explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
1284  const _parameters_name##_type& parameters) \
1285  : ::gko::EnableDefaultReusableLinOpFactory< \
1286  _factory_name, _lin_op, _parameters_name##_type, \
1287  _reuse_data_type>(std::move(exec), parameters) \
1288  {} \
1289  }; \
1290  friend ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \
1291  _parameters_name##_type>; \
1292  friend ::gko::EnableDefaultReusableLinOpFactory< \
1293  _factory_name, _lin_op, _parameters_name##_type, _reuse_data_type>; \
1294  \
1295  \
1296 private: \
1297  _parameters_name##_type _parameters_name##_; \
1298  \
1299 public: \
1300  static_assert(true, \
1301  "This assert is used to counter the false positive extra " \
1302  "semi-colon warnings")
1303 
1304 
1305 } // namespace gko
1306 
1307 
1308 #endif // GKO_PUBLIC_CORE_BASE_LIN_OP_HPP_
gko::device_matrix_data::copy_to_host
host_type copy_to_host() const
Copies the device_matrix_data entries to the host to return a regular matrix_data object with the sam...
gko::read
std::unique_ptr< MatrixType > read(StreamType &&is, MatrixArgs &&... args)
Reads a matrix stored in matrix market format from an input stream.
Definition: mtx_io.hpp:160
gko::LinOp
Definition: lin_op.hpp:163
gko::EnableDefaultReusableLinOpFactory
EnableDefaultLinOpFactory with LinOpFactory::generate_reuse() support, usually used through GKO_ENABL...
Definition: lin_op.hpp:1066
gko::matrix::Dense
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: lin_op.hpp:35
gko::Preconditionable
A LinOp implementing this interface can be preconditioned.
Definition: lin_op.hpp:862
gko::DiagonalExtractable
The diagonal of a LinOp implementing this interface can be extracted.
Definition: lin_op.hpp:922
gko::AbstractFactory
The AbstractFactory is a generic interface template that enables easy implementation of the abstract ...
Definition: abstract_factory.hpp:77
gko::DiagonalLinOpExtractable
The diagonal of a LinOp can be extracted.
Definition: lin_op.hpp:901
gko::PolymorphicObject
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:46
gko::LinOp::LinOp
LinOp(LinOp &&other)
Move-constructs a LinOp.
Definition: lin_op.hpp:295
gko::AbstractFactory::generate
std::unique_ptr< abstract_product_type > generate(Args &&... args) const
Creates a new product from the given components.
Definition: abstract_factory.hpp:97
gko::Permutable::permute
virtual std::unique_ptr< LinOp > permute(const array< IndexType > *permutation_indices) const
Returns a LinOp representing the symmetric row and column permutation of the Permutable object.
Definition: lin_op.hpp:665
gko::device_matrix_data::get_executor
std::shared_ptr< const Executor > get_executor() const
Returns the executor used to store the device_matrix_data entries.
Definition: device_matrix_data.hpp:151
gko::Transposable
Linear operators which support transposition should implement the Transposable interface.
Definition: lin_op.hpp:596
gko::device_matrix_data::create_from_host
static device_matrix_data create_from_host(std::shared_ptr< const Executor > exec, const host_type &data)
Creates a device_matrix_data object from the given host data on the given executor.
gko::AbsoluteComputable
The AbsoluteComputable is an interface that allows to get the component wise absolute of a LinOp.
Definition: lin_op.hpp:945
gko::ptr_param::get
T * get() const
Definition: utils_helper.hpp:77
gko::AbsoluteComputable::compute_absolute_linop
virtual std::unique_ptr< LinOp > compute_absolute_linop() const =0
Gets the absolute LinOp.
gko::EnableDefaultFactory
This mixin provides a default implementation of a concrete factory.
Definition: abstract_factory.hpp:154
gko::clone
detail::cloned_type< Pointer > clone(const Pointer &p)
Creates a unique clone of the object pointed to by p.
Definition: utils_helper.hpp:425
gko::Permutable
Linear operators which support permutation should implement the Permutable interface.
Definition: lin_op.hpp:647
gko::LinOp::operator=
LinOp & operator=(LinOp &&other)
Move-assigns a LinOp.
Definition: lin_op.hpp:278
gko::Preconditionable::get_preconditioner
virtual std::shared_ptr< const LinOp > get_preconditioner() const
Returns the preconditioner operator used by the Preconditionable.
Definition: lin_op.hpp:871
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::ReadableFromMatrixData::read
virtual void read(const device_matrix_data< ValueType, IndexType > &data)
Reads a matrix from a device_matrix_data structure.
Definition: lin_op.hpp:797
gko::array< IndexType >
gko::ReadableFromMatrixData::read
void read(const matrix_assembly_data< ValueType, IndexType > &data)
Reads a matrix from a matrix_assembly_data structure.
Definition: lin_op.hpp:787
gko::dim< 2 >
gko::matrix_data
This structure is used as an intermediate data type to store a sparse matrix.
Definition: matrix_data.hpp:126
gko::LinOp::apply_uses_initial_guess
virtual bool apply_uses_initial_guess() const
Returns true if the linear operator uses the data given in x as an initial guess.
Definition: lin_op.hpp:268
gko::Permutable::inverse_permute
virtual std::unique_ptr< LinOp > inverse_permute(const array< IndexType > *permutation_indices) const
Returns a LinOp representing the symmetric inverse row and column permutation of the Permutable objec...
Definition: lin_op.hpp:686
gko::LinOpFactory::check_reuse_consistent
virtual void check_reuse_consistent(const LinOp *input, const ReuseData &reuse_data) const
Throws if input can't be used with reuse_data.
gko::matrix::Diagonal
This class is a utility which efficiently implements the diagonal matrix (a linear operator which sca...
Definition: lin_op.hpp:32
gko::EnableDefaultReusableLinOpFactory::generate_reuse
std::unique_ptr< ConcreteLinOp > generate_reuse(std::shared_ptr< const LinOp > input, LinOpFactory::ReuseData &reuse_data) const
LinOpFactory::generate_reuse(), returning the concrete LinOp type.
Definition: lin_op.hpp:1075
gko::matrix_assembly_data::get_ordered_data
matrix_data< ValueType, IndexType > get_ordered_data() const
Definition: matrix_assembly_data.hpp:142
gko::Preconditionable::set_preconditioner
virtual void set_preconditioner(std::shared_ptr< const LinOp > new_precond)
Sets the preconditioner operator used by the Preconditionable.
Definition: lin_op.hpp:882
gko::ptr_param
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:43
gko::LinOpFactory::create_empty_reuse_data
virtual std::unique_ptr< ReuseData > create_empty_reuse_data() const
Creates an empty ReuseData.
gko::LinOpFactory::generate_reuse
std::unique_ptr< LinOp > generate_reuse(std::shared_ptr< const LinOp > input, ReuseData &reuse_data) const
Generates a LinOp like generate(), reusing what earlier calls recorded in reuse_data.
gko::AbsoluteComputable::compute_absolute_inplace
virtual void compute_absolute_inplace()=0
Compute absolute inplace on each element.
gko::ReadableFromMatrixData::read
virtual void read(device_matrix_data< ValueType, IndexType > &&data)
Reads a matrix from a device_matrix_data structure.
Definition: lin_op.hpp:808
gko::ScaledIdentityAddable::add_scaled_identity
void add_scaled_identity(ptr_param< const AbstractMultiVector > a, ptr_param< const AbstractMultiVector > b)
Scales this and adds another scalar times the identity to it.
gko::ReadableFromMatrixData
A LinOp implementing this interface can read its data from a matrix_data structure.
Definition: lin_op.hpp:768
gko::WritableToMatrixData
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition: lin_op.hpp:823
gko::LinOp::operator=
LinOp & operator=(const LinOp &)=default
Copy-assigns a LinOp.
gko::write
void write(StreamType &&os, MatrixPtrType &&matrix, layout_type layout=detail::mtx_io_traits< std::remove_cv_t< detail::pointee< MatrixPtrType >>>::default_layout)
Writes a matrix into an output stream in matrix market format.
Definition: mtx_io.hpp:299
gko::transpose
batch_dim< 2, DimensionType > transpose(const batch_dim< 2, DimensionType > &input)
Returns a batch_dim object with its dimensions swapped for batched operators.
Definition: batch_dim.hpp:118
gko::LinOp::apply
void apply(ptr_param< const AbstractMultiVector > b, ptr_param< AbstractMultiVector > x) const
Applies a linear operator to a vector (or a sequence of vectors).
Definition: lin_op.hpp:176
gko::ScaledIdentityAddable
Adds the operation M <- a I + b M for matrix M, identity operator I and scalars a and b,...
Definition: lin_op.hpp:999
gko::matrix_assembly_data
This structure is used as an intermediate type to assemble a sparse matrix.
Definition: matrix_assembly_data.hpp:59
gko::LinOpFactory::ReuseData
Opaque base for the data a factory records in generate_reuse() to speed up later generations.
Definition: lin_op.hpp:475
gko::WritableToMatrixData::write
virtual void write(device_matrix_data< ValueType, IndexType > &data) const
Writes a matrix to a device_matrix_data structure.
Definition: lin_op.hpp:846
gko::EnableAbsoluteComputation::compute_absolute
virtual std::unique_ptr< absolute_type > compute_absolute() const =0
Gets the AbsoluteLinOp.
gko::make_temporary_clone
detail::temporary_clone< detail::pointee< Ptr > > make_temporary_clone(std::shared_ptr< const Executor > exec, Ptr &&ptr)
Creates a temporary_clone.
Definition: temporary_clone.hpp:208
gko::LinOp::apply
void apply(ptr_param< const AbstractMultiVector > alpha, ptr_param< const AbstractMultiVector > b, ptr_param< const AbstractMultiVector > beta, ptr_param< AbstractMultiVector > x) const
Performs the operation x = alpha * op(b) + beta * x.
Definition: lin_op.hpp:206
gko::EnableAbsoluteComputation
The EnableAbsoluteComputation mixin provides the default implementations of compute_absolute_linop an...
Definition: lin_op.hpp:975
gko::LinOpFactory
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition: lin_op.hpp:447
gko::EnableAbsoluteComputation::compute_absolute_linop
std::unique_ptr< LinOp > compute_absolute_linop() const override
Gets the absolute LinOp.
Definition: lin_op.hpp:981
gko::AbstractMultiVector
Abstract interface class for (multi-)vector types.
Definition: multivector.hpp:81
gko::PolymorphicObject::get_executor
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:69
gko::LinOp::get_size
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:259
gko::device_matrix_data
This type is a device-side equivalent to matrix_data.
Definition: device_matrix_data.hpp:36
gko::LinOp::LinOp
LinOp(const LinOp &)=default
Copy-constructs a LinOp.