KASKADE 7 development version
linalg
matrixTraits.hh
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2
/* */
3
/* This file is part of the library KASKADE 7 */
4
/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5
/* */
6
/* Copyright (C) 2015-2016 Zuse Institute Berlin */
7
/* */
8
/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9
/* see $KASKADE/academic.txt */
10
/* */
11
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
#ifndef LINALG_MATRIX_TRAITS
14
#define LINALG_MATRIX_TRAITS
15
16
// forward declarations
17
namespace
Dune
18
{
19
template
<
class
Scalar,
int
n,
int
m>
class
FieldMatrix;
20
template
<
class
Scalar,
int
n>
class
FieldVector;
21
template
<
class
Entry,
class
Allocator>
class
BlockVector
;
22
}
23
28
namespace
Kaskade
29
{
30
// forward declaration
31
template
<
class
Entry,
class
Index>
class
NumaBCRSMatrix;
32
33
// --------------------------------------------------------------------------------------
34
39
template
<
class
Matrix>
40
struct
MatrixTraits
41
{
50
using
NaturalDomain
= void;
51
58
using
NaturalRange
= void;
59
63
static
bool
isSquare
(Matrix
const
& A);
64
};
65
66
template
<
class
Scalar,
int
n,
int
m>
67
struct
MatrixTraits
<
Dune
::FieldMatrix<Scalar,n,m>>
68
{
69
using
NaturalDomain
=
Dune::FieldVector<Scalar,m>
;
70
using
NaturalRange
=
Dune::FieldVector<Scalar,n>
;
71
72
constexpr
static
bool
isSquare
(
Dune::FieldMatrix<Scalar,n,m>
const
&)
73
{
74
return
n==m;
// has to have the same number of rows and columns
75
}
76
};
77
78
template
<
class
Entry,
class
Index>
79
struct
MatrixTraits
<
NumaBCRSMatrix
<Entry,Index>>
80
{
81
using
NaturalDomain
=
Dune::BlockVector<typename MatrixTraits<Entry>::NaturalDomain
>;
82
using
NaturalRange
=
Dune::BlockVector<typename MatrixTraits<Entry>::NaturalRange
>;
83
84
static
bool
isSquare
(
NumaBCRSMatrix<Entry,Index>
const
& A)
85
{
86
int
n = A.
N
();
87
88
if
(A.
M
() != n)
// matrix needs to have the same number
89
return
false
;
// of rows and columns - otherwise it's not square
90
91
for
(
int
i=0; i<n; ++i)
// and every diagonal entry needs to be square
92
if
( !
MatrixTraits<Entry>::isSquare
(A[i][i]) )
// otherwise it's not square
93
return
false
;
94
95
return
true
;
// everything's ok - we're square
96
}
97
};
98
}
99
100
#endif
Dune::BlockVector
Definition:
dynamicMatrix.hh:34
Dune::FieldMatrix
Definition:
errorDistribution.hh:30
Dune::FieldVector
Definition:
errorDistribution.hh:29
Kaskade::NumaBCRSMatrix
A NUMA-aware compressed row storage matrix adhering mostly to the Dune ISTL interface (to complete....
Definition:
threadedMatrix.hh:2115
Kaskade::NumaBCRSMatrix::M
Index M() const
The number of columns.
Definition:
threadedMatrix.hh:2514
Kaskade::NumaBCRSMatrix::N
Index N() const
The number of rows.
Definition:
threadedMatrix.hh:2509
Dune
Definition:
errorDistribution.hh:28
Kaskade::MultiGridSolver_Detail::BlockVector
Dune::BlockVector< Dune::FieldVector< Scalar, n >, Allocator > BlockVector
Definition:
multiGridSolver.hh:42
Kaskade
Definition:
abstract_interface.hh:15
Kaskade::MatrixTraits< Dune::FieldMatrix< Scalar, n, m > >::isSquare
static constexpr bool isSquare(Dune::FieldMatrix< Scalar, n, m > const &)
Definition:
matrixTraits.hh:72
Kaskade::MatrixTraits< NumaBCRSMatrix< Entry, Index > >::isSquare
static bool isSquare(NumaBCRSMatrix< Entry, Index > const &A)
Definition:
matrixTraits.hh:84
Kaskade::MatrixTraits
Defines domain and range types for matrix classes.
Definition:
matrixTraits.hh:41
Kaskade::MatrixTraits::NaturalDomain
void NaturalDomain
The natural domain type.
Definition:
matrixTraits.hh:50
Kaskade::MatrixTraits::isSquare
static bool isSquare(Matrix const &A)
Checks whether a matrix is square.
Kaskade::MatrixTraits::NaturalRange
void NaturalRange
The natural range type.
Definition:
matrixTraits.hh:58
Generated on Fri Sep 6 2024 13:13:00 for KASKADE 7 development version by
1.9.4