DUNE PDELab (unstable)

dotproduct.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_DOTPRODUCT_HH
6#define DUNE_DOTPRODUCT_HH
7
8#include "ftraits.hh"
9#include "typetraits.hh"
10
11namespace Dune {
26 template<class T, class = void>
27 struct IsVector : std::false_type {};
28
29 template<class T>
30 struct IsVector<T, std::void_t<typename T::field_type> >
31 : std::true_type {};
32
38 template<class A, class B>
39 auto
40 dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && !std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type> ::value, decltype(conj(a)*b)>::type
41 {
42 return conj(a)*b;
43 }
44
52 // fundamental type with A being a real type
53 template<class A, class B>
54 auto
55 dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type>::value, decltype(a*b)>::type
56 {
57 return a*b;
58 }
59
67 template<typename A, typename B>
68 auto
69 dot(const A & a, const B & b) -> typename std::enable_if<IsVector<A>::value, decltype(a.dot(b))>::type
70 {
71 return a.dot(b);
72 }
73
79 template<class A, class B>
80 auto
81 dotT(const A & a, const B & b) -> decltype(a*b)
82 {
83 return a*b;
84 }
85
87} // end namespace DUNE
88
89#endif // DUNE_DOTPRODUCT_HH
Type traits to determine the type of reals (when working with complex numbers)
auto dotT(const A &a, const B &b) -> decltype(a *b)
Computes an indefinite vector dot product for fundamental data types according to Petsc's VectTDot fu...
Definition: dotproduct.hh:81
auto dot(const A &a, const B &b) -> typename std::enable_if< IsNumber< A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,...
Definition: dotproduct.hh:40
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Oct 20, 22:40, 2025)