fml
0.1-0
Fused Matrix Library
linalg_solve.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_SOLVE_H
6
#define FML_MPI_LINALG_LINALG_SOLVE_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 "linalg_lu.hh"
23
#include "scalapack.hh"
24
25
26
namespace
fml
27
{
28
namespace
linalg
29
{
51
template
<
typename
REAL>
52
void
solve
(
mpimat<REAL>
&x,
mpimat<REAL>
&y)
53
{
54
err::check_grid(x, y);
55
56
const
len_t n = x.
nrows
();
57
if
(!x.
is_square
())
58
throw
std::runtime_error(
"'x' must be a square matrix"
);
59
if
(n != y.
nrows
())
60
throw
std::runtime_error(
"rhs 'y' must be compatible with data matrix 'x'"
);
61
62
int
info;
63
cpuvec<int>
p(n);
64
fml::scalapack::gesv(n, y.
ncols
(), x.
data_ptr
(), x.desc_ptr(), p.
data_ptr
(), y.
data_ptr
(), y.desc_ptr(), &info);
65
fml::linalgutils::check_info(info,
"gesv"
);
66
}
67
}
68
}
69
70
71
#endif
fml::linalg::solve
void solve(cpumat< REAL > &x, cpuvec< REAL > &y)
Solve a system of equations.
Definition:
linalg_solve.hh:63
fml::mpimat
Matrix class for data distributed over MPI in the 2-d block cyclic format.
Definition:
mpimat.hh:40
fml::unimat::is_square
bool is_square() const
Is the matrix square?
Definition:
unimat.hh:34
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
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
fml
src
fml
mpi
linalg
linalg_solve.hh
Generated by
1.8.17