5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_DOT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_DOT_HPP_
11#include "arene/base/linalg/detail/constraints_for.hpp"
12#include "arene/base/linalg/detail/mandates.hpp"
13#include "arene/base/linalg/detail/preconditions.hpp"
16#include "arene/base/stdlib_choice/common_type.hpp"
17#include "arene/base/stdlib_choice/declval.hpp"
18#include "arene/base/stdlib_choice/enable_if.hpp"
19#include "arene/base/stdlib_choice/is_assignable.hpp"
20#include "arene/base/stdlib_choice/move.hpp"
35template <
typename LeftValue,
typename RightValue>
45 typename Result = mul_result_t<LeftRef, RightRef>,
47constexpr bool dot_ops_supported_v{
false};
53template <
typename LeftRef,
typename RightRef,
typename Result>
54constexpr bool dot_ops_supported_v<
68template <
typename LeftVec,
typename RightVec>
69using default_dot_result_t = mul_result_t<typename LeftVec::value_type, typename RightVec::value_type>;
73class algorithm_constraints<class dot_fn> {
79 template <
typename LeftVec,
typename RightVec,
typename Scalar = default_dot_result_t<LeftVec, RightVec>>
107 constraints_for<dot_fn, LeftVec, RightVec, Scalar> =
nullptr>
108 constexpr auto operator()(LeftVec
const left_vec, RightVec
const right_vec, Scalar init)
const
109 noexcept(
noexcept(init =
std::move(init) + (left_vec(0U) * right_vec(0U)))) -> Scalar {
110 static_assert(possibly_comparable_v<LeftVec, RightVec>,
"Operands to dot must have the same extents");
117 for (index_type idx{}; cmp_less(idx, left_vec.extent(0U)); ++idx) {
119 init =
static_cast<Scalar
>(
std::move(init) + (left_vec(idx) * right_vec(idx)));
137 template <
typename LeftVec,
typename RightVec, constra
ints_for<dot_fn, LeftVec, RightVec> =
nullptr>
138 constexpr auto operator()(LeftVec
const left_vec, RightVec
const right_vec)
const noexcept(
noexcept(
140 )) -> default_dot_result_t<LeftVec, RightVec> {
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
constexpr const & zero_v
constexpr reference to the additive identity value zero<T>::value .
Definition arithmetic_identities.hpp:58
Definition accumulate.hpp:37
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
typename common_type< Ts... >::type common_type_t
Helper alias template for common_type.
Definition common_type.hpp:99
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...
Provides backports of the safe integer comparison functions from C++20.