Ginkgo: ginkgo/core/matrix/hybrid.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
hybrid.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 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
18namespace gko {
19namespace matrix {
20
21
22template <typename ValueType>
23class Dense;
24
25template <typename ValueType, typename IndexType>
26class Csr;
27
28
41template <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#if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
46 public ConvertibleTo<Hybrid<next_precision<ValueType, 2>, IndexType>>,
47#endif
48#if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
49 public ConvertibleTo<Hybrid<next_precision<ValueType, 3>, IndexType>>,
50#endif
51 public ConvertibleTo<Dense<ValueType>>,
52 public ConvertibleTo<Csr<ValueType, IndexType>>,
53 public DiagonalExtractable<ValueType>,
54 public ReadableFromMatrixData<ValueType, IndexType>,
55 public WritableToMatrixData<ValueType, IndexType>,
56 public EnableAbsoluteComputation<
57 remove_complex<Hybrid<ValueType, IndexType>>> {
58 friend class EnablePolymorphicObject<Hybrid, LinOp>;
59 friend class Dense<ValueType>;
60 friend class Csr<ValueType, IndexType>;
61 friend class Hybrid<to_complex<ValueType>, IndexType>;
62 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
63
64public:
65 using EnableLinOp<Hybrid>::convert_to;
66 using EnableLinOp<Hybrid>::move_to;
67 using ConvertibleTo<
68 Hybrid<next_precision<ValueType>, IndexType>>::convert_to;
69 using ConvertibleTo<Hybrid<next_precision<ValueType>, IndexType>>::move_to;
70 using ConvertibleTo<Dense<ValueType>>::convert_to;
71 using ConvertibleTo<Dense<ValueType>>::move_to;
72 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
73 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
74 using ReadableFromMatrixData<ValueType, IndexType>::read;
75
76 using value_type = ValueType;
77 using index_type = IndexType;
78 using mat_data = matrix_data<ValueType, IndexType>;
79 using device_mat_data = device_matrix_data<ValueType, IndexType>;
80 using coo_type = Coo<ValueType, IndexType>;
81 using ell_type = Ell<ValueType, IndexType>;
82 using absolute_type = remove_complex<Hybrid>;
83
84
94 class strategy_type {
95 public:
99 strategy_type()
100 : ell_num_stored_elements_per_row_(zero<size_type>()),
101 coo_nnz_(zero<size_type>())
102 {}
103
116 void compute_hybrid_config(const array<size_type>& row_nnz,
117 size_type* ell_num_stored_elements_per_row,
118 size_type* coo_nnz)
119 {
120 array<size_type> ref_row_nnz(row_nnz.get_executor()->get_master(),
121 row_nnz.get_size());
122 ref_row_nnz = row_nnz;
123 ell_num_stored_elements_per_row_ =
124 this->compute_ell_num_stored_elements_per_row(&ref_row_nnz);
125 coo_nnz_ = this->compute_coo_nnz(ref_row_nnz);
126 *ell_num_stored_elements_per_row = ell_num_stored_elements_per_row_;
127 *coo_nnz = coo_nnz_;
128 }
129
135 size_type get_ell_num_stored_elements_per_row() const noexcept
136 {
137 return ell_num_stored_elements_per_row_;
138 }
139
145 size_type get_coo_nnz() const noexcept { return coo_nnz_; }
146
154 virtual size_type compute_ell_num_stored_elements_per_row(
155 array<size_type>* row_nnz) const = 0;
156
157 protected:
166 size_type compute_coo_nnz(const array<size_type>& row_nnz) const
167 {
168 size_type coo_nnz = 0;
169 auto row_nnz_val = row_nnz.get_const_data();
170 for (size_type i = 0; i < row_nnz.get_size(); i++) {
171 if (row_nnz_val[i] > ell_num_stored_elements_per_row_) {
172 coo_nnz +=
173 row_nnz_val[i] - ell_num_stored_elements_per_row_;
174 }
175 }
176 return coo_nnz;
177 }
178
179 private:
180 size_type ell_num_stored_elements_per_row_;
181 size_type coo_nnz_;
182 };
183
188 class column_limit : public strategy_type {
189 public:
195 explicit column_limit(size_type num_column = 0)
196 : num_columns_(num_column)
197 {}
198
199 size_type compute_ell_num_stored_elements_per_row(
200 array<size_type>* row_nnz) const override
201 {
202 return num_columns_;
203 }
204
210 auto get_num_columns() const { return num_columns_; }
211
212 private:
213 size_type num_columns_;
214 };
215
223 class imbalance_limit : public strategy_type {
224 public:
231 explicit imbalance_limit(double percent = 0.8) : percent_(percent)
232 {
233 percent_ = std::min(percent_, 1.0);
234 percent_ = std::max(percent_, 0.0);
235 }
236
237 size_type compute_ell_num_stored_elements_per_row(
238 array<size_type>* row_nnz) const override
239 {
240 auto row_nnz_val = row_nnz->get_data();
241 auto num_rows = row_nnz->get_size();
242 if (num_rows == 0) {
243 return 0;
244 }
245 std::sort(row_nnz_val, row_nnz_val + num_rows);
246 if (percent_ < 1) {
247 auto percent_pos = static_cast<size_type>(num_rows * percent_);
248 return row_nnz_val[percent_pos];
249 } else {
250 return row_nnz_val[num_rows - 1];
251 }
252 }
253
259 auto get_percentage() const { return percent_; }
260
261 private:
262 double percent_;
263 };
264
270 class imbalance_bounded_limit : public strategy_type {
271 public:
275 imbalance_bounded_limit(double percent = 0.8, double ratio = 0.0001)
276 : strategy_(imbalance_limit(percent)), ratio_(ratio)
277 {}
278
279 size_type compute_ell_num_stored_elements_per_row(
280 array<size_type>* row_nnz) const override
281 {
282 auto num_rows = row_nnz->get_size();
283 auto ell_cols =
284 strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
285 return std::min(ell_cols,
286 static_cast<size_type>(num_rows * ratio_));
287 }
288
294 auto get_percentage() const { return strategy_.get_percentage(); }
295
301 auto get_ratio() const { return ratio_; }
302
303 private:
304 imbalance_limit strategy_;
305 double ratio_;
306 };
307
308
314 class minimal_storage_limit : public strategy_type {
315 public:
319 minimal_storage_limit()
320 : strategy_(
321 imbalance_limit(static_cast<double>(sizeof(IndexType)) /
322 (sizeof(ValueType) + 2 * sizeof(IndexType))))
323 {}
324
325 size_type compute_ell_num_stored_elements_per_row(
326 array<size_type>* row_nnz) const override
327 {
328 return strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
329 }
330
336 auto get_percentage() const { return strategy_.get_percentage(); }
337
338 private:
339 imbalance_limit strategy_;
340 };
341
342
347 class automatic : public strategy_type {
348 public:
352 automatic() : strategy_(imbalance_bounded_limit(1.0 / 3.0, 0.001)) {}
353
354 size_type compute_ell_num_stored_elements_per_row(
355 array<size_type>* row_nnz) const override
356 {
357 return strategy_.compute_ell_num_stored_elements_per_row(row_nnz);
358 }
359
360 private:
361 imbalance_bounded_limit strategy_;
362 };
363
364 friend class Hybrid<previous_precision<ValueType>, IndexType>;
365
366 void convert_to(
367 Hybrid<next_precision<ValueType>, IndexType>* result) const override;
368
369 void move_to(Hybrid<next_precision<ValueType>, IndexType>* result) override;
370
371#if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
372 friend class Hybrid<previous_precision<ValueType, 2>, IndexType>;
373 using ConvertibleTo<
374 Hybrid<next_precision<ValueType, 2>, IndexType>>::convert_to;
375 using ConvertibleTo<
376 Hybrid<next_precision<ValueType, 2>, IndexType>>::move_to;
377
378 void convert_to(
379 Hybrid<next_precision<ValueType, 2>, IndexType>* result) const override;
380
381 void move_to(
382 Hybrid<next_precision<ValueType, 2>, IndexType>* result) override;
383#endif
384
385#if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
386 friend class Hybrid<previous_precision<ValueType, 3>, IndexType>;
387 using ConvertibleTo<
388 Hybrid<next_precision<ValueType, 3>, IndexType>>::convert_to;
389 using ConvertibleTo<
390 Hybrid<next_precision<ValueType, 3>, IndexType>>::move_to;
391
392 void convert_to(
393 Hybrid<next_precision<ValueType, 3>, IndexType>* result) const override;
394
395 void move_to(
396 Hybrid<next_precision<ValueType, 3>, IndexType>* result) override;
397#endif
398
399 void convert_to(Dense<ValueType>* other) const override;
400
401 void move_to(Dense<ValueType>* other) override;
402
403 void convert_to(Csr<ValueType, IndexType>* other) const override;
404
405 void move_to(Csr<ValueType, IndexType>* other) override;
406
407 void read(const mat_data& data) override;
408
409 void read(const device_mat_data& data) override;
410
411 void read(device_mat_data&& data) override;
412
413 void write(mat_data& data) const override;
414
415 std::unique_ptr<Diagonal<ValueType>> extract_diagonal() const override;
416
417 std::unique_ptr<absolute_type> compute_absolute() const override;
418
419 void compute_absolute_inplace() override;
420
426 value_type* get_ell_values() noexcept { return ell_->get_values(); }
427
435 const value_type* get_const_ell_values() const noexcept
436 {
437 return ell_->get_const_values();
438 }
439
445 index_type* get_ell_col_idxs() noexcept { return ell_->get_col_idxs(); }
446
454 const index_type* get_const_ell_col_idxs() const noexcept
455 {
456 return ell_->get_const_col_idxs();
457 }
458
464 size_type get_ell_num_stored_elements_per_row() const noexcept
465 {
466 return ell_->get_num_stored_elements_per_row();
467 }
468
474 size_type get_ell_stride() const noexcept { return ell_->get_stride(); }
475
481 size_type get_ell_num_stored_elements() const noexcept
482 {
483 return ell_->get_num_stored_elements();
484 }
485
497 value_type& ell_val_at(size_type row, size_type idx) noexcept
498 {
499 return ell_->val_at(row, idx);
500 }
501
505 value_type ell_val_at(size_type row, size_type idx) const noexcept
506 {
507 return ell_->val_at(row, idx);
508 }
509
520 index_type& ell_col_at(size_type row, size_type idx) noexcept
521 {
522 return ell_->col_at(row, idx);
523 }
524
528 index_type ell_col_at(size_type row, size_type idx) const noexcept
529 {
530 return ell_->col_at(row, idx);
531 }
532
538 const ell_type* get_ell() const noexcept { return ell_.get(); }
539
545 value_type* get_coo_values() noexcept { return coo_->get_values(); }
546
554 const value_type* get_const_coo_values() const noexcept
555 {
556 return coo_->get_const_values();
557 }
558
564 index_type* get_coo_col_idxs() noexcept { return coo_->get_col_idxs(); }
565
573 const index_type* get_const_coo_col_idxs() const noexcept
574 {
575 return coo_->get_const_col_idxs();
576 }
577
583 index_type* get_coo_row_idxs() noexcept { return coo_->get_row_idxs(); }
584
592 const index_type* get_const_coo_row_idxs() const noexcept
593 {
594 return coo_->get_const_row_idxs();
595 }
596
602 size_type get_coo_num_stored_elements() const noexcept
603 {
604 return coo_->get_num_stored_elements();
605 }
606
612 const coo_type* get_coo() const noexcept { return coo_.get(); }
613
619 size_type get_num_stored_elements() const noexcept
620 {
621 return coo_->get_num_stored_elements() +
622 ell_->get_num_stored_elements();
623 }
624
630 std::shared_ptr<strategy_type> get_strategy() const noexcept
631 {
632 return strategy_;
633 }
634
642 template <typename HybType>
643 std::shared_ptr<typename HybType::strategy_type> get_strategy() const;
644
655 static std::unique_ptr<Hybrid> create(
656 std::shared_ptr<const Executor> exec,
657 std::shared_ptr<strategy_type> strategy =
658 std::make_shared<automatic>());
659
671 static std::unique_ptr<Hybrid> create(
672 std::shared_ptr<const Executor> exec, const dim<2>& size,
673 std::shared_ptr<strategy_type> strategy =
674 std::make_shared<automatic>());
675
688 static std::unique_ptr<Hybrid> create(
689 std::shared_ptr<const Executor> exec, const dim<2>& size,
690 size_type num_stored_elements_per_row,
691 std::shared_ptr<strategy_type> strategy =
692 std::make_shared<automatic>());
693
706 static std::unique_ptr<Hybrid> create(
707 std::shared_ptr<const Executor> exec, const dim<2>& size,
708 size_type num_stored_elements_per_row, size_type stride,
709 std::shared_ptr<strategy_type> strategy);
710
724 static std::unique_ptr<Hybrid> create(
725 std::shared_ptr<const Executor> exec, const dim<2>& size,
726 size_type num_stored_elements_per_row, size_type stride,
727 size_type num_nonzeros = {},
728 std::shared_ptr<strategy_type> strategy =
729 std::make_shared<automatic>());
730
735 Hybrid& operator=(const Hybrid&);
736
742 Hybrid& operator=(Hybrid&&);
743
748 Hybrid(const Hybrid&);
749
755 Hybrid(Hybrid&&);
756
757protected:
758 Hybrid(std::shared_ptr<const Executor> exec, const dim<2>& size = {},
759 size_type num_stored_elements_per_row = 0, size_type stride = 0,
760 size_type num_nonzeros = 0,
761 std::shared_ptr<strategy_type> strategy =
762 std::make_shared<automatic>());
763
774 void resize(dim<2> new_size, size_type ell_row_nnz, size_type coo_nnz);
775
776 void apply_impl(const LinOp* b, LinOp* x) const override;
777
778 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
779 LinOp* x) const override;
780
781private:
782 std::unique_ptr<ell_type> ell_;
783 std::unique_ptr<coo_type> coo_;
784 std::shared_ptr<strategy_type> strategy_;
785};
786
787
788template <typename ValueType, typename IndexType>
789template <typename HybType>
790std::shared_ptr<typename HybType::strategy_type>
791 Hybrid<ValueType, IndexType>::get_strategy() const
792{
793 static_assert(
794 std::is_same<HybType, Hybrid<typename HybType::value_type,
795 typename HybType::index_type>>::value,
796 "The given `HybType` type must be of type `matrix::Hybrid`!");
797
798 std::shared_ptr<typename HybType::strategy_type> strategy;
799 if (std::dynamic_pointer_cast<automatic>(strategy_)) {
800 strategy = std::make_shared<typename HybType::automatic>();
801 } else if (auto temp = std::dynamic_pointer_cast<minimal_storage_limit>(
802 strategy_)) {
803 // minimal_storage_limit is related to ValueType and IndexType size.
804 if (sizeof(value_type) == sizeof(typename HybType::value_type) &&
805 sizeof(index_type) == sizeof(typename HybType::index_type)) {
806 strategy =
807 std::make_shared<typename HybType::minimal_storage_limit>();
808 } else {
809 strategy = std::make_shared<typename HybType::imbalance_limit>(
810 temp->get_percentage());
811 }
812 } else if (auto temp = std::dynamic_pointer_cast<imbalance_bounded_limit>(
813 strategy_)) {
814 strategy = std::make_shared<typename HybType::imbalance_bounded_limit>(
815 temp->get_percentage(), temp->get_ratio());
816 } else if (auto temp =
817 std::dynamic_pointer_cast<imbalance_limit>(strategy_)) {
818 strategy = std::make_shared<typename HybType::imbalance_limit>(
819 temp->get_percentage());
820 } else if (auto temp = std::dynamic_pointer_cast<column_limit>(strategy_)) {
821 strategy = std::make_shared<typename HybType::column_limit>(
822 temp->get_num_columns());
823 } else {
824 GKO_NOT_SUPPORTED(strategy_);
825 }
826 return strategy;
827}
828
829
830} // namespace matrix
831} // namespace gko
832
833
834#endif // GKO_PUBLIC_CORE_MATRIX_HYBRID_HPP_
gko::DiagonalExtractable
The diagonal of a LinOp implementing this interface can be extracted.
Definition lin_op.hpp:743
gko::EnableAbsoluteComputation
The EnableAbsoluteComputation mixin provides the default implementations of compute_absolute_linop an...
Definition lin_op.hpp:794
gko::EnableLinOp
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:879
gko::EnablePolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
gko::LinOp
Definition lin_op.hpp:117
gko::ReadableFromMatrixData
A LinOp implementing this interface can read its data from a matrix_data structure.
Definition lin_op.hpp:605
gko::WritableToMatrixData
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition lin_op.hpp:660
gko::array
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
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:687
gko::array::get_executor
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor associated with the array.
Definition array.hpp:703
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:696
gko::array::get_size
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition array.hpp:670
gko::device_matrix_data
This type is a device-side equivalent to matrix_data.
Definition device_matrix_data.hpp:36
gko::matrix::Coo
COO stores a matrix in the coordinate matrix format.
Definition coo.hpp:65
gko::matrix::Csr
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition csr.hpp:126
gko::matrix::Dense
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:120
gko::matrix::Ell
ELL is a matrix format where stride with explicit zeros is used such that all rows have the same numb...
Definition ell.hpp:66
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:354
gko::matrix::Hybrid::automatic::automatic
automatic()
Creates an automatic strategy.
Definition hybrid.hpp:352
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:199
gko::matrix::Hybrid::column_limit::column_limit
column_limit(size_type num_column=0)
Creates a column_limit strategy.
Definition hybrid.hpp:195
gko::matrix::Hybrid::column_limit::get_num_columns
auto get_num_columns() const
Get the number of columns limit.
Definition hybrid.hpp:210
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:270
gko::matrix::Hybrid::imbalance_bounded_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition hybrid.hpp:294
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:279
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:275
gko::matrix::Hybrid::imbalance_bounded_limit::get_ratio
auto get_ratio() const
Get the ratio setting.
Definition hybrid.hpp:301
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:223
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:237
gko::matrix::Hybrid::imbalance_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition hybrid.hpp:259
gko::matrix::Hybrid::imbalance_limit::imbalance_limit
imbalance_limit(double percent=0.8)
Creates a imbalance_limit strategy.
Definition hybrid.hpp:231
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:325
gko::matrix::Hybrid::minimal_storage_limit::get_percentage
auto get_percentage() const
Get the percent setting.
Definition hybrid.hpp:336
gko::matrix::Hybrid::minimal_storage_limit::minimal_storage_limit
minimal_storage_limit()
Creates a minimal_storage_limit strategy.
Definition hybrid.hpp:319
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::strategy_type
strategy_type()
Creates a strategy_type.
Definition hybrid.hpp:99
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:135
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:116
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:145
gko::matrix::Hybrid
HYBRID is a matrix format which splits the matrix into ELLPACK and COO format.
Definition hybrid.hpp:57
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:619
gko::matrix::Hybrid::create
static std::unique_ptr< Hybrid > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, size_type num_stored_elements_per_row, size_type stride, std::shared_ptr< strategy_type > strategy)
Creates an uninitialized Hybrid matrix of the specified size and method.
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:583
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:497
gko::matrix::Hybrid::create
static std::unique_ptr< Hybrid > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, size_type num_stored_elements_per_row, std::shared_ptr< strategy_type > strategy=std::make_shared< automatic >())
Creates an uninitialized Hybrid matrix of the specified size and method.
gko::matrix::Hybrid::get_ell_stride
size_type get_ell_stride() const noexcept
Returns the stride of the ell part.
Definition hybrid.hpp:474
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:602
gko::matrix::Hybrid::compute_absolute
std::unique_ptr< absolute_type > compute_absolute() const override
Gets the AbsoluteLinOp.
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:528
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:564
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:505
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:592
gko::matrix::Hybrid::Hybrid
Hybrid(Hybrid &&)
Move-assigns a Hybrid matrix.
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:435
gko::matrix::Hybrid::get_ell
const ell_type * get_ell() const noexcept
Returns the matrix of the ell part.
Definition hybrid.hpp:538
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::matrix::Hybrid::get_ell_values
value_type * get_ell_values() noexcept
Returns the values of the ell part.
Definition hybrid.hpp:426
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::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:481
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:464
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:573
gko::matrix::Hybrid::Hybrid
Hybrid(const Hybrid &)
Copy-assigns a Hybrid matrix.
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:445
gko::matrix::Hybrid::compute_absolute_inplace
void compute_absolute_inplace() override
Compute absolute inplace on each element.
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:454
gko::matrix::Hybrid::get_strategy
std::shared_ptr< strategy_type > get_strategy() const noexcept
Returns the strategy.
Definition hybrid.hpp:630
gko::matrix::Hybrid::get_coo
const coo_type * get_coo() const noexcept
Returns the matrix of the coo part.
Definition hybrid.hpp:612
gko::matrix::Hybrid::create
static std::unique_ptr< Hybrid > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, size_type num_stored_elements_per_row, size_type stride, size_type num_nonzeros={}, std::shared_ptr< strategy_type > strategy=std::make_shared< automatic >())
Creates an uninitialized Hybrid matrix of the specified size and method.
gko::matrix::Hybrid::get_coo_values
value_type * get_coo_values() noexcept
Returns the values of the coo part.
Definition hybrid.hpp:545
gko::matrix::Hybrid::create
static std::unique_ptr< Hybrid > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, std::shared_ptr< strategy_type > strategy=std::make_shared< automatic >())
Creates an uninitialized Hybrid matrix of the specified size and method.
gko::matrix::Hybrid::operator=
Hybrid & operator=(const Hybrid &)
Copy-assigns a Hybrid matrix.
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:520
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:554
gko::matrix::Hybrid::operator=
Hybrid & operator=(Hybrid &&)
Move-assigns a Hybrid matrix.
gko::matrix
The matrix namespace.
Definition dense_cache.hpp:24
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::remove_complex
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition math.hpp:264
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:283
gko::move_to
virtual void move_to(result_type *result)=0
Converts the implementer to an object of type result_type by moving data from this object.
gko::zero
constexpr T zero()
Returns the additive identity for T.
Definition math.hpp:626
gko::convert_to
virtual void convert_to(result_type *result) const =0
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
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::previous_precision
typename detail::find_precision_impl< T, -step >::type previous_precision
Obtains the previous move type of T in the singly-linked precision corresponding bfloat16/half.
Definition math.hpp:473
gko::next_precision
typename detail::find_precision_impl< T, step >::type next_precision
Obtains the next move type of T in the singly-linked precision corresponding bfloat16/half.
Definition math.hpp:466
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::dim
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:26
gko::matrix_data
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:126