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--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 "../macros.hpp"
17#include "../traits.hpp"
18
19#ifndef NDA_HAVE_DEVICE
20#include "../device.hpp"
21#endif // NDA_HAVE_DEVICE
22
23#include <algorithm>
24#include <type_traits>
25
26namespace nda::lapack {
27
51 template <MemoryMatrix A, MemoryMatrix B, MemoryVector IPIV>
53 int getrs(A const &a, B &&b, IPIV const &ipiv) { // NOLINT (temporary views are allowed here)
54 static_assert(std::is_same_v<get_value_t<IPIV>, int>, "Error in nda::lapack::getrs: Pivoting array must have elements of type int");
55 EXPECTS(ipiv.size() >= std::min(a.extent(0), a.extent(1)));
56
57 // must be lapack compatible
58 EXPECTS(a.indexmap().min_stride() == 1);
59 EXPECTS(b.indexmap().min_stride() == 1);
60 EXPECTS(ipiv.indexmap().min_stride() == 1);
61
62 // perform actual library call
63 int info = 0;
65#if defined(NDA_HAVE_DEVICE)
66 device::getrs(get_op<A>, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
67#else
69#endif
70 } else {
71 f77::getrs(get_op<A>, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
72 }
73 return info;
74 }
75
76} // 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:186
int getrs(A const &a, B &&b, IPIV const &ipiv)
Interface to the LAPACK getrs routine.
Definition getrs.hpp:53
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:36
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Definition traits.hpp:92
Provides a C++ interface for various LAPACK routines.
int get_ncols(A const &a)
Get the number of columns of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
Definition tools.hpp:142
int get_ld(A const &a)
Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for LAPACK calls.
Definition tools.hpp:122
static constexpr char get_op
Variable template that determines the BLAS matrix operation tag ('N','T','C') based on the given bool...
Definition tools.hpp:98
Macros used in the nda library.
Provides type traits for the nda library.