fml
0.1-0
Fused Matrix Library
linalg_chol.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_CHOL_H
6
#define FML_MPI_LINALG_LINALG_CHOL_H
7
#pragma once
8
9
10
#include <stdexcept>
11
12
#include "../../_internals/linalgutils.hh"
13
14
#include "../internals/bcutils.hh"
15
#include "../internals/mpi_utils.hh"
16
17
#include "../mpimat.hh"
18
19
#include "linalg_blas.hh"
20
#include "linalg_err.hh"
21
#include "scalapack.hh"
22
23
24
namespace
fml
25
{
26
namespace
linalg
27
{
47
template
<
typename
REAL>
48
void
chol
(
mpimat<REAL>
&x)
49
{
50
const
len_t n = x.
nrows
();
51
if
(n != x.
ncols
())
52
throw
std::runtime_error(
"'x' must be a square matrix"
);
53
54
int
info = 0;
55
fml::scalapack::potrf(
'L'
, n, x.
data_ptr
(), x.desc_ptr(), &info);
56
57
if
(info < 0)
58
fml::linalgutils::check_info(info,
"potrf"
);
59
else
if
(info > 0)
60
throw
std::runtime_error(
"chol: leading minor of order "
+ std::to_string(info) +
" is not positive definite"
);
61
62
fml::mpi_utils::tri2zero(
'U'
,
false
, x.get_grid(), n, n, x.
data_ptr
(), x.desc_ptr());
63
}
64
}
65
}
66
67
68
#endif
fml::mpimat
Matrix class for data distributed over MPI in the 2-d block cyclic format.
Definition:
mpimat.hh:40
fml::unimat::nrows
len_t nrows() const
Number of rows.
Definition:
unimat.hh:36
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::linalg::chol
void chol(cpumat< REAL > &x)
Compute the Choleski factorization.
Definition:
linalg_chol.hh:47
fml
src
fml
mpi
linalg
linalg_chol.hh
Generated by
1.8.17