Ginkgo  Generated from pipelines/3133041809 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
multivector.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_MATRIX_MULTIVECTOR_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_MULTIVECTOR_HPP_
7 
8 
9 #include <initializer_list>
10 #include <type_traits>
11 
12 #include <ginkgo/core/base/array.hpp>
13 #include <ginkgo/core/base/exception_helpers.hpp>
14 #include <ginkgo/core/base/executor.hpp>
15 #include <ginkgo/core/base/lin_op.hpp>
16 #include <ginkgo/core/base/multivector_mixin.hpp>
17 #include <ginkgo/core/base/range_accessors.hpp>
18 #include <ginkgo/core/base/types.hpp>
19 #include <ginkgo/core/base/utils.hpp>
20 #include <ginkgo/core/matrix/device_views.hpp>
21 #include <ginkgo/core/matrix/permutation.hpp>
22 #include <ginkgo/core/matrix/scaled_permutation.hpp>
23 
24 
25 namespace gko {
26 namespace experimental {
27 namespace distributed {
28 
29 
30 template <typename ValueType>
31 class Vector;
32 
33 
34 namespace detail {
35 
36 
37 template <typename ValueType>
38 class VectorCache;
39 
40 
41 } // namespace detail
42 } // namespace distributed
43 } // namespace experimental
44 
45 
46 namespace matrix {
47 
48 
49 template <typename ValueType>
50 class Dense;
51 
52 
66 template <typename ValueType = default_precision>
67 class MultiVector
68  : public EnableMultiVector<MultiVector<ValueType>>,
69  public ConvertibleTo<MultiVector<next_precision<ValueType>>>,
70 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
71  public ConvertibleTo<MultiVector<next_precision<ValueType, 2>>>,
72 #endif
73 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
74  public ConvertibleTo<MultiVector<next_precision<ValueType, 3>>>,
75 #endif
76  public ConvertibleTo<Dense<ValueType>>,
77  public ReadableFromMatrixData<ValueType, int32>,
78  public ReadableFromMatrixData<ValueType, int64>,
79  public WritableToMatrixData<ValueType, int32>,
80  public WritableToMatrixData<ValueType, int64> {
81  friend class Dense<ValueType>;
82  friend class MultiVector<to_complex<ValueType>>;
83  friend class EnableMultiVector<MultiVector>;
84  friend class experimental::distributed::Vector<ValueType>;
85  friend class experimental::distributed::detail::VectorCache<ValueType>;
86  GKO_ASSERT_SUPPORTED_VALUE_TYPE;
87 
88 public:
91  using ConvertibleTo<MultiVector<next_precision<ValueType>>>::convert_to;
92  using ConvertibleTo<MultiVector<next_precision<ValueType>>>::move_to;
93  using ConvertibleTo<Dense<ValueType>>::convert_to;
94  using ConvertibleTo<Dense<ValueType>>::move_to;
97 
98  using value_type = typename EnableMultiVector<MultiVector>::value_type;
99  using index_type = int64;
100  using transposed_type = MultiVector<value_type>;
101  using mat_data64 = matrix_data<value_type, int64>;
102  using mat_data32 = matrix_data<value_type, int32>;
103  using device_mat_data64 = device_matrix_data<value_type, int64>;
104  using device_mat_data32 = device_matrix_data<value_type, int32>;
105  using absolute_type =
107  using real_type = typename EnableMultiVector<MultiVector>::real_type;
108  using complex_type = typename EnableMultiVector<MultiVector>::complex_type;
109  using norm_type = typename EnableMultiVector<MultiVector>::norm_type;
110  using device_view = typename EnableMultiVector<MultiVector>::device_view;
111  using const_device_view =
113 
114  using row_major_range = gko::range<gko::accessor::row_major<ValueType, 2>>;
115 
116  [[nodiscard]] static std::unique_ptr<MultiVector> create_with_type_of(
117  ptr_param<const MultiVector> other,
118  std::shared_ptr<const Executor> exec, const dim<2>& size,
119  size_type stride);
120 
121  friend class MultiVector<previous_precision<ValueType>>;
122 
123  void convert_to(
124  MultiVector<next_precision<ValueType>>* result) const override;
125 
126  void move_to(MultiVector<next_precision<ValueType>>* result) override;
127 
128 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
129  friend class MultiVector<previous_precision<ValueType, 2>>;
130  using ConvertibleTo<MultiVector<next_precision<ValueType, 2>>>::convert_to;
131  using ConvertibleTo<MultiVector<next_precision<ValueType, 2>>>::move_to;
132 
133  void convert_to(
134  MultiVector<next_precision<ValueType, 2>>* result) const override;
135 
136  void move_to(MultiVector<next_precision<ValueType, 2>>* result) override;
137 #endif
138 
139 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
140  friend class MultiVector<previous_precision<ValueType, 3>>;
141  using ConvertibleTo<MultiVector<next_precision<ValueType, 3>>>::convert_to;
142  using ConvertibleTo<MultiVector<next_precision<ValueType, 3>>>::move_to;
143 
144  void convert_to(
145  MultiVector<next_precision<ValueType, 3>>* result) const override;
146 
147  void move_to(MultiVector<next_precision<ValueType, 3>>* result) override;
148 #endif
149 
150  void convert_to(Dense<ValueType>* result) const override;
151 
152  void move_to(Dense<ValueType>* result) override;
153 
154  void read(const mat_data64& data) override;
155 
156  void read(const mat_data32& data) override;
157 
158  void read(const device_mat_data64& data) override;
159 
160  void read(const device_mat_data32& data) override;
161 
162  void read(device_mat_data64&& data) override;
163 
164  void read(device_mat_data32&& data) override;
165 
168 
169  void write(mat_data64& data) const override;
170 
171  void write(mat_data32& data) const override;
172 
173  std::unique_ptr<MultiVector> transpose() const;
174 
175  std::unique_ptr<MultiVector> conj_transpose() const;
176 
183  void transpose(ptr_param<MultiVector> output) const;
184 
192  void conj_transpose(ptr_param<MultiVector> output) const;
193 
204  std::unique_ptr<MultiVector> permute(
205  ptr_param<const Permutation<int32>> permutation,
207 
211  std::unique_ptr<MultiVector> permute(
212  ptr_param<const Permutation<int64>> permutation,
214 
222  void permute(ptr_param<const Permutation<int32>> permutation,
223  ptr_param<MultiVector> output, permute_mode mode) const;
224 
229  void permute(ptr_param<const Permutation<int64>> permutation,
230  ptr_param<MultiVector> output, permute_mode mode) const;
231 
246  std::unique_ptr<MultiVector> permute(
247  ptr_param<const Permutation<int32>> row_permutation,
248  ptr_param<const Permutation<int32>> column_permutation,
249  bool invert = false) const;
250 
255  std::unique_ptr<MultiVector> permute(
256  ptr_param<const Permutation<int64>> row_permutation,
257  ptr_param<const Permutation<int64>> column_permutation,
258  bool invert = false) const;
259 
269  void permute(ptr_param<const Permutation<int32>> row_permutation,
270  ptr_param<const Permutation<int32>> column_permutation,
271  ptr_param<MultiVector> output, bool invert = false) const;
272 
277  void permute(ptr_param<const Permutation<int64>> row_permutation,
278  ptr_param<const Permutation<int64>> column_permutation,
279  ptr_param<MultiVector> output, bool invert = false) const;
280 
290  std::unique_ptr<MultiVector> scale_permute(
291  ptr_param<const ScaledPermutation<value_type, int32>> permutation,
293 
298  std::unique_ptr<MultiVector> scale_permute(
299  ptr_param<const ScaledPermutation<value_type, int64>> permutation,
301 
310  void scale_permute(
311  ptr_param<const ScaledPermutation<value_type, int32>> permutation,
312  ptr_param<MultiVector> output, permute_mode mode) const;
313 
318  void scale_permute(
319  ptr_param<const ScaledPermutation<value_type, int64>> permutation,
320  ptr_param<MultiVector> output, permute_mode mode) const;
321 
334  std::unique_ptr<MultiVector> scale_permute(
335  ptr_param<const ScaledPermutation<value_type, int32>> row_permutation,
336  ptr_param<const ScaledPermutation<value_type, int32>>
337  column_permutation,
338  bool invert = false) const;
339 
344  std::unique_ptr<MultiVector> scale_permute(
345  ptr_param<const ScaledPermutation<value_type, int64>> row_permutation,
346  ptr_param<const ScaledPermutation<value_type, int64>>
347  column_permutation,
348  bool invert = false) const;
349 
359  void scale_permute(
360  ptr_param<const ScaledPermutation<value_type, int32>> row_permutation,
361  ptr_param<const ScaledPermutation<value_type, int32>>
362  column_permutation,
363  ptr_param<MultiVector> output, bool invert = false) const;
364 
370  void scale_permute(
371  ptr_param<const ScaledPermutation<value_type, int64>> row_permutation,
372  ptr_param<const ScaledPermutation<value_type, int64>>
373  column_permutation,
374  ptr_param<MultiVector> output, bool invert = false) const;
375 
376  std::unique_ptr<MultiVector> permute(
377  const array<int32>* permutation_indices) const;
378 
379  std::unique_ptr<MultiVector> permute(
380  const array<int64>* permutation_indices) const;
381 
392  void permute(const array<int32>* permutation_indices,
393  ptr_param<MultiVector> output) const;
394 
398  void permute(const array<int64>* permutation_indices,
399  ptr_param<MultiVector> output) const;
400 
401  std::unique_ptr<MultiVector> inverse_permute(
402  const array<int32>* permutation_indices) const;
403 
404  std::unique_ptr<MultiVector> inverse_permute(
405  const array<int64>* permutation_indices) const;
406 
417  void inverse_permute(const array<int32>* permutation_indices,
418  ptr_param<MultiVector> output) const;
419 
423  void inverse_permute(const array<int64>* permutation_indices,
424  ptr_param<MultiVector> output) const;
425 
426  std::unique_ptr<MultiVector> row_permute(
427  const array<int32>* permutation_indices) const;
428 
429  std::unique_ptr<MultiVector> row_permute(
430  const array<int64>* permutation_indices) const;
431 
441  void row_permute(const array<int32>* permutation_indices,
442  ptr_param<MultiVector> output) const;
443 
447  void row_permute(const array<int64>* permutation_indices,
448  ptr_param<MultiVector> output) const;
449 
461  std::unique_ptr<MultiVector> row_gather(
462  const array<int32>* gather_indices) const;
463 
467  std::unique_ptr<MultiVector> row_gather(
468  const array<int64>* gather_indices) const;
469 
482  void row_gather(const array<int32>* gather_indices,
483  ptr_param<AbstractMultiVector> row_collection) const;
484 
489  void row_gather(const array<int64>* gather_indices,
490  ptr_param<AbstractMultiVector> row_collection) const;
491 
506  void row_gather(ptr_param<const AbstractMultiVector> alpha,
507  const array<int32>* gather_indices,
508  ptr_param<const AbstractMultiVector> beta,
509  ptr_param<AbstractMultiVector> row_collection) const;
510 
516  void row_gather(ptr_param<const AbstractMultiVector> alpha,
517  const array<int64>* gather_indices,
518  ptr_param<const AbstractMultiVector> beta,
519  ptr_param<AbstractMultiVector> row_collection) const;
520 
534  void scatter_add(const array<int32>* scatter_indices,
535  ptr_param<const AbstractMultiVector> source);
536 
541  void scatter_add(const array<int64>* scatter_indices,
542  ptr_param<const AbstractMultiVector> source);
543 
544  std::unique_ptr<MultiVector> column_permute(
545  const array<int32>* permutation_indices) const;
546 
547  std::unique_ptr<MultiVector> column_permute(
548  const array<int64>* permutation_indices) const;
549 
559  void column_permute(const array<int32>* permutation_indices,
560  ptr_param<MultiVector> output) const;
561 
565  void column_permute(const array<int64>* permutation_indices,
566  ptr_param<MultiVector> output) const;
567 
568  std::unique_ptr<MultiVector> inverse_row_permute(
569  const array<int32>* permutation_indices) const;
570 
571  std::unique_ptr<MultiVector> inverse_row_permute(
572  const array<int64>* permutation_indices) const;
573 
584  void inverse_row_permute(const array<int32>* permutation_indices,
585  ptr_param<MultiVector> output) const;
586 
591  void inverse_row_permute(const array<int64>* permutation_indices,
592  ptr_param<MultiVector> output) const;
593 
594  std::unique_ptr<MultiVector> inverse_column_permute(
595  const array<int32>* permutation_indices) const;
596 
597  std::unique_ptr<MultiVector> inverse_column_permute(
598  const array<int64>* permutation_indices) const;
599 
610  void inverse_column_permute(const array<int32>* permutation_indices,
611  ptr_param<MultiVector> output) const;
612 
617  void inverse_column_permute(const array<int64>* permutation_indices,
618  ptr_param<MultiVector> output) const;
619 
625  value_type* get_values() noexcept { return values_.get_data(); }
626 
634  const value_type* get_const_values() const noexcept
635  {
636  return values_.get_const_data();
637  }
638 
644  size_type get_stride() const noexcept { return stride_; }
645 
652  {
653  return values_.get_size();
654  }
655 
656  device_view get_device_view();
657 
658  const_device_view get_const_device_view() const;
659 
670  value_type& at(size_type row, size_type col) noexcept
671  {
672  return values_.get_data()[linearize_index(row, col)];
673  }
674 
678  value_type at(size_type row, size_type col) const noexcept
679  {
680  return values_.get_const_data()[linearize_index(row, col)];
681  }
682 
697  ValueType& at(size_type idx) noexcept
698  {
699  return values_.get_data()[linearize_index(idx)];
700  }
701 
705  ValueType at(size_type idx) const noexcept
706  {
707  return values_.get_const_data()[linearize_index(idx)];
708  }
709 
717  void compute_mean(ptr_param<AbstractMultiVector> result) const;
718 
730  array<char>& tmp) const;
731 
732  void validate_data() const override;
733 
746  static std::unique_ptr<MultiVector> create(
747  std::shared_ptr<const Executor> exec, const dim<2>& size = {},
748  size_type stride = 0);
749 
767  static std::unique_ptr<MultiVector> create(
768  std::shared_ptr<const Executor> exec, const dim<2>& size,
769  array<value_type> values, size_type stride);
770 
775  template <typename InputValueType>
776  GKO_DEPRECATED(
777  "explicitly construct the gko::array argument instead of passing an"
778  "initializer list")
779  static std::unique_ptr<MultiVector> create(
780  std::shared_ptr<const Executor> exec, const dim<2>& size,
781  std::initializer_list<InputValueType> values, size_type stride)
782  {
783  return create(exec, size, array<value_type>{exec, std::move(values)},
784  stride);
785  }
786 
798  static std::unique_ptr<const MultiVector> create_const(
799  std::shared_ptr<const Executor> exec, const dim<2>& size,
800  gko::detail::const_array_view<ValueType>&& values, size_type stride);
801 
802  [[nodiscard]] std::unique_ptr<const Dense<ValueType>> as_const_dense_view()
803  const;
804 
805  [[nodiscard]] std::unique_ptr<Dense<ValueType>> as_dense_view();
806 
819  template <typename OtherValueType,
820  typename = std::enable_if_t<is_complex<ValueType>() ==
821  is_complex<OtherValueType>()>>
823  as_precision();
824 
834  template <typename OtherValueType,
835  typename = std::enable_if_t<is_complex<ValueType>() ==
836  is_complex<OtherValueType>()>>
838  as_precision() const;
839 
846 
853 
858  MultiVector(const MultiVector&);
859 
865 
866 protected:
867  MultiVector(std::shared_ptr<const Executor> exec, const dim<2>& size = {},
868  size_type stride = 0);
869 
870  MultiVector(std::shared_ptr<const Executor> exec, const dim<2>& size,
871  array<value_type> values, size_type stride);
872 
880  virtual std::unique_ptr<MultiVector> create_with_type_of_impl(
881  std::shared_ptr<const Executor> exec, const dim<2>& size,
882  size_type stride) const
883  {
884  return MultiVector::create(exec, size, stride);
885  }
886 
895  void resize(gko::dim<2> new_size);
896 
897  size_type linearize_index(size_type row, size_type col) const noexcept
898  {
899  return row * stride_ + col;
900  }
901 
902  size_type linearize_index(size_type idx) const noexcept
903  {
904  return linearize_index(idx / this->get_size()[1],
905  idx % this->get_size()[1]);
906  }
907 
908  template <typename IndexType>
909  void permute_impl(const Permutation<IndexType>* permutation,
910  permute_mode mode, MultiVector* output) const;
911 
912  template <typename IndexType>
913  void permute_impl(const Permutation<IndexType>* row_permutation,
914  const Permutation<IndexType>* col_permutation,
915  bool invert, MultiVector* output) const;
916 
917  template <typename IndexType>
918  void scale_permute_impl(
919  const ScaledPermutation<ValueType, IndexType>* permutation,
920  permute_mode mode, MultiVector* output) const;
921 
922  template <typename IndexType>
923  void scale_permute_impl(
924  const ScaledPermutation<ValueType, IndexType>* row_permutation,
925  const ScaledPermutation<ValueType, IndexType>* column_permutation,
926  bool invert, MultiVector* output) const;
927 
928  template <typename OutputType, typename IndexType>
929  void row_gather_impl(const array<IndexType>* row_idxs,
930  MultiVector<OutputType>* row_collection) const;
931 
932  template <typename OutputType, typename IndexType>
933  void row_gather_impl(const MultiVector<ValueType>* alpha,
934  const array<IndexType>* row_idxs,
935  const MultiVector<ValueType>* beta,
936  MultiVector<OutputType>* row_collection) const;
937 
938  template <typename IndexType>
939  void scatter_add_impl(const array<IndexType>* scatter_indices,
940  const AbstractMultiVector* source);
941 
942  void compute_absolute_inplace_impl() override;
943 
944  [[nodiscard]] std::unique_ptr<MultiVector> create_with_same_config_impl()
945  const override;
946 
947  [[nodiscard]] std::unique_ptr<MultiVector> create_with_type_of_impl(
948  std::shared_ptr<const Executor> exec, const dim<2>& global_size,
949  const dim<2>& local_size, size_type stride) const override;
950 
951  [[nodiscard]] std::unique_ptr<MultiVector> create_subview_impl(
952  local_span rows, local_span columns) override;
953 
954  [[nodiscard]] std::unique_ptr<const MultiVector> create_subview_impl(
955  local_span rows, local_span columns) const override;
956 
957  [[nodiscard]] std::unique_ptr<MultiVector> create_subview_impl(
958  local_span rows, local_span columns, dim<2> global_size) override;
959 
960  [[nodiscard]] std::unique_ptr<const MultiVector> create_subview_impl(
961  local_span rows, local_span columns, dim<2> global_size) const override;
962 
963  [[nodiscard]] std::unique_ptr<const real_type> create_real_view_impl()
964  const override;
965 
966  [[nodiscard]] std::unique_ptr<real_type> create_real_view_impl() override;
967 
968  [[nodiscard]] std::unique_ptr<absolute_type> compute_absolute_impl()
969  const override;
970 
971  void compute_absolute_impl(absolute_type* result) const override;
972 
973  [[nodiscard]] std::unique_ptr<complex_type> make_complex_impl()
974  const override;
975 
976  [[nodiscard]] std::unique_ptr<real_type> get_real_impl() const override;
977 
978  [[nodiscard]] std::unique_ptr<real_type> get_imag_impl() const override;
979 
980  void make_complex_impl(complex_type* result) const override;
981 
982  void get_real_impl(real_type* result) const override;
983 
984  void get_imag_impl(real_type* result) const override;
985 
986  void fill_impl(value_type value) override;
987 
988  void scale_impl(scaling_param<value_type> alpha) override;
989 
990  void inv_scale_impl(scaling_param<value_type> alpha) override;
991 
992  void add_scaled_impl(scaling_param<value_type> alpha,
993  const MultiVector* b) override;
994 
995  void sub_scaled_impl(scaling_param<value_type> alpha,
996  const MultiVector* b) override;
997 
998  void compute_dot_impl(const MultiVector* b,
999  matrix::MultiVector<value_type>* result,
1000  array<char>& tmp) const override;
1001 
1002  void compute_conj_dot_impl(const MultiVector* b,
1003  matrix::MultiVector<value_type>* result,
1004  array<char>& tmp) const override;
1005 
1006  void compute_norm2_impl(norm_type* result, array<char>& tmp) const override;
1007 
1008  void compute_squared_norm2_impl(norm_type* result,
1009  array<char>& tmp) const override;
1010 
1011  void compute_norm1_impl(norm_type* result, array<char>& tmp) const override;
1012  AbstractMultiVector::device_view<value_type> get_local_device_view_impl()
1013  override;
1014 
1015  AbstractMultiVector::device_view<const value_type>
1016  get_const_local_device_view_impl() const override;
1017 
1018 private:
1019  size_type stride_;
1020  array<value_type> values_;
1021 };
1022 
1023 
1024 } // namespace matrix
1025 
1026 
1027 namespace detail {
1028 
1029 
1030 template <typename ValueType>
1031 struct temporary_clone_helper<matrix::MultiVector<ValueType>> {
1032  static std::unique_ptr<matrix::MultiVector<ValueType>> create(
1033  std::shared_ptr<const Executor> exec,
1034  matrix::MultiVector<ValueType>* ptr, bool copy_data)
1035  {
1036  if (copy_data) {
1037  return gko::clone(std::move(exec), ptr);
1038  } else {
1040  ptr->get_size());
1041  }
1042  }
1043 };
1044 
1045 
1046 } // namespace detail
1047 
1048 
1056 template <typename VecPtr>
1057 std::unique_ptr<
1058  matrix::MultiVector<typename detail::pointee<VecPtr>::value_type>>
1059 make_dense_view(VecPtr&& vector)
1060 {
1061  return vector->create_subview({0, vector->get_size()[0]},
1062  {0, vector->get_size()[1]});
1063 }
1064 
1065 
1073 template <typename VecPtr>
1074 std::unique_ptr<
1075  const matrix::MultiVector<typename detail::pointee<VecPtr>::value_type>>
1076 make_const_dense_view(VecPtr&& vector)
1077 {
1078  return vector->create_subview({0, vector->get_size()[0]},
1079  {0, vector->get_size()[1]});
1080 }
1081 
1082 
1083 } // namespace gko
1084 
1085 
1086 #endif // GKO_PUBLIC_CORE_MATRIX_MULTIVECTOR_HPP_
gko::matrix::permute_mode::rows
The rows will be permuted.
gko::matrix::permute_mode::columns
The columns will be permuted.
gko::ReadableFromMatrixData< ValueType, int32 >::read
virtual void read(const matrix_data< ValueType, int32 > &data)=0
Reads a matrix from a matrix_data structure.
gko::matrix::MultiVector::at
ValueType & at(size_type idx) noexcept
Returns a single element of the multivector.
Definition: multivector.hpp:697
gko::EnableMultiVector::norm_type
matrix::MultiVector< absolute_value_type > norm_type
The vector type used to store the results of reductions to norms.
Definition: multivector_mixin.hpp:170
gko::matrix::MultiVector::get_num_stored_elements
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the multivector.
Definition: multivector.hpp:651
gko::make_const_dense_view
std::unique_ptr< const matrix::MultiVector< typename detail::pointee< VecPtr >::value_type > > make_const_dense_view(VecPtr &&vector)
Creates a view of a given MultiVector vector.
Definition: multivector.hpp:1076
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:102
gko::EnableMultiVector::const_device_view
AbstractMultiVector::device_view< const value_type > const_device_view
The immutable device view type of the local data.
Definition: multivector_mixin.hpp:175
gko::EnableMultiVector::move_to
void move_to(result_type *result) override
Converts the implementer to an object of type result_type by moving data from this object.
Definition: multivector_mixin.hpp:892
gko::matrix::MultiVector::scatter_add
void scatter_add(const array< int32 > *scatter_indices, ptr_param< const AbstractMultiVector > source)
Accumulates rows from source into this multivector at scattered positions: this(scatter_indices(i),...
gko::make_dense_view
std::unique_ptr< matrix::MultiVector< typename detail::pointee< VecPtr >::value_type > > make_dense_view(VecPtr &&vector)
Creates a view of a given MultiVector vector.
Definition: multivector.hpp:1059
gko::EnableMultiVector::real_type
typename traits::real_type real_type
The vector type holding real or imaginary parts of this vector.
Definition: multivector_mixin.hpp:164
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::AbstractMultiVector::get_size
dim< 2 > get_size() const noexcept
Gets the size (number of rows and columns) of this vector.
gko::EnableMultiVector::convert_to
void convert_to(result_type *result) const override
Definition: multivector_mixin.hpp:885
gko::matrix::MultiVector::get_stride
size_type get_stride() const noexcept
Returns the stride of the multivector.
Definition: multivector.hpp:644
gko::matrix::MultiVector::MultiVector
MultiVector(const MultiVector &)
Copy-constructs a MultiVector.
gko::range
A range is a multidimensional view of the memory.
Definition: range.hpp:320
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::matrix::MultiVector::as_precision
temporary_conversion< MultiVector< OtherValueType > > as_precision()
Converts the vector to the target precision type.
gko::array< char >
gko::matrix::MultiVector::get_const_values
const value_type * get_const_values() const noexcept
Returns a pointer to the array of values of the multivector.
Definition: multivector.hpp:634
gko::dim< 2 >
gko::matrix::MultiVector::compute_mean
void compute_mean(ptr_param< AbstractMultiVector > result) const
Computes the column-wise arithmetic mean of this multivector.
gko::matrix::MultiVector::operator=
MultiVector & operator=(const MultiVector &)
Copy-assigns a MultiVector.
gko::matrix::MultiVector::at
ValueType at(size_type idx) const noexcept
Returns a single element of the multivector.
Definition: multivector.hpp:705
gko::matrix::MultiVector::get_values
value_type * get_values() noexcept
Returns a pointer to the array of values of the multivector.
Definition: multivector.hpp:625
gko::ptr_param
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:43
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:686
gko::matrix::MultiVector::at
value_type & at(size_type row, size_type col) noexcept
Returns a single element of the multivector.
Definition: multivector.hpp:670
gko::matrix::MultiVector::scale_permute
std::unique_ptr< MultiVector > scale_permute(ptr_param< const ScaledPermutation< value_type, int32 >> permutation, permute_mode mode=permute_mode::symmetric) const
Creates a scaled and permuted copy of this multivector.
gko::matrix::permute_mode::symmetric
The rows and columns will be permuted.
gko::matrix::MultiVector::validate_data
void validate_data() const override
Throws gko::InvalidData exception if we found the data inside the object does not fulfill certain pro...
gko::EnableMultiVector::absolute_type
typename traits::absolute_type absolute_type
The vector type holding absolute values of this vector.
Definition: multivector_mixin.hpp:162
gko::EnableMultiVector::device_view
AbstractMultiVector::device_view< value_type > device_view
The mutable device view type of the local data.
Definition: multivector_mixin.hpp:172
gko::matrix::MultiVector::create_const
static std::unique_ptr< const MultiVector > create_const(std::shared_ptr< const Executor > exec, const dim< 2 > &size, gko::detail::const_array_view< ValueType > &&values, size_type stride)
Creates a constant (immutable) MultiVector from a constant array.
gko::stop::mode
mode
The mode for the residual norm criterion.
Definition: residual_norm.hpp:37
gko::matrix::MultiVector
MultiVector is a multivector format which explicitly stores all values of the vector.
Definition: dense_cache.hpp:28
gko::WritableToMatrixData< ValueType, int32 >::write
virtual void write(matrix_data< ValueType, int32 > &data) const=0
Writes a matrix to a matrix_data structure.
gko::EnableMultiVector::value_type
typename traits::value_type value_type
The value type of the stored elements.
Definition: multivector_mixin.hpp:158
gko::matrix::MultiVector::row_gather
std::unique_ptr< MultiVector > row_gather(const array< int32 > *gather_indices) const
Create a MultiVector consisting of the given rows from this multivector.
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:472
gko::int64
std::int64_t int64
64-bit signed integral type.
Definition: types.hpp:125
gko::temporary_conversion
A temporary_conversion is a special smart pointer-like object that is designed to hold an object temp...
Definition: temporary_conversion.hpp:129
gko::Executor
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:617
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:695
gko::matrix::permute_mode
permute_mode
Specifies how a permutation will be applied to a matrix.
Definition: permutation.hpp:42
gko::matrix::MultiVector::at
value_type at(size_type row, size_type col) const noexcept
Returns a single element of the multivector.
Definition: multivector.hpp:678
gko::EnableMultiVector::complex_type
typename traits::complex_type complex_type
The vector type holding a complex version of this vector.
Definition: multivector_mixin.hpp:166
gko::matrix::MultiVector::create
static std::unique_ptr< MultiVector > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={}, size_type stride=0)
Creates an uninitialized MultiVector of the specified size.
gko::array::get_size
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:669
gko::matrix::MultiVector::permute
std::unique_ptr< MultiVector > permute(ptr_param< const Permutation< int32 >> permutation, permute_mode mode=permute_mode::symmetric) const
Creates a permuted copy of this multivector with the given permutation .
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:282