TRIQS/nda 2.0.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 "../blas/tools.hpp"
15#include "../concepts.hpp"
16#include "../declarations.hpp"
17#include "../device.hpp"
18#include "../macros.hpp"
20#include "../traits.hpp"
21
22#include <type_traits>
23
24namespace nda::lapack {
25
54 template <BlasArrayOrConj<2> A, BlasArrayFor<A> B, PivotArrayFor<A, 1> IPIV>
55 requires((get_rank<B> == 1 or get_rank<B> == 2) and has_F_layout<B>)
56 int getrs(A const &a, B &&b, IPIV const &ipiv) { // NOLINT (temporary views are allowed here)
57 // get underlying matrix in case it is given as a lazy conjugate expression
58 auto &a_mat = get_array(a);
59
60 // check the dimensions of the input/output arrays/views
61 EXPECTS(a_mat.extent(0) == a_mat.extent(1));
62 EXPECTS(b.extent(0) == a_mat.extent(0));
63 EXPECTS(ipiv.size() == a_mat.extent(0));
64
65 // arrays/views must be LAPACK compatible
66 EXPECTS(a_mat.indexmap().min_stride() == 1);
67 EXPECTS(b.indexmap().min_stride() == 1);
68 EXPECTS(ipiv.indexmap().min_stride() == 1);
69
70 // perform actual library call
71 int info = 0;
73 device::getrs(get_op<A>, get_ncols(a_mat), get_ncols(b), a_mat.data(), get_ld(a_mat), ipiv.data(), b.data(), get_ld(b), info);
74 } else {
75 f77::getrs(get_op<A>, get_ncols(a_mat), get_ncols(b), a_mat.data(), get_ld(a_mat), ipiv.data(), b.data(), get_ld(b), info);
76 }
77
78 return info;
79 }
80
81} // namespace nda::lapack
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides various traits and utilities for the BLAS interface.
Provides concepts for the nda library.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
Provides GPU and non-GPU specific functionality.
constexpr int get_rank
Constexpr variable that specifies the rank of an nda::Array or of a contiguous 1-dimensional range.
Definition traits.hpp:147
MemoryArray decltype(auto) get_array(A &&a)
Get the underlying array of a conjugate lazy expression or return the array itself in case it is an n...
Definition tools.hpp:68
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:104
int get_ld(A const &a)
Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
Definition tools.hpp:128
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:148
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 getrs(A const &a, B &&b, IPIV const &ipiv)
Interface to the LAPACK/cuSOLVER getrs routine.
Definition getrs.hpp:56
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
Provides a C++ interface for various LAPACK routines.
Macros used in the nda library.
Provides type traits for the nda library.