Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
VectorOperationsT.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* VectorOperationsT.h (C) 2014 */
9/* */
10/* Arithmetic operators for matrices. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_VECTOR_OPERATIONS_H
13#define ARCANE_VECTOR_OPERATIONS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17//#include "arcane/ArcaneTypes.h"
18//#include "arcane/matrix/VectorExpressionT.h"
19
20#include "VectorExpressionT.h"
21#include "IndexedSpace.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26ARCANE_BEGIN_NAMESPACE
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31
32
36template <class V1, class V2>
37 class VectorLinComb: public VectorExpr<VectorLinComb<V1,V2> >
38{
39 public:
40 VectorLinComb(double alpha, const VectorExpr<V1>& x,
41 double beta, const VectorExpr<V2>& y);
42
44
45 const IndexedSpace& domain() const;
46
47 Real operator[](int i) const { return 0; }
48
49 private:
50 V1 const & m_x;
51 V2 const & m_y;
52};
53
54
55template<class V1, class V2>
56 VectorLinComb<V1,V2> operator+(const VectorExpr<V1>& x,
57 const VectorExpr<V2>& y)
58{
59 return VectorLinComb<V1,V2>(1, x, 1, y);
60}
61
62template<class V1, class V2>
63 VectorLinComb<V1,V2> operator-(const VectorExpr<V1>& x,
64 const VectorExpr<V2>& y)
65{
66 return VectorLinComb<V1,V2>(1, x, -1, y);
67}
68
69template<class V1>
70VectorLinComb<V1,V1> operator*(double alpha,
71 const VectorExpr<V1>& x)
72{
73 return VectorLinComb<V1,V1>(alpha, x, 0, x);
74}
75
76
77template <class V1, class V2>
78 VectorLinComb<V1,V2>::
79 VectorLinComb(double alpha, const VectorExpr<V1>& x,
80 double beta, const VectorExpr<V2>& y)
81 :m_x(x),m_y(y)
82{
83 // Here: call the correct saxpy when V1 and V2 are not VectorLinComb.
84}
85
86
87template <class V1, class V2>
88const IndexedSpace&
89 VectorLinComb<V1,V2>::domain() const {
90 return m_x.domain() + m_y.domain();
91}
92
93
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98ARCANE_END_NAMESPACE
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103#endif // ARCANE_VECTOR_OPERATIONS_H
Indexed set/space to define matrix and vector support.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Class to inherite to perform matrix computations.
Vector Helper class to handle add and scalar multiply.