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 "
../blas/tools.hpp
"
16
#include "
../concepts.hpp
"
17
#include "
../device.hpp
"
18
#include "
../layout_transforms.hpp
"
19
#include "
../macros.hpp
"
20
#include "
../mem/address_space.hpp
"
21
#include "
../traits.hpp
"
22
23
#include <algorithm>
24
#include <type_traits>
25
26
namespace
nda::lapack {
27
60
template
<BlasArray<2> A, PivotArrayFor<A, 1> IPIV, BlasArrayFor<A, 1> W = vector_value_t<A>>
61
int
getrf
(A &&a, IPIV &&ipiv, [[maybe_unused]] W &&work =
vector_value_t<A>
{}) {
// NOLINT (temporary views are allowed here)
62
// for C-layout arrays/views, call getrf with the transpose
63
if
constexpr
(
has_C_layout<A>
)
return
getrf
(
transpose
(a), ipiv);
64
65
// check the dimensions of the input/output arrays/views and resize if necessary
66
auto
const
[m, n] = a.shape();
67
resize_or_check_if_view
(ipiv, {std::min(m, n)});
68
69
// arrays/views must be LAPACK compatible
70
EXPECTS(a.indexmap().min_stride() == 1);
71
EXPECTS(ipiv.indexmap().min_stride() == 1);
72
73
#if defined(__has_feature)
74
#if __has_feature(memory_sanitizer)
75
ipiv = 0;
76
#endif
77
#endif
78
79
// perform actual library call
80
int
info = 0;
81
if
constexpr
(
mem::have_device_compatible_addr_space<A, IPIV, W>
) {
82
// resize/check work buffer
83
int
const
lwork = device::getrf_buffer_size(m, n, a.data(),
get_ld
(a));
84
resize_or_check_work_buffer
(work, lwork);
85
86
device::getrf(m, n, a.data(),
get_ld
(a), work.data(), ipiv.data(), info);
87
}
else
{
88
f77::getrf(m, n, a.data(),
get_ld
(a), ipiv.data(), info);
89
}
90
return
info;
91
}
92
93
}
// 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.
tools.hpp
Provides various traits and utilities for the BLAS interface.
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::blas_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:128
nda::blas_lapack::has_C_layout
static constexpr bool has_C_layout
Constexpr variable that is true if all given nda::Array types have nda::C_layout.
Definition
tools.hpp:89
nda::blas_lapack::resize_or_check_work_buffer
void resize_or_check_work_buffer(A &a, long min_size)
Resize or check the size of a 1D array/view.
Definition
tools.hpp:207
nda::blas_lapack::vector_value_t
vector< get_value_t< A >, heap< mem::get_addr_space< A > > > vector_value_t
Alias for an nda::vector with the same value type and address space as the given type.
Definition
tools.hpp:161
nda::lapack::getrf
int getrf(A &&a, IPIV &&ipiv, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER getrf routine.
Definition
getrf.hpp:61
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
cxx_interface.hpp
Provides a C++ interface for various LAPACK routines.
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