Loading...
Searching...
No Matches
CSRMatrix.hpp
Go to the documentation of this file.
1/*
2 * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3 * Regents of the University of California, through Lawrence Berkeley
4 * National Laboratory (subject to receipt of any required approvals
5 * from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * If you have questions about your rights to use or distribute this
8 * software, please contact Berkeley Lab's Technology Transfer
9 * Department at TTD@lbl.gov.
10 *
11 * NOTICE. This software is owned by the U.S. Department of Energy. As
12 * such, the U.S. Government has been granted for itself and others
13 * acting on its behalf a paid-up, nonexclusive, irrevocable,
14 * worldwide license in the Software to reproduce, prepare derivative
15 * works, and perform publicly and display publicly. Beginning five
16 * (5) years after the date permission to assert copyright is obtained
17 * from the U.S. Department of Energy, and subject to any subsequent
18 * five (5) year renewals, the U.S. Government is granted for itself
19 * and others acting on its behalf a paid-up, nonexclusive,
20 * irrevocable, worldwide license in the Software to reproduce,
21 * prepare derivative works, distribute copies to the public, perform
22 * publicly and display publicly, and to permit others to do so.
23 *
24 * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25 * (Lawrence Berkeley National Lab, Computational Research
26 * Division).
27 *
28 */
33#ifndef STRUMPACK_CSR_MATRIX_HPP
34#define STRUMPACK_CSR_MATRIX_HPP
35
36#include <vector>
37
39#include "CSRGraph.hpp"
40// #include "ordering/Graph.hpp"
41
42namespace strumpack {
43
54 template<typename scalar_t,typename integer_t> class CSRMatrix
55 : public CompressedSparseMatrix<scalar_t,integer_t> {
56#if defined(STRUMPACK_USE_MPI)
58#endif
62 using real_t = typename RealType<scalar_t>::value_type;
65
66 public:
67 CSRMatrix();
68 CSRMatrix(integer_t n, integer_t nnz);
69 CSRMatrix(integer_t n, const integer_t* ptr, const integer_t* ind,
70 const scalar_t* values, bool symm_sparsity=false);
71
72 real_t norm1() const override;
73
74 void spmv(const DenseM_t& x, DenseM_t& y) const override;
75 void spmv(const scalar_t* x, scalar_t* y) const override;
76
77 void spmv(Trans op, const DenseM_t& x, DenseM_t& y) const;
78
79 Equil_t equilibration() const override;
80
81 void equilibrate(const Equil_t& eq) override;
82
83 void permute_columns(const std::vector<integer_t>& perm) override;
84
85 real_t max_scaled_residual(const scalar_t* x, const scalar_t* b)
86 const override;
87 real_t max_scaled_residual(const DenseM_t& x, const DenseM_t& b)
88 const override;
89
90 std::unique_ptr<CSRMatrix<scalar_t,integer_t>>
91 add_missing_diagonal(const scalar_t& s) const;
92
93 int read_matrix_market(const std::string& filename) override;
94 int read_binary(const std::string& filename);
95 void print_dense(const std::string& name) const override;
96 void print_matrix_market(const std::string& filename) const override;
97 void print_binary(const std::string& filename) const;
98
100 extract_graph(int ordering_level,
101 integer_t lo, integer_t hi) const override;
103 extract_graph_sep_CB(int ordering_level, integer_t lo, integer_t hi,
104 const std::vector<integer_t>& upd) const override;
106 extract_graph_CB_sep(int ordering_level, integer_t lo, integer_t hi,
107 const std::vector<integer_t>& upd) const override;
109 extract_graph_CB(int ordering_level,
110 const std::vector<integer_t>& upd) const override;
111
112 // ordering::Graph<integer_t> graph() const;
113
114#ifndef DOXYGEN_SHOULD_SKIP_THIS
115 // TODO implement these outside of this class
116 void front_multiply(integer_t slo, integer_t shi,
117 const std::vector<integer_t>& upd,
118 const DenseM_t& R, DenseM_t& Sr, DenseM_t& Sc,
119 int depth) const override;
120 void extract_separator(integer_t sep_end,
121 const std::vector<std::size_t>& I,
122 const std::vector<std::size_t>& J,
123 DenseM_t& B, int depth) const override;
124 void extract_front(DenseM_t& F11, DenseM_t& F12, DenseM_t& F21,
125 integer_t sep_begin, integer_t sep_end,
126 const std::vector<integer_t>& upd,
127 int depth) const override;
128
129 void push_front_elements(integer_t, integer_t,
130 const std::vector<integer_t>&,
131 std::vector<Triplet<scalar_t>>&,
132 std::vector<Triplet<scalar_t>>&,
133 std::vector<Triplet<scalar_t>>&) const override;
134 void set_front_elements(integer_t, integer_t,
135 const std::vector<integer_t>&,
136 Triplet<scalar_t>*, Triplet<scalar_t>*,
137 Triplet<scalar_t>*) const override;
138
139 void set_front_elements_symmetric(integer_t, integer_t,
140 const std::vector<integer_t>&,
141 Triplet<scalar_t>*, Triplet<scalar_t>*) const override;
142
143 void count_front_elements(integer_t, integer_t,
144 const std::vector<integer_t>&,
145 std::size_t&, std::size_t&, std::size_t&)
146 const override;
147
148 void count_front_elements_symmetric(integer_t, integer_t,
149 const std::vector<integer_t>&,
150 std::size_t&, std::size_t&) const override;
151
152 void front_multiply_F11(Trans op, integer_t slo, integer_t shi,
153 const DenseM_t& R, DenseM_t& S,
154 int depth) const override;
155 void front_multiply_F12(Trans op, integer_t slo, integer_t shi,
156 const std::vector<integer_t>& upd,
157 const DenseM_t& R, DenseM_t& S,
158 int depth) const override;
159 void front_multiply_F21(Trans op, integer_t slo, integer_t shi,
160 const std::vector<integer_t>& upd,
161 const DenseM_t& R, DenseM_t& S,
162 int depth) const override;
163
164#if defined(STRUMPACK_USE_MPI)
165 void extract_F11_block(scalar_t* F, integer_t ldF,
166 integer_t row, integer_t nr_rows,
167 integer_t col, integer_t nr_cols) const override;
168 void extract_F12_block(scalar_t* F, integer_t ldF,
169 integer_t row, integer_t nr_rows,
170 integer_t col, integer_t nr_cols,
171 const integer_t* upd) const override;
172 void extract_F21_block(scalar_t* F, integer_t ldF,
173 integer_t row, integer_t nr_rows,
174 integer_t col, integer_t nr_cols,
175 const integer_t* upd) const override;
176 void extract_separator_2d(integer_t sep_end,
177 const std::vector<std::size_t>& I,
178 const std::vector<std::size_t>& J,
179 DistM_t& B) const override;
180 void front_multiply_2d(integer_t sep_begin, integer_t sep_end,
181 const std::vector<integer_t>& upd,
182 const DistM_t& R, DistM_t& Srow, DistM_t& Scol,
183 int depth) const override;
184 void front_multiply_2d(Trans op, integer_t sep_begin, integer_t sep_end,
185 const std::vector<integer_t>& upd,
186 const DistM_t& R, DistM_t& S,
187 int depth) const override;
188#endif //defined(STRUMPACK_USE_MPI)
189#endif //DOXYGEN_SHOULD_SKIP_THIS
190
191 protected:
192 int strumpack_mc64(MatchingJob, Match_t&) override;
193
194 void scale(const std::vector<scalar_t>& Dr,
195 const std::vector<scalar_t>& Dc) override;
196 void scale_real(const std::vector<real_t>& Dr,
197 const std::vector<real_t>& Dc) override;
198 void sort_rows();
199
200 private:
201 using CSM_t::n_;
202 using CSM_t::nnz_;
203 using CSM_t::ptr_;
204 using CSM_t::ind_;
205 using CSM_t::val_;
206 using CSM_t::symm_sparse_;
207 };
208
220 template<typename scalar_t, typename integer_t, typename cast_t>
223
224} // end namespace strumpack
225
226#endif // STRUMPACK_CSR_MATRIX_HPP
Contains the CompressedSparseMatrix class, a base class for compressed sparse storage.
Definition CompressedSparseMatrix.hpp:49
Class for storing a compressed sparse row matrix (single node).
Definition CSRMatrix.hpp:55
void spmv(const scalar_t *x, scalar_t *y) const override
void spmv(const DenseM_t &x, DenseM_t &y) const override
Abstract base class for compressed sparse matrix storage.
Definition CompressedSparseMatrix.hpp:149
integer_t nnz() const
Definition CompressedSparseMatrix.hpp:176
const integer_t * ptr() const
Definition CompressedSparseMatrix.hpp:187
const integer_t * ind() const
Definition CompressedSparseMatrix.hpp:196
Like DenseMatrix, this class represents a matrix, stored in column major format, to allow direct use ...
Definition DenseMatrix.hpp:1018
This class represents a matrix, stored in column major format, to allow direct use of BLAS/LAPACK rou...
Definition DenseMatrix.hpp:139
2D block cyclicly distributed matrix, as used by ScaLAPACK.
Definition DistributedMatrix.hpp:84
Definition CompressedSparseMatrix.hpp:97
Definition CompressedSparseMatrix.hpp:56
Definition StrumpackOptions.hpp:44
CSRMatrix< cast_t, integer_t > cast_matrix(const CSRMatrix< scalar_t, integer_t > &mat)
MatchingJob
Definition StrumpackOptions.hpp:120
Trans
Definition DenseMatrix.hpp:51