TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
orgqr.hpp
Go to the documentation of this file.
1
// Copyright (c) 2024--present, The Simons Foundation
2
// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3
// SPDX-License-Identifier: Apache-2.0
4
// See LICENSE in the root of this distribution for details.
5
10
11
#pragma once
12
13
#include "
./interface/cxx_interface.hpp
"
14
#include "
../basic_array.hpp
"
15
#include "
../blas/tools.hpp
"
16
#include "
../concepts.hpp
"
17
#include "
../declarations.hpp
"
18
#include "
../macros.hpp
"
19
#include "
../mem/address_space.hpp
"
20
#include "
../traits.hpp
"
21
22
#include <algorithm>
23
#include <cmath>
24
#include <type_traits>
25
26
namespace
nda::lapack {
27
64
template
<BlasArrayReal<2> A, BlasArrayFor<A, 1> TAU, BlasArrayFor<A, 1> W = vector_value_t<A>>
65
requires
(
has_F_layout<A>
)
66
int
orgqr
(A &&a, TAU &&tau, W &&work =
vector_value_t<A>
{}) {
// NOLINT (temporary views are allowed here)
67
constexpr
bool
run_on_device =
mem::have_device_compatible_addr_space<A, TAU, W>
;
68
69
// check the dimensions of the input/output arrays/views
70
auto
const
[m, n] = a.shape();
71
auto
const
k = tau.size();
72
EXPECTS(m >= n);
73
EXPECTS(n >= k);
74
75
// arrays/views must be LAPACK compatible
76
EXPECTS(a.indexmap().min_stride() == 1);
77
EXPECTS(tau.indexmap().min_stride() == 1);
78
79
// first call to get the optimal buffer size
80
auto
tmp_lwork =
get_value_t<A>
{};
81
int
info = 0;
82
if
constexpr
(run_on_device) {
83
tmp_lwork = device::orgqr_buffer_size(m, n, k, a.data(),
get_ld
(a), tau.data());
84
}
else
{
85
f77::orgqr(m, n, k, a.data(),
get_ld
(a), tau.data(), &tmp_lwork, -1, info);
86
}
87
int
lwork =
static_cast<
int
>
(std::ceil(tmp_lwork));
88
89
// resize/check work buffer
90
resize_or_check_work_buffer
(work, lwork);
91
92
// perform actual library call
93
if
constexpr
(run_on_device) {
94
device::orgqr(m, n, k, a.data(),
get_ld
(a), tau.data(), work.data(), lwork, info);
95
}
else
{
96
f77::orgqr(m, n, k, a.data(),
get_ld
(a), tau.data(), work.data(), lwork, info);
97
}
98
99
return
info;
100
}
101
102
}
// namespace nda::lapack
address_space.hpp
Provides definitions and type traits involving the different memory address spaces supported by nda.
basic_array.hpp
Provides the generic class for arrays.
tools.hpp
Provides various traits and utilities for the BLAS interface.
concepts.hpp
Provides concepts for the nda library.
declarations.hpp
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
nda::get_value_t
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
Definition
traits.hpp:212
nda::blas_lapack::get_ld
int get_ld(A const &a)
Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
Definition
tools.hpp:128
nda::blas_lapack::resize_or_check_work_buffer
void resize_or_check_work_buffer(A &a, long min_size)
Resize or check the size of a 1D array/view.
Definition
tools.hpp:207
nda::blas_lapack::vector_value_t
vector< get_value_t< A >, heap< mem::get_addr_space< A > > > vector_value_t
Alias for an nda::vector with the same value type and address space as the given type.
Definition
tools.hpp:161
nda::blas_lapack::has_F_layout
static constexpr bool has_F_layout
Constexpr variable that is true if all given nda::Array types have nda::F_layout.
Definition
tools.hpp:79
nda::lapack::orgqr
int orgqr(A &&a, TAU &&tau, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER orgqr routine.
Definition
orgqr.hpp:66
nda::mem::have_device_compatible_addr_space
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
Definition
address_space.hpp:177
cxx_interface.hpp
Provides a C++ interface for various LAPACK routines.
macros.hpp
Macros used in the nda library.
traits.hpp
Provides type traits for the nda library.
nda
lapack
orgqr.hpp
Generated by
1.17.0