1#ifndef TATOOINE_LAPACK_ORMQR_H
2#define TATOOINE_LAPACK_ORMQR_H
5auto dormqr_(
char* SIDE,
char* TRANS,
int* M,
int* N,
int* K,
double* A,
6 int* LDA,
double* TAU,
double* C,
int* LDC,
double* WORK,
7 int* LWORK,
int* INFO) -> void;
8auto sormqr_(
char* SIDE,
char* TRANS,
int* M,
int* N,
int* K,
float* A,
9 int* LDA,
float* TAU,
float* C,
int* LDC,
float* WORK,
int* LWORK,
20template <std::
floating_po
int Float>
21auto ormqr(side SIDE, op TRANS,
int M,
int N,
int K, Float* A,
int LDA,
22 Float* TAU, Float* C,
int LDC, Float* WORK,
int LWORK) ->
int {
24 if constexpr (std::same_as<Float, double>) {
25 dormqr_(
reinterpret_cast<char*
>(&SIDE),
reinterpret_cast<char*
>(&TRANS), &M,
26 &N, &K, A, &LDA, TAU, C, &LDC, WORK, &LWORK, &INFO);
27 }
else if constexpr (std::same_as<Float, float>) {
28 sormqr_(
reinterpret_cast<char*
>(&SIDE),
reinterpret_cast<char*
>(&TRANS), &M,
29 &N, &K, A, &LDA, TAU, C, &LDC, WORK, &LWORK, &INFO);
34template <std::
floating_po
int Float>
35auto ormqr(side SIDE, op TRANS,
int M,
int N,
int K, Float* A,
int LDA,
36 Float* TAU, Float* C,
int LDC) ->
int {
38 auto WORK = std::unique_ptr<Float[]>{
new Float[1]};
40 ormqr<Float>(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK.get(), LWORK);
41 LWORK =
static_cast<int>(WORK[0]);
42 WORK = std::unique_ptr<Float[]>{
new Float[LWORK]};
43 return ormqr<Float>(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK.get(),
72template <
typename T,
size_t K,
size_t M>
75 return ormqr(s, trans,
static_cast<int>(M), 1,
static_cast<int>(K), A.
data(),
76 static_cast<int>(M), tau.
data(), c.
data(),
static_cast<int>(M));
79template <
typename T,
size_t K,
size_t M,
size_t N>
81 side
const s, op trans) {
82 return ormqr(s, trans,
static_cast<int>(M),
static_cast<int>(N),
83 static_cast<int>(K), A.
data(),
static_cast<int>(M), tau.
data(),
84 C.
data(),
static_cast<int>(M));
89 assert(A.
rank() == 2);
90 assert(C.
rank() == 1 || C.
rank() == 2);
91 assert(tau.
rank() == 1);
97 return ormqr(s, trans,
static_cast<int>(M),
static_cast<int>(N),
98 static_cast<int>(K), A.
data(),
static_cast<int>(M), tau.
data(),
99 C.
data(),
static_cast<int>(M));
constexpr auto data() -> ValueType *
Definition: static_multidim_array.h:260
auto ormqr(side SIDE, op TRANS, int M, int N, int K, Float *A, int LDA, Float *TAU, Float *C, int LDC, Float *WORK, int LWORK) -> int
Definition: ormqr.h:21
auto sormqr_(char *SIDE, char *TRANS, int *M, int *N, int *K, float *A, int *LDA, float *TAU, float *C, int *LDC, float *WORK, int *LWORK, int *INFO) -> void
auto dormqr_(char *SIDE, char *TRANS, int *M, int *N, int *K, double *A, int *LDA, double *TAU, double *C, int *LDC, double *WORK, int *LWORK, int *INFO) -> void
static auto constexpr rank()
Definition: base_tensor.h:41
static auto constexpr dimension(std::size_t const i)
Definition: base_tensor.h:49