Loading...
Searching...
No Matches
DenseMatrix.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 */
34#ifndef DENSE_MATRIX_HPP
35#define DENSE_MATRIX_HPP
36
37#include <string>
38#include <vector>
39#include <functional>
40
41#include "misc/RandomWrapper.hpp"
42#include "BLASLAPACKWrapper.hpp"
43
44
45namespace strumpack {
46
51 enum class Trans : char {
52 N='N',
53 C='C',
54 T='T'
55 };
56
57 inline Trans c2T(char op) {
58 switch (op) {
59 case 'n': case 'N': return Trans::N;
60 case 't': case 'T': return Trans::T;
61 case 'c': case 'C': return Trans::C;
62 default:
63 std::cerr << "ERROR: char " << op << " not recognized,"
64 << " should be one of n/N, t/T or c/C" << std::endl;
65 return Trans::N;
66 }
67 }
68
69
74 enum class Side : char {
75 L='L',
76 R='R'
77 };
78
83 enum class UpLo : char {
84 U='U',
85 L='L',
86 F='F'
87 };
88
93 enum class Diag : char {
94 U='U',
95 N='N'
96 };
97
102 enum class Jobz : char {
103 N='N',
104 V='V'
105 };
106
107
139 template<typename scalar_t> class DenseMatrix {
140 using real_t = typename RealType<scalar_t>::value_type;
141
142 protected:
143 scalar_t* data_ = nullptr;
144 std::size_t rows_ = 0;
145 std::size_t cols_ = 0;
146 std::size_t ld_ = 1;
147
148 public:
149
155
163 DenseMatrix(std::size_t m, std::size_t n);
164
173 DenseMatrix(std::size_t m, std::size_t n,
174 const std::function<scalar_t(std::size_t,std::size_t)>& A);
175
188 DenseMatrix(std::size_t m, std::size_t n,
189 const scalar_t* D, std::size_t ld);
190
206 DenseMatrix(std::size_t m, std::size_t n, const DenseMatrix<scalar_t>& D,
207 std::size_t i, std::size_t j);
208
211
214
216 virtual ~DenseMatrix();
217
220
226
228 inline std::size_t rows() const { return rows_; }
229
231 inline std::size_t cols() const { return cols_; }
232
237 inline std::size_t ld() const { return ld_; }
238
242 inline const scalar_t* data() const { return data_; }
243
247 inline scalar_t* data() { return data_; }
248
253 inline scalar_t* end() { return data_ + ld_ * cols_; }
254
259 inline const scalar_t* end() const {
260 if (rows_ == 0 || cols_ == 0) return data_;
261 return data_ + ld_ * cols_;
262 }
263
272 inline const scalar_t& operator()(std::size_t i, std::size_t j) const
273 { assert(i<=rows() && j<=cols()); return data_[i+ld_*j]; }
274
283 inline const scalar_t* ptr(std::size_t i, std::size_t j) const
284 { assert(i<=rows() && j<=cols()); return data_+i+ld_*j; }
285
294 inline scalar_t& operator()(std::size_t i, std::size_t j)
295 { assert(i<=rows() && j<=cols()); return data_[i+ld_*j]; }
296
305 inline scalar_t* ptr(std::size_t i, std::size_t j)
306 { assert(i<=rows() && j<=cols()); return data_+i+ld_*j; }
307
314 void print() const { print("A"); }
315
329 void print(std::string name, bool all=false, int width=8) const;
330
340 void print_to_file(std::string name,
341 std::string filename, int width=8) const;
342
348 void random();
349
354 void random(random::RandomGeneratorBase<typename RealType<scalar_t>::
355 value_type>& rgen);
356
362 void fill(scalar_t v);
363
370 void fill(const std::function<scalar_t(std::size_t,std::size_t)>& A);
371
373 void zero();
374
379 void eye();
380
384 virtual void clear();
385
394 void resize(std::size_t m, std::size_t n);
395
405
418 std::size_t i=0, std::size_t j=0);
419
428 void copy(const scalar_t* B, std::size_t ldb);
429
432
437
448 void laswp(const std::vector<int>& P, bool fwd);
449
460 void laswp(const int* P, bool fwd);
461
474 void lapmr(const std::vector<int>& P, bool fwd);
475
488 void lapmt(const std::vector<int>& P, bool fwd);
489
500 void extract_rows(const std::vector<std::size_t>& I,
501 DenseMatrix<scalar_t>& B) const;
502
513 extract_rows(const std::vector<std::size_t>& I) const;
514
525 void extract_cols(const std::vector<std::size_t>& I,
526 DenseMatrix<scalar_t>& B) const;
527
538 extract_cols(const std::vector<std::size_t>& I) const;
539
551 extract(const std::vector<std::size_t>& I,
552 const std::vector<std::size_t>& J) const;
553
565 scatter_rows_add(const std::vector<std::size_t>& I,
566 const DenseMatrix<scalar_t>& B, int depth);
567
575
584
590 DenseMatrix<scalar_t>& scale(scalar_t alpha, int depth=0);
591
601 scaled_add(scalar_t alpha, const DenseMatrix<scalar_t>& B, int depth=0);
602
612 scale_and_add(scalar_t alpha, const DenseMatrix<scalar_t>& B, int depth=0);
613
622 scale_rows(const std::vector<scalar_t>& D, int depth=0);
623
625 scale_rows_real(const std::vector<real_t>& D, int depth=0);
626
627
636 DenseMatrix<scalar_t>& scale_rows(const scalar_t* D, int depth=0);
637
638 DenseMatrix<scalar_t>& scale_rows_real(const real_t* D, int depth=0);
639
648 (const std::vector<scalar_t>& D, int depth=0);
649
654 real_t norm() const;
655
659 real_t normF() const;
660
664 real_t norm1() const;
665
669 real_t normI() const;
670
676 virtual std::size_t memory() const {
677 return sizeof(scalar_t) * rows() * cols();
678 }
679
684 virtual std::size_t nonzeros() const {
685 return rows()*cols();
686 }
687
702 int LU(std::vector<int>& piv, int depth=0);
703
717 std::vector<int> LU(int depth=0);
718
728 int Cholesky(int depth=0);
729
739 std::vector<int> LDLt(int depth=0);
740
753 //std::vector<int> LDLt_rook(int depth=0);
754
755
769 const std::vector<int>& piv, int depth=0) const;
770
783 const std::vector<int>& piv, int depth=0) const;
784
797 const int* piv, int depth=0) const;
798
811 const std::vector<int>& piv, int depth=0) const;
812
827 // void solve_LDLt_rook_in_place
828 // (DenseMatrix<scalar_t>& b, const std::vector<int>& piv, int depth=0) const;
829
843 DenseMatrix<scalar_t>& Q, int depth) const;
844
858 void orthogonalize(scalar_t& r_max, scalar_t& r_min, int depth);
859
883 void ID_column(DenseMatrix<scalar_t>& X, std::vector<int>& piv,
884 std::vector<std::size_t>& ind, real_t rel_tol,
885 real_t abs_tol, int max_rank, int depth);
886
904 void ID_row(DenseMatrix<scalar_t>& X, std::vector<int>& piv,
905 std::vector<std::size_t>& ind, real_t rel_tol, real_t abs_tol,
906 int max_rank, int depth) const;
907
927 real_t rel_tol, real_t abs_tol, int max_rank, int depth) const;
928
933 std::vector<scalar_t> singular_values() const;
934
941 void shift(scalar_t sigma);
942
943
958 int syev(Jobz job, UpLo ul, std::vector<scalar_t>& lambda);
959
966 void write(const std::string& fname) const;
967
974 static DenseMatrix<scalar_t> read(const std::string& fname);
975
976
980 std::size_t subnormals() const;
981 std::size_t zeros() const;
982
983 private:
984 void ID_column_GEQP3(DenseMatrix<scalar_t>& X, std::vector<int>& piv,
985 std::vector<std::size_t>& ind, real_t rel_tol,
986 real_t abs_tol, int max_rank, int depth);
987
988 template<typename T> friend class DistributedMatrix;
989
990 template<typename T> friend std::ofstream&
991 operator<<(std::ofstream& os, const DenseMatrix<T>& D);
992 template<typename T> friend std::ifstream&
993 operator>>(std::ifstream& is, DenseMatrix<T>& D);
994 };
995
996
1017 template<typename scalar_t>
1018 class DenseMatrixWrapper : public DenseMatrix<scalar_t> {
1019 public:
1024
1035 DenseMatrixWrapper(std::size_t m, std::size_t n,
1036 scalar_t* D, std::size_t ld) noexcept {
1037 this->data_ = D; this->rows_ = m; this->cols_ = n;
1038 this->ld_ = std::max(std::size_t(1), ld);
1039 }
1040
1054 DenseMatrixWrapper(std::size_t m, std::size_t n, DenseMatrix<scalar_t>& D,
1055 std::size_t i, std::size_t j) noexcept
1056 : DenseMatrixWrapper<scalar_t>(m, n, &D(i, j), D.ld()) {
1057 assert(i+m <= D.rows());
1058 assert(j+n <= D.cols());
1059 }
1060
1062 this->data_ = D.data();
1063 this->rows_ = D.rows();
1064 this->cols_ = D.cols();
1065 this->ld_ = D.ld();
1066 }
1067
1072 this->data_ = D.data();
1073 this->rows_ = D.rows();
1074 this->cols_ = D.cols();
1075 this->ld_ = D.ld();
1076 }
1077
1084
1089
1095 virtual ~DenseMatrixWrapper() { this->data_ = nullptr; }
1096
1103 void clear() override {
1104 this->rows_ = 0; this->cols_ = 0;
1105 this->ld_ = 1; this->data_ = nullptr;
1106 }
1107
1117 std::size_t memory() const override { return 0; }
1118
1128 std::size_t nonzeros() const override { return 0; }
1129
1130
1139
1148 this->data_ = D.data(); this->rows_ = D.rows();
1149 this->cols_ = D.cols(); this->ld_ = D.ld(); return *this; }
1150
1161 assert(a.rows()==this->rows() && a.cols()==this->cols());
1162 for (std::size_t j=0; j<this->cols(); j++)
1163 for (std::size_t i=0; i<this->rows(); i++)
1164 this->operator()(i, j) = a(i, j);
1165 return *this;
1166 }
1167
1168 using DenseMatrix<scalar_t>::operator=;
1169 };
1170
1171
1184 template<typename scalar_t>
1185 std::unique_ptr<const DenseMatrixWrapper<scalar_t>>
1187 (std::size_t m, std::size_t n, const scalar_t* D, std::size_t ld) {
1188 return std::unique_ptr<const DenseMatrixWrapper<scalar_t>>
1189 (new DenseMatrixWrapper<scalar_t>(m, n, const_cast<scalar_t*>(D), ld));
1190 }
1191
1210 template<typename scalar_t>
1211 std::unique_ptr<const DenseMatrixWrapper<scalar_t>>
1213 (std::size_t m, std::size_t n, const DenseMatrix<scalar_t>& D,
1214 std::size_t i, std::size_t j) {
1215 return std::unique_ptr<const DenseMatrixWrapper<scalar_t>>
1217 (m, n, const_cast<DenseMatrix<scalar_t>&>(D), i, j));
1218 }
1219
1220
1237 template<typename scalar_from_t, typename scalar_to_t> void
1238 copy(std::size_t m, std::size_t n, const DenseMatrix<scalar_from_t>& a,
1239 std::size_t ia, std::size_t ja, DenseMatrix<scalar_to_t>& b,
1240 std::size_t ib, std::size_t jb) {
1241 for (std::size_t j=0; j<n; j++)
1242 for (std::size_t i=0; i<m; i++)
1243 b(ib+i, jb+j) = static_cast<scalar_to_t>(a(ia+i, ja+j));
1244 }
1245
1256 template<typename scalar_from_t, typename scalar_to_t> void
1258 std::size_t ib=0, std::size_t jb=0) {
1259 copy(a.rows(), a.cols(), a, 0, 0, b, ib, jb);
1260 }
1261
1270 template<typename scalar_t> void
1271 copy(const DenseMatrix<scalar_t>& a, scalar_t* b, std::size_t ldb) {
1272 for (std::size_t j=0; j<a.cols(); j++)
1273 for (std::size_t i=0; i<a.rows(); i++)
1274 b[i+j*ldb] = a(i, j);
1275 }
1276
1277
1286 template<typename scalar_t> DenseMatrix<scalar_t>
1288 assert(a.cols() == b.cols());
1289 DenseMatrix<scalar_t> tmp(a.rows()+b.rows(), a.cols());
1290 copy(a, tmp, 0, 0);
1291 copy(b, tmp, a.rows(), 0);
1292 return tmp;
1293 }
1294
1303 template<typename scalar_t> DenseMatrix<scalar_t>
1305 assert(a.rows() == b.rows());
1306 DenseMatrix<scalar_t> tmp(a.rows(), a.cols()+b.cols());
1307 copy(a, tmp, 0, 0);
1308 copy(b, tmp, 0, a.cols());
1309 return tmp;
1310 }
1311
1319 template<typename scalar_t> DenseMatrix<scalar_t>
1320 eye(std::size_t m, std::size_t n) {
1321 DenseMatrix<scalar_t> I(m, n);
1322 I.eye();
1323 return I;
1324 }
1325
1326
1327
1328
1345 template<typename scalar_t> void
1346 gemm(Trans ta, Trans tb, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1347 const DenseMatrix<scalar_t>& b, scalar_t beta,
1348 DenseMatrix<scalar_t>& c, int depth=0);
1349
1350 template<typename scalar_t> void
1351 gemm(Trans ta, Trans tb, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1352 const scalar_t* b, int ldb, scalar_t beta,
1353 DenseMatrix<scalar_t>& c, int depth=0);
1354
1355 template<typename scalar_t> void
1356 gemm(Trans ta, Trans tb, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1357 const DenseMatrix<scalar_t>& b, scalar_t beta,
1358 scalar_t* c, int ldc, int depth=0);
1359
1369 template<typename scalar_t> void
1370 trmm(Side s, UpLo ul, Trans ta, Diag d, scalar_t alpha,
1372 int depth=0);
1373
1387 template<typename scalar_t> void
1388 trsm(Side s, UpLo ul, Trans ta, Diag d, scalar_t alpha,
1390 int depth=0);
1391
1400 template<typename scalar_t> void
1402 DenseMatrix<scalar_t>& b, int depth=0);
1403
1412 template<typename scalar_t> void
1413 gemv(Trans ta, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1414 const DenseMatrix<scalar_t>& x, scalar_t beta,
1415 DenseMatrix<scalar_t>& y, int depth=0);
1416
1425 template<typename scalar_t> void
1426 gemv(Trans ta, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1427 const scalar_t* x, int incx, scalar_t beta,
1428 DenseMatrix<scalar_t>& y, int depth=0);
1429
1438 template<typename scalar_t> void
1439 gemv(Trans ta, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1440 const DenseMatrix<scalar_t>& x, scalar_t beta,
1441 scalar_t* y, int incy, int depth=0);
1442
1451 template<typename scalar_t> void
1452 gemv(Trans ta, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1453 const scalar_t* x, int incx, scalar_t beta,
1454 scalar_t* y, int incy, int depth=0);
1455
1456
1458 template<typename scalar_t> long long int
1460 return (is_complex<scalar_t>() ? 4:1) *
1461 blas::getrf_flops(a.rows(), a.cols());
1462 }
1463
1465 template<typename scalar_t> long long int
1467 return (is_complex<scalar_t>() ? 4:1) *
1468 blas::getrs_flops(b.rows(), b.cols());
1469 }
1470
1472 template<typename scalar_t> long long int
1474 auto minrc = std::min(a.rows(), a.cols());
1475 return (is_complex<scalar_t>() ? 4:1) *
1476 (blas::gelqf_flops(a.rows(), a.cols()) +
1477 blas::xxglq_flops(a.cols(), a.cols(), minrc));
1478 }
1479
1481 template<typename scalar_t> long long int
1483 return (is_complex<scalar_t>() ? 4:1) *
1484 (blas::geqp3_flops(a.cols(), a.rows()) +
1485 blas::trsm_flops(rank, a.cols() - rank, scalar_t(1.), 'L'));
1486 }
1487
1489 template<typename scalar_t> long long int
1490 trsm_flops(Side s, scalar_t alpha, const DenseMatrix<scalar_t>& a,
1491 const DenseMatrix<scalar_t>& b) {
1492 return (is_complex<scalar_t>() ? 4:1) *
1493 blas::trsm_flops(b.rows(), b.cols(), alpha, char(s));
1494 }
1495
1497 template<typename scalar_t> long long int
1498 gemm_flops(Trans ta, Trans tb, scalar_t alpha,
1499 const DenseMatrix<scalar_t>& a,
1500 const DenseMatrix<scalar_t>& b, scalar_t beta) {
1501 return (is_complex<scalar_t>() ? 4:1) *
1502 blas::gemm_flops
1503 ((ta==Trans::N) ? a.rows() : a.cols(),
1504 (tb==Trans::N) ? b.cols() : b.rows(),
1505 (ta==Trans::N) ? a.cols() : a.rows(), alpha, beta);
1506 }
1507
1509 template<typename scalar_t> long long int
1510 gemm_flops(Trans ta, Trans tb, scalar_t alpha,
1511 const DenseMatrix<scalar_t>& a, scalar_t beta,
1512 const DenseMatrix<scalar_t>& c) {
1513 return (is_complex<scalar_t>() ? 4:1) *
1514 blas::gemm_flops
1515 (c.rows(), c.cols(), (ta==Trans::N) ? a.cols() : a.rows(), alpha, beta);
1516 }
1517
1519 template<typename scalar_t> long long int
1521 auto minrc = std::min(a.rows(), a.cols());
1522 return (is_complex<scalar_t>() ? 4:1) *
1523 (blas::geqrf_flops(a.rows(), minrc) +
1524 blas::xxgqr_flops(a.rows(), minrc, minrc));
1525 }
1526
1536 template<typename scalar_t,typename cast_t>
1538
1539} // end namespace strumpack
1540
1541#endif // DENSE_MATRIX_HPP
Like DenseMatrix, this class represents a matrix, stored in column major format, to allow direct use ...
Definition DenseMatrix.hpp:1018
DenseMatrix< scalar_t > & operator=(const DenseMatrix< scalar_t > &a) override
Definition DenseMatrix.hpp:1160
virtual ~DenseMatrixWrapper()
Definition DenseMatrix.hpp:1095
DenseMatrixWrapper()
Definition DenseMatrix.hpp:1023
DenseMatrixWrapper< scalar_t > & operator=(const DenseMatrixWrapper< scalar_t > &D)=delete
DenseMatrixWrapper(const DenseMatrix< scalar_t > &)=delete
void clear() override
Definition DenseMatrix.hpp:1103
std::size_t nonzeros() const override
Definition DenseMatrix.hpp:1128
DenseMatrixWrapper(DenseMatrixWrapper< scalar_t > &&D) noexcept
Definition DenseMatrix.hpp:1071
std::size_t memory() const override
Definition DenseMatrix.hpp:1117
DenseMatrixWrapper(std::size_t m, std::size_t n, scalar_t *D, std::size_t ld) noexcept
Definition DenseMatrix.hpp:1035
DenseMatrixWrapper(DenseMatrix< scalar_t > &&)=delete
DenseMatrixWrapper(std::size_t m, std::size_t n, DenseMatrix< scalar_t > &D, std::size_t i, std::size_t j) noexcept
Definition DenseMatrix.hpp:1054
DenseMatrixWrapper< scalar_t > & operator=(DenseMatrixWrapper< scalar_t > &&D)
Definition DenseMatrix.hpp:1147
This class represents a matrix, stored in column major format, to allow direct use of BLAS/LAPACK rou...
Definition DenseMatrix.hpp:139
real_t norm() const
void lapmt(const std::vector< int > &P, bool fwd)
DenseMatrix< scalar_t > solve(const DenseMatrix< scalar_t > &b, const std::vector< int > &piv, int depth=0) const
static DenseMatrix< scalar_t > read(const std::string &fname)
real_t norm1() const
DenseMatrix(DenseMatrix< scalar_t > &&D)
void copy(const scalar_t *B, std::size_t ldb)
void solve_LDLt_in_place(DenseMatrix< scalar_t > &b, const std::vector< int > &piv, int depth=0) const
std::size_t cols() const
Definition DenseMatrix.hpp:231
DenseMatrix< scalar_t > & scale_and_add(scalar_t alpha, const DenseMatrix< scalar_t > &B, int depth=0)
void laswp(const int *P, bool fwd)
scalar_t * ptr(std::size_t i, std::size_t j)
Definition DenseMatrix.hpp:305
void fill(const std::function< scalar_t(std::size_t, std::size_t)> &A)
void conj_transpose(DenseMatrix< scalar_t > &X) const
virtual std::size_t nonzeros() const
Definition DenseMatrix.hpp:684
std::size_t subnormals() const
void random(random::RandomGeneratorBase< typename RealType< scalar_t >::value_type > &rgen)
void copy(const DenseMatrix< scalar_t > &B, std::size_t i=0, std::size_t j=0)
DenseMatrix< scalar_t > & sub(const DenseMatrix< scalar_t > &B, int depth=0)
DenseMatrix< scalar_t > & scale_rows(const scalar_t *D, int depth=0)
DenseMatrix(std::size_t m, std::size_t n, const scalar_t *D, std::size_t ld)
std::vector< scalar_t > singular_values() const
std::size_t rows() const
Definition DenseMatrix.hpp:228
std::size_t ld() const
Definition DenseMatrix.hpp:237
DenseMatrix(std::size_t m, std::size_t n, const DenseMatrix< scalar_t > &D, std::size_t i, std::size_t j)
virtual DenseMatrix< scalar_t > & operator=(DenseMatrix< scalar_t > &&D)
DenseMatrix< scalar_t > conj_transpose() const
void print(std::string name, bool all=false, int width=8) const
void laswp(const std::vector< int > &P, bool fwd)
void fill(scalar_t v)
void solve_LU_in_place(DenseMatrix< scalar_t > &b, const std::vector< int > &piv, int depth=0) const
void ID_column(DenseMatrix< scalar_t > &X, std::vector< int > &piv, std::vector< std::size_t > &ind, real_t rel_tol, real_t abs_tol, int max_rank, int depth)
const scalar_t * ptr(std::size_t i, std::size_t j) const
Definition DenseMatrix.hpp:283
scalar_t * data()
Definition DenseMatrix.hpp:247
void lapmr(const std::vector< int > &P, bool fwd)
DenseMatrix(const DenseMatrix< scalar_t > &D)
void LQ(DenseMatrix< scalar_t > &L, DenseMatrix< scalar_t > &Q, int depth) const
virtual DenseMatrix< scalar_t > & operator=(const DenseMatrix< scalar_t > &D)
void print_to_file(std::string name, std::string filename, int width=8) const
scalar_t * end()
Definition DenseMatrix.hpp:253
void extract_cols(const std::vector< std::size_t > &I, DenseMatrix< scalar_t > &B) const
DenseMatrix< scalar_t > extract_cols(const std::vector< std::size_t > &I) const
DenseMatrix< scalar_t > extract_rows(const std::vector< std::size_t > &I) const
real_t normI() const
void hconcat(const DenseMatrix< scalar_t > &b)
std::vector< int > LDLt(int depth=0)
real_t normF() const
virtual std::size_t memory() const
Definition DenseMatrix.hpp:676
void solve_LU_in_place(DenseMatrix< scalar_t > &b, const int *piv, int depth=0) const
int syev(Jobz job, UpLo ul, std::vector< scalar_t > &lambda)
DenseMatrix< scalar_t > & add(const DenseMatrix< scalar_t > &B, int depth=0)
DenseMatrix< scalar_t > & div_rows(const std::vector< scalar_t > &D, int depth=0)
DenseMatrix< scalar_t > & scale(scalar_t alpha, int depth=0)
DenseMatrix< scalar_t > & scatter_rows_add(const std::vector< std::size_t > &I, const DenseMatrix< scalar_t > &B, int depth)
scalar_t & operator()(std::size_t i, std::size_t j)
Definition DenseMatrix.hpp:294
DenseMatrix< scalar_t > extract(const std::vector< std::size_t > &I, const std::vector< std::size_t > &J) const
DenseMatrix(std::size_t m, std::size_t n)
void extract_rows(const std::vector< std::size_t > &I, DenseMatrix< scalar_t > &B) const
void orthogonalize(scalar_t &r_max, scalar_t &r_min, int depth)
int Cholesky(int depth=0)
DenseMatrix< scalar_t > & scaled_add(scalar_t alpha, const DenseMatrix< scalar_t > &B, int depth=0)
DenseMatrix< scalar_t > & scale_rows(const std::vector< scalar_t > &D, int depth=0)
int LU(std::vector< int > &piv, int depth=0)
void write(const std::string &fname) const
virtual void clear()
void print() const
Definition DenseMatrix.hpp:314
std::vector< int > LU(int depth=0)
const scalar_t * end() const
Definition DenseMatrix.hpp:259
void resize(std::size_t m, std::size_t n)
const scalar_t & operator()(std::size_t i, std::size_t j) const
Definition DenseMatrix.hpp:272
void ID_row(DenseMatrix< scalar_t > &X, std::vector< int > &piv, std::vector< std::size_t > &ind, real_t rel_tol, real_t abs_tol, int max_rank, int depth) const
const scalar_t * data() const
Definition DenseMatrix.hpp:242
DenseMatrix(std::size_t m, std::size_t n, const std::function< scalar_t(std::size_t, std::size_t)> &A)
void low_rank(DenseMatrix< scalar_t > &U, DenseMatrix< scalar_t > &V, real_t rel_tol, real_t abs_tol, int max_rank, int depth) const
void shift(scalar_t sigma)
2D block cyclicly distributed matrix, as used by ScaLAPACK.
Definition DistributedMatrix.hpp:84
class to wrap the C++11 random number generator/distribution
Definition RandomWrapper.hpp:105
Definition StrumpackOptions.hpp:44
long long int LU_flops(const DenseMatrix< scalar_t > &a)
Definition DenseMatrix.hpp:1459
long long int gemm_flops(Trans ta, Trans tb, scalar_t alpha, const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &b, scalar_t beta)
Definition DenseMatrix.hpp:1498
DenseMatrix< scalar_t > eye(std::size_t m, std::size_t n)
Definition DenseMatrix.hpp:1320
UpLo
Definition DenseMatrix.hpp:83
CSRMatrix< cast_t, integer_t > cast_matrix(const CSRMatrix< scalar_t, integer_t > &mat)
std::unique_ptr< const DenseMatrixWrapper< scalar_t > > ConstDenseMatrixWrapperPtr(std::size_t m, std::size_t n, const scalar_t *D, std::size_t ld)
Definition DenseMatrix.hpp:1187
DenseMatrix< scalar_t > vconcat(const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &b)
Definition DenseMatrix.hpp:1287
void trmm(Side s, UpLo ul, Trans ta, Diag d, scalar_t alpha, const DenseMatrix< scalar_t > &a, DenseMatrix< scalar_t > &b, int depth=0)
void trsv(UpLo ul, Trans ta, Diag d, const DenseMatrix< scalar_t > &a, DenseMatrix< scalar_t > &b, int depth=0)
DenseMatrix< scalar_t > hconcat(const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &b)
Definition DenseMatrix.hpp:1304
void gemv(Trans ta, scalar_t alpha, const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &x, scalar_t beta, DenseMatrix< scalar_t > &y, int depth=0)
Trans
Definition DenseMatrix.hpp:51
void trsm(Side s, UpLo ul, Trans ta, Diag d, scalar_t alpha, const DenseMatrix< scalar_t > &a, DenseMatrix< scalar_t > &b, int depth=0)
long long int orthogonalize_flops(const DenseMatrix< scalar_t > &a)
Definition DenseMatrix.hpp:1520
long long int trsm_flops(Side s, scalar_t alpha, const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &b)
Definition DenseMatrix.hpp:1490
Side
Definition DenseMatrix.hpp:74
void copy(std::size_t m, std::size_t n, const DenseMatrix< scalar_from_t > &a, std::size_t ia, std::size_t ja, DenseMatrix< scalar_to_t > &b, std::size_t ib, std::size_t jb)
Definition DenseMatrix.hpp:1238
void gemm(Trans ta, Trans tb, scalar_t alpha, const DenseMatrix< scalar_t > &a, const DenseMatrix< scalar_t > &b, scalar_t beta, DenseMatrix< scalar_t > &c, int depth=0)
long long int ID_row_flops(const DenseMatrix< scalar_t > &a, int rank)
Definition DenseMatrix.hpp:1482
long long int LQ_flops(const DenseMatrix< scalar_t > &a)
Definition DenseMatrix.hpp:1473
long long int solve_flops(const DenseMatrix< scalar_t > &b)
Definition DenseMatrix.hpp:1466
Diag
Definition DenseMatrix.hpp:93
Jobz
Definition DenseMatrix.hpp:102