Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
MatrixData.cc
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#include "MatrixData.h"
20
22#include <alien/data/ISpace.h>
25
26#include <alien/utils/ICopyOnWriteObject.h>
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Alien::Move
32{
33
34using namespace Arccore;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
40: m_impl(new MultiMatrixImpl(std::make_shared<Space>(0), std::make_shared<Space>(0),
41 std::make_shared<MatrixDistribution>(MatrixDistribution())))
42{}
43
44/*---------------------------------------------------------------------------*/
45
47: m_impl(new MultiMatrixImpl(
48 std::make_shared<Space>(space), std::make_shared<Space>(space), dist.clone()))
49{}
50
51/*---------------------------------------------------------------------------*/
52
54const Space& row_space, const Space& col_space, const MatrixDistribution& dist)
55: m_impl(new MultiMatrixImpl(
56 std::make_shared<Space>(row_space), std::make_shared<Space>(col_space), dist.clone()))
57{}
58
59/*---------------------------------------------------------------------------*/
60
62: m_impl(new MultiMatrixImpl(
63 std::make_shared<Space>(size), std::make_shared<Space>(size), dist.clone()))
64{}
65
66/*---------------------------------------------------------------------------*/
67
68MatrixData::MatrixData(Integer row_size, Integer col_size, const MatrixDistribution& dist)
69: m_impl(new MultiMatrixImpl(
70 std::make_shared<Space>(row_size), std::make_shared<Space>(col_size), dist.clone()))
71{}
72
73/*---------------------------------------------------------------------------*/
74
76: m_impl(new MultiMatrixImpl(dist.rowDistribution().space().clone(),
77 dist.colDistribution().space().clone(), dist.clone()))
78{}
79
80/*---------------------------------------------------------------------------*/
81
83: m_impl(std::move(matrix.m_impl))
84{}
85
86/*---------------------------------------------------------------------------*/
87
89{
90 m_impl = std::move(matrix.m_impl);
91 return *this;
92}
93
94/*---------------------------------------------------------------------------*/
95
96void MatrixData::init(const Space& space, const MatrixDistribution& dist)
97{
98 m_impl.reset(new MultiMatrixImpl(
99 std::make_shared<Space>(space), std::make_shared<Space>(space), dist.clone()));
100}
101
102/*---------------------------------------------------------------------------*/
103
104const Block*
105MatrixData::block() const
106{
107 return m_impl->block();
108}
109
110/*---------------------------------------------------------------------------*/
111
112const VBlock*
113MatrixData::vblock() const
114{
115 return m_impl->vblock();
116}
117
118/*---------------------------------------------------------------------------*/
119
120void MatrixData::setBlockInfos(const Integer block_size)
121{
122 m_impl->setBlockInfos(block_size);
123}
124
125/*---------------------------------------------------------------------------*/
126
127void MatrixData::setBlockInfos(const Block* block)
128{
129 if (block) {
130 m_impl->setBlockInfos(block);
131 }
132}
133
134/*---------------------------------------------------------------------------*/
135
136void MatrixData::setBlockInfos(const VBlock* block)
137{
138 if (block) {
139 m_impl->setBlockInfos(block);
140 }
141}
142
143/*---------------------------------------------------------------------------*/
144
146{
147 m_impl->free();
148}
149
150/*---------------------------------------------------------------------------*/
151
153{
154 m_impl->clear();
155}
156
157/*---------------------------------------------------------------------------*/
158
160{
161 m.accept(m_impl);
162}
163
164/*---------------------------------------------------------------------------*/
165
166const ISpace&
168{
169 return m_impl->rowSpace();
170}
171
172/*---------------------------------------------------------------------------*/
173
174const ISpace&
176{
177 return m_impl->colSpace();
178}
179
180/*---------------------------------------------------------------------------*/
181
184{
185 return m_impl->distribution();
186}
187
188/*---------------------------------------------------------------------------*/
189
190void MatrixData::setUserFeature(String feature)
191{
192 m_impl->setFeature(feature);
193}
194
195/*---------------------------------------------------------------------------*/
196
197bool MatrixData::hasUserFeature(String feature) const
198{
199 return m_impl->hasFeature(feature);
200}
201
202/*---------------------------------------------------------------------------*/
203
205{
206 return m_impl->hasFeature("composite");
207}
208
209/*---------------------------------------------------------------------------*/
210
213{
214 if (!m_impl) {
215 m_impl.reset(new MultiMatrixImpl());
216 }
217
218 return m_impl.get();
219}
220
221/*---------------------------------------------------------------------------*/
222
223const MultiMatrixImpl*
225{
226 return m_impl.get();
227}
228
229/*---------------------------------------------------------------------------*/
230
232MatrixData::clone() const
233{
234 MatrixData out;
235 out.m_impl.reset(m_impl->clone());
236 return out;
237}
238
239MatrixData createMatrixData(std::shared_ptr<MultiMatrixImpl> multi)
240{
241 MatrixData out;
242 out.m_impl = multi;
243 return out;
244}
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
248
249} // namespace Alien::Move
250
251/*---------------------------------------------------------------------------*/
252/*---------------------------------------------------------------------------*/
ISpace.h.
MatrixDistribution.h.
MultiMatrixImpl.h.
VectorDistribution.h.
Block elements for block matrices.
Definition Block.h:45
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a matrix distribution.
std::shared_ptr< MatrixDistribution > clone() const
Clone the distribution.
Algebraic Matrix with internal multi-representation object.
Definition MatrixData.h:40
Multi matrices representation container.
const AlgebraTraits< tag >::matrix_type & get() const
Get a specific matrix implementation.
Implementation of an algebraic space.
Definition Space.h:47
Variable size block elements for block matrices.
Definition VBlock.h:46
void visit(ICopyOnWriteMatrix &) const
void init(const Space &space, const MatrixDistribution &dist)
Definition MatrixData.cc:96
MatrixData & operator=(MatrixData &&matrix)
Move from Matrix.
Definition MatrixData.cc:88
MultiMatrixImpl * impl()
Get the multimatrix implementation.
friend MatrixData createMatrixData(std::shared_ptr< MultiMatrixImpl > multi)
void setUserFeature(String feature)
bool hasUserFeature(String feature) const
const MatrixDistribution & distribution() const
const ISpace & rowSpace() const
const ISpace & colSpace() const