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
3004176d
Commit
3004176d
authored
8 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Incorporate *Axy from Arithmetic
parent
22a8e39e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/matrix-vector/CMakeLists.txt
+1
-0
1 addition, 0 deletions
dune/matrix-vector/CMakeLists.txt
dune/matrix-vector/axy.hh
+108
-0
108 additions, 0 deletions
dune/matrix-vector/axy.hh
with
109 additions
and
0 deletions
dune/matrix-vector/CMakeLists.txt
+
1
−
0
View file @
3004176d
...
...
@@ -2,6 +2,7 @@
install
(
FILES
addtodiagonal.hh
axpy.hh
axy.hh
componentwisematrixmap.hh
crossproduct.hh
genericvectortools.hh
...
...
This diff is collapsed.
Click to expand it.
dune/matrix-vector/axy.hh
0 → 100644
+
108
−
0
View file @
3004176d
#ifndef DUNE_MATRIX_VECTOR_AXY_HH
#define DUNE_MATRIX_VECTOR_AXY_HH
#include
<cassert>
#include
"axpy.hh"
#include
"matrixtraits.hh"
namespace
Dune
{
namespace
MatrixVector
{
/** \brief Internal helper class for Matrix operations
*
*/
template
<
class
OperatorType
,
bool
isMatrix
>
struct
OperatorHelper
{
template
<
class
VectorType
,
class
VectorType2
>
static
typename
VectorType
::
field_type
Axy
(
const
OperatorType
&
A
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
VectorType2
tmp
=
y
;
tmp
=
0
;
addProduct
(
tmp
,
A
,
x
);
return
tmp
*
y
;
}
template
<
class
VectorType
,
class
VectorType2
>
static
typename
VectorType
::
field_type
bmAxy
(
const
OperatorType
&
A
,
const
VectorType2
&
b
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
VectorType2
tmp
=
b
;
subtractProduct
(
tmp
,
A
,
x
);
return
tmp
*
y
;
}
};
template
<
class
MatrixType
>
struct
OperatorHelper
<
MatrixType
,
true
>
{
template
<
class
VectorType
,
class
VectorType2
>
static
typename
VectorType
::
field_type
Axy
(
const
MatrixType
&
A
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
assert
(
x
.
N
()
==
A
.
M
());
assert
(
y
.
N
()
==
A
.
N
());
typename
VectorType
::
field_type
outer
=
0.0
;
typename
VectorType2
::
block_type
inner
;
typename
MatrixType
::
ConstIterator
endi
=
A
.
end
();
for
(
typename
MatrixType
::
ConstIterator
i
=
A
.
begin
();
i
!=
endi
;
++
i
)
{
inner
=
0.0
;
const
size_t
iindex
=
i
.
index
();
typename
MatrixType
::
row_type
::
ConstIterator
endj
=
i
->
end
();
for
(
typename
MatrixType
::
row_type
::
ConstIterator
j
=
i
->
begin
();
j
!=
endj
;
++
j
)
addProduct
(
inner
,
*
j
,
x
[
j
.
index
()]);
outer
+=
inner
*
y
[
iindex
];
}
return
outer
;
}
template
<
class
VectorType
,
class
VectorType2
>
static
typename
VectorType
::
field_type
bmAxy
(
const
MatrixType
&
A
,
const
VectorType2
&
b
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
assert
(
x
.
N
()
==
A
.
M
());
assert
(
y
.
N
()
==
A
.
N
());
assert
(
y
.
N
()
==
b
.
N
());
typename
VectorType
::
field_type
outer
=
0.0
;
typename
VectorType2
::
block_type
inner
;
typename
MatrixType
::
ConstIterator
endi
=
A
.
end
();
for
(
typename
MatrixType
::
ConstIterator
i
=
A
.
begin
();
i
!=
endi
;
++
i
)
{
const
size_t
iindex
=
i
.
index
();
inner
=
b
[
iindex
];
typename
MatrixType
::
row_type
::
ConstIterator
endj
=
i
->
end
();
for
(
typename
MatrixType
::
row_type
::
ConstIterator
j
=
i
->
begin
();
j
!=
endj
;
++
j
)
subtractProduct
(
inner
,
*
j
,
x
[
j
.
index
()]);
outer
+=
inner
*
y
[
iindex
];
}
return
outer
;
}
};
//! Compute \f$(Ax,y)\f$
template
<
class
OperatorType
,
class
VectorType
,
class
VectorType2
>
typename
VectorType
::
field_type
Axy
(
const
OperatorType
&
A
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
return
OperatorHelper
<
OperatorType
,
MatrixTraits
<
OperatorType
>::
isMatrix
>::
Axy
(
A
,
x
,
y
);
}
//! Compute \f$(b-Ax,y)\f$
template
<
class
OperatorType
,
class
VectorType
,
class
VectorType2
>
typename
VectorType
::
field_type
bmAxy
(
const
OperatorType
&
A
,
const
VectorType2
&
b
,
const
VectorType
&
x
,
const
VectorType2
&
y
)
{
return
OperatorHelper
<
OperatorType
,
MatrixTraits
<
OperatorType
>::
isMatrix
>::
bmAxy
(
A
,
b
,
x
,
y
);
}
}
}
#endif
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