TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
dot.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
14#include "../concepts.hpp"
15#include "../device.hpp"
16#include "../macros.hpp"
18#include "../traits.hpp"
19
20namespace nda::blas {
21
26
43 template <BlasArray<1> X, BlasArrayFor<X, 1> Y>
44 auto dot(X const &x, Y const &y) {
45 // check the dimensions of the input/output arrays/views
46 EXPECTS(x.size() == y.size());
47
48 // perform actual library call
50 return device::dot(x.size(), x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0]);
51 } else {
52 return f77::dot(x.size(), x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0]);
53 }
54 }
55
71 template <BlasArray<1> X, BlasArrayFor<X, 1> Y>
72 auto dotc(X const &x, Y const &y) {
73 // check the dimensions of the input/output arrays/views
74 EXPECTS(x.size() == y.size());
75
76 // perform actual library call
77 if constexpr (!is_complex_v<get_value_t<X>>) {
78 return dot(x, y);
80 return device::dotc(x.size(), x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0]);
81 } else {
82 return f77::dotc(x.size(), x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0]);
83 }
84 }
85
87
88} // namespace nda::blas
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides a C++ interface for various BLAS routines.
Provides concepts for the nda library.
Provides GPU and non-GPU specific functionality.
auto dotc(X const &x, Y const &y)
Interface to the BLAS/cuBLAS dotc routine.
Definition dot.hpp:72
auto dot(X const &x, Y const &y)
Interface to the BLAS/cuBLAS dot and dotu routines.
Definition dot.hpp:44
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
constexpr bool is_complex_v
Constexpr variable that is true if type T is a std::complex type.
Definition traits.hpp:65
Macros used in the nda library.
Provides type traits for the nda library.