58 requires(mem::have_compatible_addr_space<A, IPIV>
and is_blas_lapack_v<get_value_t<A>>)
59 int getri(A &&a, IPIV
const &ipiv) {
60 static_assert(std::is_same_v<get_value_t<IPIV>,
int>,
"Error in nda::lapack::getri: Pivoting array must have elements of type int");
61 auto dm = std::min(a.extent(0), a.extent(1));
64 NDA_RUNTIME_ERROR <<
"Error in nda::lapack::getri: Pivot index array size " << ipiv.size() <<
" smaller than required size " << dm;
67 EXPECTS(a.indexmap().min_stride() == 1);
68 EXPECTS(ipiv.indexmap().min_stride() == 1);
71 if constexpr (mem::have_device_compatible_addr_space<A, IPIV>) {
72#if defined(NDA_HAVE_DEVICE)
73 device::getri(a.extent(0), a.data(), get_ld(a), ipiv.data(), NULL, 0, info);
79 using value_type = get_value_t<A>;
80 value_type bufferSize_T{};
81 f77::getri(a.extent(0), a.data(), get_ld(a), ipiv.data(), &bufferSize_T, -1, info);
82 int bufferSize =
static_cast<
int>(std::ceil(std::real(bufferSize_T)));
85 array<value_type, 1> work(bufferSize);
86#if defined(__has_feature
)
87#if __has_feature
(memory_sanitizer)
91 f77::getri(a.extent(0), a.data(), get_ld(a), ipiv.data(), work.data(), bufferSize, info);