Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
Matrix.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 <alien/ref/data/scalar/Matrix.h>
20
21#include <alien/ref/AlienRefSemantic.h>
22#include <alien/utils/ICopyOnWriteObject.h>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Alien
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33Matrix::Matrix()
34: m_impl(new MultiMatrixImpl(std::make_shared<Space>(0), std::make_shared<Space>(0),
35 std::make_shared<MatrixDistribution>(MatrixDistribution())))
36{}
37
38/*---------------------------------------------------------------------------*/
39
40Matrix::Matrix(const MatrixDistribution& dist)
41: m_impl(
42 new MultiMatrixImpl(dist.rowSpace().clone(), dist.colSpace().clone(), dist.clone()))
43{}
44
45/*---------------------------------------------------------------------------*/
46
47Matrix::Matrix(
48Integer nrows, Integer ncols, Integer nrows_local, IMessagePassingMng* parallel_mng)
49: m_impl(
50 new MultiMatrixImpl(std::make_shared<Space>(nrows), std::make_shared<Space>(ncols),
51 std::make_shared<MatrixDistribution>(
52 MatrixDistribution(nrows, ncols, nrows_local, parallel_mng))))
53{}
54
55/*---------------------------------------------------------------------------*/
56
57Matrix::Matrix(Integer nrows, Integer ncols, IMessagePassingMng* parallel_mng)
58: m_impl(new MultiMatrixImpl(std::make_shared<Space>(nrows),
59 std::make_shared<Space>(ncols),
60 std::make_shared<MatrixDistribution>(MatrixDistribution(nrows, ncols, parallel_mng))))
61{}
62
63/*---------------------------------------------------------------------------*/
64
65Matrix::Matrix(Matrix&& matrix)
66: m_impl(std::move(matrix.m_impl))
67{}
68
69/*---------------------------------------------------------------------------*/
70
71Matrix::~Matrix() {}
72
73/*---------------------------------------------------------------------------*/
74
75Matrix&
76Matrix::operator=(Matrix&& matrix)
77{
78 m_impl = std::move(matrix.m_impl);
79 return *this;
80}
81
82/*---------------------------------------------------------------------------*/
83
85{
86 m.accept(m_impl);
87}
88
89/*---------------------------------------------------------------------------*/
90
92Matrix::distribution() const
93{
94 return m_impl->distribution();
95}
96
97/*---------------------------------------------------------------------------*/
98
99const ISpace&
101{
102 return m_impl->rowSpace();
103}
104
105/*---------------------------------------------------------------------------*/
106
107const ISpace&
109{
110 return m_impl->colSpace();
111}
112
113/*---------------------------------------------------------------------------*/
114
115void Matrix::setUserFeature(String feature)
116{
117 m_impl->setFeature(feature);
118}
119
120/*---------------------------------------------------------------------------*/
121
122bool Matrix::hasUserFeature(String feature) const
123{
124 return m_impl->hasFeature(feature);
125}
126
127/*---------------------------------------------------------------------------*/
128
129MultiMatrixImpl*
131{
132 if (!m_impl) {
133 m_impl.reset(new MultiMatrixImpl());
134 }
135 /* JMG ????
136 else if (!m_impl.unique()) { // Need to clone due to other references.
137 m_impl.reset(m_impl->clone());
138 } */
139 return m_impl.get();
140}
141
142/*---------------------------------------------------------------------------*/
143
144const MultiMatrixImpl*
146{
147 return m_impl.get();
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153} // namespace Alien
154
155/*---------------------------------------------------------------------------*/
156/*---------------------------------------------------------------------------*/
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a matrix distribution.
const ISpace & colSpace() const
Get col space associated to the matrix.
Definition Matrix.cc:108
void visit(ICopyOnWriteMatrix &) const
Visit method.
Definition Matrix.cc:84
const ISpace & rowSpace() const
Get row space associated to the matrix.
Definition Matrix.cc:100
MultiMatrixImpl * impl()
Get the multimatrix implementation.
Definition Matrix.cc:130
Multi matrices representation container.
Implementation of an algebraic space.
Definition Space.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17