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 "
../concepts.hpp
"
16
#include "
../declarations.hpp
"
17
#include "
../macros.hpp
"
18
#include "
../mem/address_space.hpp
"
19
#include "
../traits.hpp
"
20
21
#include <algorithm>
22
#include <cmath>
23
#include <type_traits>
24
25
namespace
nda::lapack {
26
57
template
<MemoryMatrix A, MemoryVector TAU>
58
requires
(
mem::have_host_compatible_addr_space<A>
and std::is_same_v<double, get_value_t<A>> and
have_same_value_type_v<A, TAU>
)
59
int
orgqr
(A &&a, TAU &&tau) {
// NOLINT (temporary views are allowed here)
60
static_assert
(
has_F_layout<A>
,
"Error in nda::lapack::orgqr: A must have Fortran layout"
);
61
62
// check the dimensions of the input/output arrays/views
63
auto
const
[m, n] = a.shape();
64
auto
const
k = tau.size();
65
EXPECTS(m >= n);
66
EXPECTS(n >= k);
67
68
// arrays/views must be LAPACK compatible
69
EXPECTS(a.indexmap().min_stride() == 1);
70
EXPECTS(tau.indexmap().min_stride() == 1);
71
72
// first call to get the optimal buffer size
73
double
tmp_lwork{};
74
int
info = 0;
75
lapack::f77::orgqr(m, n, k, a.data(),
get_ld
(a), tau.data(), &tmp_lwork, -1, info);
76
int
lwork =
static_cast<
int
>
(std::ceil(tmp_lwork));
77
78
// allocate work buffer and perform actual library call
79
array<double, 1>
work(lwork);
80
lapack::f77::orgqr(m, n, k, a.data(),
get_ld
(a), tau.data(), work.
data
(), lwork, info);
81
82
return
info;
83
}
84
85
}
// 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.
nda::basic_array::data
ValueType const * data() const noexcept
Get a pointer to the actual data (in general this is not the beginning of the memory block for a view...
Definition
basic_array.hpp:619
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::array
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
Definition
declarations.hpp:64
nda::have_same_value_type_v
constexpr bool have_same_value_type_v
Constexpr variable that is true if all types in As have the same value type as A0.
Definition
traits.hpp:195
nda::lapack::orgqr
int orgqr(A &&a, TAU &&tau)
Interface to the LAPACK orgqr routine.
Definition
orgqr.hpp:59
nda::mem::have_host_compatible_addr_space
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
Definition
address_space.hpp:173
cxx_interface.hpp
Provides a C++ interface for various LAPACK routines.
nda::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:122
nda::lapack::has_F_layout
static constexpr bool has_F_layout
Constexpr variable that is true if the given nda::Array type has nda::F_layout.
Definition
tools.hpp:73
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