TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
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
13
#include "
./interface/cxx_interface.hpp
"
14
#include "
../basic_functions.hpp
"
15
#include "
../concepts.hpp
"
16
#include "
../layout_transforms.hpp
"
17
#include "
../macros.hpp
"
18
#include "
../mem/address_space.hpp
"
19
#include "
../traits.hpp
"
20
21
#ifndef NDA_HAVE_DEVICE
22
#include "
../device.hpp
"
23
#endif
// NDA_HAVE_DEVICE
24
25
#include <algorithm>
26
#include <type_traits>
27
28
namespace
nda::lapack {
29
56
template
<MemoryMatrix A, MemoryVector IPIV>
57
requires
(
mem::have_compatible_addr_space<A, IPIV>
and
is_blas_lapack_v<get_value_t<A>
> and std::is_same_v<get_value_t<IPIV>,
int
>)
58
int
getrf
(A &&a, IPIV &&ipiv) {
// NOLINT (temporary views are allowed here)
59
// for C-layout arrays/views, call getrf with the transpose
60
if
constexpr
(
has_C_layout<A>
)
return
getrf
(
transpose
(a), ipiv);
61
62
// check the dimensions of the input/output arrays/views and resize if necessary
63
auto
const
[m, n] = a.shape();
64
resize_or_check_if_view
(ipiv, {std::min(m, n)});
65
66
// arrays/views must be LAPACK compatible
67
EXPECTS(a.indexmap().min_stride() == 1);
68
EXPECTS(ipiv.indexmap().min_stride() == 1);
69
70
#if defined(__has_feature)
71
#if __has_feature(memory_sanitizer)
72
ipiv = 0;
73
#endif
74
#endif
75
76
// perform actual library call
77
int
info = 0;
78
if
constexpr
(
mem::have_device_compatible_addr_space<A, IPIV>
) {
79
#if defined(NDA_HAVE_DEVICE)
80
device::getrf(m, n, a.data(),
get_ld
(a), ipiv.data(), info);
81
#else
82
compile_error_no_gpu
();
83
#endif
84
}
else
{
85
f77::getrf(m, n, a.data(),
get_ld
(a), ipiv.data(), info);
86
}
87
return
info;
88
}
89
90
}
// namespace nda::lapack
address_space.hpp
Provides definitions and type traits involving the different memory address spaces supported by nda.
basic_functions.hpp
Provides basic functions to create and manipulate arrays and views.
concepts.hpp
Provides concepts for the nda library.
device.hpp
Provides GPU and non-GPU specific functionality.
nda::resize_or_check_if_view
void resize_or_check_if_view(A &a, std::array< long, A::rank > const &sha)
Resize a given regular array to the given shape or check if a given view as the correct shape.
Definition
basic_functions.hpp:305
nda::transpose
auto transpose(A &&a)
Transpose the memory layout of an nda::MemoryArray or an nda::expr_call.
Definition
layout_transforms.hpp:180
nda::lapack::getrf
int getrf(A &&a, IPIV &&ipiv)
Interface to the LAPACK getrf routine.
Definition
getrf.hpp:58
nda::mem::have_compatible_addr_space
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
Definition
address_space.hpp:181
nda::mem::have_device_compatible_addr_space
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
Definition
address_space.hpp:177
nda::compile_error_no_gpu
void compile_error_no_gpu()
Trigger a compilation error in case GPU specific functionality is used without configuring the projec...
Definition
device.hpp:36
nda::is_blas_lapack_v
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Definition
traits.hpp:92
cxx_interface.hpp
Provides a C++ interface for various LAPACK routines.
nda::lapack::has_C_layout
static constexpr bool has_C_layout
Constexpr variable that is true if the given nda::Array type has nda::C_layout.
Definition
tools.hpp:83
nda::lapack::get_ld
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:122
layout_transforms.hpp
Provides functions to transform the memory layout of an nda::basic_array or nda::basic_array_view.
macros.hpp
Macros used in the nda library.
traits.hpp
Provides type traits for the nda library.
nda
lapack
getrf.hpp
Generated by
1.17.0