12 inline void Ainv_B(nda::matrix<dcomplex, nda::F_layout> A, nda::matrix_view<dcomplex, nda::F_layout> B) {
13 nda::vector<int> ipiv(A.extent(0));
14 lapack::getrf(A, ipiv);
15 lapack::getrs(A, B, ipiv);
20 int N = int(p.size());
21 auto res = nda::matrix<T>::zeros(N, N);
22 for (
int j = 0; j < N; ++j) res(p[j], j) = 1;
26 template <
typename T> std::vector<T>
flatten(
const std::vector<std::vector<T>> &nested) {
28 for (
const auto &sub : nested) { flat.insert(flat.end(), sub.begin(), sub.end()); }
32 template <
typename T>
bool is_diagonal(nda::matrix<T>
const &M) {
33 auto dim = M.shape()[0];
34 for (
size_t i = 0; i < dim; i++)
35 for (
size_t j = i + 1; j < dim; j++)
36 if (abs(M(i, j)) > 1.e-14)
return false;
nda::matrix< T > make_matrix_from_permutation(std::vector< int > const &p)
std::vector< T > flatten(const std::vector< std::vector< T > > &nested)
bool is_diagonal(nda::matrix< T > const &M)
void Ainv_B(nda::matrix< dcomplex, nda::F_layout > A, nda::matrix_view< dcomplex, nda::F_layout > B)
std::complex< double > dcomplex