fml  0.1-0
Fused Matrix Library
linalg_lu.hh
1 // This file is part of fml which is released under the Boost Software
2 // License, Version 1.0. See accompanying file LICENSE or copy at
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef FML_MPI_LINALG_LINALG_LU_H
6 #define FML_MPI_LINALG_LINALG_LU_H
7 #pragma once
8 
9 
10 #include <stdexcept>
11 
12 #include "../../_internals/linalgutils.hh"
13 #include "../../cpu/cpuvec.hh"
14 
15 #include "../internals/bcutils.hh"
16 #include "../internals/mpi_utils.hh"
17 
18 #include "../copy.hh"
19 #include "../mpimat.hh"
20 
21 #include "linalg_err.hh"
22 #include "scalapack.hh"
23 
24 
25 namespace fml
26 {
27 namespace linalg
28 {
52  template <typename REAL>
53  void lu(mpimat<REAL> &x, cpuvec<int> &p, int &info)
54  {
55  info = 0;
56  const len_t m = x.nrows();
57  const len_t lipiv = std::min(m, x.ncols());
58 
59  p.resize(lipiv);
60 
61  fml::scalapack::getrf(m, x.ncols(), x.data_ptr(), x.desc_ptr(), p.data_ptr(), &info);
62  }
63 
65  template <typename REAL>
66  void lu(mpimat<REAL> &x)
67  {
68  cpuvec<int> p;
69  int info;
70 
71  lu(x, p, info);
72 
73  fml::linalgutils::check_info(info, "getrf");
74  }
75 }
76 }
77 
78 
79 #endif
fml::mpimat
Matrix class for data distributed over MPI in the 2-d block cyclic format.
Definition: mpimat.hh:40
fml::univec::data_ptr
T * data_ptr()
Pointer to the internal array.
Definition: univec.hh:28
fml::unimat::nrows
len_t nrows() const
Number of rows.
Definition: unimat.hh:36
fml::cpuvec::resize
void resize(len_t size)
Resize the internal object storage.
Definition: cpuvec.hh:209
fml::linalg::lu
void lu(cpumat< REAL > &x, cpuvec< int > &p, int &info)
Computes the PLU factorization with partial pivoting.
Definition: linalg_lu.hh:48
fml::cpuvec
Vector class for data held on a single CPU.
Definition: cpuvec.hh:31
fml::unimat::ncols
len_t ncols() const
Number of columns.
Definition: unimat.hh:38
fml::unimat::data_ptr
REAL * data_ptr()
Pointer to the internal array.
Definition: unimat.hh:40
fml
Core namespace.
Definition: dimops.hh:10