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
568138a3
Commit
568138a3
authored
6 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Implement and test method countNonZeros for BCRSMatrix<double>
parent
c55d5167
No related branches found
No related tags found
1 merge request
!252
Generalize countNonZeros to scalar matrices
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dune/istl/matrixutils.hh
+3
-3
3 additions, 3 deletions
dune/istl/matrixutils.hh
dune/istl/test/laplacian.hh
+14
-9
14 additions, 9 deletions
dune/istl/test/laplacian.hh
dune/istl/test/matrixutilstest.cc
+9
-0
9 additions, 0 deletions
dune/istl/test/matrixutilstest.cc
with
26 additions
and
12 deletions
dune/istl/matrixutils.hh
+
3
−
3
View file @
568138a3
...
...
@@ -63,12 +63,12 @@ namespace Dune
};
template
<
>
struct
NonZeroCounter
<
1
>
struct
NonZeroCounter
<
0
>
{
template
<
class
M
>
static
typename
M
::
size_type
count
(
const
M
&
matrix
)
static
auto
count
(
const
M
&
matrix
)
{
return
matrix
.
N
()
*
matrix
.
M
()
;
return
1
;
}
};
...
...
This diff is collapsed.
Click to expand it.
dune/istl/test/laplacian.hh
+
14
−
9
View file @
568138a3
...
...
@@ -43,15 +43,20 @@ void setupLaplacian(Dune::BCRSMatrix<B,Alloc>& A, int N)
setupSparsityPattern
(
A
,
N
);
B
diagonal
(
static_cast
<
FieldType
>
(
0
)),
bone
(
static_cast
<
FieldType
>
(
0
)),
beps
(
static_cast
<
FieldType
>
(
0
));
for
(
typename
B
::
RowIterator
b
=
diagonal
.
begin
();
b
!=
diagonal
.
end
();
++
b
)
b
->
operator
[](
b
.
index
())
=
4
;
for
(
typename
B
::
RowIterator
b
=
bone
.
begin
();
b
!=
bone
.
end
();
++
b
)
b
->
operator
[](
b
.
index
())
=-
1.0
;
B
diagonal
(
static_cast
<
FieldType
>
(
0
)),
bone
(
static_cast
<
FieldType
>
(
0
));
Dune
::
Hybrid
::
ifElse
(
Dune
::
IsNumber
<
B
>
(),
[
&
](
auto
id
)
{
diagonal
=
B
(
4.0
);
bone
=
B
(
-
1.0
);
},
[
&
](
auto
id
)
{
for
(
auto
b
=
id
(
diagonal
).
begin
();
b
!=
id
(
diagonal
).
end
();
++
b
)
b
->
operator
[](
b
.
index
())
=
4
;
for
(
auto
b
=
id
(
bone
).
begin
();
b
!=
id
(
bone
).
end
();
++
b
)
b
->
operator
[](
b
.
index
())
=-
1.0
;
});
for
(
typename
Dune
::
BCRSMatrix
<
B
,
Alloc
>::
RowIterator
i
=
A
.
begin
();
i
!=
A
.
end
();
++
i
)
{
int
x
=
i
.
index
()
%
N
;
// x coordinate in the 2d field
...
...
This diff is collapsed.
Click to expand it.
dune/istl/test/matrixutilstest.cc
+
9
−
0
View file @
568138a3
...
...
@@ -20,6 +20,15 @@ int main(int argc, char** argv)
const
int
N
=
4
;
// Test sparse matrix with scalar entries
Dune
::
BCRSMatrix
<
double
>
slaplace
;
setupLaplacian
(
slaplace
,
N
);
if
(
N
*
N
*
5
-
4
*
2
-
(
N
-
2
)
*
4
!=
countNonZeros
(
slaplace
))
{
++
ret
;
Dune
::
derr
<<
"Counting nonzeros of BCRSMatrix<double> failed!"
<<
std
::
endl
;
}
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>
>
BMatrix
;
BMatrix
laplace
;
...
...
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