Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-solvers
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
Show more breadcrumbs
agnumpde
dune-solvers
Commits
bce95bfd
Commit
bce95bfd
authored
13 years ago
by
Uli Sack
Committed by
usack
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
updated sumoperatortest to latest changes in SumOperator
[[Imported from SVN: r5484]]
parent
370d0b0d
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/solvers/test/sumoperatortest.cc
+43
-13
43 additions, 13 deletions
dune/solvers/test/sumoperatortest.cc
with
43 additions
and
13 deletions
dune/solvers/test/sumoperatortest.cc
+
43
−
13
View file @
bce95bfd
...
...
@@ -9,6 +9,7 @@
#include
<dune/istl/bvector.hh>
#include
<dune/istl/matrix.hh>
#include
<dune/istl/matrixindexset.hh>
#include
<dune/istl/diagonalmatrix.hh>
#include
<dune/istl/scaledidmatrix.hh>
#include
<dune/istl/io.hh>
...
...
@@ -24,24 +25,28 @@ bool check()
{
bool
passed
=
true
;
typedef
LowRankOperator
<
LowRankFactorType
>
LowRankMatrixType
;
typedef
typename
SparseMatrixType
::
block_type
sp_block_type
;
typedef
typename
LowRankFactorType
::
block_type
lr_block_type
;
size_t
block_size
=
sp_block_type
::
rows
;
assert
(
block_size
==
lr_block_type
::
rows
);
size_t
m
=
1
,
n
=
2
;
size_t
m
=
3
,
n
=
10
;
typedef
Dune
::
FieldVector
<
typename
sp_block_type
::
field_type
,
sp_block_type
::
rows
>
Vblock_type
;
typedef
Dune
::
BlockVector
<
Vblock_type
>
Vector
;
Vector
x
(
n
),
b
(
n
),
ref_vec
(
n
);
Vector
x
(
n
),
b
(
n
),
c
(
n
),
ref_vec
(
n
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
// x[i] = 1.0;
x
[
i
]
=
(
1.0
*
rand
())
/
RAND_MAX
;
b
=
ref_vec
=
0.0
;
b
=
c
=
ref_vec
=
0.0
;
SumOperator
<
SparseMatrixType
,
LowRankMatrixType
>
sum_op_default
;
LowRankFactorType
lr_factor
(
m
,
n
);
SparseMatrixType
sparse_matrix
(
n
,
n
,
4
,
SparseMatrixType
::
row_wise
);
SparseMatrixType
sparse_matrix
(
n
,
n
,
3
*
n
,
SparseMatrixType
::
row_wise
);
// create sparse Matrix as tridiagonal matrix
typedef
typename
SparseMatrixType
::
CreateIterator
Iter
;
...
...
@@ -57,15 +62,25 @@ bool check()
}
// Now the sparsity pattern is fully set up and we can add values
double
entry
=
0.0
;
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
if
(
i
>
0
)
sparse_matrix
[
i
][
i
-
1
]
=
(
1.0
*
rand
())
/
RAND_MAX
;
sparse_matrix
[
i
][
i
]
=
(
1.0
*
rand
())
/
RAND_MAX
;
{
entry
=
(
1.0
*
rand
())
/
RAND_MAX
;
sparse_matrix
[
i
][
i
-
1
]
=
entry
;
}
entry
=
(
1.0
*
rand
())
/
RAND_MAX
;
sparse_matrix
[
i
][
i
]
=
entry
;
if
(
i
<
n
-
1
)
sparse_matrix
[
i
][
i
+
1
]
=
(
1.0
*
rand
())
/
RAND_MAX
;
{
entry
=
(
1.0
*
rand
())
/
RAND_MAX
;
sparse_matrix
[
i
][
i
+
1
]
=
entry
;
}
}
sum_op_default
.
sparseMatrix
()
=
sparse_matrix
;
// set lowrankfactor to random values
typedef
typename
lr_block_type
::
RowIterator
BlockRowIterator
;
typedef
typename
lr_block_type
::
ColIterator
BlockColIterator
;
...
...
@@ -82,7 +97,9 @@ bool check()
}
}
LowRankOperator
<
LowRankFactorType
>
lr_op
(
lr_factor
);
sum_op_default
.
lowRankMatrix
().
lowRankFactor
()
=
lr_factor
;
LowRankMatrixType
lr_op
(
lr_factor
);
std
::
cout
<<
"Checking SumOperator<"
<<
Dune
::
className
(
sparse_matrix
)
<<
", "
<<
Dune
::
className
(
lr_op
)
<<
" > ... "
;
...
...
@@ -93,8 +110,9 @@ bool check()
sparse_matrix
.
umv
(
x
,
ref_vec
);
sum_op
.
umv
(
x
,
b
);
sum_op_default
.
umv
(
x
,
c
);
for
(
size_t
i
=
0
;
i
<
b
.
size
();
++
i
)
if
((
b
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-1
5
)
if
((
b
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-1
2
or
(
c
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-12
)
{
std
::
cout
<<
"SumOperator::umv does not yield correct result."
<<
std
::
endl
;
passed
=
false
;
...
...
@@ -104,19 +122,31 @@ bool check()
break
;
}
b
=
1.0
;
c
=
b
=
1.0
;
sum_op
.
mv
(
x
,
b
);
sum_op_default
.
mv
(
x
,
c
);
for
(
size_t
i
=
0
;
i
<
b
.
size
();
++
i
)
if
((
b
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-1
5
)
if
((
b
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-1
2
or
(
c
[
i
]
-
ref_vec
[
i
]).
two_norm
()
>
1e-12
)
{
std
::
cout
<<
"SumOperator::mv does not yield correct result."
<<
std
::
endl
;
passed
=
false
;
break
;
}
LowRankOperator
<
LowRankFactorType
>
lr_factor_reborn
=
sum_op
.
getLowRankMatrix
();
SparseMatrixType
sparse_matrix_reborn
=
sum_op
.
getSparseMatrix
();
sum_op
.
mmv
(
x
,
b
);
sum_op_default
.
mmv
(
x
,
c
);
for
(
size_t
i
=
0
;
i
<
b
.
size
();
++
i
)
if
(
b
[
i
].
two_norm
()
>
1e-12
or
c
[
i
].
two_norm
()
>
1e-12
)
{
std
::
cout
<<
"SumOperator::mmv does not yield correct result."
<<
std
::
endl
;
passed
=
false
;
break
;
}
LowRankOperator
<
LowRankFactorType
>
lr_factor_reborn
=
sum_op
.
lowRankMatrix
();
SparseMatrixType
sparse_matrix_reborn
=
sum_op
.
sparseMatrix
();
if
(
passed
)
std
::
cout
<<
"passed"
;
...
...
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