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
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
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
Ansgar Burchardt
dune-matrix-vector
Commits
934703a2
Commit
934703a2
authored
8 years ago
by
Max Kahnt
Browse files
Options
Downloads
Patches
Plain Diff
Fix docu. Add convenience methods.
parent
f5fb67d1
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/triangularsolve.hh
+44
-4
44 additions, 4 deletions
dune/matrix-vector/triangularsolve.hh
with
44 additions
and
4 deletions
dune/matrix-vector/triangularsolve.hh
+
44
−
4
View file @
934703a2
...
...
@@ -6,8 +6,19 @@ namespace MatrixVector {
/**
* \brief Solves L*x=b where L is a lower triangular matrix.
* \param x Solution vector. Make sure the ignored nodes are set
* correctly because their respective values for x as passed to
* this method may affect other lines.
* \param ignore Tags the lines of the system where x shall not be
* computed. Note that ignored nodes might still influence the
* solution of other lines if not set to zero.
* \param transpose Set true if L is passed as an upper triangular matrix.
*/
// Note: The current assert makes sure we actually deal with triangular
// matrices. It might be favorable to support matrices as well
// where other entries are not required to be non-existent, e.g.
// if one has a in-place decomposition and does not want to
// reimplement the iterators.
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
void
lowerTriangularSolve
(
Matrix
const
&
L
,
Vector
b
,
Vector
&
x
,
BitVector
const
*
ignore
,
...
...
@@ -23,6 +34,8 @@ namespace MatrixVector {
for
(;
cIt
!=
it
->
end
();
++
cIt
)
{
const
size_t
j
=
cIt
.
index
();
assert
(
j
>
i
);
// Note: We could drop the check for ignore nodes here bcs. b[j] will
// be ignored anyway due to the check above.
if
(
ignore
==
nullptr
or
(
*
ignore
)[
j
].
none
())
b
[
j
]
-=
x
[
i
]
*
*
cIt
;
}
...
...
@@ -46,9 +59,21 @@ namespace MatrixVector {
}
}
/**
* \brief Same as lowerTriangularSolve. Ignored nodes are set to 0.
*/
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
Vector
lowerTriangularSolve
(
Matrix
const
&
L
,
Vector
b
,
BitVector
const
*
ignore
,
bool
transpose
=
false
)
{
Vector
x
=
0
;
lowerTriangularSolve
(
L
,
std
::
move
(
b
),
x
,
ignore
,
transpose
);
return
x
;
}
/**
* \brief Solves U*x=b where U is an upper triangular matrix.
*
\param transpose Set true if U is passed as a
lower
t
riangular
matrix
.
*
See @
lower
T
riangular
Solve for details
.
*/
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
void
upperTriangularSolve
(
Matrix
const
&
U
,
Vector
b
,
Vector
&
x
,
...
...
@@ -65,6 +90,8 @@ namespace MatrixVector {
for
(;
cIt
!=
it
->
beforeBegin
();
--
cIt
)
{
const
size_t
j
=
cIt
.
index
();
assert
(
j
<
i
);
// Note: We could drop the check for ignore nodes here bcs. b[j] will
// be ignored anyway due to the check above.
if
(
ignore
==
nullptr
or
(
*
ignore
)[
j
].
none
())
b
[
j
]
-=
*
cIt
*
x
[
i
];
}
...
...
@@ -85,7 +112,20 @@ namespace MatrixVector {
}
}
}
}
}
#endif
/**
* \brief Same as upperTriangularSolve. Ignored nodes are set to 0.
*/
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
Vector
upperTriangularSolve
(
Matrix
const
&
U
,
Vector
b
,
BitVector
const
*
ignore
,
bool
transpose
=
false
)
{
Vector
x
=
0
;
upperTriangularSolve
(
U
,
std
::
move
(
b
),
x
,
ignore
,
transpose
);
return
x
;
}
}
// end namespace MatrixVector
}
// end namespace Dune
#endif // DUNE_MATRIX_VECTOR_TRIANGULARSOLVE_HH
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