16#include <deal.II/base/mpi.templates.h>
19#include <deal.II/lac/scalapack.templates.h>
21#ifdef DEAL_II_WITH_HDF5
30#ifdef DEAL_II_WITH_HDF5
34 template <
typename number>
36 hdf5_type_id(
const number *)
44 hdf5_type_id(
const double *)
46 return H5T_NATIVE_DOUBLE;
50 hdf5_type_id(
const float *)
52 return H5T_NATIVE_FLOAT;
59template <
typename NumberType>
63 const std::shared_ptr<const Utilities::MPI::ProcessGrid> &process_grid,
70 , first_process_column(0)
84template <
typename NumberType>
87 const std::shared_ptr<const Utilities::MPI::ProcessGrid> &process_grid,
100template <
typename NumberType>
102 const std::string &filename,
103 const std::shared_ptr<const Utilities::MPI::ProcessGrid> &process_grid,
109 , first_process_column(0)
111 , submatrix_column(1)
113#ifndef DEAL_II_WITH_HDF5
121 "This function is only available when deal.II is configured with HDF5"));
124 const unsigned int this_mpi_process(
130 if (this_mpi_process == 0)
135 hid_t file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
139 hid_t dataset = H5Dopen2(file,
"/matrix", H5P_DEFAULT);
143 hid_t filespace = H5Dget_space(dataset);
146 int rank = H5Sget_simple_extent_ndims(filespace);
149 status = H5Sget_simple_extent_dims(filespace, dims,
nullptr);
158 status = H5Sclose(filespace);
160 status = H5Dclose(dataset);
162 status = H5Fclose(file);
180 load(filename.c_str());
187template <
typename NumberType>
192 const std::shared_ptr<const Utilities::MPI::ProcessGrid> &process_grid,
197 Assert(row_block_size_ > 0,
ExcMessage(
"Row block size has to be positive."));
198 Assert(column_block_size_ > 0,
199 ExcMessage(
"Column block size has to be positive."));
201 row_block_size_ <= n_rows_,
203 "Row block size can not be greater than the number of rows of the matrix"));
205 column_block_size_ <= n_columns_,
207 "Column block size can not be greater than the number of columns of the matrix"));
210 property = property_;
213 n_columns = n_columns_;
214 row_block_size = row_block_size_;
215 column_block_size = column_block_size_;
217 if (grid->mpi_process_is_active)
220 n_local_rows = numroc_(&n_rows,
222 &(grid->this_process_row),
224 &(grid->n_process_rows));
225 n_local_columns = numroc_(&n_columns,
227 &(grid->this_process_column),
228 &first_process_column,
229 &(grid->n_process_columns));
233 int lda =
std::max(1, n_local_rows);
236 descinit_(descriptor,
242 &first_process_column,
243 &(grid->blacs_context),
254 n_local_columns = -1;
255 std::fill(std::begin(descriptor), std::end(descriptor), -1);
261template <
typename NumberType>
265 const std::shared_ptr<const Utilities::MPI::ProcessGrid> &process_grid,
269 reinit(
size,
size, process_grid, block_size, block_size, property);
274template <
typename NumberType>
279 property = property_;
284template <
typename NumberType>
293template <
typename NumberType>
302template <
typename NumberType>
312 Assert(n_columns ==
int(matrix.n()),
315 if (grid->mpi_process_is_active)
317 for (
int i = 0; i < n_local_rows; ++i)
319 const int glob_i = global_row(i);
320 for (
int j = 0; j < n_local_columns; ++j)
322 const int glob_j = global_column(j);
323 local_el(i, j) = matrix(glob_i, glob_j);
333template <
typename NumberType>
336 const unsigned int rank)
338 if (n_rows * n_columns == 0)
341 const unsigned int this_mpi_process(
348 "All processes have to call routine with identical rank"));
351 "All processes have to call routine with identical rank"));
355 if (this_mpi_process == rank)
366 MPI_Comm_group(this->grid->mpi_communicator, &group_A);
368 const std::vector<int> ranks(n, rank);
370 MPI_Group_incl(group_A, n, ranks.data(), &group_B);
374 const int ierr = MPI_Comm_create_group(this->grid->mpi_communicator,
379 int n_proc_rows_B = 1, n_proc_cols_B = 1;
380 int this_process_row_B = -1, this_process_column_B = -1;
381 int blacs_context_B = -1;
382 if (MPI_COMM_NULL != communicator_B)
385 blacs_context_B = Csys2blacs_handle(communicator_B);
386 const char *order =
"Col";
387 Cblacs_gridinit(&blacs_context_B, order, n_proc_rows_B, n_proc_cols_B);
388 Cblacs_gridinfo(blacs_context_B,
392 &this_process_column_B);
398 const bool mpi_process_is_active_B =
399 (this_process_row_B >= 0 && this_process_column_B >= 0);
402 std::vector<int> descriptor_B(9, -1);
403 const int first_process_row_B = 0, first_process_col_B = 0;
405 if (mpi_process_is_active_B)
408 int n_local_rows_B = numroc_(&n_rows,
411 &first_process_row_B,
413 int n_local_cols_B = numroc_(&n_columns,
415 &this_process_column_B,
416 &first_process_col_B,
421 int lda =
std::max(1, n_local_rows_B);
423 descinit_(descriptor_B.data(),
428 &first_process_row_B,
429 &first_process_col_B,
435 if (this->grid->mpi_process_is_active)
438 NumberType *loc_vals_A =
439 this->values.size() > 0 ? this->values.data() :
nullptr;
440 const NumberType *loc_vals_B =
441 mpi_process_is_active_B ? &(B(0, 0)) :
nullptr;
455 &(this->grid->blacs_context));
457 if (mpi_process_is_active_B)
458 Cblacs_gridexit(blacs_context_B);
460 MPI_Group_free(&group_A);
461 MPI_Group_free(&group_B);
462 if (MPI_COMM_NULL != communicator_B)
470template <
typename NumberType>
474 Assert(n_local_rows >= 0 && loc_row <
static_cast<unsigned int>(n_local_rows),
476 const int i = loc_row + 1;
479 &(grid->this_process_row),
481 &(grid->n_process_rows)) -
487template <
typename NumberType>
491 Assert(n_local_columns >= 0 &&
492 loc_column <
static_cast<unsigned int>(n_local_columns),
494 const int j = loc_column + 1;
497 &(grid->this_process_column),
498 &first_process_column,
499 &(grid->n_process_columns)) -
505template <
typename NumberType>
508 const unsigned int rank)
const
510 if (n_rows * n_columns == 0)
513 const unsigned int this_mpi_process(
520 "All processes have to call routine with identical rank"));
523 "All processes have to call routine with identical rank"));
526 if (this_mpi_process == rank)
539 MPI_Comm_group(this->grid->mpi_communicator, &group_A);
541 const std::vector<int> ranks(n, rank);
543 MPI_Group_incl(group_A, n, ranks.data(), &group_B);
547 const int ierr = MPI_Comm_create_group(this->grid->mpi_communicator,
552 int n_proc_rows_B = 1, n_proc_cols_B = 1;
553 int this_process_row_B = -1, this_process_column_B = -1;
554 int blacs_context_B = -1;
555 if (MPI_COMM_NULL != communicator_B)
558 blacs_context_B = Csys2blacs_handle(communicator_B);
559 const char *order =
"Col";
560 Cblacs_gridinit(&blacs_context_B, order, n_proc_rows_B, n_proc_cols_B);
561 Cblacs_gridinfo(blacs_context_B,
565 &this_process_column_B);
571 const bool mpi_process_is_active_B =
572 (this_process_row_B >= 0 && this_process_column_B >= 0);
575 std::vector<int> descriptor_B(9, -1);
576 const int first_process_row_B = 0, first_process_col_B = 0;
578 if (mpi_process_is_active_B)
581 int n_local_rows_B = numroc_(&n_rows,
584 &first_process_row_B,
586 int n_local_cols_B = numroc_(&n_columns,
588 &this_process_column_B,
589 &first_process_col_B,
594 int lda =
std::max(1, n_local_rows_B);
597 descinit_(descriptor_B.data(),
602 &first_process_row_B,
603 &first_process_col_B,
611 if (this->grid->mpi_process_is_active)
614 const NumberType *loc_vals_A =
615 this->values.size() > 0 ? this->values.data() :
nullptr;
616 NumberType *loc_vals_B = mpi_process_is_active_B ? &(B(0, 0)) :
nullptr;
628 &(this->grid->blacs_context));
630 if (mpi_process_is_active_B)
631 Cblacs_gridexit(blacs_context_B);
633 MPI_Group_free(&group_A);
634 MPI_Group_free(&group_B);
635 if (MPI_COMM_NULL != communicator_B)
641template <
typename NumberType>
650 Assert(n_columns ==
int(matrix.n()),
654 if (grid->mpi_process_is_active)
656 for (
int i = 0; i < n_local_rows; ++i)
658 const int glob_i = global_row(i);
659 for (
int j = 0; j < n_local_columns; ++j)
661 const int glob_j = global_column(j);
662 matrix(glob_i, glob_j) = local_el(i, j);
674 for (
unsigned int i = 0; i < matrix.n(); ++i)
675 for (
unsigned int j = i + 1; j < matrix.m(); ++j)
678 for (
unsigned int i = 0; i < matrix.n(); ++i)
679 for (
unsigned int j = 0; j < i; ++j)
686 for (
unsigned int i = 0; i < matrix.n(); ++i)
687 for (
unsigned int j = i + 1; j < matrix.m(); ++j)
688 matrix(i, j) = matrix(j, i);
689 else if (uplo ==
'U')
690 for (
unsigned int i = 0; i < matrix.n(); ++i)
691 for (
unsigned int j = 0; j < i; ++j)
692 matrix(i, j) = matrix(j, i);
698template <
typename NumberType>
702 const std::pair<unsigned int, unsigned int> &offset_A,
703 const std::pair<unsigned int, unsigned int> &offset_B,
704 const std::pair<unsigned int, unsigned int> &submatrix_size)
const
707 if (submatrix_size.first == 0 || submatrix_size.second == 0)
720 int ierr, comparison;
721 ierr = MPI_Comm_compare(grid->mpi_communicator,
722 B.
grid->mpi_communicator,
725 Assert(comparison == MPI_IDENT,
726 ExcMessage(
"Matrix A and B must have a common MPI Communicator"));
734 int union_blacs_context = Csys2blacs_handle(this->grid->mpi_communicator);
735 const char *order =
"Col";
736 int union_n_process_rows =
738 int union_n_process_columns = 1;
739 Cblacs_gridinit(&union_blacs_context,
741 union_n_process_rows,
742 union_n_process_columns);
744 int n_grid_rows_A, n_grid_columns_A, my_row_A, my_column_A;
745 Cblacs_gridinfo(this->grid->blacs_context,
752 const bool in_context_A =
753 (my_row_A >= 0 && my_row_A < n_grid_rows_A) &&
754 (my_column_A >= 0 && my_column_A < n_grid_columns_A);
756 int n_grid_rows_B, n_grid_columns_B, my_row_B, my_column_B;
757 Cblacs_gridinfo(B.
grid->blacs_context,
764 const bool in_context_B =
765 (my_row_B >= 0 && my_row_B < n_grid_rows_B) &&
766 (my_column_B >= 0 && my_column_B < n_grid_columns_B);
768 const int n_rows_submatrix = submatrix_size.first;
769 const int n_columns_submatrix = submatrix_size.second;
772 int ia = offset_A.first + 1, ja = offset_A.second + 1;
773 int ib = offset_B.first + 1, jb = offset_B.second + 1;
775 std::array<int, 9> desc_A, desc_B;
777 const NumberType *loc_vals_A =
nullptr;
778 NumberType *loc_vals_B =
nullptr;
787 if (this->values.size() != 0)
788 loc_vals_A = this->values.data();
790 for (
unsigned int i = 0; i < desc_A.size(); ++i)
791 desc_A[i] = this->descriptor[i];
799 loc_vals_B = B.
values.data();
801 for (
unsigned int i = 0; i < desc_B.size(); ++i)
807 pgemr2d(&n_rows_submatrix,
808 &n_columns_submatrix,
817 &union_blacs_context);
822 Cblacs_gridexit(union_blacs_context);
827template <
typename NumberType>
835 if (this->grid->mpi_process_is_active)
837 this->descriptor[0] == 1,
839 "Copying of ScaLAPACK matrices only implemented for dense matrices"));
840 if (dest.
grid->mpi_process_is_active)
844 "Copying of ScaLAPACK matrices only implemented for dense matrices"));
860 MPI_Group group_source, group_dest, group_union;
861 ierr = MPI_Comm_group(this->grid->mpi_communicator, &group_source);
863 ierr = MPI_Comm_group(dest.
grid->mpi_communicator, &group_dest);
865 ierr = MPI_Group_union(group_source, group_dest, &group_union);
882 ierr = MPI_Comm_create_group(MPI_COMM_WORLD,
885 &mpi_communicator_union);
893 int union_blacs_context = Csys2blacs_handle(mpi_communicator_union);
894 const char *order =
"Col";
895 int union_n_process_rows =
897 int union_n_process_columns = 1;
898 Cblacs_gridinit(&union_blacs_context,
900 union_n_process_rows,
901 union_n_process_columns);
903 const NumberType *loc_vals_source =
nullptr;
904 NumberType *loc_vals_dest =
nullptr;
906 if (this->grid->mpi_process_is_active && (this->values.size() > 0))
910 "source: process is active but local matrix empty"));
911 loc_vals_source = this->values.data();
913 if (dest.
grid->mpi_process_is_active && (dest.
values.size() > 0))
918 "destination: process is active but local matrix empty"));
919 loc_vals_dest = dest.
values.data();
931 &union_blacs_context);
933 Cblacs_gridexit(union_blacs_context);
935 if (mpi_communicator_union != MPI_COMM_NULL)
937 ierr = MPI_Group_free(&group_source);
939 ierr = MPI_Group_free(&group_dest);
941 ierr = MPI_Group_free(&group_union);
946 if (this->grid->mpi_process_is_active)
947 dest.
values = this->values;
955template <
typename NumberType>
965template <
typename NumberType>
968 const NumberType alpha,
969 const NumberType beta,
970 const bool transpose_B)
992 ExcMessage(
"The matrices A and B need to have the same process grid"));
994 if (this->grid->mpi_process_is_active)
996 char trans_b = transpose_B ?
'T' :
'N';
998 (this->values.size() > 0) ? this->values.data() :
nullptr;
999 const NumberType *B_loc =
1021template <
typename NumberType>
1026 add(B, 1, a,
false);
1031template <
typename NumberType>
1041template <
typename NumberType>
1047 const bool transpose_A,
1048 const bool transpose_B)
const
1051 ExcMessage(
"The matrices A and B need to have the same process grid"));
1053 ExcMessage(
"The matrices B and C need to have the same process grid"));
1057 if (!transpose_A && !transpose_B)
1061 Assert(this->n_rows == C.n_rows,
1065 Assert(this->row_block_size == C.row_block_size,
1072 else if (transpose_A && !transpose_B)
1076 Assert(this->n_columns == C.n_rows,
1080 Assert(this->column_block_size == C.row_block_size,
1087 else if (!transpose_A && transpose_B)
1091 Assert(this->n_rows == C.n_rows,
1095 Assert(this->row_block_size == C.row_block_size,
1107 Assert(this->n_columns == C.n_rows,
1111 Assert(this->column_block_size == C.row_block_size,
1119 if (this->grid->mpi_process_is_active)
1121 char trans_a = transpose_A ?
'T' :
'N';
1122 char trans_b = transpose_B ?
'T' :
'N';
1124 const NumberType *A_loc =
1125 (this->values.size() > 0) ? this->values.data() :
nullptr;
1126 const NumberType *B_loc =
1128 NumberType *C_loc = (C.values.size() > 0) ? C.values.data() :
nullptr;
1130 int n = C.n_columns;
1131 int k = transpose_A ? this->n_rows : this->n_columns;
1140 &(this->submatrix_row),
1141 &(this->submatrix_column),
1150 &C.submatrix_column,
1158template <
typename NumberType>
1162 const bool adding)
const
1165 mult(1., B, 1., C,
false,
false);
1167 mult(1., B, 0, C,
false,
false);
1172template <
typename NumberType>
1176 const bool adding)
const
1179 mult(1., B, 1., C,
true,
false);
1181 mult(1., B, 0, C,
true,
false);
1186template <
typename NumberType>
1190 const bool adding)
const
1193 mult(1., B, 1., C,
false,
true);
1195 mult(1., B, 0, C,
false,
true);
1200template <
typename NumberType>
1204 const bool adding)
const
1207 mult(1., B, 1., C,
true,
true);
1209 mult(1., B, 0, C,
true,
true);
1214template <
typename NumberType>
1221 "Cholesky factorization can be applied to symmetric matrices only."));
1224 "Matrix has to be in Matrix state before calling this function."));
1226 if (grid->mpi_process_is_active)
1229 NumberType *A_loc = this->values.data();
1247template <
typename NumberType>
1253 "Matrix has to be in Matrix state before calling this function."));
1255 if (grid->mpi_process_is_active)
1258 NumberType *A_loc = this->values.data();
1260 const int iarow = indxg2p_(&submatrix_row,
1262 &(grid->this_process_row),
1264 &(grid->n_process_rows));
1265 const int mp = numroc_(&n_rows,
1267 &(grid->this_process_row),
1269 &(grid->n_process_rows));
1270 ipiv.resize(mp + row_block_size);
1288template <
typename NumberType>
1306 if (grid->mpi_process_is_active)
1308 const char uploTriangular =
1310 const char diag =
'N';
1312 NumberType *A_loc = this->values.data();
1313 ptrtri(&uploTriangular,
1335 compute_cholesky_factorization();
1337 compute_lu_factorization();
1339 if (grid->mpi_process_is_active)
1342 NumberType *A_loc = this->values.data();
1359 int lwork = -1, liwork = -1;
1377 lwork =
static_cast<int>(work[0]);
1380 iwork.resize(liwork);
1404template <
typename NumberType>
1405std::vector<NumberType>
1407 const std::pair<unsigned int, unsigned int> &index_limits,
1408 const bool compute_eigenvectors)
1414 std::pair<unsigned int, unsigned int> idx =
1415 std::make_pair(
std::min(index_limits.first, index_limits.second),
1416 std::max(index_limits.first, index_limits.second));
1419 if (idx.first == 0 && idx.second ==
static_cast<unsigned int>(n_rows - 1))
1420 return eigenpairs_symmetric(compute_eigenvectors);
1422 return eigenpairs_symmetric(compute_eigenvectors, idx);
1427template <
typename NumberType>
1428std::vector<NumberType>
1430 const std::pair<NumberType, NumberType> &value_limits,
1431 const bool compute_eigenvectors)
1433 Assert(!std::isnan(value_limits.first),
1435 Assert(!std::isnan(value_limits.second),
1438 std::pair<unsigned int, unsigned int> indices =
1442 return eigenpairs_symmetric(compute_eigenvectors, indices, value_limits);
1447template <
typename NumberType>
1448std::vector<NumberType>
1450 const bool compute_eigenvectors,
1451 const std::pair<unsigned int, unsigned int> &eigenvalue_idx,
1452 const std::pair<NumberType, NumberType> &eigenvalue_limits)
1456 "Matrix has to be in Matrix state before calling this function."));
1458 ExcMessage(
"Matrix has to be symmetric for this operation."));
1460 std::scoped_lock lock(mutex);
1462 const bool use_values = (std::isnan(eigenvalue_limits.first) ||
1463 std::isnan(eigenvalue_limits.second)) ?
1466 const bool use_indices =
1473 !(use_values && use_indices),
1475 "Prescribing both the index and value range for the eigenvalues is ambiguous"));
1479 std::unique_ptr<ScaLAPACKMatrix<NumberType>>
eigenvectors =
1480 compute_eigenvectors ?
1481 std::make_unique<ScaLAPACKMatrix<NumberType>>(n_rows,
1484 std::make_unique<ScaLAPACKMatrix<NumberType>>(
1485 grid->n_process_rows, grid->n_process_columns, grid, 1, 1);
1492 std::vector<NumberType> ev(n_rows);
1494 if (grid->mpi_process_is_active)
1501 char jobz = compute_eigenvectors ?
'V' :
'N';
1504 bool all_eigenpairs =
true;
1505 NumberType vl = NumberType(), vu = NumberType();
1511 NumberType abstol = NumberType();
1518 NumberType orfac = 0;
1520 std::vector<int> ifail;
1527 std::vector<int> iclustr;
1533 std::vector<NumberType> gap(n_local_rows * n_local_columns);
1543 all_eigenpairs =
true;
1548 all_eigenpairs =
false;
1549 vl =
std::min(eigenvalue_limits.first, eigenvalue_limits.second);
1550 vu =
std::max(eigenvalue_limits.first, eigenvalue_limits.second);
1556 all_eigenpairs =
false;
1559 il =
std::min(eigenvalue_idx.first, eigenvalue_idx.second) + 1;
1560 iu =
std::max(eigenvalue_idx.first, eigenvalue_idx.second) + 1;
1562 NumberType *A_loc = this->values.data();
1569 NumberType *eigenvectors_loc =
1570 (compute_eigenvectors ?
eigenvectors->values.data() :
nullptr);
1605 char cmach = compute_eigenvectors ?
'U' :
'S';
1606 plamch(&(this->grid->blacs_context), &cmach, abstol);
1608 ifail.resize(n_rows);
1609 iclustr.resize(2 * grid->n_process_rows * grid->n_process_columns);
1610 gap.resize(grid->n_process_rows * grid->n_process_columns);
1643 lwork =
static_cast<int>(work[0]);
1670 iwork.resize(liwork);
1707 if (compute_eigenvectors)
1711 while (ev.size() >
static_cast<size_type>(m))
1717 grid->send_to_inactive(&m, 1);
1722 if (!grid->mpi_process_is_active)
1727 grid->send_to_inactive(ev.data(), ev.size());
1734 if (compute_eigenvectors)
1747template <
typename NumberType>
1748std::vector<NumberType>
1750 const std::pair<unsigned int, unsigned int> &index_limits,
1751 const bool compute_eigenvectors)
1757 const std::pair<unsigned int, unsigned int> idx =
1758 std::make_pair(
std::min(index_limits.first, index_limits.second),
1759 std::max(index_limits.first, index_limits.second));
1762 if (idx.first == 0 && idx.second ==
static_cast<unsigned int>(n_rows - 1))
1763 return eigenpairs_symmetric_MRRR(compute_eigenvectors);
1765 return eigenpairs_symmetric_MRRR(compute_eigenvectors, idx);
1770template <
typename NumberType>
1771std::vector<NumberType>
1773 const std::pair<NumberType, NumberType> &value_limits,
1774 const bool compute_eigenvectors)
1779 const std::pair<unsigned int, unsigned int> indices =
1783 return eigenpairs_symmetric_MRRR(compute_eigenvectors, indices, value_limits);
1788template <
typename NumberType>
1789std::vector<NumberType>
1791 const bool compute_eigenvectors,
1792 const std::pair<unsigned int, unsigned int> &eigenvalue_idx,
1793 const std::pair<NumberType, NumberType> &eigenvalue_limits)
1797 "Matrix has to be in Matrix state before calling this function."));
1799 ExcMessage(
"Matrix has to be symmetric for this operation."));
1801 std::scoped_lock lock(mutex);
1803 const bool use_values = (std::isnan(eigenvalue_limits.first) ||
1804 std::isnan(eigenvalue_limits.second)) ?
1807 const bool use_indices =
1814 !(use_values && use_indices),
1816 "Prescribing both the index and value range for the eigenvalues is ambiguous"));
1820 std::unique_ptr<ScaLAPACKMatrix<NumberType>>
eigenvectors =
1821 compute_eigenvectors ?
1822 std::make_unique<ScaLAPACKMatrix<NumberType>>(n_rows,
1825 std::make_unique<ScaLAPACKMatrix<NumberType>>(
1826 grid->n_process_rows, grid->n_process_columns, grid, 1, 1);
1832 std::vector<NumberType> ev(n_rows);
1839 if (grid->mpi_process_is_active)
1846 char jobz = compute_eigenvectors ?
'V' :
'N';
1850 NumberType vl = NumberType(), vu = NumberType();
1865 vl =
std::min(eigenvalue_limits.first, eigenvalue_limits.second);
1866 vu =
std::max(eigenvalue_limits.first, eigenvalue_limits.second);
1874 il =
std::min(eigenvalue_idx.first, eigenvalue_idx.second) + 1;
1875 iu =
std::max(eigenvalue_idx.first, eigenvalue_idx.second) + 1;
1877 NumberType *A_loc = this->values.data();
1885 NumberType *eigenvectors_loc =
1886 (compute_eigenvectors ?
eigenvectors->values.data() :
nullptr);
1917 lwork =
static_cast<int>(work[0]);
1920 iwork.resize(liwork);
1949 if (compute_eigenvectors)
1953 "psyevr failed to compute all eigenvectors for the selected eigenvalues"));
1958 if (compute_eigenvectors)
1962 while (ev.size() >
static_cast<size_type>(m))
1968 grid->send_to_inactive(&m, 1);
1973 if (!grid->mpi_process_is_active)
1978 grid->send_to_inactive(ev.data(), ev.size());
1985 if (compute_eigenvectors)
1998template <
typename NumberType>
1999std::vector<NumberType>
2005 "Matrix has to be in Matrix state before calling this function."));
2006 Assert(row_block_size == column_block_size,
2009 const bool left_singular_vectors = (U !=
nullptr) ?
true :
false;
2010 const bool right_singular_vectors = (VT !=
nullptr) ?
true :
false;
2012 if (left_singular_vectors)
2015 Assert(U->n_rows == U->n_columns,
2017 Assert(row_block_size == U->row_block_size,
2019 Assert(column_block_size == U->column_block_size,
2021 Assert(grid->blacs_context == U->grid->blacs_context,
2024 if (right_singular_vectors)
2034 Assert(grid->blacs_context == VT->
grid->blacs_context,
2036 VT->
grid->blacs_context));
2038 std::scoped_lock lock(mutex);
2040 std::vector<NumberType> sv(
std::min(n_rows, n_columns));
2042 if (grid->mpi_process_is_active)
2044 char jobu = left_singular_vectors ?
'V' :
'N';
2045 char jobvt = right_singular_vectors ?
'V' :
'N';
2046 NumberType *A_loc = this->values.data();
2047 NumberType *U_loc = left_singular_vectors ? U->values.data() :
nullptr;
2048 NumberType *VT_loc = right_singular_vectors ? VT->
values.data() :
nullptr;
2068 &U->submatrix_column,
2079 lwork =
static_cast<int>(work[0]);
2093 &U->submatrix_column,
2108 grid->send_to_inactive(sv.data(), sv.size());
2118template <
typename NumberType>
2124 ExcMessage(
"The matrices A and B need to have the same process grid"));
2127 "Matrix has to be in Matrix state before calling this function."));
2130 "Matrix B has to be in Matrix state before calling this function."));
2143 Assert(row_block_size == column_block_size,
2145 "Use identical block sizes for rows and columns of matrix A"));
2148 "Use identical block sizes for rows and columns of matrix B"));
2151 "Use identical block-cyclic distribution for matrices A and B"));
2153 std::scoped_lock lock(mutex);
2155 if (grid->mpi_process_is_active)
2158 NumberType *A_loc = this->values.data();
2159 NumberType *B_loc = B.
values.data();
2185 lwork =
static_cast<int>(work[0]);
2210template <
typename NumberType>
2216 "Matrix has to be in Matrix state before calling this function."));
2217 Assert(row_block_size == column_block_size,
2219 "Use identical block sizes for rows and columns of matrix A"));
2221 ratio > 0. && ratio < 1.,
2223 "input parameter ratio has to be larger than zero and smaller than 1"));
2237 std::vector<NumberType> sv = this->compute_SVD(&U, &VT);
2238 AssertThrow(sv[0] > std::numeric_limits<NumberType>::min(),
2245 unsigned int n_sv = 1;
2246 std::vector<NumberType> inv_sigma;
2247 inv_sigma.push_back(1 / sv[0]);
2249 for (
unsigned int i = 1; i < sv.size(); ++i)
2250 if (sv[i] > sv[0] * ratio)
2253 inv_sigma.push_back(1 / sv[i]);
2275 std::make_pair(0, 0),
2276 std::make_pair(0, 0),
2277 std::make_pair(n_rows, n_sv));
2279 std::make_pair(0, 0),
2280 std::make_pair(0, 0),
2281 std::make_pair(n_sv, n_columns));
2284 this->reinit(n_columns,
2290 VT_R.
mult(1, U_R, 0, *
this,
true,
true);
2297template <
typename NumberType>
2300 const NumberType a_norm)
const
2304 "Matrix has to be in Cholesky state before calling this function."));
2305 std::scoped_lock lock(mutex);
2306 NumberType rcond = 0.;
2308 if (grid->mpi_process_is_active)
2310 int liwork = n_local_rows;
2311 iwork.resize(liwork);
2314 const NumberType *A_loc = this->values.data();
2334 lwork =
static_cast<int>(std::ceil(work[0]));
2353 grid->send_to_inactive(&rcond);
2359template <
typename NumberType>
2363 const char type(
'O');
2366 return norm_symmetric(type);
2368 return norm_general(type);
2373template <
typename NumberType>
2377 const char type(
'I');
2380 return norm_symmetric(type);
2382 return norm_general(type);
2387template <
typename NumberType>
2391 const char type(
'F');
2394 return norm_symmetric(type);
2396 return norm_general(type);
2401template <
typename NumberType>
2407 ExcMessage(
"norms can be called in matrix state only."));
2408 std::scoped_lock lock(mutex);
2409 NumberType res = 0.;
2411 if (grid->mpi_process_is_active)
2413 const int iarow = indxg2p_(&submatrix_row,
2415 &(grid->this_process_row),
2417 &(grid->n_process_rows));
2418 const int iacol = indxg2p_(&submatrix_column,
2420 &(grid->this_process_column),
2421 &first_process_column,
2422 &(grid->n_process_columns));
2423 const int mp0 = numroc_(&n_rows,
2425 &(grid->this_process_row),
2427 &(grid->n_process_rows));
2428 const int nq0 = numroc_(&n_columns,
2430 &(grid->this_process_column),
2432 &(grid->n_process_columns));
2438 if (type ==
'O' || type ==
'1')
2440 else if (type ==
'I')
2444 const NumberType *A_loc = this->values.begin();
2454 grid->send_to_inactive(&res);
2460template <
typename NumberType>
2466 ExcMessage(
"norms can be called in matrix state only."));
2468 ExcMessage(
"Matrix has to be symmetric for this operation."));
2469 std::scoped_lock lock(mutex);
2470 NumberType res = 0.;
2472 if (grid->mpi_process_is_active)
2477 ilcm_(&(grid->n_process_rows), &(grid->n_process_columns));
2478 const int v2 = lcm / (grid->n_process_rows);
2480 const int IAROW = indxg2p_(&submatrix_row,
2482 &(grid->this_process_row),
2484 &(grid->n_process_rows));
2485 const int IACOL = indxg2p_(&submatrix_column,
2487 &(grid->this_process_column),
2488 &first_process_column,
2489 &(grid->n_process_columns));
2490 const int Np0 = numroc_(&n_columns ,
2492 &(grid->this_process_row),
2494 &(grid->n_process_rows));
2495 const int Nq0 = numroc_(&n_columns ,
2497 &(grid->this_process_column),
2499 &(grid->n_process_columns));
2501 const int v1 = iceil_(&Np0, &row_block_size);
2502 const int ldw = (n_local_rows == n_local_columns) ?
2504 row_block_size * iceil_(&
v1, &v2);
2507 (type ==
'M' || type ==
'F' || type ==
'E') ? 0 : 2 * Nq0 + Np0 + ldw;
2509 const NumberType *A_loc = this->values.begin();
2519 grid->send_to_inactive(&res);
2525#ifdef DEAL_II_WITH_HDF5
2531 create_HDF5_state_enum_id(hid_t &state_enum_id)
2537 herr_t status = H5Tenum_insert(state_enum_id,
"cholesky", &val);
2540 status = H5Tenum_insert(state_enum_id,
"eigenvalues", &val);
2543 status = H5Tenum_insert(state_enum_id,
"inverse_matrix", &val);
2546 status = H5Tenum_insert(state_enum_id,
"inverse_svd", &val);
2549 status = H5Tenum_insert(state_enum_id,
"lu", &val);
2552 status = H5Tenum_insert(state_enum_id,
"matrix", &val);
2555 status = H5Tenum_insert(state_enum_id,
"svd", &val);
2558 status = H5Tenum_insert(state_enum_id,
"unusable", &val);
2563 create_HDF5_property_enum_id(hid_t &property_enum_id)
2568 herr_t status = H5Tenum_insert(property_enum_id,
"diagonal", &prop);
2571 status = H5Tenum_insert(property_enum_id,
"general", &prop);
2574 status = H5Tenum_insert(property_enum_id,
"hessenberg", &prop);
2577 status = H5Tenum_insert(property_enum_id,
"lower_triangular", &prop);
2580 status = H5Tenum_insert(property_enum_id,
"symmetric", &prop);
2583 status = H5Tenum_insert(property_enum_id,
"upper_triangular", &prop);
2592template <
typename NumberType>
2595 const std::string &filename,
2596 const std::pair<unsigned int, unsigned int> &chunk_size)
const
2598#ifndef DEAL_II_WITH_HDF5
2604 std::pair<unsigned int, unsigned int> chunks_size_ = chunk_size;
2610 chunks_size_.first = n_rows;
2611 chunks_size_.second = 1;
2613 Assert(chunks_size_.first > 0,
2614 ExcMessage(
"The row chunk size must be larger than 0."));
2616 Assert(chunks_size_.second > 0,
2617 ExcMessage(
"The column chunk size must be larger than 0."));
2620# ifdef H5_HAVE_PARALLEL
2622 save_parallel(filename, chunks_size_);
2626 save_serial(filename, chunks_size_);
2634template <
typename NumberType>
2637 const std::string &filename,
2638 const std::pair<unsigned int, unsigned int> &chunk_size)
const
2640#ifndef DEAL_II_WITH_HDF5
2655 const auto column_grid =
2656 std::make_shared<Utilities::MPI::ProcessGrid>(this->grid->mpi_communicator,
2660 const int MB = n_rows, NB = n_columns;
2666 if (tmp.
grid->mpi_process_is_active)
2672 H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
2675 hsize_t chunk_dims[2];
2678 chunk_dims[0] = chunk_size.second;
2679 chunk_dims[1] = chunk_size.first;
2680 hid_t data_property = H5Pcreate(H5P_DATASET_CREATE);
2681 status = H5Pset_chunk(data_property, 2, chunk_dims);
2688 dims[0] = n_columns;
2690 hid_t dataspace_id = H5Screate_simple(2, dims,
nullptr);
2693 hid_t type_id = hdf5_type_id(tmp.
values.data());
2694 hid_t dataset_id = H5Dcreate2(file_id,
2704 dataset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp.
values.data());
2709 hid_t state_enum_id, property_enum_id;
2710 internal::create_HDF5_state_enum_id(state_enum_id);
2711 internal::create_HDF5_property_enum_id(property_enum_id);
2714 hsize_t dims_state[1];
2716 hid_t state_enum_dataspace = H5Screate_simple(1, dims_state,
nullptr);
2718 hid_t state_enum_dataset = H5Dcreate2(file_id,
2721 state_enum_dataspace,
2726 status = H5Dwrite(state_enum_dataset,
2735 hsize_t dims_property[1];
2736 dims_property[0] = 1;
2737 hid_t property_enum_dataspace =
2738 H5Screate_simple(1, dims_property,
nullptr);
2740 hid_t property_enum_dataset = H5Dcreate2(file_id,
2743 property_enum_dataspace,
2748 status = H5Dwrite(property_enum_dataset,
2757 status = H5Dclose(dataset_id);
2759 status = H5Dclose(state_enum_dataset);
2761 status = H5Dclose(property_enum_dataset);
2765 status = H5Sclose(dataspace_id);
2767 status = H5Sclose(state_enum_dataspace);
2769 status = H5Sclose(property_enum_dataspace);
2773 status = H5Tclose(state_enum_id);
2775 status = H5Tclose(property_enum_id);
2779 status = H5Pclose(data_property);
2783 status = H5Fclose(file_id);
2791template <
typename NumberType>
2794 const std::string &filename,
2795 const std::pair<unsigned int, unsigned int> &chunk_size)
const
2797#ifndef DEAL_II_WITH_HDF5
2803 const unsigned int n_mpi_processes(
2805 MPI_Info info = MPI_INFO_NULL;
2813 const auto column_grid =
2814 std::make_shared<Utilities::MPI::ProcessGrid>(this->grid->mpi_communicator,
2818 const int MB = n_rows;
2831 const int NB =
std::max(
static_cast<int>(std::ceil(
2832 static_cast<double>(n_columns) / n_mpi_processes)),
2846 hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
2847 status = H5Pset_fapl_mpio(plist_id, tmp.
grid->mpi_communicator, info);
2852 H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
2853 status = H5Pclose(plist_id);
2862 hid_t filespace = H5Screate_simple(2, dims,
nullptr);
2865 hsize_t chunk_dims[2];
2867 chunk_dims[0] = chunk_size.second;
2868 chunk_dims[1] = chunk_size.first;
2869 plist_id = H5Pcreate(H5P_DATASET_CREATE);
2870 H5Pset_chunk(plist_id, 2, chunk_dims);
2871 hid_t type_id = hdf5_type_id(
data);
2872 hid_t dset_id = H5Dcreate2(
2873 file_id,
"/matrix", type_id, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT);
2875 status = H5Sclose(filespace);
2878 status = H5Pclose(plist_id);
2882 std::vector<int> proc_n_local_rows(n_mpi_processes),
2883 proc_n_local_columns(n_mpi_processes);
2886 proc_n_local_columns =
2898 hid_t memspace = H5Screate_simple(2, count,
nullptr);
2900 hsize_t offset[2] = {0};
2901 for (
unsigned int i = 0; i <
my_rank; ++i)
2902 offset[0] += proc_n_local_columns[i];
2905 filespace = H5Dget_space(dset_id);
2906 status = H5Sselect_hyperslab(
2907 filespace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
2911 plist_id = H5Pcreate(H5P_DATASET_XFER);
2912 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_INDEPENDENT);
2916 if (tmp.
values.size() > 0)
2918 status = H5Dwrite(dset_id, type_id, memspace, filespace, plist_id,
data);
2922 status = H5Dclose(dset_id);
2924 status = H5Sclose(filespace);
2926 status = H5Sclose(memspace);
2928 status = H5Pclose(plist_id);
2930 status = H5Fclose(file_id);
2935 int ierr = MPI_Barrier(tmp.
grid->mpi_communicator);
2939 if (tmp.
grid->this_mpi_process == 0)
2942 hid_t file_id_reopen =
2943 H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
2947 hid_t state_enum_id, property_enum_id;
2948 internal::create_HDF5_state_enum_id(state_enum_id);
2949 internal::create_HDF5_property_enum_id(property_enum_id);
2952 hsize_t dims_state[1];
2954 hid_t state_enum_dataspace = H5Screate_simple(1, dims_state,
nullptr);
2956 hid_t state_enum_dataset = H5Dcreate2(file_id_reopen,
2959 state_enum_dataspace,
2964 status = H5Dwrite(state_enum_dataset,
2973 hsize_t dims_property[1];
2974 dims_property[0] = 1;
2975 hid_t property_enum_dataspace =
2976 H5Screate_simple(1, dims_property,
nullptr);
2978 hid_t property_enum_dataset = H5Dcreate2(file_id_reopen,
2981 property_enum_dataspace,
2986 status = H5Dwrite(property_enum_dataset,
2994 status = H5Dclose(state_enum_dataset);
2996 status = H5Dclose(property_enum_dataset);
2998 status = H5Sclose(state_enum_dataspace);
3000 status = H5Sclose(property_enum_dataspace);
3002 status = H5Tclose(state_enum_id);
3004 status = H5Tclose(property_enum_id);
3006 status = H5Fclose(file_id_reopen);
3015template <
typename NumberType>
3019#ifndef DEAL_II_WITH_HDF5
3023# ifdef H5_HAVE_PARALLEL
3025 load_parallel(filename);
3029 load_serial(filename);
3036template <
typename NumberType>
3040#ifndef DEAL_II_WITH_HDF5
3051 const auto one_grid =
3052 std::make_shared<Utilities::MPI::ProcessGrid>(this->grid->mpi_communicator,
3056 const int MB = n_rows, NB = n_columns;
3060 int property_int = -1;
3064 if (tmp.
grid->mpi_process_is_active)
3069 hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
3072 hid_t dataset_id = H5Dopen2(file_id,
"/matrix", H5P_DEFAULT);
3078 hid_t datatype = H5Dget_type(dataset_id);
3079 H5T_class_t t_class_in = H5Tget_class(datatype);
3080 H5T_class_t t_class = H5Tget_class(hdf5_type_id(tmp.
values.data()));
3082 t_class_in == t_class,
3084 "The data type of the matrix to be read does not match the archive"));
3087 hid_t dataspace_id = H5Dget_space(dataset_id);
3089 const int ndims = H5Sget_simple_extent_ndims(dataspace_id);
3093 H5Sget_simple_extent_dims(dataspace_id, dims,
nullptr);
3095 static_cast<int>(dims[0]) == n_columns,
3097 "The number of columns of the matrix does not match the content of the archive"));
3099 static_cast<int>(dims[1]) == n_rows,
3101 "The number of rows of the matrix does not match the content of the archive"));
3104 status = H5Dread(dataset_id,
3105 hdf5_type_id(tmp.
values.data()),
3114 hid_t state_enum_id, property_enum_id;
3115 internal::create_HDF5_state_enum_id(state_enum_id);
3116 internal::create_HDF5_property_enum_id(property_enum_id);
3119 hid_t dataset_state_id = H5Dopen2(file_id,
"/state", H5P_DEFAULT);
3120 hid_t datatype_state = H5Dget_type(dataset_state_id);
3121 H5T_class_t t_class_state = H5Tget_class(datatype_state);
3124 hid_t dataset_property_id = H5Dopen2(file_id,
"/property", H5P_DEFAULT);
3125 hid_t datatype_property = H5Dget_type(dataset_property_id);
3126 H5T_class_t t_class_property = H5Tget_class(datatype_property);
3130 hid_t dataspace_state = H5Dget_space(dataset_state_id);
3131 hid_t dataspace_property = H5Dget_space(dataset_property_id);
3133 const int ndims_state = H5Sget_simple_extent_ndims(dataspace_state);
3135 const int ndims_property = H5Sget_simple_extent_ndims(dataspace_property);
3138 hsize_t dims_state[1];
3139 H5Sget_simple_extent_dims(dataspace_state, dims_state,
nullptr);
3141 hsize_t dims_property[1];
3142 H5Sget_simple_extent_dims(dataspace_property, dims_property,
nullptr);
3146 status = H5Dread(dataset_state_id,
3156 state_int =
static_cast<int>(tmp.
state);
3158 status = H5Dread(dataset_property_id,
3168 property_int =
static_cast<int>(tmp.
property);
3171 status = H5Sclose(dataspace_id);
3173 status = H5Sclose(dataspace_state);
3175 status = H5Sclose(dataspace_property);
3179 status = H5Tclose(datatype);
3181 status = H5Tclose(state_enum_id);
3183 status = H5Tclose(property_enum_id);
3187 status = H5Dclose(dataset_state_id);
3189 status = H5Dclose(dataset_id);
3191 status = H5Dclose(dataset_property_id);
3195 status = H5Fclose(file_id);
3199 tmp.
grid->send_to_inactive(&state_int, 1);
3202 tmp.
grid->send_to_inactive(&property_int, 1);
3214template <
typename NumberType>
3218#ifndef DEAL_II_WITH_HDF5
3222# ifndef H5_HAVE_PARALLEL
3227 const unsigned int n_mpi_processes(
3229 MPI_Info info = MPI_INFO_NULL;
3236 const auto column_grid =
3237 std::make_shared<Utilities::MPI::ProcessGrid>(this->grid->mpi_communicator,
3241 const int MB = n_rows;
3243 const int NB =
std::max(
static_cast<int>(std::ceil(
3244 static_cast<double>(n_columns) / n_mpi_processes)),
3255 hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
3256 status = H5Pset_fapl_mpio(plist_id, tmp.
grid->mpi_communicator, info);
3261 hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, plist_id);
3262 status = H5Pclose(plist_id);
3266 hid_t dataset_id = H5Dopen2(file_id,
"/matrix", H5P_DEFAULT);
3272 hid_t datatype = hdf5_type_id(
data);
3273 hid_t datatype_inp = H5Dget_type(dataset_id);
3274 H5T_class_t t_class_inp = H5Tget_class(datatype_inp);
3275 H5T_class_t t_class = H5Tget_class(datatype);
3277 t_class_inp == t_class,
3279 "The data type of the matrix to be read does not match the archive"));
3283 hid_t dataspace_id = H5Dget_space(dataset_id);
3285 const int ndims = H5Sget_simple_extent_ndims(dataspace_id);
3289 status = H5Sget_simple_extent_dims(dataspace_id, dims,
nullptr);
3292 static_cast<int>(dims[0]) == n_columns,
3294 "The number of columns of the matrix does not match the content of the archive"));
3296 static_cast<int>(dims[1]) == n_rows,
3298 "The number of rows of the matrix does not match the content of the archive"));
3301 std::vector<int> proc_n_local_rows(n_mpi_processes),
3302 proc_n_local_columns(n_mpi_processes);
3305 proc_n_local_columns =
3318 hsize_t offset[2] = {0};
3319 for (
unsigned int i = 0; i <
my_rank; ++i)
3320 offset[0] += proc_n_local_columns[i];
3323 status = H5Sselect_hyperslab(
3324 dataspace_id, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
3328 hid_t memspace = H5Screate_simple(2, count,
nullptr);
3332 H5Dread(dataset_id, datatype, memspace, dataspace_id, H5P_DEFAULT,
data);
3336 hid_t state_enum_id, property_enum_id;
3337 internal::create_HDF5_state_enum_id(state_enum_id);
3338 internal::create_HDF5_property_enum_id(property_enum_id);
3341 hid_t dataset_state_id = H5Dopen2(file_id,
"/state", H5P_DEFAULT);
3342 hid_t datatype_state = H5Dget_type(dataset_state_id);
3343 H5T_class_t t_class_state = H5Tget_class(datatype_state);
3346 hid_t dataset_property_id = H5Dopen2(file_id,
"/property", H5P_DEFAULT);
3347 hid_t datatype_property = H5Dget_type(dataset_property_id);
3348 H5T_class_t t_class_property = H5Tget_class(datatype_property);
3352 hid_t dataspace_state = H5Dget_space(dataset_state_id);
3353 hid_t dataspace_property = H5Dget_space(dataset_property_id);
3355 const int ndims_state = H5Sget_simple_extent_ndims(dataspace_state);
3357 const int ndims_property = H5Sget_simple_extent_ndims(dataspace_property);
3360 hsize_t dims_state[1];
3361 H5Sget_simple_extent_dims(dataspace_state, dims_state,
nullptr);
3363 hsize_t dims_property[1];
3364 H5Sget_simple_extent_dims(dataspace_property, dims_property,
nullptr);
3369 dataset_state_id, state_enum_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &tmp.
state);
3372 status = H5Dread(dataset_property_id,
3381 status = H5Sclose(memspace);
3383 status = H5Dclose(dataset_id);
3385 status = H5Dclose(dataset_state_id);
3387 status = H5Dclose(dataset_property_id);
3389 status = H5Sclose(dataspace_id);
3391 status = H5Sclose(dataspace_state);
3393 status = H5Sclose(dataspace_property);
3397 status = H5Tclose(state_enum_id);
3399 status = H5Tclose(property_enum_id);
3401 status = H5Fclose(file_id);
3417 template <
typename NumberType>
3425 for (
unsigned int i = 0; i < matrix.local_n(); ++i)
3427 const NumberType s = factors[matrix.global_column(i)];
3429 for (
unsigned int j = 0; j < matrix.local_m(); ++j)
3430 matrix.local_el(j, i) *= s;
3434 template <
typename NumberType>
3442 for (
unsigned int i = 0; i <
matrix.local_m(); ++i)
3444 const NumberType s = factors[
matrix.global_row(i)];
3446 for (
unsigned int j = 0; j <
matrix.local_n(); ++j)
3447 matrix.local_el(i, j) *= s;
3456template <
typename NumberType>
3457template <
class InputVector>
3461 if (this->grid->mpi_process_is_active)
3467template <
typename NumberType>
3468template <
class InputVector>
3472 if (this->grid->mpi_process_is_active)
3479#include "lac/scalapack.inst"
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
std::vector< NumberType > compute_SVD(ScaLAPACKMatrix< NumberType > *U=nullptr, ScaLAPACKMatrix< NumberType > *VT=nullptr)
std::vector< NumberType > eigenpairs_symmetric_by_value(const std::pair< NumberType, NumberType > &value_limits, const bool compute_eigenvectors)
NumberType frobenius_norm() const
unsigned int pseudoinverse(const NumberType ratio)
std::vector< NumberType > eigenpairs_symmetric_by_value_MRRR(const std::pair< NumberType, NumberType > &value_limits, const bool compute_eigenvectors)
void copy_from(const LAPACKFullMatrix< NumberType > &matrix, const unsigned int rank)
void save_parallel(const std::string &filename, const std::pair< unsigned int, unsigned int > &chunk_size) const
void least_squares(ScaLAPACKMatrix< NumberType > &B, const bool transpose=false)
ScaLAPACKMatrix< NumberType > & operator=(const FullMatrix< NumberType > &)
void Tadd(const NumberType b, const ScaLAPACKMatrix< NumberType > &B)
void mTmult(ScaLAPACKMatrix< NumberType > &C, const ScaLAPACKMatrix< NumberType > &B, const bool adding=false) const
void add(const ScaLAPACKMatrix< NumberType > &B, const NumberType a=0., const NumberType b=1., const bool transpose_B=false)
LAPACKSupport::State get_state() const
LAPACKSupport::Property get_property() const
void Tmmult(ScaLAPACKMatrix< NumberType > &C, const ScaLAPACKMatrix< NumberType > &B, const bool adding=false) const
std::vector< NumberType > eigenpairs_symmetric_MRRR(const bool compute_eigenvectors, const std::pair< unsigned int, unsigned int > &index_limits=std::make_pair(numbers::invalid_unsigned_int, numbers::invalid_unsigned_int), const std::pair< NumberType, NumberType > &value_limits=std::make_pair(std::numeric_limits< NumberType >::quiet_NaN(), std::numeric_limits< NumberType >::quiet_NaN()))
void scale_rows(const InputVector &factors)
std::shared_ptr< const Utilities::MPI::ProcessGrid > grid
ScaLAPACKMatrix(const size_type n_rows, const size_type n_columns, const std::shared_ptr< const Utilities::MPI::ProcessGrid > &process_grid, const size_type row_block_size=32, const size_type column_block_size=32, const LAPACKSupport::Property property=LAPACKSupport::Property::general)
void load(const std::string &filename)
const int submatrix_column
void mmult(ScaLAPACKMatrix< NumberType > &C, const ScaLAPACKMatrix< NumberType > &B, const bool adding=false) const
std::vector< NumberType > eigenpairs_symmetric(const bool compute_eigenvectors, const std::pair< unsigned int, unsigned int > &index_limits=std::make_pair(numbers::invalid_unsigned_int, numbers::invalid_unsigned_int), const std::pair< NumberType, NumberType > &value_limits=std::make_pair(std::numeric_limits< NumberType >::quiet_NaN(), std::numeric_limits< NumberType >::quiet_NaN()))
void save_serial(const std::string &filename, const std::pair< unsigned int, unsigned int > &chunk_size) const
NumberType norm_general(const char type) const
void save(const std::string &filename, const std::pair< unsigned int, unsigned int > &chunk_size=std::make_pair(numbers::invalid_unsigned_int, numbers::invalid_unsigned_int)) const
void load_parallel(const std::string &filename)
NumberType l1_norm() const
void compute_lu_factorization()
NumberType norm_symmetric(const char type) const
void mult(const NumberType b, const ScaLAPACKMatrix< NumberType > &B, const NumberType c, ScaLAPACKMatrix< NumberType > &C, const bool transpose_A=false, const bool transpose_B=false) const
LAPACKSupport::Property property
void set_property(const LAPACKSupport::Property property)
void reinit(const size_type n_rows, const size_type n_columns, const std::shared_ptr< const Utilities::MPI::ProcessGrid > &process_grid, const size_type row_block_size=32, const size_type column_block_size=32, const LAPACKSupport::Property property=LAPACKSupport::Property::general)
void load_serial(const std::string &filename)
std::vector< NumberType > eigenpairs_symmetric_by_index_MRRR(const std::pair< unsigned int, unsigned int > &index_limits, const bool compute_eigenvectors)
NumberType reciprocal_condition_number(const NumberType a_norm) const
LAPACKSupport::State state
void TmTmult(ScaLAPACKMatrix< NumberType > &C, const ScaLAPACKMatrix< NumberType > &B, const bool adding=false) const
std::vector< NumberType > eigenpairs_symmetric_by_index(const std::pair< unsigned int, unsigned int > &index_limits, const bool compute_eigenvectors)
unsigned int global_column(const unsigned int loc_column) const
void copy_to(FullMatrix< NumberType > &matrix) const
unsigned int global_row(const unsigned int loc_row) const
void compute_cholesky_factorization()
void copy_transposed(const ScaLAPACKMatrix< NumberType > &B)
NumberType linfty_norm() const
void scale_columns(const InputVector &factors)
AlignedVector< T > values
void reinit(const size_type size1, const size_type size2, const bool omit_default_initialization=false)
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcErrorCode(std::string arg1, types::blas_int arg2)
#define Assert(cond, exc)
#define AssertIsFinite(number)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNeedsHDF5()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
const unsigned int my_rank
std::vector< index_type > data
@ cholesky
Contents is a Cholesky decomposition.
@ lu
Contents is an LU decomposition.
@ matrix
Contents is actually a matrix.
@ unusable
Contents is something useless.
@ inverse_matrix
Contents is the inverse of a matrix.
@ svd
Matrix contains singular value decomposition,.
@ inverse_svd
Matrix is the inverse of a singular value decomposition.
@ eigenvalues
Eigenvalue vector is filled.
@ symmetric
Matrix is symmetric.
@ hessenberg
Matrix is in upper Hessenberg form.
@ diagonal
Matrix is diagonal.
@ upper_triangular
Matrix is upper triangular.
@ lower_triangular
Matrix is lower triangular.
@ general
No special properties.
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
T max(const T &t, const MPI_Comm mpi_communicator)
T min(const T &t, const MPI_Comm mpi_communicator)
std::vector< T > all_gather(const MPI_Comm comm, const T &object_to_send)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
void free_communicator(MPI_Comm mpi_communicator)
T broadcast(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process=0)
constexpr unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
std::array< std::pair< Number, Tensor< 1, dim, Number > >, dim > eigenvectors(const SymmetricTensor< 2, dim, Number > &T, const SymmetricTensorEigenvectorMethod method=SymmetricTensorEigenvectorMethod::ql_implicit_shifts)