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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Timo Koch
dune-common
Commits
10a73b53
Commit
10a73b53
authored
13 years ago
by
Andreas Dedner
Browse files
Options
Downloads
Patches
Plain Diff
make some vector/matrix operations with template argument (FS954)
[[Imported from SVN: r6534]]
parent
5b4e08ac
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
dune/common/densematrix.hh
+10
-5
10 additions, 5 deletions
dune/common/densematrix.hh
dune/common/densevector.hh
+16
-8
16 additions, 8 deletions
dune/common/densevector.hh
with
26 additions
and
13 deletions
dune/common/densematrix.hh
+
10
−
5
View file @
10a73b53
...
...
@@ -297,7 +297,8 @@ namespace Dune
//===== vector space arithmetic
//! vector space addition
DenseMatrix
&
operator
+=
(
const
DenseMatrix
&
y
)
template
<
class
Other
>
DenseMatrix
&
operator
+=
(
const
DenseMatrix
<
Other
>&
y
)
{
for
(
size_type
i
=
0
;
i
<
rows
();
i
++
)
(
*
this
)[
i
]
+=
y
[
i
];
...
...
@@ -305,7 +306,8 @@ namespace Dune
}
//! vector space subtraction
DenseMatrix
&
operator
-=
(
const
DenseMatrix
&
y
)
template
<
class
Other
>
DenseMatrix
&
operator
-=
(
const
DenseMatrix
<
Other
>&
y
)
{
for
(
size_type
i
=
0
;
i
<
rows
();
i
++
)
(
*
this
)[
i
]
-=
y
[
i
];
...
...
@@ -329,7 +331,8 @@ namespace Dune
}
//! vector space axpy operation (*this += k y)
DenseMatrix
&
axpy
(
const
field_type
&
k
,
const
DenseMatrix
&
y
)
template
<
class
Other
>
DenseMatrix
&
axpy
(
const
field_type
&
k
,
const
DenseMatrix
<
Other
>
&
y
)
{
for
(
size_type
i
=
0
;
i
<
rows
();
++
i
)
(
*
this
)[
i
].
axpy
(
k
,
y
[
i
]
);
...
...
@@ -337,7 +340,8 @@ namespace Dune
}
//! Binary matrix comparison
bool
operator
==
(
const
DenseMatrix
&
y
)
const
template
<
class
Other
>
bool
operator
==
(
const
DenseMatrix
<
Other
>&
y
)
const
{
for
(
size_type
i
=
0
;
i
<
rows
();
i
++
)
if
((
*
this
)[
i
]
!=
y
[
i
])
...
...
@@ -345,7 +349,8 @@ namespace Dune
return
true
;
}
//! Binary matrix incomparison
bool
operator
!=
(
const
DenseMatrix
&
y
)
const
template
<
class
Other
>
bool
operator
!=
(
const
DenseMatrix
<
Other
>&
y
)
const
{
return
!
operator
==
(
y
);
}
...
...
This diff is collapsed.
Click to expand it.
dune/common/densevector.hh
+
16
−
8
View file @
10a73b53
...
...
@@ -393,7 +393,8 @@ namespace Dune {
//===== vector space arithmetic
//! vector space addition
derived_type
&
operator
+=
(
const
DenseVector
&
y
)
template
<
class
Other
>
derived_type
&
operator
+=
(
const
DenseVector
<
Other
>&
y
)
{
assert
(
y
.
size
()
==
size
());
for
(
size_type
i
=
0
;
i
<
size
();
i
++
)
...
...
@@ -402,7 +403,8 @@ namespace Dune {
}
//! vector space subtraction
derived_type
&
operator
-=
(
const
DenseVector
&
y
)
template
<
class
Other
>
derived_type
&
operator
-=
(
const
DenseVector
<
Other
>&
y
)
{
assert
(
y
.
size
()
==
size
());
for
(
size_type
i
=
0
;
i
<
size
();
i
++
)
...
...
@@ -411,14 +413,16 @@ namespace Dune {
}
//! Binary vector addition
derived_type
operator
+
(
const
DenseVector
&
b
)
const
template
<
class
Other
>
derived_type
operator
+
(
const
DenseVector
<
Other
>&
b
)
const
{
derived_type
z
=
asImp
();
return
(
z
+=
b
);
}
//! Binary vector subtraction
derived_type
operator
-
(
const
DenseVector
&
b
)
const
template
<
class
Other
>
derived_type
operator
-
(
const
DenseVector
<
Other
>&
b
)
const
{
derived_type
z
=
asImp
();
return
(
z
-=
b
);
...
...
@@ -457,7 +461,8 @@ namespace Dune {
}
//! Binary vector comparison
bool
operator
==
(
const
DenseVector
&
y
)
const
template
<
class
Other
>
bool
operator
==
(
const
DenseVector
<
Other
>&
y
)
const
{
assert
(
y
.
size
()
==
size
());
for
(
size_type
i
=
0
;
i
<
size
();
i
++
)
...
...
@@ -468,14 +473,16 @@ namespace Dune {
}
//! Binary vector incomparison
bool
operator
!=
(
const
DenseVector
&
y
)
const
template
<
class
Other
>
bool
operator
!=
(
const
DenseVector
<
Other
>&
y
)
const
{
return
!
operator
==
(
y
);
}
//! vector space axpy operation ( *this += a y )
derived_type
&
axpy
(
const
value_type
&
a
,
const
DenseVector
&
y
)
template
<
class
Other
>
derived_type
&
axpy
(
const
value_type
&
a
,
const
DenseVector
<
Other
>&
y
)
{
assert
(
y
.
size
()
==
size
());
for
(
size_type
i
=
0
;
i
<
size
();
i
++
)
...
...
@@ -486,7 +493,8 @@ namespace Dune {
//===== Euclidean scalar product
//! scalar product (x^T y)
value_type
operator
*
(
const
DenseVector
&
y
)
const
template
<
class
Other
>
value_type
operator
*
(
const
DenseVector
<
Other
>&
y
)
const
{
assert
(
y
.
size
()
==
size
());
value_type
result
(
0
);
...
...
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