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_CPU_LINALG_LINALG_LU_H
6
#define FML_CPU_LINALG_LINALG_LU_H
7
#pragma once
8
9
10
#include <cmath>
11
#include <stdexcept>
12
13
#include "../../_internals/linalgutils.hh"
14
#include "../../_internals/omp.hh"
15
16
#include "../cpumat.hh"
17
#include "../cpuvec.hh"
18
19
#include "lapack.hh"
20
21
22
namespace
fml
23
{
24
namespace
linalg
25
{
47
template
<
typename
REAL>
48
void
lu
(
cpumat<REAL>
&x,
cpuvec<int>
&p,
int
&info)
49
{
50
info = 0;
51
const
len_t m = x.
nrows
();
52
const
len_t lipiv = std::min(m, x.
ncols
());
53
54
p.
resize
(lipiv);
55
56
fml::lapack::getrf(m, x.
ncols
(), x.
data_ptr
(), m, p.
data_ptr
(), &info);
57
}
58
60
template
<
typename
REAL>
61
void
lu
(
cpumat<REAL>
&x)
62
{
63
cpuvec<int>
p;
64
int
info;
65
66
lu
(x, p, info);
67
68
fml::linalgutils::check_info(info,
"getrf"
);
69
}
70
}
71
}
72
73
74
#endif
fml::cpumat
Matrix class for data held on a single CPU.
Definition:
cpumat.hh:36
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
fml
src
fml
cpu
linalg
linalg_lu.hh
Generated by
1.8.17