TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
ungqr_batch.hpp
Go to the documentation of this file.
1// Copyright (c) 2026--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 "./ungqr.hpp"
14#include "../blas/tools.hpp"
15#include "../macros.hpp"
16
17#include <type_traits>
18#include <utility>
19
20namespace nda::lapack {
21
51 template <BlasArrayCplx<3> A, BlasArrayFor<A, 2> TAU, BlasArrayFor<A, 1> W = vector_value_t<A>>
52 requires(has_F_layout<A, TAU>)
53 int ungqr_batch(A &&a, TAU &&tau, W &&work = vector_value_t<A>{}) { // NOLINT (temporary views are allowed here)
54 auto const n_b = a.extent(2);
55 auto const k = tau.extent(0);
56 EXPECTS(tau.extent(1) == n_b);
57 EXPECTS(k <= a.extent(0) && k <= a.extent(1));
58
59 // arrays/views must be LAPACK compatible
60 EXPECTS(a.indexmap().min_stride() == 1);
61 EXPECTS(tau.indexmap().min_stride() == 1);
62
63 int info = 0;
64 for (int i = 0; i < n_b; ++i) {
65 int local_info = ungqr(a(range::all, range(k), i), tau(range::all, i), work);
66 if (local_info != 0 && info == 0) info = local_info;
67 }
68 return info;
69 }
70
78 template <BlasArrayCplx<3> A, BlasArrayFor<A, 2> TAU, BlasArrayFor<A, 1> W = vector_value_t<A>>
79 requires(has_F_layout<A, TAU>)
80 int ungqr(A &&a, TAU &&tau, W &&work = vector_value_t<A>{}) { // NOLINT (temporary views are allowed here)
81 return ungqr_batch(std::forward<A>(a), std::forward<TAU>(tau), std::forward<W>(work));
82 }
83
84} // namespace nda::lapack
Provides various traits and utilities for the BLAS interface.
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
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
int ungqr(A &&a, TAU &&tau, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER ungqr routine.
Definition ungqr.hpp:67
int ungqr_batch(A &&a, TAU &&tau, W &&work=vector_value_t< A >{})
Interface to batched versions of the LAPACK/cuSOLVER ungqr routine.
Macros used in the nda library.
Provides a generic interface to the LAPACK/cuSOLVER ungqr routine.