Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Core Modules
dune-common
Commits
ceb58ec2
Commit
ceb58ec2
authored
16 years ago
by
Christian Engwer
Browse files
Options
Downloads
Patches
Plain Diff
add methods to multiply FieldMatrizes of different size
[[Imported from SVN: r5431]]
parent
9db6b67a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/fmatrix.hh
+33
-0
33 additions, 0 deletions
common/fmatrix.hh
common/test/fmatrixtest.cc
+3
-0
3 additions, 0 deletions
common/test/fmatrixtest.cc
with
36 additions
and
0 deletions
common/fmatrix.hh
+
33
−
0
View file @
ceb58ec2
...
...
@@ -284,6 +284,7 @@ namespace Dune {
void
mv
(
const
X
&
x
,
Y
&
y
)
const
{
#ifdef DUNE_FMatrix_WITH_CHECKING
assert
(
&
x
!=
&
y
);
if
(
x
.
N
()
!=
M
())
DUNE_THROW
(
FMatrixError
,
"index out of range"
);
if
(
y
.
N
()
!=
N
())
DUNE_THROW
(
FMatrixError
,
"index out of range"
);
#endif
...
...
@@ -485,6 +486,22 @@ namespace Dune {
return
*
this
;
}
//! Multiplies M from the left to this matrix, this matrix is not modified
template
<
int
l
>
FieldMatrix
<
K
,
l
,
m
>
leftmultiplyany
(
const
FieldMatrix
<
K
,
l
,
n
>&
M
)
{
FieldMatrix
<
K
,
l
,
m
>
C
;
for
(
size_type
i
=
0
;
i
<
l
;
i
++
)
{
for
(
size_type
j
=
0
;
j
<
m
;
j
++
)
{
C
[
i
][
j
]
=
0
;
for
(
size_type
k
=
0
;
k
<
n
;
k
++
)
C
[
i
][
j
]
+=
M
[
i
][
k
]
*
(
*
this
)[
k
][
j
];
}
}
return
C
;
}
//! Multiplies M from the right to this matrix
FieldMatrix
&
rightmultiply
(
const
FieldMatrix
<
K
,
m
,
m
>&
M
)
{
...
...
@@ -499,6 +516,22 @@ namespace Dune {
return
*
this
;
}
//! Multiplies M from the right to this matrix, this matrix is not modified
template
<
int
l
>
FieldMatrix
<
K
,
n
,
l
>
rightmultiplyany
(
const
FieldMatrix
<
K
,
m
,
l
>&
M
)
{
FieldMatrix
<
K
,
n
,
l
>
C
;
for
(
size_type
i
=
0
;
i
<
n
;
i
++
)
{
for
(
size_type
j
=
0
;
j
<
l
;
j
++
)
{
C
[
i
][
j
]
=
0
;
for
(
size_type
k
=
0
;
k
<
m
;
k
++
)
C
[
i
][
j
]
+=
(
*
this
)[
i
][
k
]
*
M
[
k
][
j
];
}
}
return
C
;
}
//===== sizes
...
...
This diff is collapsed.
Click to expand it.
common/test/fmatrixtest.cc
+
3
−
0
View file @
ceb58ec2
...
...
@@ -228,6 +228,9 @@ int main()
test_matrix
<
double
,
1
,
1
>
();
test_matrix
<
int
,
10
,
5
>
();
test_matrix
<
double
,
5
,
10
>
();
Dune
::
FieldMatrix
<
double
,
34
,
34
>
A
(
1e-15
);
for
(
int
i
=
0
;
i
<
34
;
i
++
)
A
[
i
][
i
]
=
1
;
A
.
invert
();
return
test_invert_solve
();
}
catch
(
Dune
::
Exception
&
e
)
...
...
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