TRIQS/nda 1.3.0
Multi-dimensional array library for C++
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
14#include "../concepts.hpp"
15#include "../declarations.hpp"
16#include "../exceptions.hpp"
18#include "../macros.hpp"
20#include "../mem/policies.hpp"
21#include "../traits.hpp"
22
23#include <cmath>
24#include <complex>
25#include <type_traits>
26
27namespace nda::lapack {
28
49 template <MemoryMatrix A, MemoryVector TAU>
50 requires(mem::on_host<A> and std::is_same_v<double, get_value_t<A>> and have_same_value_type_v<A, TAU>
52 int orgqr(A &&a, TAU &&tau) { // NOLINT (temporary views are allowed here)
53 static_assert(has_F_layout<A>, "Error in nda::lapack::orgqr: C order is not supported");
54 static_assert(mem::have_host_compatible_addr_space<A, TAU>, "Error in nda::lapack::orgqr: Only CPU is supported");
55
56 // must be lapack compatible
57 EXPECTS(a.indexmap().min_stride() == 1);
58 EXPECTS(tau.indexmap().min_stride() == 1);
59
60 // first call to get the optimal buffersize
61 using value_type = get_value_t<A>;
62 value_type bufferSize_T{};
63 auto [m, n] = a.shape();
64 auto k = tau.size();
65 int info = 0;
66 lapack::f77::orgqr(m, std::min(m, n), k, a.data(), get_ld(a), tau.data(), &bufferSize_T, -1, info);
67 int bufferSize = static_cast<int>(std::ceil(std::real(bufferSize_T)));
68
69 // allocate work buffer and perform actual library call
71 lapack::f77::orgqr(m, std::min(m, n), k, a.data(), get_ld(a), tau.data(), work.data(), bufferSize, info);
72
73 if (info) NDA_RUNTIME_ERROR << "Error in nda::lapack::orgqr: info = " << info;
74 return info;
75 }
76
77} // namespace nda::lapack
Provides definitions and type traits involving the different memory address spaces supported by nda.
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...
Provides concepts for the nda library.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
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:185
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:181
int orgqr(A &&a, TAU &&tau)
Interface to the LAPACK orgqr routine.
Definition orgqr.hpp:52
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
static constexpr bool on_host
Constexpr variable that is true if all given types have a Host address space.
Provides a C++ interface for various LAPACK routines.
int get_ld(A const &a)
Get the leading dimension in LAPACK jargon of an nda::MemoryMatrix.
Definition tools.hpp:98
static constexpr bool has_F_layout
Constexpr variable that is true if the given nda::Array type has a Fortran memory layout.
Definition tools.hpp:55
Provides definitions of various layout policies.
Macros used in the nda library.
Defines various memory handling policies.
Provides type traits for the nda library.