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-2023 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: Miguel Morales, Nils Wentzell
16
22#pragma once
23
25#include "../concepts.hpp"
26#include "../macros.hpp"
28#include "../traits.hpp"
29
30#include <algorithm>
31#include <type_traits>
32
33namespace nda::lapack {
34
60 template <MemoryMatrix A, MemoryVector IPIV>
62 int getrf(A &&a, IPIV &&ipiv) { // NOLINT (temporary views are allowed here)
63 static_assert(std::is_same_v<get_value_t<IPIV>, int>, "Error in nda::lapack::getri: Pivoting array must have elements of type int");
64
65 auto dm = std::min(a.extent(0), a.extent(1));
66 if (ipiv.size() < dm) ipiv.resize(dm); // ipiv needs to be a regular array?
67
68 // must be lapack compatible
69 EXPECTS(a.indexmap().min_stride() == 1);
70 EXPECTS(ipiv.indexmap().min_stride() == 1);
71
72#if defined(__has_feature)
73#if __has_feature(memory_sanitizer)
74 ipiv = 0;
75#endif
76#endif
77
78 int info = 0;
80#if defined(NDA_HAVE_DEVICE)
81 device::getrf(a.extent(0), a.extent(1), a.data(), get_ld(a), ipiv.data(), info);
82#else
84#endif
85 } else {
86 f77::getrf(a.extent(0), a.extent(1), a.data(), get_ld(a), ipiv.data(), 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.
int getrf(A &&a, IPIV &&ipiv)
Interface to the LAPACK getrf routine.
Definition getrf.hpp:62
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.