Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-matrix-vector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
agnumpde
dune-matrix-vector
Commits
4b984142
Commit
4b984142
authored
8 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Tests: More general test; more helpful output
parent
f1e532ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/matrix-vector/test/triangularsolvetest.cc
+21
-6
21 additions, 6 deletions
dune/matrix-vector/test/triangularsolvetest.cc
with
21 additions
and
6 deletions
dune/matrix-vector/test/triangularsolvetest.cc
+
21
−
6
View file @
4b984142
...
...
@@ -11,6 +11,7 @@
#include
<dune/istl/bvector.hh>
#include
<dune/istl/matrixindexset.hh>
#include
"../transpose.hh"
#include
"../triangularsolve.hh"
#include
"common.hh"
...
...
@@ -42,18 +43,18 @@ bool test() {
}
indices
.
exportIdx
(
M
);
std
::
uniform_real_distribution
<>
low
Distribution
(
reg
,
0.4
);
std
::
uniform_real_distribution
<>
unconstrained
Distribution
(
-
1
,
1
);
for
(
auto
it
=
M
.
begin
();
it
!=
M
.
end
();
++
it
)
{
size_t
const
i
=
it
.
index
();
for
(
auto
cIt
=
it
->
begin
();
cIt
!=
it
->
end
();
++
cIt
)
{
size_t
const
j
=
cIt
.
index
();
*
cIt
=
lowDistribution
(
generator
);
*
cIt
=
unconstrainedDistribution
(
generator
);
// Make sure the diagonal is bounded away from zero
if
(
i
==
j
)
*
cIt
+=
0.6
;
*
cIt
+=
(
*
cIt
>
0
?
1
:
-
1
)
+
reg
;
}
}
std
::
uniform_real_distribution
<>
unconstrainedDistribution
(
reg
,
0.4
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
sol
(
n
);
for
(
auto
&
x
:
sol
)
x
=
unconstrainedDistribution
(
generator
);
...
...
@@ -67,7 +68,7 @@ bool test() {
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
M
.
mv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"
Difference:
"
<<
diff
<<
std
::
endl
;
std
::
cout
<<
"
|x - A^{-1}b| =
"
<<
diff
<<
std
::
endl
;
passed
&=
diff
<
tol
;
}
{
...
...
@@ -77,7 +78,19 @@ bool test() {
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
M
.
mtv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"Difference: "
<<
diff
<<
std
::
endl
;
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
" (manual transpose)"
<<
std
::
endl
;
passed
&=
diff
<
tol
;
}
{
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
Mt
;
Dune
::
MatrixVector
::
transpose
(
M
,
Mt
);
auto
x
=
lower
?
Dune
::
MatrixVector
::
upperTriangularSolve
(
Mt
,
b
,
ignore
)
:
Dune
::
MatrixVector
::
lowerTriangularSolve
(
Mt
,
b
,
ignore
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
M
.
mtv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
std
::
endl
;
passed
&=
diff
<
tol
;
}
return
passed
;
...
...
@@ -85,7 +98,9 @@ bool test() {
int
main
()
{
bool
passed
=
true
;
std
::
cout
<<
"Testing random upper triangular matrix"
<<
std
::
endl
;
passed
&=
test
<
5000
,
false
>
();
std
::
cout
<<
"Testing lower triangular matrix"
<<
std
::
endl
;
passed
&=
test
<
5000
,
true
>
();
return
passed
?
0
:
1
;
}
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