TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
getrf.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#include <algorithm>
20#include <type_traits>
21
22namespace nda::lapack {
23
49 template <MemoryMatrix A, MemoryVector IPIV>
51 int getrf(A &&a, IPIV &&ipiv) { // NOLINT (temporary views are allowed here)
52 static_assert(std::is_same_v<get_value_t<IPIV>, int>, "Error in nda::lapack::getri: Pivoting array must have elements of type int");
53
54 auto dm = std::min(a.extent(0), a.extent(1));
55 if (ipiv.size() < dm) ipiv.resize(dm); // ipiv needs to be a regular array?
56
57 // must be lapack compatible
58 EXPECTS(a.indexmap().min_stride() == 1);
59 EXPECTS(ipiv.indexmap().min_stride() == 1);
60
61#if defined(__has_feature)
62#if __has_feature(memory_sanitizer)
63 ipiv = 0;
64#endif
65#endif
66
67 int info = 0;
69#if defined(NDA_HAVE_DEVICE)
70 device::getrf(a.extent(0), a.extent(1), a.data(), get_ld(a), ipiv.data(), info);
71#else
73#endif
74 } else {
75 f77::getrf(a.extent(0), a.extent(1), a.data(), get_ld(a), ipiv.data(), 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.
int getrf(A &&a, IPIV &&ipiv)
Interface to the LAPACK getrf routine.
Definition getrf.hpp:51
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
Macros used in the nda library.
Provides type traits for the nda library.