TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
getrs.hpp
Go to the documentation of this file.
1// Copyright (c) 2021-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Thomas Hahn, Miguel Morales, Nils Wentzell
16
22#pragma once
23
25#include "../concepts.hpp"
26#include "../macros.hpp"
28#include "../traits.hpp"
29
30#ifndef NDA_HAVE_DEVICE
31#include "../device.hpp"
32#endif // NDA_HAVE_DEVICE
33
34#include <algorithm>
35#include <type_traits>
36
37namespace nda::lapack {
38
62 template <MemoryMatrix A, MemoryMatrix B, MemoryVector IPIV>
64 int getrs(A const &a, B &&b, IPIV const &ipiv) { // NOLINT (temporary views are allowed here)
65 static_assert(std::is_same_v<get_value_t<IPIV>, int>, "Error in nda::lapack::getrs: Pivoting array must have elements of type int");
66 EXPECTS(ipiv.size() >= std::min(a.extent(0), a.extent(1)));
67
68 // must be lapack compatible
69 EXPECTS(a.indexmap().min_stride() == 1);
70 EXPECTS(b.indexmap().min_stride() == 1);
71 EXPECTS(ipiv.indexmap().min_stride() == 1);
72
73 // check for lazy expressions
74 static constexpr bool conj_A = is_conj_array_expr<A>;
75 char op_a = get_op<conj_A, /* transpose = */ has_C_layout<A>>;
76
77 // perform actual library call
78 int info = 0;
80#if defined(NDA_HAVE_DEVICE)
81 device::getrs(op_a, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
82#else
84#endif
85 } else {
86 f77::getrs(op_a, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
87 }
88 return info;
89 }
90
91} // namespace nda::lapack
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides concepts for the nda library.
Provides GPU and non-GPU specific functionality.
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:196
int getrs(A const &a, B &&b, IPIV const &ipiv)
Interface to the LAPACK getrs routine.
Definition getrs.hpp:64
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
void compile_error_no_gpu()
Trigger a compilation error in case GPU specific functionality is used without configuring the projec...
Definition device.hpp:47
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Definition traits.hpp:102
Provides a C++ interface for various LAPACK routines.
Macros used in the nda library.
Provides type traits for the nda library.