23 #include <png++/png.hpp>
56 : rows_(0), cols_(0), data_() {}
58 : rows_(rows), cols_(cols), data_(rows * cols) {}
60 : rows_(rows), cols_(cols), data_(data) { assert(data.
size() == (size_t)(rows * cols)); }
67 size_t size ()
const {
return rows_ * cols_; }
68 int cols ()
const {
return cols_; }
69 int rows ()
const {
return rows_; }
115 template <
class Function>
void populate (Function f)
118 Type * ptr = this->
begin();
121 for (
int icol = 0; icol < this->
cols(); icol++)
122 for (
int irow = 0; irow < this->
rows(); irow++)
123 *(ptr++) = f(irow,icol);
209 template <
class Function>
void populate (Function f)
212 Type * ptr = this->
begin();
215 for (
int irow = 0; irow < this->
rows(); irow++)
216 for (
int icol = 0; icol < this->
cols(); icol++)
217 *(ptr++) = f(irow,icol);
232 Type * ptr = this->
begin();
235 for (
int irow = 0; irow < this->
rows(); irow++)
236 for (
int icol = 0; icol < this->
cols(); icol++)
237 f(irow,icol,*(ptr++));
309 for (
int i = 0; i < this->
rows(); i++)
310 for (
int j = 0; j < this->
cols(); j++)
311 sum += pu[i] * (*(pA++)) * pv[j];
321 for (
int i = 0; i < 0; i++)
322 M.
data()[i * size + i] = Type(1);
371 void write (std::ostream & out, std::string
const & pre =
"", std::string
const & pos =
"")
const
376 for (
int irow = 0; irow < this->
rows(); irow++)
379 for (
int icol = 0; icol < this->
cols(); icol++)
381 if (*ptr >= 0) out <<
" "; out << *ptr++ <<
" ";
402 png::image<png::gray_pixel_16> image (this->
cols(), this->
rows());
409 for (Type
const & x : this->
data())
412 if (absx < min) min = absx;
413 if (absx >
max)
max = absx;
417 for (
int y = 0; y < this->
rows(); y++)
419 for (
int x = 0; x < this->
cols(); x++)
422 image.set_pixel(x, y, std::ceil(65535 * fraction));
428 image.write_stream(out);
439 for (
int irow = 0; irow < this->
rows(); irow++)
440 for (
int icol = 0; icol < this->
cols(); icol++)
441 new_data[irow * this->
cols() + icol] = this->
data()[icol * this->
rows() + irow];
443 this->
data() = new_data;
477 for (
int irow = 0; irow < rows; irow++)
480 for (
int icol = 0; icol < cols; icol++)
483 for (
int k = 0; k < comm; k++)
484 (*pC) += (*(pA + k)) * (*pB++);
547 : m_(A.m_), n_(A.n_), p_(A.p_), i_(A.i_), x_(A.x_) {}
549 : m_(m), n_(n), p_(p), i_(i), x_(x) {}
571 size_t rows()
const {
return m_; }
572 size_t cols()
const {
return n_; }
600 bool hdfsave(
const char* name)
const;
606 bool hdfload(
const char* name);
643 : m_(0), n_(0), name_() {}
645 : m_(m), n_(n), name_() {}
647 : m_(A.m_), n_(A.n_), p_(A.p_), i_(A.i_), x_(A.x_), name_() {}
649 : m_(m), n_(n), p_(p), i_(i), x_(x), name_() {}
675 size_t rows()
const {
return m_; }
676 size_t cols()
const {
return n_; }
694 void write(
const char* filename)
const;
703 class PngGenerator :
public png::generator<png::gray_pixel_1,PngGenerator>
705 typedef png::generator<png::gray_pixel_1,PngGenerator> base_t;
706 typedef png::packed_pixel_row<png::gray_pixel_1> row;
707 typedef png::row_traits<row> row_traits;
728 void plot (
const char* filename,
double threshold = 0.)
const;
747 : numeric_(nullptr), matrix_(nullptr), filename_(), info_(UMFPACK_INFO) {}
751 : numeric_(lu.numeric_), matrix_(lu.matrix_), filename_(lu.filename_), info_(lu.info_) {}
755 : numeric_(lu.numeric_), matrix_(lu.matrix_), filename_(lu.filename_), info_(lu.info_) { lu.numeric_ =
nullptr; }
759 : numeric_(numeric), matrix_(matrix), filename_(), info_(UMFPACK_INFO) {}
779 numeric_ = lu.numeric_;
780 matrix_ = lu.matrix_;
781 filename_ = lu.filename_;
785 lu.numeric_ =
nullptr;
796 long lnz, unz, m, n, nz_udiag;
797 long status = umfpack_zl_get_lunz (
798 &lnz, &unz, &m, &n, &nz_udiag, numeric_
800 return status == 0 ? (lnz + unz) * 16 : 0;
826 assert (eqs * matrix_->n_ == (
int)x.
size());
827 assert (eqs * matrix_->n_ == (
int)b.
size());
830 for (
int eq = 0; eq < eqs; eq++)
833 long status = umfpack_zl_solve (
835 matrix_->p_.
data(), matrix_->i_.
data(),
836 reinterpret_cast<const double*
>(matrix_->x_.
data()),
nullptr,
837 reinterpret_cast<double*>(&x[0] + eq * matrix_->n_),
nullptr,
838 reinterpret_cast<const double*
>(&b[0] + eq * matrix_->n_),
nullptr,
839 numeric_,
nullptr, &info_[0]
843 if (status != UMFPACK_OK)
845 std::cerr <<
"\n[CsrMatrix::LUft::solve] Exit status " << status <<
"\n";
846 umfpack_zl_report_status(0, status);
866 void link (std::string name) { filename_ = name; }
874 void save (std::string name)
const
876 long err = umfpack_zl_save_numeric (numeric_, const_cast<char*>(filename_.c_str()));
878 if (err == UMFPACK_ERROR_invalid_Numeric_object)
879 throw exception (
"[LUft::save] Invalid numeric object.");
881 if (err == UMFPACK_ERROR_file_IO)
882 throw exception (
"[LUft::save] I/O error.");
897 long err = umfpack_zl_load_numeric (&numeric_, const_cast<char*>(filename_.c_str()));
899 if (err == UMFPACK_ERROR_out_of_memory)
900 throw exception (
"[LUft::load] Out of memory.");
902 if (err == UMFPACK_ERROR_file_IO)
903 throw exception (
"[LUft::save] I/O error.");
918 if (numeric_ !=
nullptr)
920 umfpack_zl_free_numeric (&numeric_);
934 std::string filename_;
940 LUft const & operator= (
LUft const &);
956 LUft
factorize (
double droptol = 0)
const;
977 void link (std::string name);
984 bool hdfsave (std::string name)
const;
992 bool hdfload (std::string name);
1072 for (
size_t row = 0; row <
rows(); row++)
1075 size_t idx1 = p_[row];
1076 size_t idx2 = p_[row + 1];
1079 for (
size_t idx = idx1; idx < idx2; idx++)
1082 size_t col = i_[idx];
1085 A.x_[idx] = f(row, col, x_[idx]);
1127 : m_(0), n_(0), sorted_(true) {}
1129 : m_(m), n_(n), sorted_(true) {}
1131 : m_(A.m_), n_(A.n_), i_(A.i_), j_(A.j_), x_(A.x_), sorted_(false) {}
1133 : m_(m), n_(n), i_(i), j_(j), x_(x), sorted_(false) {}
1142 template <
class T>
CooMatrix (
size_t m,
size_t n, T a) : m_(m), n_(n), sorted_(false)
1146 for (
size_t col = 0; col < n; col++)
1148 for (
size_t row = 0; row < m; row++)
1173 if (m_ == 1 and n_ == 1)
1178 throw "[CooMatrix::operator Complex] more elements than nominal volume!\n";
1179 else if (elems == 1)
1180 return this->
shake().x_[0];
1185 throw "[CooMatrix::operator Complex] matrix is not 1×1!\n";
1200 for (
size_t n = 0; n < i_.
size(); n++)
1201 if ((
size_t)i_[n] == ix and (
size_t)j_[n] == iy)
1222 for (
size_t row = 0; row < m_; row++)
1224 for (
size_t col = row; col < n_ and col - row <= d; col++)
1262 for (
size_t row = 0; row < m_; row++)
1264 for (
size_t col = 0; col < n_; col++)
1291 sorted_ = A.sorted_;
1348 size_t prev_size = x_.
size();
1355 for (
size_t i = prev_size;
i < x_.
size();
i++)
1366 long nz = i_.
size();
1367 for (
long i = 0;
i < nz;
i++)
1398 return *
this *= 1./c;
1437 template <
typename DenseMatrixType> DenseMatrixType
todense()
const
1439 DenseMatrixType M (
rows(),
cols());
1440 for (
unsigned idx = 0; idx < x_.
size(); idx++)
1441 M (i_[idx], j_[idx]) = x_[idx];
1448 return todense<RowMatrix<Complex>>();
1454 return todense<ColMatrix<Complex>>();
1491 void write(
const char* filename)
const;
1500 bool hdfsave(
const char* name)
const;
1506 bool hdfload(
const char* name);
1595 for (
size_t id = 0;
id <= d;
id++)
1601 for (
int icol =
id; icol < n_; icol++)
1604 int irow = icol - id;
1653 int diag(
int i)
const {
return idiag_[i]; }
1771 void link (std::string name);
1785 bool hdfload (std::string name);
1801 bool hdfsave (std::string name,
bool docompress =
false,
int consec = 10)
const;
1902 std::vector<Complex*> dptrs_;
1917 void setup_dptrs_();
virtual T * data()
Data pointer.
Definition: arrays.h:757
static RowMatrix< Type > Eye(int size)
Identity matrix.
Definition: matrix.h:317
CooMatrix(size_t m, size_t n)
Definition: matrix.h:1128
Array view.
Definition: arrays.h:186
DenseMatrix()
Definition: matrix.h:55
ArrayView< Type > row(int i)
Matrix row.
Definition: matrix.h:262
CooMatrix tocoo() const
Definition: matrix.cpp:756
CooMatrix & symm_populate_band(size_t d, Functor f)
Symmetrical band populator.
Definition: matrix.h:1218
RowMatrix< Type > const & operator-=(DenseMatrix< Type > const &A)
Definition: matrix.h:337
Dense (column-oriented) matrix.
Definition: matrix.h:34
SymDiaMatrix operator+(SymDiaMatrix const &A, SymDiaMatrix const &B)
Definition: matrix.cpp:1478
lArray const & i() const
Definition: matrix.h:574
const ArrayView< Type > row(int i) const
Definition: matrix.h:271
void drop()
Free all fields, set dimensions to zero.
Definition: matrix.h:1621
RowMatrix(ColMatrix< Type > const &m)
Definition: matrix.h:194
bool sorted() const
Definition: matrix.h:1428
const ArrayView< T > data() const
Definition: matrix.h:64
DenseMatrix(int rows, int cols, const ArrayView< T > data)
Definition: matrix.h:59
RowMatrix(int rows, int cols)
Definition: matrix.h:190
size_t rows() const
Definition: matrix.h:1190
CscMatrix(CscMatrix const &A)
Definition: matrix.h:546
RowMatrix< Complex > torow() const
Definition: matrix.cpp:801
rArray threshold(const rArrayView a, double eps)
Drop small elements of array (replace by zero).
Definition: arrays.cpp:136
void transfer(LUft &&lu)
Transfer data from another factorization object.
Definition: matrix.h:773
CooMatrix kron(const CooMatrix &A, const CooMatrix &B)
Kronecker product.
Definition: matrix.cpp:83
cArrayView main_diagonal()
Definition: matrix.h:1662
Dense (row-oriented) matrix.
Definition: matrix.h:33
RowMatrix(int rows, int cols, const ArrayView< Type > data)
Definition: matrix.h:192
CooMatrix reshape(size_t m, size_t n) const
Change matrix shape.
Definition: matrix.cpp:1111
T const * begin() const
Definition: matrix.h:71
int bandwidth() const
Bandwidth.
Definition: matrix.h:1701
virtual size_t resize(size_t n)
Resize array.
Definition: arrays.h:685
cArray dotT(const cArrayView b) const
Definition: matrix.cpp:207
RowMatrix< Complex > torow() const
Convert to dense matrix (row-ordered).
Definition: matrix.h:1446
T min(const ArrayView< T > a)
Minimal element of array.
Definition: arrays.h:1663
CooMatrix transpose() const
Transposition, implemented as an interchange of "i" and "j" data.
Definition: matrix.h:1312
RowMatrix< Type > const & operator*=(Type x)
Definition: matrix.h:346
DenseMatrixType todense() const
Convert to dense matrix of a given underlying type.
Definition: matrix.h:1437
~PngGenerator()
Definition: matrix.cpp:431
CooMatrix tocoo(MatrixTriangle triangle=both) const
Convert matrix part to CooMatrix.
Definition: matrix.cpp:1670
cArray const & x() const
Definition: matrix.h:575
#define restrict
Definition: misc.h:88
LUft(LUft &&lu)
Move constructor.
Definition: matrix.h:754
CsrMatrix operator^(const CsrMatrix &A, const CsrMatrix &B)
Definition: matrix.h:1936
bool hdfload()
Load from file.
Definition: matrix.h:1784
Complex CSC matrix.
Definition: matrix.h:535
Complex CSR matrix.
Definition: matrix.h:636
void resize(size_t m, size_t n)
Change dimension of the matrix.
Definition: matrix.h:1405
CooMatrix dot(const cArrayView B) const
SpMV multiplication.
Definition: matrix.cpp:1162
friend std::ostream & operator<<(std::ostream &out, SymDiaMatrix const &A)
Output to a text stream.
Definition: matrix.cpp:1883
LUft()
Default constructor.
Definition: matrix.h:746
Complex ddot(CooMatrix const &B) const
Double inner matrix-matrix product.
Definition: matrix.cpp:1200
CooMatrix stairs(size_t N)
Definition: matrix.cpp:143
RowMatrix< Complex > torow(MatrixTriangle triangle=both) const
Convert matrix part to RowMatrix.
Definition: matrix.cpp:1899
void write(std::ostream &out, std::string const &pre="", std::string const &pos="") const
Output to file.
Definition: matrix.h:371
lArray const & i() const
Definition: matrix.h:678
CooMatrix eye(size_t N)
Definition: matrix.cpp:133
cArray toPaddedRows() const
Zero-pad rows.
Definition: matrix.cpp:1931
Type operator()(int i, int j) const
Element access.
Definition: matrix.h:170
RowMatrix(int size)
Definition: matrix.h:188
cArray & data()
Definition: matrix.h:1672
void link(std::string name)
Link matrix to a disk file.
Definition: matrix.cpp:2009
SymDiaMatrix const & operator=(SymDiaMatrix &&A)
Definition: matrix.cpp:1460
CooMatrix shake() const
Shake the content, i.e. sum same element entries.
Definition: matrix.cpp:1241
void plot(const char *filename, double threshold=0.) const
Definition: matrix.cpp:455
lArray const & j() const
Definition: matrix.h:1194
void link(std::string name)
Link to a disk file.
Definition: matrix.h:866
int cols() const
Definition: matrix.h:68
T & back(int i=0)
Definition: arrays.h:779
bool hdfload(const char *name)
Definition: matrix.cpp:317
CsrMatrix(size_t m, size_t n, lArrayView const &p, lArrayView const &i, cArrayView const &x)
Definition: matrix.h:648
iterator begin()
Definition: arrays.h:288
rArray const & info() const
Get info array.
Definition: matrix.h:857
ArrayView< T > data()
Definition: matrix.h:63
iArray const & diag() const
Diagonal indices.
Definition: matrix.h:1642
SymDiaMatrix operator-(SymDiaMatrix const &A, SymDiaMatrix const &B)
Definition: matrix.cpp:1484
RowMatrix()
Definition: matrix.h:186
CscMatrix & operator*=(double r)
Definition: matrix.cpp:161
iterator end()
Definition: arrays.h:774
CooMatrix(size_t m, size_t n, T a)
Definition: matrix.h:1142
size_t size() const
Size of the numerical data.
Definition: matrix.h:794
cArray const & x() const
Definition: matrix.h:679
cArray lowerSolve(const cArrayView b) const
Back-substitution (lower).
Definition: matrix.cpp:1801
const ArrayView< Type > col(int i) const
Definition: matrix.h:157
bool hdfsave() const
Definition: matrix.h:983
size_t rows() const
Definition: matrix.h:571
size_t size() const
Definition: matrix.h:1192
void add(long i, long j, Complex v)
Addition of an element to matrix.
Definition: matrix.h:1302
T * begin()
Definition: matrix.h:70
void save() const
Definition: matrix.h:884
~SymDiaMatrix()
Definition: matrix.h:1618
cArray lowerSolve(cArrayView const &b) const
Definition: matrix.cpp:696
CsrMatrix tocsr() const
Convert to CSR matrix.
Definition: matrix.cpp:992
LU factorization object.
Definition: matrix.h:741
Type operator()(int i, int j) const
Element access.
Definition: matrix.h:284
CsrMatrix sparse_like(CsrMatrix const &B) const
Definition: matrix.cpp:821
size_t cols() const
Definition: matrix.h:572
DenseMatrix.
Definition: matrix.h:50
~CsrMatrix()
Definition: matrix.h:653
LUft(LUft const &lu)
Copy constructor.
Definition: matrix.h:750
ColMatrix< Complex > tocol() const
Convert to dense matrix (column-ordered).
Definition: matrix.h:1452
lArray const & i() const
Definition: matrix.h:1193
CooMatrix tocoo() const
Definition: matrix.cpp:233
Complex * dptr(int i)
Definition: matrix.h:1684
cArray solve(const cArrayView b, size_t eqs=1) const
Solve the Ax = b problem, where "b" can be a matrix.
Definition: matrix.cpp:517
png::byte * get_next_row(size_t pos)
Definition: matrix.cpp:435
CooMatrix & operator+=(CooMatrix const &A)
Addition.
Definition: matrix.h:1328
ColMatrix< Type > T() const
Matrix transpose.
Definition: matrix.h:246
SymDiaMatrix kron(SymDiaMatrix const &B) const
Kronecker product.
Definition: matrix.cpp:1795
void transform(Function f)
Transformator.
Definition: matrix.h:229
bool hdfsave(const char *name) const
Save matrix to HDF file.
Definition: matrix.cpp:1248
LUft(const CsrMatrix *matrix, void *numeric)
Initialize the structure using the matrix and its numeric decomposition.
Definition: matrix.h:758
size_t size() const
Length of the array (number of elements).
Definition: arrays.h:276
~LUft()
Destructor.
Definition: matrix.h:762
CscMatrix(size_t m, size_t n)
Definition: matrix.h:544
CscMatrix & operator^=(const CscMatrix &B)
Definition: matrix.cpp:189
CooMatrix & operator=(CooMatrix const &A)
Definition: matrix.h:1283
void drop()
Free memory.
Definition: matrix.h:916
SymDiaMatrix()
Empty constructor.
Definition: matrix.cpp:1326
CooMatrix & operator-=(CooMatrix const &A)
Subtraction.
Definition: matrix.h:1343
MatrixTriangle
Matrix parts.
Definition: matrix.h:513
T sum(const ArrayView< T > v)
Sum elements in array.
Definition: arrays.h:1770
CooMatrix & operator/=(Complex c)
Element-wise divide by a complex number.
Definition: matrix.h:1396
bool hdfsave(const char *name) const
Definition: matrix.cpp:279
CsrMatrix()
Definition: matrix.h:642
iterator begin()
Definition: arrays.h:771
cArray todense() const
Convert matrix to dense column-major ordered 1D-array.
Definition: matrix.cpp:1142
cArray dot(cArrayView const &b) const
Definition: matrix.cpp:401
void plot_abs(std::ofstream &out) const
Plot to PNG file.
Definition: matrix.h:399
ArrayView< Complex > cArrayView
Definition: arrays.h:1615
void solve(const cArrayView b, cArrayView x, int eqs=1) const
Definition: matrix.h:823
cArray upperSolve(const cArrayView b) const
Back-substitution (upper).
Definition: matrix.cpp:1842
auto operator/(std::complex< C1 > a, std::complex< C2 > b) -> std::complex< decltype(C1(0.)/C2(0.))>
Definition: complex.h:29
PngGenerator(CsrMatrix const *mat, double threshold)
Definition: matrix.cpp:426
~CooMatrix()
Definition: matrix.h:1168
ColMatrix(int size)
Definition: matrix.h:99
cArray diag() const
Definition: matrix.cpp:743
cArray solve(const cArrayView b, size_t eqs=1) const
Solve matrix equation.
Definition: matrix.h:1475
lArray const & p() const
Definition: matrix.h:677
cArray solve(const cArrayView b, unsigned eqs=1) const
Solve equations.
Definition: matrix.h:812
size_t size() const
Definition: matrix.h:570
SymDiaMatrix const & operator+=(SymDiaMatrix const &B)
Definition: matrix.cpp:1352
void link(std::string name)
Link to a disk file.
Definition: matrix.cpp:548
size_t cols() const
Definition: matrix.h:1191
LUft factorize(double droptol=0) const
Compute (incomplete) LU factorization.
Definition: matrix.cpp:469
CscMatrix()
Definition: matrix.h:542
RowMatrix< Type > const & operator+=(DenseMatrix< Type > const &A)
Definition: matrix.h:328
void load()
Definition: matrix.h:905
cArray const & v() const
Definition: matrix.h:1195
int rows() const
Definition: matrix.h:69
ColMatrix(int rows, int cols)
Definition: matrix.h:101
CsrMatrix(CsrMatrix const &A)
Definition: matrix.h:646
void populate(Function f)
Populator.
Definition: matrix.h:209
RowMatrix(DenseMatrix< Type > const &M)
Definition: matrix.h:197
CsrMatrix & operator*=(Complex r)
Definition: matrix.cpp:362
void write(const char *filename) const
Write the matrix data to a file.
Definition: matrix.cpp:1100
Complex operator()(unsigned i, unsigned j) const
Definition: matrix.cpp:848
size_t size() const
Matrix dimension.
Definition: matrix.h:1693
CooMatrix()
Definition: matrix.h:1126
void sort()
Sort indices (by i_, then by j_)
void append(InputIterator first, InputIterator last)
Append a range of values at end.
Definition: arrays.h:877
cArray upperSolve(cArrayView const &b) const
Definition: matrix.cpp:648
auto operator*(std::complex< C1 > a, std::complex< C2 > b) -> std::complex< decltype(C1(0.)*C2(0.))>
Definition: complex.h:24
iArray & diag()
Definition: matrix.h:1643
SymDiaMatrix & populate(unsigned d, Functor f)
Plain symmetrical populator.
Definition: matrix.h:1589
size_t rows() const
Definition: matrix.h:675
void save(std::string name) const
Save Numeric object to a disk file.
Definition: matrix.h:874
size_t size() const
Definition: matrix.h:67
CsrMatrix & operator^=(CsrMatrix const &B)
Definition: matrix.cpp:387
virtual T * data()
Pointer to the data.
Definition: arrays.h:280
ArrayView< Type > col(int i)
Matrix column.
Definition: matrix.h:148
bool hdfsave() const
Save data to file.
Definition: matrix.h:1800
double norm() const
Definition: matrix.cpp:629
std::string linkedto() const
Return the name of the linked disk file.
Definition: matrix.h:1774
cArray dot(const cArrayView B, MatrixTriangle triangle=both, bool parallelize=false) const
Dot product.
Definition: matrix.cpp:1722
Complex const * dptr(int i) const
Pointer to diagonal data.
Definition: matrix.h:1683
lArray const & p() const
Definition: matrix.h:573
ColMatrix(int rows, int cols, const ArrayView< Type > data)
Definition: matrix.h:103
CooMatrix(size_t m, size_t n, NumberArray< long > const &i, NumberArray< long > const &j, NumberArray< Complex > const &x)
Definition: matrix.h:1132
CsrMatrix operator&(const CsrMatrix &A, const CsrMatrix &B)
Definition: matrix.h:1927
CsrMatrix(size_t m, size_t n)
Definition: matrix.h:644
cArray const & data() const
Data pointer.
Definition: matrix.h:1671
~CscMatrix()
Definition: matrix.h:553
SymDiaMatrix const & operator-=(SymDiaMatrix const &B)
Definition: matrix.cpp:1405
Complex COO matrix.
Definition: matrix.h:1120
CscMatrix(size_t m, size_t n, const lArrayView p, const lArrayView i, const cArrayView x)
Definition: matrix.h:548
CooMatrix & populate(Functor f)
Full populator.
Definition: matrix.h:1258
void load(std::string name)
Load Numeric object from a disk file.
Definition: matrix.h:895
cArrayView main_diagonal() const
Main diagonal.
Definition: matrix.h:1661
void drop()
Clear data.
Definition: matrix.h:658
virtual void push_back(T const &a)
Add element to end.
Definition: arrays.h:833
rArray abs(const cArrayView u)
Definition: arrays.cpp:19
bool is_compatible(SymDiaMatrix const &B) const
Check compatibility of matrices.
Definition: matrix.cpp:1566
std::complex< double > Complex
Definition: complex.h:20
ColMatrix(DenseMatrix< Type > const &M)
Definition: matrix.h:106
bool hdfload()
Definition: matrix.h:991
Symmetric diagonal matrix.
Definition: matrix.h:1547
void write(const char *filename) const
Definition: matrix.cpp:533
ColMatrix()
Definition: matrix.h:97
T max(const ArrayView< T > a)
Maximal element of array.
Definition: arrays.h:1673
Complex operator()(size_t ix, size_t iy) const
Index operator. Returns the existing value or zero.
Definition: matrix.h:1198
cArray toPaddedCols() const
Zero-pad columns.
Definition: matrix.cpp:1970
CscMatrix tocsc() const
Convert to CSC matrix.
Definition: matrix.cpp:949
CooMatrix & operator*=(Complex c)
Element-wise multiplication by complex number.
Definition: matrix.h:1364
size_t size() const
Definition: matrix.h:674
DenseMatrix(int rows, int cols)
Definition: matrix.h:57
void drop()
Reset array: deallocate everything, resize to zero.
Definition: arrays.h:918
bool hdfload(const char *name)
Load matrix from HDF file.
Definition: matrix.cpp:1286
SymDiaMatrix todia(MatrixTriangle triangle=lower) const
Convert to symmetric DIA format.
Definition: matrix.cpp:1044
size_t cols() const
Definition: matrix.h:676
CooMatrix(CooMatrix const &A)
Definition: matrix.h:1130
int diag(int i) const
Diagonal index.
Definition: matrix.h:1653
size_t size() const
Item count.
Definition: arrays.h:673
CsrMatrix & operator&=(CsrMatrix const &B)
Definition: matrix.cpp:372
void populate(Function f)
Populator.
Definition: matrix.h:115
CscMatrix & operator&=(const CscMatrix &B)
Definition: matrix.cpp:171
CsrMatrix nzTransform(Functor f) const
Definition: matrix.h:1066
RowMatrix< Type > T() const
Matrix transpose.
Definition: matrix.h:132