 |
fml
0.1-0
Fused Matrix Library
|
5 #ifndef FML_MPI_LINALG_DET_H
6 #define FML_MPI_LINALG_DET_H
12 #include "../../cpu/cpuvec.hh"
14 #include "../mpimat.hh"
41 template <
typename REAL>
45 throw std::runtime_error(
"'x' must be a square matrix");
68 const len_t m_local = x.nrows_local();
69 const len_t n_local = x.ncols_local();
73 const grid g = x.get_grid();
75 for (len_t i=0; i<m_local; i++)
77 len_t gi = fml::bcutils::l2g(i, x.bf_rows(), g.
nprow(), g.
myrow());
79 if (ipiv[i] != (gi + 1))
83 for (len_t j=0; j<n_local; j++)
85 for (len_t i=0; i<m_local; i++)
87 len_t gi = fml::bcutils::l2g(i, x.bf_rows(), g.
nprow(), g.
myrow());
88 len_t gj = fml::bcutils::l2g(j, x.bf_cols(), g.
npcol(), g.
mycol());
92 const REAL d = a[i + m_local*j];
106 sgn = (sgn<0 ? 1 : 0);
108 sgn = (sgn%2==0 ? 1 : -1);
void allreduce(const int m, const int n, int *x, const char scope='A', const blacsops op=BLACS_SUM) const
Sum reduce operation across all processes in the grid.
Definition: grid.hh:420
2-dimensional MPI process grid.
Definition: grid.hh:70
Matrix class for data distributed over MPI in the 2-d block cyclic format.
Definition: mpimat.hh:40
int mycol() const
The process column (0-based index) of the calling process.
Definition: grid.hh:129
bool is_square() const
Is the matrix square?
Definition: unimat.hh:34
T * data_ptr()
Pointer to the internal array.
Definition: univec.hh:28
void lu(cpumat< REAL > &x, cpuvec< int > &p, int &info)
Computes the PLU factorization with partial pivoting.
Definition: lu.hh:48
Vector class for data held on a single CPU.
Definition: cpuvec.hh:31
void det(cpumat< REAL > &x, int &sign, REAL &modulus)
Computes the determinant in logarithmic form.
Definition: det.hh:41
REAL * data_ptr()
Pointer to the internal array.
Definition: unimat.hh:40
Core namespace.
Definition: dimops.hh:10
int npcol() const
The number of processes columns in the BLACS context.
Definition: grid.hh:125
int myrow() const
The process row (0-based index) of the calling process.
Definition: grid.hh:127
int nprow() const
The number of processes rows in the BLACS context.
Definition: grid.hh:123