Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
MatrixElement.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19/*!
20 * \file MatrixElement.h
21 * \brief MatrixElement.h
22 */
23
24#ifndef ALIEN_COMMON_UTILS_MATRIXELEMENT_H
25#define ALIEN_COMMON_UTILS_MATRIXELEMENT_H
26
27#include <alien/utils/Precomp.h>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38/*!
39 * \ingroup utils
40 * \brief Tool to manipulate a matrix entry while building the matrix
41 * \tparam Builder The type of the builder used to build the matrix
42 */
43template <typename Builder>
45{
46 public:
47 /*!
48 * \brief Constructor
49 * \param[in] iIndex The row index of the entry
50 * \param[in] jIndex The col index of the entry
51 * \param[in] parent The builder used to build the matrix
52 */
54 const Arccore::Integer iIndex, const Arccore::Integer jIndex, Builder& parent)
55 : m_iIndex(iIndex)
56 , m_jIndex(jIndex)
57 , m_parent(parent)
58 {}
59
60 /*!
61 * \brief accessor operator
62 * \return value
63 */
64 Arccore::Real operator()() const { return m_parent.getData(m_iIndex, m_jIndex); }
65
66 /*!
67 * \brief Add and set operator
68 * \param[in] value The value to add
69 */
70 void operator+=(Real value)
71 {
72 m_parent.addData(m_iIndex, m_jIndex, value);
73 }
74
75 /*!
76 * \brief Minus and set operator
77 * \param[in] value The value to substract
78 */
79 void operator-=(Real value)
80 {
81 m_parent.addData(m_iIndex, m_jIndex, -value);
82 }
83
84 /*!
85 * \brief Assignment operator
86 * \param[in] value The value to set
87 */
88 void operator=(Real value)
89 {
90 m_parent.setData(m_iIndex, m_jIndex, value);
91 }
92
93 /*!
94 * \brief Comparison operator
95 * \param[in] other To be compare against.
96 */
97 template <typename Builder2>
99 {
100 bool test_pattern = (m_iIndex == other.m_iIndex) && (m_jIndex == other.m_jIndex);
101 // TODO: Check values.
102 return test_pattern;
103 }
104
105 private:
106 //! The row index
107 const Arccore::Integer m_iIndex;
108 //! The col index
109 const Arccore::Integer m_jIndex;
110 //! The builder
111 Builder& m_parent;
112};
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117} // namespace Alien
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122#endif /* ALIEN_COMMON_UTILS_MATRIXELEMENT_H */
void operator+=(Real value)
Add and set operator.
MatrixElementT(const Arccore::Integer iIndex, const Arccore::Integer jIndex, Builder &parent)
Constructor.
bool operator=(const MatrixElementT< Builder2 > &other)
Comparison operator.
void operator-=(Real value)
Minus and set operator.
void operator=(Real value)
Assignment operator.
Arccore::Real operator()() const
accessor operator
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17