Ginkgo  Generated from pipelines/1478841010 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
hybrid.hpp
1 // SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_MATRIX_HYBRID_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_HYBRID_HPP_
7 
8 
9 #include <algorithm>
10 
11 #include <ginkgo/core/base/array.hpp>
12 #include <ginkgo/core/base/lin_op.hpp>
13 #include <ginkgo/core/matrix/coo.hpp>
14 #include <ginkgo/core/matrix/csr.hpp>
15 #include <ginkgo/core/matrix/ell.hpp>
16 
17 
18 namespace gko {
19 namespace matrix {
20 
21 
22 template <typename ValueType>
23 class Dense;
24 
25 template <typename ValueType, typename IndexType>
26 class Csr;
27 
28 
41 template <typename ValueType = default_precision, typename IndexType = int32>
42 class Hybrid
43  : public EnableLinOp<Hybrid<ValueType, IndexType>>,
44  public ConvertibleTo<Hybrid<next_precision<ValueType>, IndexType>>,
45  public ConvertibleTo<Dense<ValueType>>,
46  public ConvertibleTo<Csr<ValueType, IndexType>>,
47  public DiagonalExtractable<ValueType>,
48  public ReadableFromMatrixData<ValueType, IndexType>,
49  public WritableToMatrixData<ValueType, IndexType>,
50  public EnableAbsoluteComputation<
51  remove_complex<Hybrid<ValueType, IndexType>>> {
52  friend class EnablePolymorphicObject<Hybrid, LinOp>;
53  friend class Dense<ValueType>;
54  friend class Csr<ValueType, IndexType>;
55  friend class Hybrid<to_complex<ValueType>, IndexType>;
56 
57 
58 public:
61  using ConvertibleTo<
62  Hybrid<next_precision<ValueType>, IndexType>>::convert_to;
63  using ConvertibleTo<Hybrid<next_precision<ValueType>, IndexType>>::move_to;
64  using ConvertibleTo<Dense<ValueType>>::convert_to;
65  using ConvertibleTo<Dense<ValueType>>::move_to;
66  using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
67  using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
69 
70  using value_type = ValueType;
71  using index_type = IndexType;
72  using mat_data = matrix_data<ValueType, IndexType>;
73  using device_mat_data = device_matrix_data<ValueType, IndexType>;
74  using coo_type = Coo<ValueType, IndexType>;
75  using ell_type = Ell<ValueType, IndexType>;
76  using absolute_type = remove_complex<Hybrid>;
77 
78 
88  class strategy_type {
89  public:
94  : ell_num_stored_elements_per_row_(zero<size_type>()),
95  coo_nnz_(zero<size_type>())
96  {}
97 
111  size_type* ell_num_stored_elements_per_row,
112  size_type* coo_nnz)
113  {
114  array<size_type> ref_row_nnz(row_nnz.get_executor()->get_master(),
115  row_nnz.get_size());
116  ref_row_nnz = row_nnz;
117  ell_num_stored_elements_per_row_ =
118  this->compute_ell_num_stored_elements_per_row(&ref_row_nnz);
119  coo_nnz_ = this->compute_coo_nnz(ref_row_nnz);
120  *ell_num_stored_elements_per_row = ell_num_stored_elements_per_row_;
121  *coo_nnz = coo_nnz_;
122  }
123 
130  {
131  return ell_num_stored_elements_per_row_;
132  }
133 
139  size_type get_coo_nnz() const noexcept { return coo_nnz_; }
140 
149  array<size_type>* row_nnz) const = 0;
150 
151  protected:
160  size_type compute_coo_nnz(const array<size_type>& row_nnz) const
161  {
162  size_type coo_nnz = 0;
163  auto row_nnz_val = row_nnz.get_const_data();
164  for (size_type i = 0; i < row_nnz.get_size(); i++) {
165  if (row_nnz_val[i] > ell_num_stored_elements_per_row_) {
166  coo_nnz +=
167  row_nnz_val[i] - ell_num_stored_elements_per_row_;
168  }
169  }
170  return coo_nnz;
171  }
172 
173  private:
174  size_type ell_num_stored_elements_per_row_;
175  size_type coo_nnz_;
176  };
177 
182  class column_limit : public strategy_type {
183  public:
189  explicit column_limit(size_type num_column = 0)
190  : num_columns_(num_column)
191  {}
192 
194  array<size_type>* row_nnz) const override
195  {
196  return num_columns_;
197  }
198 
204  auto get_num_columns() const { return num_columns_; }
205 
206  private:
207  size_type num_columns_;
208  };
209 
218  public:
225  explicit imbalance_limit(double percent = 0.8) : percent_(percent)
226  {
227  percent_ = std::min(percent_, 1.0);
228  percent_ = std::max(percent_, 0.0);
229  }
230 
232  array<size_type>* row_nnz) const override
233  {
234  auto row_nnz_val = row_nnz->get_data();
235  auto num_rows = row_nnz->get_size();
236  if (num_rows == 0) {
237  return 0;
238  }
239  std::sort(row_nnz_val, row_nnz_val + num_rows);
240  if (percent_ < 1) {
241  auto percent_pos = static_cast<size_type>(num_rows * percent_);
242  return row_nnz_val[percent_pos];
243  } else {
244  return row_nnz_val[num_rows - 1];
245  }
246  }
247 
253  auto get_percentage() const { return percent_; }
254 
255  private:
256  double percent_;
257  };
258 
265  public:
269  imbalance_bounded_limit(double percent = 0.8, double ratio = 0.0001)
270  : strategy_(imbalance_limit(percent)), ratio_(ratio)
271  {}
272 
274  array<size_type>* row_nnz) const override
275  {
276  auto num_rows = row_nnz->get_size();
277  auto ell_cols =
278  strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
279  return std::min(ell_cols,
280  static_cast<size_type>(num_rows * ratio_));
281  }
282 
288  auto get_percentage() const { return strategy_.get_percentage(); }
289 
295  auto get_ratio() const { return ratio_; }
296 
297  private:
298  imbalance_limit strategy_;
299  double ratio_;
300  };
301 
302 
309  public:
314  : strategy_(
315  imbalance_limit(static_cast<double>(sizeof(IndexType)) /
316  (sizeof(ValueType) + 2 * sizeof(IndexType))))
317  {}
318 
320  array<size_type>* row_nnz) const override
321  {
322  return strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
323  }
324 
330  auto get_percentage() const { return strategy_.get_percentage(); }
331 
332  private:
333  imbalance_limit strategy_;
334  };
335 
336 
341  class automatic : public strategy_type {
342  public:
346  automatic() : strategy_(imbalance_bounded_limit(1.0 / 3.0, 0.001)) {}
347 
349  array<size_type>* row_nnz) const override
350  {
351  return strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
352  }
353 
354  private:
355  imbalance_bounded_limit strategy_;
356  };
357 
358  friend class Hybrid<next_precision<ValueType>, IndexType>;
359 
360  void convert_to(
361  Hybrid<next_precision<ValueType>, IndexType>* result) const override;
362 
363  void move_to(Hybrid<next_precision<ValueType>, IndexType>* result) override;
364 
365  void convert_to(Dense<ValueType>* other) const override;
366 
367  void move_to(Dense<ValueType>* other) override;
368 
369  void convert_to(Csr<ValueType, IndexType>* other) const override;
370 
371  void move_to(Csr<ValueType, IndexType>* other) override;
372 
373  void read(const mat_data& data) override;
374 
375  void read(const device_mat_data& data) override;
376 
377  void read(device_mat_data&& data) override;
378 
379  void write(mat_data& data) const override;
380 
381  std::unique_ptr<Diagonal<ValueType>> extract_diagonal() const override;
382 
383  std::unique_ptr<absolute_type> compute_absolute() const override;
384 
385  void compute_absolute_inplace() override;
386 
392  value_type* get_ell_values() noexcept { return ell_->get_values(); }
393 
401  const value_type* get_const_ell_values() const noexcept
402  {
403  return ell_->get_const_values();
404  }
405 
411  index_type* get_ell_col_idxs() noexcept { return ell_->get_col_idxs(); }
412 
420  const index_type* get_const_ell_col_idxs() const noexcept
421  {
422  return ell_->get_const_col_idxs();
423  }
424 
431  {
432  return ell_->get_num_stored_elements_per_row();
433  }
434 
440  size_type get_ell_stride() const noexcept { return ell_->get_stride(); }
441 
448  {
449  return ell_->get_num_stored_elements();
450  }
451 
463  value_type& ell_val_at(size_type row, size_type idx) noexcept
464  {
465  return ell_->val_at(row, idx);
466  }
467 
471  value_type ell_val_at(size_type row, size_type idx) const noexcept
472  {
473  return ell_->val_at(row, idx);
474  }
475 
486  index_type& ell_col_at(size_type row, size_type idx) noexcept
487  {
488  return ell_->col_at(row, idx);
489  }
490 
494  index_type ell_col_at(size_type row, size_type idx) const noexcept
495  {
496  return ell_->col_at(row, idx);
497  }
498 
504  const ell_type* get_ell() const noexcept { return ell_.get(); }
505 
511  value_type* get_coo_values() noexcept { return coo_->get_values(); }
512 
520  const value_type* get_const_coo_values() const noexcept
521  {
522  return coo_->get_const_values();
523  }
524 
530  index_type* get_coo_col_idxs() noexcept { return coo_->get_col_idxs(); }
531 
539  const index_type* get_const_coo_col_idxs() const noexcept
540  {
541  return coo_->get_const_col_idxs();
542  }
543 
549  index_type* get_coo_row_idxs() noexcept { return coo_->get_row_idxs(); }
550 
558  const index_type* get_const_coo_row_idxs() const noexcept
559  {
560  return coo_->get_const_row_idxs();
561  }
562 
569  {
570  return coo_->get_num_stored_elements();
571  }
572 
578  const coo_type* get_coo() const noexcept { return coo_.get(); }
579 
586  {
587  return coo_->get_num_stored_elements() +
588  ell_->get_num_stored_elements();
589  }
590 
596  std::shared_ptr<strategy_type> get_strategy() const noexcept
597  {
598  return strategy_;
599  }
600 
608  template <typename HybType>
609  std::shared_ptr<typename HybType::strategy_type> get_strategy() const;
610 
621  static std::unique_ptr<Hybrid> create(
622  std::shared_ptr<const Executor> exec,
623  std::shared_ptr<strategy_type> strategy =
624  std::make_shared<automatic>());
625 
637  static std::unique_ptr<Hybrid> create(
638  std::shared_ptr<const Executor> exec, const dim<2>& size,
639  std::shared_ptr<strategy_type> strategy =
640  std::make_shared<automatic>());
641 
654  static std::unique_ptr<Hybrid> create(
655  std::shared_ptr<const Executor> exec, const dim<2>& size,
656  size_type num_stored_elements_per_row,
657  std::shared_ptr<strategy_type> strategy =
658  std::make_shared<automatic>());
659 
672  static std::unique_ptr<Hybrid> create(
673  std::shared_ptr<const Executor> exec, const dim<2>& size,
674  size_type num_stored_elements_per_row, size_type stride,
675  std::shared_ptr<strategy_type> strategy);
676 
690  static std::unique_ptr<Hybrid> create(
691  std::shared_ptr<const Executor> exec, const dim<2>& size,
692  size_type num_stored_elements_per_row, size_type stride,
693  size_type num_nonzeros = {},
694  std::shared_ptr<strategy_type> strategy =
695  std::make_shared<automatic>());
696 
701  Hybrid& operator=(const Hybrid&);
702 
708  Hybrid& operator=(Hybrid&&);
709 
714  Hybrid(const Hybrid&);
715 
721  Hybrid(Hybrid&&);
722 
723 protected:
724  Hybrid(std::shared_ptr<const Executor> exec, const dim<2>& size = {},
725  size_type num_stored_elements_per_row = 0, size_type stride = 0,
726  size_type num_nonzeros = 0,
727  std::shared_ptr<strategy_type> strategy =
728  std::make_shared<automatic>());
729 
740  void resize(dim<2> new_size, size_type ell_row_nnz, size_type coo_nnz);
741 
742  void apply_impl(const LinOp* b, LinOp* x) const override;
743 
744  void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
745  LinOp* x) const override;
746 
747 private:
748  std::unique_ptr<ell_type> ell_;
749  std::unique_ptr<coo_type> coo_;
750  std::shared_ptr<strategy_type> strategy_;
751 };
752 
753 
754 template <typename ValueType, typename IndexType>
755 template <typename HybType>
756 std::shared_ptr<typename HybType::strategy_type>
758 {
759  static_assert(
760  std::is_same<HybType, Hybrid<typename HybType::value_type,
761  typename HybType::index_type>>::value,
762  "The given `HybType` type must be of type `matrix::Hybrid`!");
763 
764  std::shared_ptr<typename HybType::strategy_type> strategy;
765  if (std::dynamic_pointer_cast<automatic>(strategy_)) {
766  strategy = std::make_shared<typename HybType::automatic>();
767  } else if (auto temp = std::dynamic_pointer_cast<minimal_storage_limit>(
768  strategy_)) {
769  // minimal_storage_limit is related to ValueType and IndexType size.
770  if (sizeof(value_type) == sizeof(typename HybType::value_type) &&
771  sizeof(index_type) == sizeof(typename HybType::index_type)) {
772  strategy =
773  std::make_shared<typename HybType::minimal_storage_limit>();
774  } else {
775  strategy = std::make_shared<typename HybType::imbalance_limit>(
776  temp->get_percentage());
777  }
778  } else if (auto temp = std::dynamic_pointer_cast<imbalance_bounded_limit>(
779  strategy_)) {
780  strategy = std::make_shared<typename HybType::imbalance_bounded_limit>(
781  temp->get_percentage(), temp->get_ratio());
782  } else if (auto temp =
783  std::dynamic_pointer_cast<imbalance_limit>(strategy_)) {
784  strategy = std::make_shared<typename HybType::imbalance_limit>(
785  temp->get_percentage());
786  } else if (auto temp = std::dynamic_pointer_cast<column_limit>(strategy_)) {
787  strategy = std::make_shared<typename HybType::column_limit>(
788  temp->get_num_columns());
789  } else {
790  GKO_NOT_SUPPORTED(strategy_);
791  }
792  return strategy;
793 }
794 
795 
796 } // namespace matrix
797 } // namespace gko
798 
799 
800 #endif // GKO_PUBLIC_CORE_MATRIX_HYBRID_HPP_
gko::matrix::Hybrid::get_const_coo_values
const value_type * get_const_coo_values() const noexcept
Returns the values of the coo part.
Definition: hybrid.hpp:520
gko::matrix::Hybrid::ell_col_at
index_type ell_col_at(size_type row, size_type idx) const noexcept
Returns the idx-th column index of the row-th row in the ell part.
Definition: hybrid.hpp:494
gko::matrix::Hybrid::get_ell_num_stored_elements_per_row
size_type get_ell_num_stored_elements_per_row() const noexcept
Returns the number of stored elements per row of ell part.
Definition: hybrid.hpp:430
gko::matrix::Hybrid::get_const_coo_row_idxs
const index_type * get_const_coo_row_idxs() const noexcept
Returns the row indexes of the coo part.
Definition: hybrid.hpp:558
gko::matrix::Hybrid::minimal_storage_limit::minimal_storage_limit
minimal_storage_limit()
Creates a minimal_storage_limit strategy.
Definition: hybrid.hpp:313
gko::EnablePolymorphicAssignment< ConcreteLinOp >::move_to
void move_to(result_type *result) override
Definition: polymorphic_object.hpp:731
gko::EnablePolymorphicAssignment< ConcreteLinOp >::convert_to
void convert_to(result_type *result) const override
Definition: polymorphic_object.hpp:729
gko::matrix::Csr
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition: matrix.hpp:27
gko::matrix::Hybrid::imbalance_bounded_limit::imbalance_bounded_limit
imbalance_bounded_limit(double percent=0.8, double ratio=0.0001)
Creates a imbalance_bounded_limit strategy.
Definition: hybrid.hpp:269
gko::matrix::Hybrid::column_limit
column_limit is a strategy_type which decides the number of stored elements per row of the ell part b...
Definition: hybrid.hpp:182
gko::matrix::Hybrid::automatic::compute_ell_num_stored_elements_per_row
size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const override
Computes the number of stored elements per row of the ell part.
Definition: hybrid.hpp:348
gko::matrix::Hybrid::imbalance_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition: hybrid.hpp:253
gko::ReadableFromMatrixData::read
virtual void read(const matrix_data< ValueType, IndexType > &data)=0
Reads a matrix from a matrix_data structure.
gko::matrix::Dense
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: dense_cache.hpp:19
gko::matrix::Hybrid::strategy_type
strategy_type is to decide how to set the hybrid config.
Definition: hybrid.hpp:88
gko::matrix::Hybrid::strategy_type::compute_hybrid_config
void compute_hybrid_config(const array< size_type > &row_nnz, size_type *ell_num_stored_elements_per_row, size_type *coo_nnz)
Computes the config of the Hybrid matrix (ell_num_stored_elements_per_row and coo_nnz).
Definition: hybrid.hpp:110
gko::matrix::Hybrid::ell_col_at
index_type & ell_col_at(size_type row, size_type idx) noexcept
Returns the idx-th column index of the row-th row in the ell part.
Definition: hybrid.hpp:486
gko::matrix::Hybrid::get_ell
const ell_type * get_ell() const noexcept
Returns the matrix of the ell part.
Definition: hybrid.hpp:504
gko::matrix::Hybrid::get_coo_values
value_type * get_coo_values() noexcept
Returns the values of the coo part.
Definition: hybrid.hpp:511
gko::matrix::Hybrid::get_ell_col_idxs
index_type * get_ell_col_idxs() noexcept
Returns the column indexes of the ell part.
Definition: hybrid.hpp:411
gko::matrix::Hybrid::strategy_type::get_ell_num_stored_elements_per_row
size_type get_ell_num_stored_elements_per_row() const noexcept
Returns the number of stored elements per row of the ell part.
Definition: hybrid.hpp:129
gko::matrix::Hybrid::column_limit::compute_ell_num_stored_elements_per_row
size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const override
Computes the number of stored elements per row of the ell part.
Definition: hybrid.hpp:193
gko::matrix::Hybrid::get_ell_values
value_type * get_ell_values() noexcept
Returns the values of the ell part.
Definition: hybrid.hpp:392
gko::matrix::Hybrid::automatic
automatic is a strategy_type which decides the number of stored elements per row of the ell part auto...
Definition: hybrid.hpp:341
gko::matrix::Hybrid::get_coo_num_stored_elements
size_type get_coo_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the coo part.
Definition: hybrid.hpp:568
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:86
gko::matrix::Hybrid::read
void read(const mat_data &data) override
Reads a matrix from a matrix_data structure.
gko::matrix::Hybrid::get_coo_row_idxs
index_type * get_coo_row_idxs() noexcept
Returns the row indexes of the coo part.
Definition: hybrid.hpp:549
gko::matrix::Hybrid::minimal_storage_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition: hybrid.hpp:330
gko::matrix::Hybrid::get_ell_stride
size_type get_ell_stride() const noexcept
Returns the stride of the ell part.
Definition: hybrid.hpp:440
gko::matrix::Hybrid::get_const_ell_values
const value_type * get_const_ell_values() const noexcept
Returns the values of the ell part.
Definition: hybrid.hpp:401
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::matrix::Hybrid::minimal_storage_limit::compute_ell_num_stored_elements_per_row
size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const override
Computes the number of stored elements per row of the ell part.
Definition: hybrid.hpp:319
gko::matrix::Hybrid::get_num_stored_elements
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the matrix.
Definition: hybrid.hpp:585
gko::array< size_type >
gko::dim< 2 >
gko::matrix::Hybrid::get_coo_col_idxs
index_type * get_coo_col_idxs() noexcept
Returns the column indexes of the coo part.
Definition: hybrid.hpp:530
gko::matrix::Hybrid::get_const_coo_col_idxs
const index_type * get_const_coo_col_idxs() const noexcept
Returns the column indexes of the coo part.
Definition: hybrid.hpp:539
gko::matrix::Hybrid::strategy_type::compute_ell_num_stored_elements_per_row
virtual size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const =0
Computes the number of stored elements per row of the ell part.
gko::matrix::Hybrid::strategy_type::get_coo_nnz
size_type get_coo_nnz() const noexcept
Returns the number of nonzeros of the coo part.
Definition: hybrid.hpp:139
gko::matrix::Hybrid::imbalance_limit::compute_ell_num_stored_elements_per_row
size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const override
Computes the number of stored elements per row of the ell part.
Definition: hybrid.hpp:231
gko::matrix::Hybrid::imbalance_bounded_limit
imbalance_bounded_limit is a strategy_type which decides the number of stored elements per row of the...
Definition: hybrid.hpp:264
gko::next_precision
typename detail::next_precision_impl< T >::type next_precision
Obtains the next type in the singly-linked precision list.
Definition: math.hpp:461
gko::array::get_data
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:673
gko::matrix::Hybrid::get_strategy
std::shared_ptr< strategy_type > get_strategy() const noexcept
Returns the strategy.
Definition: hybrid.hpp:596
gko::matrix::Hybrid::create
static std::unique_ptr< Hybrid > create(std::shared_ptr< const Executor > exec, std::shared_ptr< strategy_type > strategy=std::make_shared< automatic >())
Creates an uninitialized Hybrid matrix of specified method.
gko::matrix::Hybrid::strategy_type::strategy_type
strategy_type()
Creates a strategy_type.
Definition: hybrid.hpp:93
gko::matrix::Hybrid::automatic::automatic
automatic()
Creates an automatic strategy.
Definition: hybrid.hpp:346
gko::array::get_executor
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor associated with the array.
Definition: array.hpp:689
gko::matrix::Hybrid::get_const_ell_col_idxs
const index_type * get_const_ell_col_idxs() const noexcept
Returns the column indexes of the ell part.
Definition: hybrid.hpp:420
gko::matrix::Hybrid::compute_absolute_inplace
void compute_absolute_inplace() override
Compute absolute inplace on each element.
gko::matrix::Hybrid::column_limit::get_num_columns
auto get_num_columns() const
Get the number of columns limit.
Definition: hybrid.hpp:204
gko::matrix::Hybrid::compute_absolute
std::unique_ptr< absolute_type > compute_absolute() const override
Gets the AbsoluteLinOp.
gko::matrix::Hybrid::column_limit::column_limit
column_limit(size_type num_column=0)
Creates a column_limit strategy.
Definition: hybrid.hpp:189
gko::matrix::Hybrid::ell_val_at
value_type & ell_val_at(size_type row, size_type idx) noexcept
Returns the idx-th non-zero element of the row-th row in the ell part.
Definition: hybrid.hpp:463
gko::matrix::Hybrid::write
void write(mat_data &data) const override
Writes a matrix to a matrix_data structure.
gko::matrix::Hybrid::imbalance_limit
imbalance_limit is a strategy_type which decides the number of stored elements per row of the ell par...
Definition: hybrid.hpp:217
gko::matrix::Ell
ELL is a matrix format where stride with explicit zeros is used such that all rows have the same numb...
Definition: csr.hpp:31
gko::matrix::Hybrid::Hybrid
Hybrid(const Hybrid &)
Copy-assigns a Hybrid matrix.
gko::matrix::Hybrid::ell_val_at
value_type ell_val_at(size_type row, size_type idx) const noexcept
Returns the idx-th non-zero element of the row-th row in the ell part.
Definition: hybrid.hpp:471
gko::matrix::Hybrid
HYBRID is a matrix format which splits the matrix into ELLPACK and COO format.
Definition: coo.hpp:32
gko::array::get_const_data
const value_type * get_const_data() const noexcept
Returns a constant pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:682
gko::matrix::Hybrid::get_ell_num_stored_elements
size_type get_ell_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the ell part.
Definition: hybrid.hpp:447
gko::matrix::Hybrid::extract_diagonal
std::unique_ptr< Diagonal< ValueType > > extract_diagonal() const override
Extracts the diagonal entries of the matrix into a vector.
gko::array::get_size
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:656
gko::matrix::Hybrid::get_coo
const coo_type * get_coo() const noexcept
Returns the matrix of the coo part.
Definition: hybrid.hpp:578
gko::matrix::Hybrid::imbalance_limit::imbalance_limit
imbalance_limit(double percent=0.8)
Creates a imbalance_limit strategy.
Definition: hybrid.hpp:225
gko::matrix::Hybrid::imbalance_bounded_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition: hybrid.hpp:288
gko::matrix::Hybrid::minimal_storage_limit
minimal_storage_limit is a strategy_type which decides the number of stored elements per row of the e...
Definition: hybrid.hpp:308
gko::matrix::Hybrid::imbalance_bounded_limit::compute_ell_num_stored_elements_per_row
size_type compute_ell_num_stored_elements_per_row(array< size_type > *row_nnz) const override
Computes the number of stored elements per row of the ell part.
Definition: hybrid.hpp:273
gko::matrix::Hybrid::imbalance_bounded_limit::get_ratio
auto get_ratio() const
Get the ratio setting.
Definition: hybrid.hpp:295
gko::LinOp::LinOp
LinOp(const LinOp &)=default
Copy-constructs a LinOp.
gko::matrix::Hybrid::operator=
Hybrid & operator=(const Hybrid &)
Copy-assigns a Hybrid matrix.
gko::zero
constexpr T zero()
Returns the additive identity for T.
Definition: math.hpp:746
gko::to_complex
typename detail::to_complex_s< T >::type to_complex
Obtain the type which adds the complex of complex/scalar type or the template parameter of class by a...
Definition: math.hpp:344
gko::matrix::Coo
COO stores a matrix in the coordinate matrix format.
Definition: coo.hpp:50