Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
LinearAlgebraExpr.h
Go to the documentation of this file.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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//-----------------------------------------------------------------------------
11#pragma once
12
13#include <alien/utils/Precomp.h>
14
15#include <memory>
16
17#include <alien/core/backend/BackEnd.h>
19
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Alien
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31class Space;
32class IVector;
33class IMatrix;
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
47template <class Tag, class TagV = Tag>
49{
50 public:
59 template <typename... T>
61 : m_algebra(AlgebraTraits<Tag>::algebra_expr_factory(args...))
62 {}
63
66
72 Real norm0(const IVector& x) const;
73
79 Real norm1(const IVector& x) const;
80
86 Real norm2(const IVector& x) const;
87
93 Real normInf(const IVector& x) const;
94
100 Real norm2(const IMatrix& x) const;
101
111 void mult(const IMatrix& a, const IVector& x, IVector& r) const;
112
123 void axpy(Real alpha, const IVector& x, IVector& y) const;
124
134 void aypx(Real alpha, IVector& y, const IVector& x) const;
135
142 void copy(const IVector& x, IVector& r) const;
143
150 void copy(const IMatrix& x, IMatrix& r) const;
151
160 void add(const IMatrix& a, IMatrix& b) const;
161
168 Real dot(const IVector& x, const IVector& y) const;
169
175 void scal(Real alpha, IVector& x) const;
176
182 void scal(Real alpha, IMatrix& a) const;
183
189 void diagonal(const IMatrix& a, IVector& x) const;
190
195 void reciprocal(IVector& x) const;
196
204 void pointwiseMult(const IVector& x, const IVector& y, IVector& w) const;
205
215 void mult(const IMatrix& a, const UniqueArray<Real>& x, UniqueArray<Real>& r) const;
216
227 void axpy(Real alpha, const UniqueArray<Real>& x, UniqueArray<Real>& r) const;
228
238 void aypx(Real alpha, UniqueArray<Real>& y, const UniqueArray<Real>& x) const;
239
246 void copy(const UniqueArray<Real>& x, UniqueArray<Real>& r) const;
247
255 Real dot(
256 Integer local_size, const UniqueArray<Real>& x, const UniqueArray<Real>& y) const;
257
263 void scal(Real alpha, UniqueArray<Real>& x) const;
264
270 void dump(IMatrix const& a, std::string const& filename) const;
271
277 void dump(IVector const& x, std::string const& filename) const;
278
279 private:
282 typedef typename AlgebraTraits<Tag>::algebra_expr_type KernelAlgebraExpr;
284 std::unique_ptr<KernelAlgebraExpr> m_algebra;
285};
286
287/*---------------------------------------------------------------------------*/
288/*---------------------------------------------------------------------------*/
289
290} // namespace Alien
291
292/*---------------------------------------------------------------------------*/
293/*---------------------------------------------------------------------------*/
IInternalLinearAlgebraExprT.h.
ILinearAlgebra.h.
Interface for all matrices.
Definition IMatrix.h:51
Interface for all vectors.
Definition IVector.h:51
Real norm0(const IVector &x) const
Compute L0 norm of a vector.
void aypx(Real alpha, IVector &y, const IVector &x) const
Scale a vector by a factor and adds the result to another vector.
void mult(const IMatrix &a, const IVector &x, IVector &r) const
Compute a matrix vector product.
Real norm2(const IMatrix &x) const
Compute L2 (Frobenous) norm of a matrix.
void copy(const IMatrix &x, IMatrix &r) const
Copy a matrix in another one.
std::unique_ptr< KernelAlgebraExpr > m_algebra
Real normInf(const IVector &x) const
Compute LInf norm of a vector.
Real norm1(const IVector &x) const
Compute L1 norm of a vector.
void scal(Real alpha, IMatrix &a) const
Scale a matrix by a factor.
void add(const IMatrix &a, IMatrix &b) const
Add two matrices A and B.
Real dot(Integer local_size, const UniqueArray< Real > &x, const UniqueArray< Real > &y) const
Compute the dot product of two vectors.
LinearAlgebraExpr(T... args)
Creates a linear algebra.
void copy(const IVector &x, IVector &r) const
Copy a vector in another one.
Real norm2(const IVector &x) const
Compute L2 norm of a vector.
void axpy(Real alpha, const IVector &x, IVector &y) const
Scale a vector by a factor and adds the result to another vector.
void aypx(Real alpha, UniqueArray< Real > &y, const UniqueArray< Real > &x) const
Scale a vector by a factor and adds the result to another vector.
void copy(const UniqueArray< Real > &x, UniqueArray< Real > &r) const
Copy a vector in another one.
void dump(IMatrix const &a, std::string const &filename) const
Dumps a matrix to a file.
virtual ~LinearAlgebraExpr()
Free resources.
void mult(const IMatrix &a, const UniqueArray< Real > &x, UniqueArray< Real > &r) const
Compute a matrix vector product.
void axpy(Real alpha, const UniqueArray< Real > &x, UniqueArray< Real > &r) const
Scale a vector by a factor and adds the result to another vector.
void reciprocal(IVector &x) const
Compute the reciprocal of a vector.
AlgebraTraits< Tag >::algebra_type KernelAlgebra
The type of the linear algebra.
void pointwiseMult(const IVector &x, const IVector &y, IVector &w) const
Compute the point wise multiplication of two vectors and store the result in another one.
void dump(IVector const &x, std::string const &filename) const
Dumps a vector to a file.
void scal(Real alpha, UniqueArray< Real > &x) const
Scale a vector by a factor.
void diagonal(const IMatrix &a, IVector &x) const
Extract the diagonal of a matrix in a vector.
void scal(Real alpha, IVector &x) const
Scale a vector by a factor.
Real dot(const IVector &x, const IVector &y) const
Compute the dot product of two vectors.
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