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
c8a41d3b
Commit
c8a41d3b
authored
8 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Cleanup
Whitespace, typedefs, remove #undef left over from debugging
parent
4b984142
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
+21
-15
21 additions, 15 deletions
dune/matrix-vector/test/triangularsolvetest.cc
with
21 additions
and
15 deletions
dune/matrix-vector/test/triangularsolvetest.cc
+
21
−
15
View file @
c8a41d3b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
#include
"config.h"
#include
"config.h"
#endif
#endif
#undef NDEBUG
#include
<dune/common/bitsetvector.hh>
#include
<dune/common/bitsetvector.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/fvector.hh>
...
@@ -21,17 +19,25 @@ double const reg = 1e-6;
...
@@ -21,17 +19,25 @@ double const reg = 1e-6;
template
<
int
n
,
bool
lower
>
template
<
int
n
,
bool
lower
>
bool
test
()
{
bool
test
()
{
using
ft
=
double
;
using
LocalMatrix
=
Dune
::
FieldMatrix
<
ft
,
1
,
1
>
;
using
Matrix
=
Dune
::
BCRSMatrix
<
LocalMatrix
>
;
using
LocalVector
=
Dune
::
FieldVector
<
ft
,
1
>
;
using
Vector
=
Dune
::
BlockVector
<
LocalVector
>
;
bool
passed
=
true
;
bool
passed
=
true
;
std
::
random_device
randomDevice
;
std
::
random_device
randomDevice
;
std
::
mt19937
generator
(
randomDevice
());
std
::
mt19937
generator
(
randomDevice
());
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
M
;
Matrix
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
)
{
size_t
initialJ
=
lower
?
0
:
i
;
size_t
initialJ
=
lower
?
0
:
i
;
size_t
finalJ
=
lower
?
i
+
1
:
n
;
size_t
finalJ
=
lower
?
i
+
1
:
n
;
for
(
size_t
j
=
initialJ
;
j
<
finalJ
;
++
j
)
{
for
(
size_t
j
=
initialJ
;
j
<
finalJ
;
++
j
)
{
std
::
uniform_int_distribution
<
int
>
integerDistribution
(
1
,
finalJ
-
initialJ
);
std
::
uniform_int_distribution
<
int
>
integerDistribution
(
1
,
finalJ
-
initialJ
);
auto
aroundTen
=
[
&
]()
{
auto
aroundTen
=
[
&
]()
{
auto
x
=
integerDistribution
(
generator
);
auto
x
=
integerDistribution
(
generator
);
return
x
<=
10
;
return
x
<=
10
;
...
@@ -43,7 +49,7 @@ bool test() {
...
@@ -43,7 +49,7 @@ bool test() {
}
}
indices
.
exportIdx
(
M
);
indices
.
exportIdx
(
M
);
std
::
uniform_real_distribution
<>
unconstrainedDistribution
(
-
1
,
1
);
std
::
uniform_real_distribution
<
ft
>
unconstrainedDistribution
(
-
1
,
1
);
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
)
{
...
@@ -55,17 +61,17 @@ bool test() {
...
@@ -55,17 +61,17 @@ bool test() {
}
}
}
}
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
sol
(
n
);
Vector
sol
(
n
);
for
(
auto
&
x
:
sol
)
for
(
auto
&
x
:
sol
)
x
=
unconstrainedDistribution
(
generator
);
x
=
unconstrainedDistribution
(
generator
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
b
(
n
);
Vector
b
(
n
);
M
.
mv
(
sol
,
b
);
M
.
mv
(
sol
,
b
);
Dune
::
BitSetVector
<
1
>
*
ignore
=
nullptr
;
Dune
::
BitSetVector
<
1
>
*
ignore
=
nullptr
;
{
{
auto
x
=
lower
?
Dune
::
MatrixVector
::
lowerTriangularSolve
(
M
,
b
,
ignore
)
auto
x
=
lower
?
Dune
::
MatrixVector
::
lowerTriangularSolve
(
M
,
b
,
ignore
)
:
Dune
::
MatrixVector
::
upperTriangularSolve
(
M
,
b
,
ignore
);
:
Dune
::
MatrixVector
::
upperTriangularSolve
(
M
,
b
,
ignore
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
Vector
y
(
n
);
M
.
mv
(
x
,
y
);
M
.
mv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"|x - A^{-1}b| = "
<<
diff
<<
std
::
endl
;
std
::
cout
<<
"|x - A^{-1}b| = "
<<
diff
<<
std
::
endl
;
...
@@ -75,19 +81,19 @@ bool test() {
...
@@ -75,19 +81,19 @@ bool test() {
auto
x
=
lower
auto
x
=
lower
?
Dune
::
MatrixVector
::
upperTriangularSolve
(
M
,
b
,
ignore
,
true
)
?
Dune
::
MatrixVector
::
upperTriangularSolve
(
M
,
b
,
ignore
,
true
)
:
Dune
::
MatrixVector
::
lowerTriangularSolve
(
M
,
b
,
ignore
,
true
);
:
Dune
::
MatrixVector
::
lowerTriangularSolve
(
M
,
b
,
ignore
,
true
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
Vector
y
(
n
);
M
.
mtv
(
x
,
y
);
M
.
mtv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
" (manual transpose)"
<<
std
::
endl
;
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
" (manual transpose)"
<<
std
::
endl
;
passed
&=
diff
<
tol
;
passed
&=
diff
<
tol
;
}
}
{
{
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>>
Mt
;
Matrix
Mt
;
Dune
::
MatrixVector
::
transpose
(
M
,
Mt
);
Dune
::
MatrixVector
::
transpose
(
M
,
Mt
);
auto
x
=
lower
auto
x
=
lower
?
Dune
::
MatrixVector
::
upperTriangularSolve
(
Mt
,
b
,
ignore
)
?
Dune
::
MatrixVector
::
upperTriangularSolve
(
Mt
,
b
,
ignore
)
:
Dune
::
MatrixVector
::
lowerTriangularSolve
(
Mt
,
b
,
ignore
);
:
Dune
::
MatrixVector
::
lowerTriangularSolve
(
Mt
,
b
,
ignore
);
Vector
y
(
n
);
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>>
y
(
n
);
M
.
mtv
(
x
,
y
);
M
.
mtv
(
x
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
auto
diff
=
diffDune
(
b
,
y
);
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
std
::
endl
;
std
::
cout
<<
"|x - A^{-T}b| = "
<<
diff
<<
std
::
endl
;
...
...
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