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
f1e532ba
Commit
f1e532ba
authored
8 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Use a sparse matrix
Otherwise, rounding errors dominate once the problem becomes larger
parent
83950abb
Branches
Branches containing commit
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
+24
-11
24 additions, 11 deletions
dune/matrix-vector/test/triangularsolvetest.cc
with
24 additions
and
11 deletions
dune/matrix-vector/test/triangularsolvetest.cc
+
24
−
11
View file @
f1e532ba
...
@@ -16,34 +16,47 @@
...
@@ -16,34 +16,47 @@
#include
"common.hh"
#include
"common.hh"
double
const
tol
=
1e-10
;
double
const
tol
=
1e-10
;
double
const
reg
=
1e-6
;
template
<
int
n
,
bool
lower
>
template
<
int
n
,
bool
lower
>
bool
test
()
{
bool
test
()
{
bool
passed
=
true
;
bool
passed
=
true
;
std
::
random_device
randomDevice
;
std
::
mt19937
generator
(
randomDevice
());
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
M
;
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
M
;
Dune
::
MatrixIndexSet
indices
(
n
,
n
);
Dune
::
MatrixIndexSet
indices
(
n
,
n
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
for
(
size_t
j
=
lower
?
0
:
i
;
j
<
(
lower
?
i
+
1
:
n
);
++
j
)
size_t
initialJ
=
lower
?
0
:
i
;
indices
.
add
(
i
,
j
);
size_t
finalJ
=
lower
?
i
+
1
:
n
;
for
(
size_t
j
=
initialJ
;
j
<
finalJ
;
++
j
)
{
std
::
uniform_int_distribution
<
int
>
integerDistribution
(
1
,
finalJ
-
initialJ
);
auto
aroundTen
=
[
&
]()
{
auto
x
=
integerDistribution
(
generator
);
return
x
<=
10
;
};
// Add a diagonal entry and approximately ten non-zero entries
if
(
i
==
j
or
aroundTen
())
indices
.
add
(
i
,
j
);
}
}
indices
.
exportIdx
(
M
);
indices
.
exportIdx
(
M
);
std
::
random_device
randomDevice
;
std
::
uniform_real_distribution
<>
lowDistribution
(
reg
,
0.4
);
std
::
mt19937
generator
(
randomDevice
());
std
::
uniform_real_distribution
<>
distribution
(
0.1
,
0.4
);
for
(
auto
it
=
M
.
begin
();
it
!=
M
.
end
();
++
it
)
{
for
(
auto
it
=
M
.
begin
();
it
!=
M
.
end
();
++
it
)
{
size_t
const
i
=
it
.
index
();
size_t
const
i
=
it
.
index
();
for
(
auto
cIt
=
it
->
begin
();
cIt
!=
it
->
end
();
++
cIt
)
{
for
(
auto
cIt
=
it
->
begin
();
cIt
!=
it
->
end
();
++
cIt
)
{
size_t
const
j
=
cIt
.
index
();
size_t
const
j
=
cIt
.
index
();
*
cIt
=
d
istribution
(
generator
);
*
cIt
=
lowD
istribution
(
generator
);
if
(
i
==
j
)
if
(
i
==
j
)
*
cIt
+=
0.6
;
*
cIt
+=
0.6
;
}
}
}
}
std
::
uniform_real_distribution
<>
unconstrainedDistribution
(
reg
,
0.4
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
sol
(
n
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
sol
(
n
);
for
(
auto
&
x
:
sol
)
for
(
auto
&
x
:
sol
)
x
=
d
istribution
(
generator
);
x
=
unconstrainedD
istribution
(
generator
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
b
(
n
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
b
(
n
);
M
.
mv
(
sol
,
b
);
M
.
mv
(
sol
,
b
);
...
@@ -72,7 +85,7 @@ bool test() {
...
@@ -72,7 +85,7 @@ bool test() {
int
main
()
{
int
main
()
{
bool
passed
=
true
;
bool
passed
=
true
;
passed
&=
test
<
1
000
,
false
>
();
passed
&=
test
<
5
000
,
false
>
();
passed
&=
test
<
1
000
,
true
>
();
passed
&=
test
<
5
000
,
true
>
();
return
passed
?
0
:
1
;
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