Arcane
v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
EigenAdapter.h
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2026 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
/* EigenAdapter.h (C) 2000-2026 */
9
/* */
10
/* Adapters for Eigen types to be used with builtin backend. */
11
/*---------------------------------------------------------------------------*/
12
#ifndef ARCCORE_ALINA_EIGENADAPTER_H
13
#define ARCCORE_ALINA_EIGENADAPTER_H
14
/*---------------------------------------------------------------------------*/
15
/*---------------------------------------------------------------------------*/
16
/*
17
* This file is based on the work on AMGCL library (version march 2026)
18
* which can be found at https://github.com/ddemidov/amgcl.
19
*
20
* Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
21
* SPDX-License-Identifier: MIT
22
*/
23
/*---------------------------------------------------------------------------*/
24
/*---------------------------------------------------------------------------*/
25
26
#include <type_traits>
27
#include <Eigen/SparseCore>
28
#include "arccore/alina/AlinaUtils.h"
29
#include "arccore/alina/BuiltinBackend.h"
30
31
/*---------------------------------------------------------------------------*/
32
/*---------------------------------------------------------------------------*/
33
34
namespace
Arcane::Alina::backend
35
{
36
37
/*---------------------------------------------------------------------------*/
38
/*---------------------------------------------------------------------------*/
39
40
//---------------------------------------------------------------------------
41
// Backend interface specialization for Eigen types
42
//---------------------------------------------------------------------------
43
template
<
class
T,
class
Enable =
void
>
44
struct
is_eigen_sparse_matrix
: std::false_type
45
{};
46
47
template
<
class
T,
class
Enable =
void
>
48
struct
is_eigen_type
: std::false_type
49
{};
50
51
template
<
typename
Scalar,
int
Flags,
typename
Storage>
52
struct
is_eigen_sparse_matrix
<Eigen::Map<Eigen::SparseMatrix<Scalar, Flags, Storage>>> : std::true_type
53
{};
54
55
template
<
typename
Scalar,
int
Flags,
typename
Storage>
56
struct
is_eigen_sparse_matrix
<Eigen::SparseMatrix<Scalar, Flags, Storage>> : std::true_type
57
{};
58
59
template
<
class
T>
60
struct
is_eigen_type
<T,
61
typename std::enable_if<std::is_arithmetic<typename T::RealScalar>::value &&
62
std::is_base_of<Eigen::EigenBase<T>, T>::value>
::type
> : std::true_type
63
{};
64
65
template
<
class
T>
66
struct
value_type
<T, typename std::enable_if<is_eigen_type<T>::value>::type>
67
{
68
typedef
typename
T::Scalar type;
69
};
70
71
template
<
class
T>
72
struct
nonzeros_impl
<T, typename std::enable_if<is_eigen_sparse_matrix<T>::value>
::type
>
73
{
74
static
size_t
get(
const
T&
matrix
)
75
{
76
return
matrix
.nonZeros();
77
}
78
};
79
80
template
<
class
T>
81
struct
row_iterator
<T, typename std::enable_if<is_eigen_sparse_matrix<T>::value>::type>
82
{
83
typedef
typename
T::InnerIterator type;
84
};
85
86
template
<
class
T>
87
struct
row_begin_impl
<T, typename std::enable_if<is_eigen_sparse_matrix<T>::value>
::type
>
88
{
89
typedef
typename
row_iterator<T>::type iterator;
90
static
iterator get(
const
T&
matrix
,
size_t
row)
91
{
92
return
iterator(
matrix
, row);
93
}
94
};
95
96
/*---------------------------------------------------------------------------*/
97
/*---------------------------------------------------------------------------*/
98
99
}
// namespace Arcane::Alina::backend
100
101
/*---------------------------------------------------------------------------*/
102
/*---------------------------------------------------------------------------*/
103
104
#endif
Arcane::Alina::matrix
Arcane::Alina::backend::is_eigen_sparse_matrix
Definition
EigenAdapter.h:45
Arcane::Alina::backend::is_eigen_type
Definition
EigenAdapter.h:49
Arcane::Alina::backend::nonzeros_impl
Implementation for function returning the number of nonzeros in a matrix.
Definition
BackendInterface.h:188
Arcane::Alina::backend::row_begin_impl
Implementation for function returning row iterator for a matrix.
Definition
BackendInterface.h:233
Arcane::Alina::backend::type
Arcane::Alina::backend::value_type
Metafunction that returns value type of a matrix or a vector type.
Definition
BackendInterface.h:78
arccore
src
alina
arccore
alina
EigenAdapter.h
Généré le Lundi 20 Avril 2026 04:40:02 pour Arcane par
1.13.2