Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MatrixOperationsT.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/* MatrixOperationsT.h (C) 2014 */
9/* */
10/* Arithmetic operators for matrices. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATRIX_OPERATIONS_H
13#define ARCANE_MATRIX_OPERATIONS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17//#include "arcane/ArcaneTypes.h"
18//#include "arcane/matrix/MatrixExpressionT.h"
19
20#include "MatrixExpressionT.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25ARCANE_BEGIN_NAMESPACE
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30
31
35template <class M1, class M2>
36 class MatrixLinComb: public MatrixExpr<MatrixLinComb<M1,M2> >
37{
38 public:
39 MatrixLinComb(double alpha, const MatrixExpr<M1>& x,
40 double beta, const MatrixExpr<M2>& y);
41
43
44 const IndexedSpace& maps_from() const { return m_x.maps_from()+m_y.maps_from(); }
45 const IndexedSpace& maps_to() const { return m_x.maps_to()+m_y.maps_to(); }
46
47 private:
48
49 M1 const & m_x;
50 M2 const & m_y;
51};
52
53
54template<class M1, class M2>
55 MatrixLinComb<M1,M2> operator+(const MatrixExpr<M1>& x, const MatrixExpr<M2>& y)
56{
57 return MatrixLinComb<M1,M2>(1, x, 1, y);
58}
59
60template<class M1, class M2>
61 MatrixLinComb<M1,M2> operator-(const MatrixExpr<M1>& x, const MatrixExpr<M2>& y)
62{
63 return MatrixLinComb<M1,M2>(1, x, -1, y);
64}
65
66template<class M1>
67MatrixLinComb<M1,M1> operator*(double alpha, const MatrixExpr<M1>& x)
68{
69 return MatrixLinComb<M1,M1>(1, x, 0, x);
70}
71
72
73template <class M1, class M2>
74 MatrixLinComb<M1,M2>::
75 MatrixLinComb(double alpha, const MatrixExpr<M1>& x,
76 double beta, const MatrixExpr<M2>& y)
77 :m_x(x),m_y(y)
78{
79 // Here: call the correct saxpy when M1 and M2 are not MatrixLinComb.
80}
81
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86ARCANE_END_NAMESPACE
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
91#endif // ARCANE_MATRIX_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.
Matrix Helper class to handle add and scalar multiply.