TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
gemv.hpp
Go to the documentation of this file.
1
// Copyright (c) 2019--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 "
./tools.hpp
"
15
#include "
../concepts.hpp
"
16
#include "
../device.hpp
"
17
#include "
../macros.hpp
"
18
#include "
../mem/address_space.hpp
"
19
#include "
../traits.hpp
"
20
21
#include <utility>
22
23
namespace
nda::blas {
24
29
54
template
<BlasArrayOrConj<2> A, BlasArrayFor<A, 1> X, BlasArrayFor<A, 1> Y>
55
void
gemv
(
get_value_t<A>
alpha, A
const
&a, X
const
&x,
get_value_t<A>
beta, Y &&y) {
// NOLINT (temporary views are allowed here)
56
// get the underlying matrix in case it is given as a conjugate expression
57
auto
&mat =
get_array
(a);
58
59
// check the dimensions of the input/output arrays/views
60
auto
[m, n] = mat.shape();
61
EXPECTS(m == y.size());
62
EXPECTS(n == x.size());
63
64
// arrays/views must be BLAS compatible
65
EXPECTS(mat.indexmap().min_stride() == 1);
66
67
// swap axis for the transpose case
68
if
constexpr
(has_C_layout<A>)
std::swap
(m, n);
69
70
// perform actual library call
71
if
constexpr
(mem::have_device_compatible_addr_space<A, X, Y>) {
72
device::gemv(get_op<A>, m, n, alpha, mat.data(),
get_ld
(mat), x.data(), x.indexmap().strides()[0], beta, y.data(), y.indexmap().strides()[0]);
73
}
else
{
74
f77::gemv(get_op<A>, m, n, alpha, mat.data(),
get_ld
(mat), x.data(), x.indexmap().strides()[0], beta, y.data(), y.indexmap().strides()[0]);
75
}
76
}
77
79
80
}
// namespace nda::blas
address_space.hpp
Provides definitions and type traits involving the different memory address spaces supported by nda.
std::swap
void swap(nda::basic_array_view< V1, R1, LP1, A1, AP1, OP1 > &a, nda::basic_array_view< V2, R2, LP2, A2, AP2, OP2 > &b)=delete
std::swap is deleted for nda::basic_array_view.
cxx_interface.hpp
Provides a C++ interface for various BLAS routines.
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::get_value_t
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
Definition
traits.hpp:225
nda::blas_lapack::get_array
MemoryArray decltype(auto) get_array(A &&a)
Get the underlying array of a conjugate lazy expression or return the array itself in case it is an n...
Definition
tools.hpp:70
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:130
nda::blas::gemv
void gemv(get_value_t< A > alpha, A const &a, X const &x, get_value_t< A > beta, Y &&y)
Interface to the BLAS/cuBLAS gemv routine.
Definition
gemv.hpp:55
macros.hpp
Macros used in the nda library.
traits.hpp
Provides type traits for the nda library.
nda
blas
gemv.hpp
Generated by
1.18.0