Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ValueTypeComplex.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ValueTypeComplex.h (C) 2000-2026 */
9/* */
10/* Enable std::complex<T> as value type. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_ALINA_VALUETYPECOMPLEX_H
13#define ARCCORE_ALINA_VALUETYPECOMPLEX_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16/*
17 * This file is based on the work on AMGCL library (version march 2026)
18 * which can be found at https://github.com/ddemidov/amgcl.
19 *
20 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
21 * SPDX-License-Identifier: MIT
22 */
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26#include "arccore/alina/BuiltinBackend.h"
27#include "arccore/alina/ValueTypeInterface.h"
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::Alina::backend
33{
34
36template <typename T>
37struct is_builtin_vector<std::vector<std::complex<T>>> : std::true_type
38{};
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43} // namespace Arcane::Alina::backend
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48namespace Arcane::Alina::math
49{
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
55template <class T>
56struct scalar_of<std::complex<T>>
57{
58 typedef T type;
59};
60
62template <class T, class S>
63struct replace_scalar<std::complex<T>, S>
64{
65 typedef std::complex<S> type;
66};
67
69template <typename T>
70struct adjoint_impl<std::complex<T>>
71{
72 typedef std::complex<T> return_type;
73
74 static std::complex<T> get(std::complex<T> x)
75 {
76 return std::conj(x);
77 }
78};
79
85template <typename T>
86struct inner_product_impl<std::complex<T>>
87{
88 typedef std::complex<T> return_type;
89
90 static return_type get(std::complex<T> x, std::complex<T> y)
91 {
92 return x * std::conj(y);
93 }
94};
95
97template <typename T>
98struct constant_impl<std::complex<T>>
99{
100 static std::complex<T> get(T c)
101 {
102 return std::complex<T>(c, c);
103 }
104};
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109} // namespace Arcane::Alina::math
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114namespace std
115{
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119//GG: not sure it is legal to specialize in namespace std
120template <typename V>
121bool operator<(const std::complex<V>& a, const std::complex<V>& b)
122{
123 return std::abs(a) < std::abs(b);
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129} // namespace std
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134#endif
bool operator<(const Item &item1, const Item &item2)
Compare deux entités.
Definition Item.h:551
Default implementation for conjugate transpose.
Default implementation for the constant element.
Default implementation for inner product.
Replace scalar type in the static matrix.
Scalar type of a non-scalar type.