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 // check for lazy expressions
63 static constexpr bool conj_A = is_conj_array_expr<A>;
64 char op_a = get_op<conj_A, /* transpose = */ has_C_layout<A>>;
65
66 // perform actual library call
67 int info = 0;
69#if defined(NDA_HAVE_DEVICE)
70 device::getrs(op_a, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
71#else
73#endif
74 } else {
75 f77::getrs(op_a, get_ncols(a), get_ncols(b), a.data(), get_ld(a), ipiv.data(), b.data(), get_ld(b), info);
76 }
77 return info;
78 }
79
80} // 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:185
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:91
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_C_layout
Constexpr variable that is true if the given nda::Array type has a C memory layout.
Definition tools.hpp:65
static constexpr bool is_conj_array_expr
Constexpr variable that is true if the given type is a conjugate lazy expression.
Definition tools.hpp:41
int get_ncols(A const &a)
Get the number of columns in LAPACK jargon of an nda::MemoryMatrix.
Definition tools.hpp:110
const char get_op
Variable template that determines the BLAS matrix operation tag ('N','T','C') based on the given bool...
Definition tools.hpp:80
Macros used in the nda library.
Provides type traits for the nda library.