Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-istl
Commits
7fb6680b
Commit
7fb6680b
authored
6 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Implement BDMatrix<double>
parent
c91c332e
No related branches found
No related tags found
1 merge request
!240
Allow number types as entries of matrix and vector types
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/istl/bdmatrix.hh
+11
-4
11 additions, 4 deletions
dune/istl/bdmatrix.hh
dune/istl/test/matrixtest.cc
+32
-1
32 additions, 1 deletion
dune/istl/test/matrixtest.cc
with
43 additions
and
5 deletions
dune/istl/bdmatrix.hh
+
11
−
4
View file @
7fb6680b
...
...
@@ -32,7 +32,7 @@ namespace Dune {
//===== type definitions and constants
//! export the type representing the field
type
def
typename
B
::
field_type
field_type
;
using
field_
type
=
typename
Imp
::
BlockTraits
<
B
>::
field_type
;
//! export the type representing the components
typedef
B
block_type
;
...
...
@@ -47,7 +47,7 @@ namespace Dune {
typedef
typename
A
::
size_type
size_type
;
//! increment block level counter
enum
{
blocklevel
=
B
::
block
l
evel
+
1
}
;
static
constexpr
unsigned
int
blocklevel
=
Imp
::
BlockTraits
<
B
>
::
block
L
evel
()
+
1
;
/** \brief Default constructor */
BDMatrix
()
:
BCRSMatrix
<
B
,
A
>
()
{}
...
...
@@ -108,8 +108,15 @@ namespace Dune {
/** \brief Inverts the matrix */
void
invert
()
{
for
(
size_type
i
=
0
;
i
<
this
->
N
();
i
++
)
(
*
this
)[
i
][
i
].
invert
();
Hybrid
::
ifElse
(
IsNumber
<
B
>
(),
[
&
](
auto
id
)
{
for
(
size_type
i
=
0
;
i
<
this
->
N
();
i
++
)
(
*
this
)[
i
][
i
]
=
1.0
/
id
((
*
this
)[
i
][
i
]);
},
[
&
](
auto
id
)
{
for
(
size_type
i
=
0
;
i
<
this
->
N
();
i
++
)
id
((
*
this
)[
i
][
i
]).
invert
();
});
}
private
:
...
...
This diff is collapsed.
Click to expand it.
dune/istl/test/matrixtest.cc
+
32
−
1
View file @
7fb6680b
...
...
@@ -458,8 +458,34 @@ int main()
testSuperMatrix
(
bcrsMatrix
);
//
////////////////////////////////////////////////////////////////////////
//
/
////////////////////////////////////////////////////////////////////////
// Test the BDMatrix class -- a dynamic block-diagonal matrix
///////////////////////////////////////////////////////////////////////////
{
BDMatrix
<
double
>
bdMatrix
(
3
);
bdMatrix
=
4.0
;
BlockVector
<
double
>
x
(
3
),
y
(
3
);
testMatrix
(
bdMatrix
,
x
,
y
);
// Test construction from initializer list
BDMatrix
<
double
>
bdMatrix2
=
{
1.0
,
2.0
,
3.0
};
testMatrix
(
bdMatrix2
,
x
,
y
);
// test whether resizing works
bdMatrix2
.
setSize
(
5
);
bdMatrix2
=
4.0
;
x
.
resize
(
5
);
y
.
resize
(
5
);
testMatrix
(
bdMatrix2
,
x
,
y
);
// Test whether inversion works
bdMatrix2
.
invert
();
}
// ////////////////////////////////////////////////////////////////////////
// Test the BDMatrix class with FieldMatrix entries
// ////////////////////////////////////////////////////////////////////////
BDMatrix
<
FieldMatrix
<
double
,
4
,
4
>
>
bdMatrix
(
2
);
...
...
@@ -469,6 +495,11 @@ int main()
// Test construction from initializer list
BDMatrix
<
FieldMatrix
<
double
,
2
,
2
>
>
bdMatrix2
=
{
{{
1
,
0
},{
0
,
1
}},
{{
0
,
1
},{
-
1
,
0
}}};
// Test whether inversion works
bdMatrix2
.
invert
();
// Run matrix tests on this matrix
testSuperMatrix
(
bdMatrix2
);
// test whether resizing works
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment