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
0e1afee4
There was a problem fetching the pipeline summary.
Commit
0e1afee4
authored
9 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Add (lower|upper)TriangularSolve
parent
3dee0543
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/common/staticmatrixtools.hh
+83
-1
83 additions, 1 deletion
dune/solvers/common/staticmatrixtools.hh
with
83 additions
and
1 deletion
dune/solvers/common/staticmatrixtools.hh
+
83
−
1
View file @
0e1afee4
...
...
@@ -3,6 +3,8 @@
#ifndef STATIC_MATRIX_TOOL_HH
#define STATIC_MATRIX_TOOL_HH
#include
<cassert>
#include
"dune/common/diagonalmatrix.hh"
#include
"dune/common/fmatrix.hh"
#include
"dune/istl/scaledidmatrix.hh"
...
...
@@ -458,7 +460,87 @@ class StaticMatrix
}
}
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
void
lowerTriangularSolve
(
Matrix
const
&
A
,
Vector
const
&
b
,
Vector
&
x
,
BitVector
const
*
ignore
,
bool
transpose
=
false
)
{
static_assert
(
Matrix
::
block_type
::
rows
==
1
and
Matrix
::
block_type
::
cols
==
1
,
"Only implemented for scalar problems"
);
x
=
0
;
Vector
r
=
b
;
if
(
transpose
)
{
for
(
auto
it
=
A
.
begin
();
it
!=
A
.
end
();
++
it
)
{
const
size_t
i
=
it
.
index
();
if
(
ignore
!=
nullptr
and
(
*
ignore
)[
i
].
all
())
continue
;
auto
cIt
=
it
->
begin
();
assert
(
cIt
.
index
()
==
it
.
index
());
x
[
i
]
=
r
[
i
]
/
*
cIt
;
for
(;
cIt
!=
it
->
end
();
++
cIt
)
{
const
size_t
j
=
cIt
.
index
();
r
[
j
]
-=
x
[
i
]
*
*
cIt
;
}
}
}
else
{
for
(
auto
it
=
A
.
begin
();
it
!=
A
.
end
();
++
it
)
{
const
size_t
i
=
it
.
index
();
if
(
ignore
!=
nullptr
and
(
*
ignore
)[
i
].
all
())
continue
;
for
(
auto
cIt
=
it
->
begin
();
cIt
!=
it
->
end
();
++
cIt
)
{
const
size_t
j
=
cIt
.
index
();
if
(
i
==
j
)
{
x
[
i
]
=
r
[
i
]
/
*
cIt
;
break
;
}
assert
(
j
<
i
);
r
[
i
]
-=
*
cIt
*
x
[
j
];
}
}
}
}
template
<
class
Matrix
,
class
Vector
,
class
BitVector
>
static
void
upperTriangularSolve
(
Matrix
const
&
U
,
Vector
const
&
b
,
Vector
&
x
,
BitVector
const
*
ignore
,
bool
transpose
=
false
)
{
static_assert
(
Matrix
::
block_type
::
rows
==
1
and
Matrix
::
block_type
::
cols
==
1
,
"Only implemented for scalar problems"
);
x
=
0
;
Vector
r
=
b
;
if
(
transpose
)
{
for
(
auto
it
=
U
.
beforeEnd
();
it
!=
U
.
beforeBegin
();
--
it
)
{
const
size_t
i
=
it
.
index
();
if
(
ignore
!=
nullptr
and
(
*
ignore
)[
i
].
all
())
continue
;
auto
cIt
=
it
->
beforeEnd
();
assert
(
cIt
.
index
()
==
i
);
x
[
i
]
=
r
[
i
]
/
*
cIt
;
cIt
--
;
for
(;
cIt
!=
it
->
beforeBegin
();
--
cIt
)
{
const
size_t
j
=
cIt
.
index
();
assert
(
j
<
i
);
r
[
j
]
-=
*
cIt
*
x
[
i
];
}
}
}
else
{
for
(
auto
it
=
U
.
beforeEnd
();
it
!=
U
.
beforeBegin
();
--
it
)
{
const
size_t
i
=
it
.
index
();
if
(
ignore
!=
nullptr
and
(
*
ignore
)[
i
].
all
())
continue
;
auto
cIt
=
it
->
begin
();
assert
(
cIt
.
index
()
==
i
);
auto
diagonal
=
*
cIt
;
cIt
++
;
for
(;
cIt
!=
it
->
end
();
++
cIt
)
{
const
size_t
j
=
cIt
.
index
();
r
[
i
]
-=
*
cIt
*
x
[
j
];
}
x
[
i
]
=
r
[
i
]
/
diagonal
;
}
}
}
};
#endif
This diff is collapsed.
Click to expand it.
pipping
@pipping
mentioned in commit
52e9a7e1
·
9 years ago
mentioned in commit
52e9a7e1
mentioned in commit 52e9a7e1ed88bcb9d3403da9a0a7e8085eb43c05
Toggle commit list
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