Ginkgo Generated from branch based on main. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
dense.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_MATRIX_DENSE_HPP_
6#define GKO_PUBLIC_CORE_MATRIX_DENSE_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/range_accessors.hpp>
17#include <ginkgo/core/base/types.hpp>
18#include <ginkgo/core/base/utils.hpp>
19#include <ginkgo/core/matrix/permutation.hpp>
20#include <ginkgo/core/matrix/scaled_permutation.hpp>
21
22
23namespace gko {
24namespace experimental {
25namespace distributed {
26
27
28template <typename ValueType>
29class Vector;
30
31
32namespace detail {
33
34
35template <typename ValueType>
36class VectorCache;
37
38
39} // namespace detail
40} // namespace distributed
41} // namespace experimental
42
43
44namespace matrix {
45
46
47template <typename ValueType, typename IndexType>
48class Coo;
49
50template <typename ValueType, typename IndexType>
51class Csr;
52
53template <typename ValueType>
54class Diagonal;
55
56template <typename ValueType, typename IndexType>
57class Ell;
58
59template <typename ValueType, typename IndexType>
60class Fbcsr;
61
62template <typename ValueType, typename IndexType>
63class Hybrid;
64
65template <typename ValueType, typename IndexType>
66class Sellp;
67
68template <typename ValueType, typename IndexType>
69class SparsityCsr;
70
71
87template <typename ValueType = default_precision>
88class Dense
89 : public EnableLinOp<Dense<ValueType>>,
90 public ConvertibleTo<Dense<next_precision<ValueType>>>,
91#if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
92 public ConvertibleTo<Dense<next_precision<ValueType, 2>>>,
93#endif
94#if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
95 public ConvertibleTo<Dense<next_precision<ValueType, 3>>>,
96#endif
97 public ConvertibleTo<Coo<ValueType, int32>>,
98 public ConvertibleTo<Coo<ValueType, int64>>,
99 public ConvertibleTo<Csr<ValueType, int32>>,
100 public ConvertibleTo<Csr<ValueType, int64>>,
101 public ConvertibleTo<Ell<ValueType, int32>>,
102 public ConvertibleTo<Ell<ValueType, int64>>,
103 public ConvertibleTo<Fbcsr<ValueType, int32>>,
104 public ConvertibleTo<Fbcsr<ValueType, int64>>,
105 public ConvertibleTo<Hybrid<ValueType, int32>>,
106 public ConvertibleTo<Hybrid<ValueType, int64>>,
107 public ConvertibleTo<Sellp<ValueType, int32>>,
108 public ConvertibleTo<Sellp<ValueType, int64>>,
109 public ConvertibleTo<SparsityCsr<ValueType, int32>>,
110 public ConvertibleTo<SparsityCsr<ValueType, int64>>,
111 public DiagonalExtractable<ValueType>,
112 public ReadableFromMatrixData<ValueType, int32>,
113 public ReadableFromMatrixData<ValueType, int64>,
114 public WritableToMatrixData<ValueType, int32>,
115 public WritableToMatrixData<ValueType, int64>,
116 public Transposable,
117 public Permutable<int32>,
118 public Permutable<int64>,
119 public EnableAbsoluteComputation<remove_complex<Dense<ValueType>>>,
120 public ScaledIdentityAddable {
121 friend class EnablePolymorphicObject<Dense, LinOp>;
122 friend class Coo<ValueType, int32>;
123 friend class Coo<ValueType, int64>;
124 friend class Csr<ValueType, int32>;
125 friend class Csr<ValueType, int64>;
126 friend class Diagonal<ValueType>;
127 friend class Ell<ValueType, int32>;
128 friend class Ell<ValueType, int64>;
129 friend class Fbcsr<ValueType, int32>;
130 friend class Fbcsr<ValueType, int64>;
131 friend class Hybrid<ValueType, int32>;
132 friend class Hybrid<ValueType, int64>;
133 friend class Sellp<ValueType, int32>;
134 friend class Sellp<ValueType, int64>;
135 friend class SparsityCsr<ValueType, int32>;
136 friend class SparsityCsr<ValueType, int64>;
137 friend class Dense<to_complex<ValueType>>;
138 friend class experimental::distributed::Vector<ValueType>;
139 friend class experimental::distributed::detail::VectorCache<ValueType>;
140
141public:
142 using EnableLinOp<Dense>::convert_to;
143 using EnableLinOp<Dense>::move_to;
146 using ConvertibleTo<Coo<ValueType, int32>>::convert_to;
147 using ConvertibleTo<Coo<ValueType, int32>>::move_to;
148 using ConvertibleTo<Coo<ValueType, int64>>::convert_to;
149 using ConvertibleTo<Coo<ValueType, int64>>::move_to;
150 using ConvertibleTo<Csr<ValueType, int32>>::convert_to;
151 using ConvertibleTo<Csr<ValueType, int32>>::move_to;
152 using ConvertibleTo<Csr<ValueType, int64>>::convert_to;
153 using ConvertibleTo<Csr<ValueType, int64>>::move_to;
154 using ConvertibleTo<Ell<ValueType, int32>>::convert_to;
155 using ConvertibleTo<Ell<ValueType, int32>>::move_to;
156 using ConvertibleTo<Ell<ValueType, int64>>::convert_to;
157 using ConvertibleTo<Ell<ValueType, int64>>::move_to;
158 using ConvertibleTo<Fbcsr<ValueType, int32>>::convert_to;
160 using ConvertibleTo<Fbcsr<ValueType, int64>>::convert_to;
162 using ConvertibleTo<Hybrid<ValueType, int32>>::convert_to;
164 using ConvertibleTo<Hybrid<ValueType, int64>>::convert_to;
166 using ConvertibleTo<Sellp<ValueType, int32>>::convert_to;
168 using ConvertibleTo<Sellp<ValueType, int64>>::convert_to;
174 using ReadableFromMatrixData<ValueType, int32>::read;
175 using ReadableFromMatrixData<ValueType, int64>::read;
176
177 using value_type = ValueType;
178 using index_type = int64;
179 using transposed_type = Dense<ValueType>;
180 using mat_data = matrix_data<ValueType, int64>;
181 using mat_data32 = matrix_data<ValueType, int32>;
182 using device_mat_data = device_matrix_data<ValueType, int64>;
183 using device_mat_data32 = device_matrix_data<ValueType, int32>;
184 using absolute_type = remove_complex<Dense>;
185 using real_type = absolute_type;
186 using complex_type = to_complex<Dense>;
187
189
196 static std::unique_ptr<Dense> create_with_config_of(
198 {
199 // De-referencing `other` before calling the functions (instead of
200 // using operator `->`) is currently required to be compatible with
201 // CUDA 10.1.
202 // Otherwise, it results in a compile error.
203 return (*other).create_with_same_config();
204 }
205
217 static std::unique_ptr<Dense> create_with_type_of(
218 ptr_param<const Dense> other, std::shared_ptr<const Executor> exec,
219 const dim<2>& size = dim<2>{})
220 {
221 // See create_with_config_of()
222 return (*other).create_with_type_of_impl(exec, size, size[1]);
223 }
224
233 static std::unique_ptr<Dense> create_with_type_of(
234 ptr_param<const Dense> other, std::shared_ptr<const Executor> exec,
235 const dim<2>& size, size_type stride)
236 {
237 // See create_with_config_of()
238 return (*other).create_with_type_of_impl(exec, size, stride);
239 }
240
251 static std::unique_ptr<Dense> create_with_type_of(
252 ptr_param<const Dense> other, std::shared_ptr<const Executor> exec,
253 const dim<2>& size, const dim<2>& local_size, size_type stride)
254 {
255 // See create_with_config_of()
256 return (*other).create_with_type_of_impl(exec, size, stride);
257 }
258
267 static std::unique_ptr<Dense> create_view_of(ptr_param<Dense> other)
268 {
269 return other->create_view_of_impl();
270 }
271
279 static std::unique_ptr<const Dense> create_const_view_of(
281 {
282 return other->create_const_view_of_impl();
283 }
284
285 friend class Dense<previous_precision<ValueType>>;
286
287 void convert_to(Dense<next_precision<ValueType>>* result) const override;
288
289 void move_to(Dense<next_precision<ValueType>>* result) override;
290
291#if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
292 friend class Dense<previous_precision<ValueType, 2>>;
295
296 void convert_to(Dense<next_precision<ValueType, 2>>* result) const override;
297
298 void move_to(Dense<next_precision<ValueType, 2>>* result) override;
299#endif
300
301#if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
302 friend class Dense<previous_precision<ValueType, 3>>;
305
306 void convert_to(Dense<next_precision<ValueType, 3>>* result) const override;
307
308 void move_to(Dense<next_precision<ValueType, 3>>* result) override;
309#endif
310
311 void convert_to(Coo<ValueType, int32>* result) const override;
312
313 void move_to(Coo<ValueType, int32>* result) override;
314
315 void convert_to(Coo<ValueType, int64>* result) const override;
316
317 void move_to(Coo<ValueType, int64>* result) override;
318
319 void convert_to(Csr<ValueType, int32>* result) const override;
320
321 void move_to(Csr<ValueType, int32>* result) override;
322
323 void convert_to(Csr<ValueType, int64>* result) const override;
324
325 void move_to(Csr<ValueType, int64>* result) override;
326
327 void convert_to(Ell<ValueType, int32>* result) const override;
328
329 void move_to(Ell<ValueType, int32>* result) override;
330
331 void convert_to(Ell<ValueType, int64>* result) const override;
332
333 void move_to(Ell<ValueType, int64>* result) override;
334
335 void convert_to(Fbcsr<ValueType, int32>* result) const override;
336
337 void move_to(Fbcsr<ValueType, int32>* result) override;
338
339 void convert_to(Fbcsr<ValueType, int64>* result) const override;
340
341 void move_to(Fbcsr<ValueType, int64>* result) override;
342
343 void convert_to(Hybrid<ValueType, int32>* result) const override;
344
345 void move_to(Hybrid<ValueType, int32>* result) override;
346
347 void convert_to(Hybrid<ValueType, int64>* result) const override;
348
349 void move_to(Hybrid<ValueType, int64>* result) override;
350
351 void convert_to(Sellp<ValueType, int32>* result) const override;
352
353 void move_to(Sellp<ValueType, int32>* result) override;
354
355 void convert_to(Sellp<ValueType, int64>* result) const override;
356
357 void move_to(Sellp<ValueType, int64>* result) override;
358
359 void convert_to(SparsityCsr<ValueType, int32>* result) const override;
360
361 void move_to(SparsityCsr<ValueType, int32>* result) override;
362
363 void convert_to(SparsityCsr<ValueType, int64>* result) const override;
364
365 void move_to(SparsityCsr<ValueType, int64>* result) override;
366
367 void read(const mat_data& data) override;
368
369 void read(const mat_data32& data) override;
370
371 void read(const device_mat_data& data) override;
372
373 void read(const device_mat_data32& data) override;
374
375 void read(device_mat_data&& data) override;
376
377 void read(device_mat_data32&& data) override;
378
379 void write(mat_data& data) const override;
380
381 void write(mat_data32& data) const override;
382
383 std::unique_ptr<LinOp> transpose() const override;
384
385 std::unique_ptr<LinOp> conj_transpose() const override;
386
393 void transpose(ptr_param<Dense> output) const;
394
402
408 void fill(const ValueType value);
409
424 std::unique_ptr<Dense> permute(
425 ptr_param<const Permutation<int32>> permutation,
427
431 std::unique_ptr<Dense> permute(
432 ptr_param<const Permutation<int64>> permutation,
434
440 void permute(ptr_param<const Permutation<int32>> permutation,
441 ptr_param<Dense> output, permute_mode mode) const;
442
447 void permute(ptr_param<const Permutation<int64>> permutation,
448 ptr_param<Dense> output, permute_mode mode) const;
449
463 std::unique_ptr<Dense> permute(
464 ptr_param<const Permutation<int32>> row_permutation,
465 ptr_param<const Permutation<int32>> column_permutation,
466 bool invert = false) const;
467
472 std::unique_ptr<Dense> permute(
473 ptr_param<const Permutation<int64>> row_permutation,
474 ptr_param<const Permutation<int64>> column_permutation,
475 bool invert = false) const;
476
483 void permute(ptr_param<const Permutation<int32>> row_permutation,
484 ptr_param<const Permutation<int32>> column_permutation,
485 ptr_param<Dense> output, bool invert = false) const;
486
491 void permute(ptr_param<const Permutation<int64>> row_permutation,
492 ptr_param<const Permutation<int64>> column_permutation,
493 ptr_param<Dense> output, bool invert = false) const;
494
504 std::unique_ptr<Dense> scale_permute(
507
512 std::unique_ptr<Dense> scale_permute(
515
524 ptr_param<Dense> output, permute_mode mode) const;
525
532 ptr_param<Dense> output, permute_mode mode) const;
533
546 std::unique_ptr<Dense> scale_permute(
547 ptr_param<const ScaledPermutation<value_type, int32>> row_permutation,
549 column_permutation,
550 bool invert = false) const;
551
556 std::unique_ptr<Dense> scale_permute(
557 ptr_param<const ScaledPermutation<value_type, int64>> row_permutation,
559 column_permutation,
560 bool invert = false) const;
561
569 ptr_param<const ScaledPermutation<value_type, int32>> row_permutation,
571 column_permutation,
572 ptr_param<Dense> output, bool invert = false) const;
573
580 ptr_param<const ScaledPermutation<value_type, int64>> row_permutation,
582 column_permutation,
583 ptr_param<Dense> output, bool invert = false) const;
584
585 std::unique_ptr<LinOp> permute(
586 const array<int32>* permutation_indices) const override;
587
588 std::unique_ptr<LinOp> permute(
589 const array<int64>* permutation_indices) const override;
590
600 void permute(const array<int32>* permutation_indices,
601 ptr_param<Dense> output) const;
602
606 void permute(const array<int64>* permutation_indices,
607 ptr_param<Dense> output) const;
608
609 std::unique_ptr<LinOp> inverse_permute(
610 const array<int32>* permutation_indices) const override;
611
612 std::unique_ptr<LinOp> inverse_permute(
613 const array<int64>* permutation_indices) const override;
614
625 void inverse_permute(const array<int32>* permutation_indices,
626 ptr_param<Dense> output) const;
627
631 void inverse_permute(const array<int64>* permutation_indices,
632 ptr_param<Dense> output) const;
633
634 std::unique_ptr<LinOp> row_permute(
635 const array<int32>* permutation_indices) const override;
636
637 std::unique_ptr<LinOp> row_permute(
638 const array<int64>* permutation_indices) const override;
639
649 void row_permute(const array<int32>* permutation_indices,
650 ptr_param<Dense> output) const;
651
655 void row_permute(const array<int64>* permutation_indices,
656 ptr_param<Dense> output) const;
657
668 std::unique_ptr<Dense> row_gather(const array<int32>* gather_indices) const;
669
673 std::unique_ptr<Dense> row_gather(const array<int64>* gather_indices) const;
674
687 void row_gather(const array<int32>* gather_indices,
688 ptr_param<LinOp> row_collection) const;
689
693 void row_gather(const array<int64>* gather_indices,
694 ptr_param<LinOp> row_collection) const;
695
710 const array<int32>* gather_indices,
712 ptr_param<LinOp> row_collection) const;
713
719 const array<int64>* gather_indices,
721 ptr_param<LinOp> row_collection) const;
722
723 std::unique_ptr<LinOp> column_permute(
724 const array<int32>* permutation_indices) const override;
725
726 std::unique_ptr<LinOp> column_permute(
727 const array<int64>* permutation_indices) const override;
728
738 void column_permute(const array<int32>* permutation_indices,
739 ptr_param<Dense> output) const;
740
744 void column_permute(const array<int64>* permutation_indices,
745 ptr_param<Dense> output) const;
746
747 std::unique_ptr<LinOp> inverse_row_permute(
748 const array<int32>* permutation_indices) const override;
749
750 std::unique_ptr<LinOp> inverse_row_permute(
751 const array<int64>* permutation_indices) const override;
752
762 void inverse_row_permute(const array<int32>* permutation_indices,
763 ptr_param<Dense> output) const;
764
768 void inverse_row_permute(const array<int64>* permutation_indices,
769 ptr_param<Dense> output) const;
770
771 std::unique_ptr<LinOp> inverse_column_permute(
772 const array<int32>* permutation_indices) const override;
773
774 std::unique_ptr<LinOp> inverse_column_permute(
775 const array<int64>* permutation_indices) const override;
776
786 void inverse_column_permute(const array<int32>* permutation_indices,
787 ptr_param<Dense> output) const;
788
792 void inverse_column_permute(const array<int64>* permutation_indices,
793 ptr_param<Dense> output) const;
794
795 std::unique_ptr<Diagonal<ValueType>> extract_diagonal() const override;
796
805
806 std::unique_ptr<absolute_type> compute_absolute() const override;
807
816
818
823 std::unique_ptr<complex_type> make_complex() const;
824
831
836 std::unique_ptr<real_type> get_real() const;
837
841 void get_real(ptr_param<real_type> result) const;
842
847 std::unique_ptr<real_type> get_imag() const;
848
853 void get_imag(ptr_param<real_type> result) const;
854
860 value_type* get_values() noexcept { return values_.get_data(); }
861
869 const value_type* get_const_values() const noexcept
870 {
871 return values_.get_const_data();
872 }
873
879 size_type get_stride() const noexcept { return stride_; }
880
887 {
888 return values_.get_size();
889 }
890
901 value_type& at(size_type row, size_type col) noexcept
902 {
903 return values_.get_data()[linearize_index(row, col)];
904 }
905
909 value_type at(size_type row, size_type col) const noexcept
910 {
911 return values_.get_const_data()[linearize_index(row, col)];
912 }
913
928 ValueType& at(size_type idx) noexcept
929 {
930 return values_.get_data()[linearize_index(idx)];
931 }
932
936 ValueType at(size_type idx) const noexcept
937 {
938 return values_.get_const_data()[linearize_index(idx)];
939 }
940
951
962
974
986
996
1009 array<char>& tmp) const;
1010
1020 ptr_param<LinOp> result) const;
1021
1034 array<char>& tmp) const;
1035
1044
1056
1065
1077
1087
1100
1108 void compute_mean(ptr_param<LinOp> result) const;
1109
1121
1132 std::unique_ptr<Dense> create_submatrix(const span& rows,
1133 const span& columns,
1134 const size_type stride)
1135 {
1136 return this->create_submatrix_impl(rows, columns, stride);
1137 }
1138
1145 std::unique_ptr<Dense> create_submatrix(const span& rows,
1146 const span& columns)
1147 {
1148 return create_submatrix(rows, columns, this->get_stride());
1149 }
1150
1158 std::unique_ptr<real_type> create_real_view();
1159
1163 std::unique_ptr<const real_type> create_real_view() const;
1164
1177 static std::unique_ptr<Dense> create(std::shared_ptr<const Executor> exec,
1178 const dim<2>& size = {},
1179 size_type stride = 0);
1180
1197 static std::unique_ptr<Dense> create(std::shared_ptr<const Executor> exec,
1198 const dim<2>& size,
1199 array<value_type> values,
1200 size_type stride);
1201
1206 template <typename InputValueType>
1207 GKO_DEPRECATED(
1208 "explicitly construct the gko::array argument instead of passing an"
1209 "initializer list")
1210 static std::unique_ptr<Dense> create(
1211 std::shared_ptr<const Executor> exec, const dim<2>& size,
1212 std::initializer_list<InputValueType> values, size_type stride)
1213 {
1214 return create(exec, size, array<value_type>{exec, std::move(values)},
1215 stride);
1216 }
1217
1229 static std::unique_ptr<const Dense> create_const(
1230 std::shared_ptr<const Executor> exec, const dim<2>& size,
1231 gko::detail::const_array_view<ValueType>&& values, size_type stride);
1232
1239
1246
1251 Dense(const Dense&);
1252
1258
1259protected:
1260 Dense(std::shared_ptr<const Executor> exec, const dim<2>& size = {},
1261 size_type stride = 0);
1262
1263 Dense(std::shared_ptr<const Executor> exec, const dim<2>& size,
1264 array<value_type> values, size_type stride);
1265
1272 virtual std::unique_ptr<Dense> create_with_same_config() const
1273 {
1274 return Dense::create(this->get_executor(), this->get_size(),
1275 this->get_stride());
1276 }
1277
1285 virtual std::unique_ptr<Dense> create_with_type_of_impl(
1286 std::shared_ptr<const Executor> exec, const dim<2>& size,
1287 size_type stride) const
1288 {
1289 return Dense::create(exec, size, stride);
1290 }
1291
1298 virtual std::unique_ptr<Dense> create_view_of_impl()
1299 {
1300 auto exec = this->get_executor();
1301 return Dense::create(
1302 exec, this->get_size(),
1304 this->get_values()),
1305 this->get_stride());
1306 }
1307
1314 virtual std::unique_ptr<const Dense> create_const_view_of_impl() const
1315 {
1316 auto exec = this->get_executor();
1317 return Dense::create_const(
1318 exec, this->get_size(),
1320 this->get_const_values()),
1321 this->get_stride());
1322 }
1323
1324 template <typename IndexType>
1325 void convert_impl(Coo<ValueType, IndexType>* result) const;
1326
1327 template <typename IndexType>
1328 void convert_impl(Csr<ValueType, IndexType>* result) const;
1329
1330 template <typename IndexType>
1331 void convert_impl(Ell<ValueType, IndexType>* result) const;
1332
1333 template <typename IndexType>
1334 void convert_impl(Fbcsr<ValueType, IndexType>* result) const;
1335
1336 template <typename IndexType>
1337 void convert_impl(Hybrid<ValueType, IndexType>* result) const;
1338
1339 template <typename IndexType>
1340 void convert_impl(Sellp<ValueType, IndexType>* result) const;
1341
1342 template <typename IndexType>
1343 void convert_impl(SparsityCsr<ValueType, IndexType>* result) const;
1344
1351 virtual void scale_impl(const LinOp* alpha);
1352
1359 virtual void inv_scale_impl(const LinOp* alpha);
1360
1367 virtual void add_scaled_impl(const LinOp* alpha, const LinOp* b);
1368
1375 virtual void sub_scaled_impl(const LinOp* alpha, const LinOp* b);
1376
1383 virtual void compute_dot_impl(const LinOp* b, LinOp* result) const;
1384
1391 virtual void compute_conj_dot_impl(const LinOp* b, LinOp* result) const;
1392
1399 virtual void compute_norm2_impl(LinOp* result) const;
1400
1407 virtual void compute_norm1_impl(LinOp* result) const;
1408
1415 virtual void compute_squared_norm2_impl(LinOp* result) const;
1416
1420 virtual void compute_mean_impl(LinOp* result) const;
1421
1430 void resize(gko::dim<2> new_size);
1431
1439 virtual std::unique_ptr<Dense> create_submatrix_impl(
1440 const span& rows, const span& columns, const size_type stride);
1441
1442 void apply_impl(const LinOp* b, LinOp* x) const override;
1443
1444 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
1445 LinOp* x) const override;
1446
1447 size_type linearize_index(size_type row, size_type col) const noexcept
1448 {
1449 return row * stride_ + col;
1450 }
1451
1452 size_type linearize_index(size_type idx) const noexcept
1453 {
1454 return linearize_index(idx / this->get_size()[1],
1455 idx % this->get_size()[1]);
1456 }
1457
1458 template <typename IndexType>
1459 void permute_impl(const Permutation<IndexType>* permutation,
1460 permute_mode mode, Dense* output) const;
1461
1462 template <typename IndexType>
1463 void permute_impl(const Permutation<IndexType>* row_permutation,
1464 const Permutation<IndexType>* col_permutation,
1465 bool invert, Dense* output) const;
1466
1467 template <typename IndexType>
1468 void scale_permute_impl(
1469 const ScaledPermutation<ValueType, IndexType>* permutation,
1470 permute_mode mode, Dense* output) const;
1471
1472 template <typename IndexType>
1473 void scale_permute_impl(
1474 const ScaledPermutation<ValueType, IndexType>* row_permutation,
1475 const ScaledPermutation<ValueType, IndexType>* column_permutation,
1476 bool invert, Dense* output) const;
1477
1478 template <typename OutputType, typename IndexType>
1479 void row_gather_impl(const array<IndexType>* row_idxs,
1480 Dense<OutputType>* row_collection) const;
1481
1482 template <typename OutputType, typename IndexType>
1483 void row_gather_impl(const Dense<ValueType>* alpha,
1484 const array<IndexType>* row_idxs,
1485 const Dense<ValueType>* beta,
1486 Dense<OutputType>* row_collection) const;
1487
1488private:
1489 size_type stride_;
1490 array<value_type> values_;
1491
1492 void add_scaled_identity_impl(const LinOp* a, const LinOp* b) override;
1493};
1494
1495
1496} // namespace matrix
1497
1498
1499namespace detail {
1500
1501
1502template <typename ValueType>
1503struct temporary_clone_helper<matrix::Dense<ValueType>> {
1504 static std::unique_ptr<matrix::Dense<ValueType>> create(
1505 std::shared_ptr<const Executor> exec, matrix::Dense<ValueType>* ptr,
1506 bool copy_data)
1507 {
1508 if (copy_data) {
1509 return gko::clone(std::move(exec), ptr);
1510 } else {
1511 return matrix::Dense<ValueType>::create(exec, ptr->get_size());
1512 }
1513 }
1514};
1515
1516
1517} // namespace detail
1518
1519
1527template <typename VecPtr>
1528std::unique_ptr<matrix::Dense<typename detail::pointee<VecPtr>::value_type>>
1529make_dense_view(VecPtr&& vector)
1530{
1531 using value_type = typename detail::pointee<VecPtr>::value_type;
1533}
1534
1535
1543template <typename VecPtr>
1544std::unique_ptr<
1545 const matrix::Dense<typename detail::pointee<VecPtr>::value_type>>
1547{
1548 using value_type = typename detail::pointee<VecPtr>::value_type;
1550}
1551
1552
1573template <typename Matrix, typename... TArgs>
1574std::unique_ptr<Matrix> initialize(
1575 size_type stride, std::initializer_list<typename Matrix::value_type> vals,
1576 std::shared_ptr<const Executor> exec, TArgs&&... create_args)
1577{
1579 size_type num_rows = vals.size();
1580 auto tmp = dense::create(exec->get_master(), dim<2>{num_rows, 1}, stride);
1581 size_type idx = 0;
1582 for (const auto& elem : vals) {
1583 tmp->at(idx) = elem;
1584 ++idx;
1585 }
1586 auto mtx = Matrix::create(exec, std::forward<TArgs>(create_args)...);
1587 tmp->move_to(mtx);
1588 return mtx;
1589}
1590
1611template <typename Matrix, typename... TArgs>
1612std::unique_ptr<Matrix> initialize(
1613 std::initializer_list<typename Matrix::value_type> vals,
1614 std::shared_ptr<const Executor> exec, TArgs&&... create_args)
1615{
1616 return initialize<Matrix>(1, vals, std::move(exec),
1617 std::forward<TArgs>(create_args)...);
1618}
1619
1620
1641template <typename Matrix, typename... TArgs>
1642std::unique_ptr<Matrix> initialize(
1643 size_type stride,
1644 std::initializer_list<std::initializer_list<typename Matrix::value_type>>
1645 vals,
1646 std::shared_ptr<const Executor> exec, TArgs&&... create_args)
1647{
1649 size_type num_rows = vals.size();
1650 size_type num_cols = num_rows > 0 ? begin(vals)->size() : 1;
1651 auto tmp =
1652 dense::create(exec->get_master(), dim<2>{num_rows, num_cols}, stride);
1653 size_type ridx = 0;
1654 for (const auto& row : vals) {
1655 size_type cidx = 0;
1656 for (const auto& elem : row) {
1657 tmp->at(ridx, cidx) = elem;
1658 ++cidx;
1659 }
1660 ++ridx;
1661 }
1662 auto mtx = Matrix::create(exec, std::forward<TArgs>(create_args)...);
1663 tmp->move_to(mtx);
1664 return mtx;
1665}
1666
1667
1689template <typename Matrix, typename... TArgs>
1690std::unique_ptr<Matrix> initialize(
1691 std::initializer_list<std::initializer_list<typename Matrix::value_type>>
1692 vals,
1693 std::shared_ptr<const Executor> exec, TArgs&&... create_args)
1694{
1695 return initialize<Matrix>(vals.size() > 0 ? begin(vals)->size() : 0, vals,
1696 std::move(exec),
1697 std::forward<TArgs>(create_args)...);
1698}
1699
1700
1701} // namespace gko
1702
1703
1704#endif // GKO_PUBLIC_CORE_MATRIX_DENSE_HPP_
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition polymorphic_object.hpp:479
The diagonal of a LinOp implementing this interface can be extracted.
Definition lin_op.hpp:743
The EnableAbsoluteComputation mixin provides the default implementations of compute_absolute_linop an...
Definition lin_op.hpp:794
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:879
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
The first step in using the Ginkgo library consists of creating an executor.
Definition executor.hpp:615
Definition lin_op.hpp:117
LinOp(const LinOp &)=default
Copy-constructs a LinOp.
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition lin_op.hpp:210
Linear operators which support permutation should implement the Permutable interface.
Definition lin_op.hpp:484
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition polymorphic_object.hpp:243
A LinOp implementing this interface can read its data from a matrix_data structure.
Definition lin_op.hpp:605
Adds the operation M <- a I + b M for matrix M, identity operator I and scalars a and b,...
Definition lin_op.hpp:818
Linear operators which support transposition should implement the Transposable interface.
Definition lin_op.hpp:433
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition lin_op.hpp:660
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
This type is a device-side equivalent to matrix_data.
Definition device_matrix_data.hpp:36
Vector is a format which explicitly stores (multiple) distributed column vectors in a dense storage f...
Definition vector.hpp:77
COO stores a matrix in the coordinate matrix format.
Definition coo.hpp:65
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition csr.hpp:126
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:120
std::unique_ptr< Dense > scale_permute(ptr_param< const ScaledPermutation< value_type, int64 > > row_permutation, ptr_param< const ScaledPermutation< value_type, int64 > > column_permutation, bool invert=false) const
value_type & at(size_type row, size_type col) noexcept
Returns a single element of the matrix.
Definition dense.hpp:901
void compute_norm1(ptr_param< LinOp > result) const
Computes the column-wise (L^1) norm of this matrix.
void compute_absolute(ptr_param< absolute_type > output) const
Writes the absolute values of this matrix into an existing matrix.
void compute_norm2(ptr_param< LinOp > result, array< char > &tmp) const
Computes the column-wise Euclidean (L^2) norm of this matrix.
std::unique_ptr< LinOp > row_permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the Permutable object.
static std::unique_ptr< Dense > create_with_config_of(ptr_param< const Dense > other)
Creates a Dense matrix with the same size and stride as another Dense matrix.
Definition dense.hpp:196
std::unique_ptr< Dense > permute(ptr_param< const Permutation< int64 > > row_permutation, ptr_param< const Permutation< int64 > > column_permutation, bool invert=false) const
Dense & operator=(const Dense &)
Copy-assigns a Dense matrix.
void get_imag(ptr_param< real_type > result) const
Extracts the imaginary part of the original matrix into a given real matrix.
void row_permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the row-permuted matrix into the given output matrix.
void get_real(ptr_param< real_type > result) const
Extracts the real part of the original matrix into a given real matrix.
std::unique_ptr< LinOp > column_permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the column permutation of the Permutable object.
static std::unique_ptr< Dense > create_with_type_of(ptr_param< const Dense > other, std::shared_ptr< const Executor > exec, const dim< 2 > &size, const dim< 2 > &local_size, size_type stride)
Definition dense.hpp:251
void compute_dot(ptr_param< const LinOp > b, ptr_param< LinOp > result) const
Computes the column-wise dot product of this matrix and b.
void sub_scaled(ptr_param< const LinOp > alpha, ptr_param< const LinOp > b)
Subtracts b scaled by alpha from the matrix (aka: BLAS axpy).
std::unique_ptr< Dense > permute(ptr_param< const Permutation< int64 > > permutation, permute_mode mode=permute_mode::symmetric) const
std::unique_ptr< LinOp > permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the symmetric row and column permutation of the Permutable object.
ValueType at(size_type idx) const noexcept
Returns a single element of the matrix.
Definition dense.hpp:936
std::unique_ptr< Dense > row_gather(const array< int64 > *gather_indices) const
Create a Dense matrix consisting of the given rows from this matrix.
std::unique_ptr< LinOp > inverse_permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the symmetric inverse row and column permutation of the Permutable objec...
std::unique_ptr< Dense > permute(ptr_param< const Permutation< int32 > > row_permutation, ptr_param< const Permutation< int32 > > column_permutation, bool invert=false) const
Creates a non-symmetrically permuted copy of this matrix with the given row and column permutations...
void row_gather(const array< int32 > *gather_indices, ptr_param< LinOp > row_collection) const
Copies the given rows from this matrix into row_collection
void column_permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the column-permuted matrix into the given output matrix.
std::unique_ptr< LinOp > inverse_row_permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the inverse permuted object.
Dense(const Dense &)
Copy-constructs a Dense matrix.
std::unique_ptr< Dense > permute(ptr_param< const Permutation< int32 > > permutation, permute_mode mode=permute_mode::symmetric) const
Creates a permuted copy of this matrix with the given permutation .
void inverse_permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
void compute_squared_norm2(ptr_param< LinOp > result, array< char > &tmp) const
Computes the square of the column-wise Euclidean (L^2) norm of this matrix.
static std::unique_ptr< Dense > create_with_type_of(ptr_param< const Dense > other, std::shared_ptr< const Executor > exec, const dim< 2 > &size=dim< 2 >{})
Creates a Dense matrix with the same type as another Dense matrix but on a different executor and wit...
Definition dense.hpp:217
void permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
void scale(ptr_param< const LinOp > alpha)
Scales the matrix with a scalar (aka: BLAS scal).
std::unique_ptr< LinOp > inverse_column_permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the inverse permuted object.
void conj_transpose(ptr_param< Dense > output) const
Writes the conjugate-transposed matrix into the given output matrix.
std::unique_ptr< Dense > create_submatrix(const span &rows, const span &columns)
Create a submatrix from the original matrix.
Definition dense.hpp:1145
void row_permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
std::unique_ptr< LinOp > permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the symmetric row and column permutation of the Permutable object.
std::unique_ptr< Dense > create_submatrix(const span &rows, const span &columns, const size_type stride)
Create a submatrix from the original matrix.
Definition dense.hpp:1132
void compute_squared_norm2(ptr_param< LinOp > result) const
Computes the square of the column-wise Euclidean (L^2) norm of this matrix.
std::unique_ptr< LinOp > row_permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the Permutable object.
void permute(ptr_param< const Permutation< int64 > > permutation, ptr_param< Dense > output, permute_mode mode) const
void inverse_permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the inverse symmetrically permuted matrix into the given output matrix.
std::unique_ptr< Dense > row_gather(const array< int32 > *gather_indices) const
Create a Dense matrix consisting of the given rows from this matrix.
void extract_diagonal(ptr_param< Diagonal< ValueType > > output) const
Writes the diagonal of this matrix into an existing diagonal matrix.
void make_complex(ptr_param< complex_type > result) const
Writes a complex copy of the original matrix to a given complex matrix.
std::unique_ptr< absolute_type > compute_absolute() const override
Gets the AbsoluteLinOp.
void scale_permute(ptr_param< const ScaledPermutation< value_type, int32 > > row_permutation, ptr_param< const ScaledPermutation< value_type, int32 > > column_permutation, ptr_param< Dense > output, bool invert=false) const
Overload of scale_permute(ptr_param<const ScaledPermutation<value_type,int32>>, ptr_param<const Scale...
void permute(ptr_param< const Permutation< int32 > > permutation, ptr_param< Dense > output, permute_mode mode) const
Overload of permute(ptr_param<const Permutation<int32>>, permute_mode) that writes the permuted copy ...
void row_gather(ptr_param< const LinOp > alpha, const array< int32 > *gather_indices, ptr_param< const LinOp > beta, ptr_param< LinOp > row_collection) const
Copies the given rows from this matrix into row_collection with scaling.
const value_type * get_const_values() const noexcept
Returns a pointer to the array of values of the matrix.
Definition dense.hpp:869
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the matrix.
Definition dense.hpp:886
void compute_mean(ptr_param< LinOp > result, array< char > &tmp) const
Computes the column-wise arithmetic mean of this matrix.
ValueType & at(size_type idx) noexcept
Returns a single element of the matrix.
Definition dense.hpp:928
std::unique_ptr< Dense > scale_permute(ptr_param< const ScaledPermutation< value_type, int32 > > row_permutation, ptr_param< const ScaledPermutation< value_type, int32 > > column_permutation, bool invert=false) const
Creates a scaled and permuted copy of this matrix.
void scale_permute(ptr_param< const ScaledPermutation< value_type, int64 > > row_permutation, ptr_param< const ScaledPermutation< value_type, int64 > > column_permutation, ptr_param< Dense > output, bool invert=false) const
void compute_conj_dot(ptr_param< const LinOp > b, ptr_param< LinOp > result, array< char > &tmp) const
Computes the column-wise dot product of conj(this matrix) and b.
void compute_mean(ptr_param< LinOp > result) const
Computes the column-wise arithmetic mean of this matrix.
static std::unique_ptr< Dense > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, array< value_type > values, size_type stride)
Creates a Dense matrix from an already allocated (and initialized) array.
size_type get_stride() const noexcept
Returns the stride of the matrix.
Definition dense.hpp:879
std::unique_ptr< LinOp > inverse_permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the symmetric inverse row and column permutation of the Permutable objec...
void permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the symmetrically permuted matrix into the given output matrix.
void scale_permute(ptr_param< const ScaledPermutation< value_type, int64 > > permutation, ptr_param< Dense > output, permute_mode mode) const
void inverse_row_permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the inverse row-permuted matrix into the given output matrix.
void inverse_column_permute(const array< int32 > *permutation_indices, ptr_param< Dense > output) const
Writes the inverse column-permuted matrix into the given output matrix.
void add_scaled(ptr_param< const LinOp > alpha, ptr_param< const LinOp > b)
Adds b scaled by alpha to the matrix (aka: BLAS axpy).
std::unique_ptr< LinOp > inverse_column_permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the inverse permuted object.
static std::unique_ptr< Dense > create_view_of(ptr_param< Dense > other)
Creates a Dense matrix, where the underlying array is a view of another Dense matrix' array.
Definition dense.hpp:267
void permute(ptr_param< const Permutation< int32 > > row_permutation, ptr_param< const Permutation< int32 > > column_permutation, ptr_param< Dense > output, bool invert=false) const
Overload of permute(ptr_param<const Permutation<int32>>, ptr_param<constPermutation<int32>>,...
void compute_norm1(ptr_param< LinOp > result, array< char > &tmp) const
Computes the column-wise (L^1) norm of this matrix.
std::unique_ptr< LinOp > inverse_row_permute(const array< int64 > *permutation_indices) const override
Returns a LinOp representing the row permutation of the inverse permuted object.
std::unique_ptr< Dense > 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 matrix.
void transpose(ptr_param< Dense > output) const
Writes the transposed matrix into the given output matrix.
void compute_conj_dot(ptr_param< const LinOp > b, ptr_param< LinOp > result) const
Computes the column-wise dot product of conj(this matrix) and b.
std::unique_ptr< real_type > get_real() const
Creates a new real matrix and extracts the real part of the original matrix into that.
std::unique_ptr< Dense > scale_permute(ptr_param< const ScaledPermutation< value_type, int64 > > permutation, permute_mode mode=permute_mode::symmetric) const
static std::unique_ptr< const Dense > create_const_view_of(ptr_param< const Dense > other)
Creates a immutable Dense matrix, where the underlying array is a view of another Dense matrix' array...
Definition dense.hpp:279
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
std::unique_ptr< LinOp > column_permute(const array< int32 > *permutation_indices) const override
Returns a LinOp representing the column permutation of the Permutable object.
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
void scale_permute(ptr_param< const ScaledPermutation< value_type, int32 > > permutation, ptr_param< Dense > output, permute_mode mode) const
Overload of scale_permute(ptr_param<const ScaledPermutation<value_type,int32>>, permute_mode) that wr...
void compute_absolute_inplace() override
Compute absolute inplace on each element.
std::unique_ptr< complex_type > make_complex() const
Creates a complex copy of the original matrix.
std::unique_ptr< const real_type > create_real_view() const
Create a real view of the (potentially) complex original matrix.
void column_permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
Dense(Dense &&)
Move-constructs a Dense matrix.
void inverse_row_permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
value_type at(size_type row, size_type col) const noexcept
Returns a single element of the matrix.
Definition dense.hpp:909
static std::unique_ptr< Dense > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={}, size_type stride=0)
Creates an uninitialized Dense matrix of the specified size.
static std::unique_ptr< const Dense > 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) Dense matrix from a constant array.
void permute(ptr_param< const Permutation< int64 > > row_permutation, ptr_param< const Permutation< int64 > > column_permutation, ptr_param< Dense > output, bool invert=false) const
void inv_scale(ptr_param< const LinOp > alpha)
Scales the matrix with the inverse of a scalar.
Dense & operator=(Dense &&)
Move-assigns a Dense matrix.
value_type * get_values() noexcept
Returns a pointer to the array of values of the matrix.
Definition dense.hpp:860
void inverse_column_permute(const array< int64 > *permutation_indices, ptr_param< Dense > output) const
void compute_norm2(ptr_param< LinOp > result) const
Computes the column-wise Euclidean (L^2) norm of this matrix.
void row_gather(const array< int64 > *gather_indices, ptr_param< LinOp > row_collection) const
std::unique_ptr< real_type > get_imag() const
Creates a new real matrix and extracts the imaginary part of the original matrix into that.
static std::unique_ptr< Dense > create_with_type_of(ptr_param< const Dense > other, std::shared_ptr< const Executor > exec, const dim< 2 > &size, size_type stride)
Definition dense.hpp:233
std::unique_ptr< real_type > create_real_view()
Create a real view of the (potentially) complex original matrix.
std::unique_ptr< Diagonal< ValueType > > extract_diagonal() const override
Extracts the diagonal entries of the matrix into a vector.
void fill(const ValueType value)
Fill the dense matrix with a given value.
void compute_dot(ptr_param< const LinOp > b, ptr_param< LinOp > result, array< char > &tmp) const
Computes the column-wise dot product of this matrix and b.
void row_gather(ptr_param< const LinOp > alpha, const array< int64 > *gather_indices, ptr_param< const LinOp > beta, ptr_param< LinOp > row_collection) const
This class is a utility which efficiently implements the diagonal matrix (a linear operator which sca...
Definition diagonal.hpp:56
ELL is a matrix format where stride with explicit zeros is used such that all rows have the same numb...
Definition ell.hpp:66
Fixed-block compressed sparse row storage matrix format.
Definition fbcsr.hpp:116
HYBRID is a matrix format which splits the matrix into ELLPACK and COO format.
Definition hybrid.hpp:57
Permutation is a matrix format that represents a permutation matrix, i.e.
Definition permutation.hpp:112
ScaledPermutation is a matrix combining a permutation with scaling factors.
Definition scaled_permutation.hpp:38
SELL-P is a matrix format similar to ELL format.
Definition sellp.hpp:58
SparsityCsr is a matrix format which stores only the sparsity pattern of a sparse matrix by compressi...
Definition sparsity_csr.hpp:56
This class is used for function parameters in the place of raw pointers.
Definition utils_helper.hpp:41
A range is a multidimensional view of the memory.
Definition range.hpp:297
std::unique_ptr< Matrix > initialize(size_type stride, std::initializer_list< typename Matrix::value_type > vals, std::shared_ptr< const Executor > exec, TArgs &&... create_args)
Creates and initializes a column-vector.
Definition dense.hpp:1574
The distributed namespace.
Definition polymorphic_object.hpp:19
The matrix namespace.
Definition dense_cache.hpp:24
permute_mode
Specifies how a permutation will be applied to a matrix.
Definition permutation.hpp:42
@ columns
The columns will be permuted.
Definition permutation.hpp:48
@ rows
The rows will be permuted.
Definition permutation.hpp:46
@ symmetric
The rows and columns will be permuted.
Definition permutation.hpp:53
The Ginkgo namespace.
Definition abstract_factory.hpp:20
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
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:107
std::unique_ptr< const matrix::Dense< typename detail::pointee< VecPtr >::value_type > > make_const_dense_view(VecPtr &&vector)
Creates a view of a given Dense vector.
Definition dense.hpp:1546
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
detail::const_array_view< ValueType > make_const_array_view(std::shared_ptr< const Executor > exec, size_type size, const ValueType *data)
Helper function to create a const array view deducing the value type.
Definition array.hpp:820
std::unique_ptr< matrix::Dense< typename detail::pointee< VecPtr >::value_type > > make_dense_view(VecPtr &&vector)
Creates a view of a given Dense vector.
Definition dense.hpp:1529
array< ValueType > make_array_view(std::shared_ptr< const Executor > exec, size_type size, ValueType *data)
Helper function to create an array view deducing the value type.
Definition array.hpp:801
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:295
std::int64_t int64
64-bit signed integral type.
Definition types.hpp:113
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
detail::cloned_type< Pointer > clone(const Pointer &p)
Creates a unique clone of the object pointed to by p.
Definition utils_helper.hpp:173
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:159
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
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
STL namespace.
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:26
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:126
A span is a lightweight structure used to create sub-ranges from other ranges.
Definition range.hpp:46