1#ifndef TATOOINE_LAPACK_GEQRF_H
2#define TATOOINE_LAPACK_GEQRF_H
5auto dgeqrf_(
int* M,
int* N,
double* A,
int* LDA,
double* TAU,
double* WORK,
6 int* LWORK,
int* INFO) -> void;
7auto sgeqrf_(
int* M,
int* N,
float* A,
int* LDA,
float* TAU,
float* WORK,
8 int* LWORK,
int* INFO) -> void;
17template <std::
floating_po
int Float>
18auto geqrf(
int M,
int N, Float* A,
int LDA, Float* TAU, Float* WORK,
int LWORK)
21 if constexpr (std::same_as<Float, double>) {
22 dgeqrf_(&M, &N, A, &LDA, TAU, WORK, &LWORK, &INFO);
23 }
else if constexpr (std::same_as<Float, float>) {
24 sgeqrf_(&M, &N, A, &LDA, TAU, WORK, &LWORK, &INFO);
29template <std::
floating_po
int Float>
30auto geqrf(
int M,
int N, Float* A,
int LDA, Float* TAU) ->
int {
32 auto WORK = std::unique_ptr<Float[]>{
new Float[1]};
34 geqrf<Float>(M, N, A, LDA, TAU, WORK.get(), LWORK);
35 LWORK =
static_cast<int>(WORK[0]);
36 WORK = std::unique_ptr<Float[]>{
new Float[LWORK]};
37 return geqrf<Float>(M, N, A, LDA, TAU, WORK.get(), LWORK);
49template <
typename T,
size_t M,
size_t N>
51 return geqrf(M, N, A.
data(), M, tau.data());
56 assert(A.
rank() == 2);
59 assert(tau.
rank() == 1);
61 return geqrf(
static_cast<int>(M),
static_cast<int>(N), A.
data(),
62 static_cast<int>(M), tau.
data());
constexpr auto data() -> ValueType *
Definition: static_multidim_array.h:260
auto sgeqrf_(int *M, int *N, float *A, int *LDA, float *TAU, float *WORK, int *LWORK, int *INFO) -> void
auto dgeqrf_(int *M, int *N, double *A, int *LDA, double *TAU, double *WORK, int *LWORK, int *INFO) -> void
auto geqrf(int M, int N, Float *A, int LDA, Float *TAU, Float *WORK, int LWORK) -> int
Definition: geqrf.h:18
constexpr auto min(A &&a, B &&b)
Definition: math.h:15
static auto constexpr rank()
Definition: base_tensor.h:41
static auto constexpr dimension(std::size_t const i)
Definition: base_tensor.h:49