Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
df22a5f4
Commit
df22a5f4
authored
Dec 01, 2017
by
Dennis Gläser
Browse files
[math] introduce vtmv function
projects a vector and calculates the scalar product with a second vector
parent
bc0d8ff6
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/common/math.hh
View file @
df22a5f4
...
...
@@ -618,6 +618,51 @@ Scalar trace(const Dune::DynamicMatrix<Scalar>& M)
return
trace
;
}
/*!
* \brief Evaluates the scalar product of a vector v2, projected by
* a matrix M, with a vector v1.
*
* Note: We use DenseVector and DenseMatrix here so that
* it can be used with the statically and dynamically
* allocated Dune Vectors/Matrices. Size mismatch
* assertions are done in the respective Dune classes.
*
* \param v1 The first vector
* \param M The matrix
* \param v2 The second vector
*/
template
<
class
V1
,
class
MAT
,
class
V2
>
typename
Dune
::
DenseMatrix
<
MAT
>::
value_type
vtmv
(
const
Dune
::
DenseVector
<
V1
>&
v1
,
const
Dune
::
DenseMatrix
<
MAT
>&
M
,
const
Dune
::
DenseVector
<
V2
>&
v2
)
{
auto
tmp
(
v2
);
M
.
mv
(
v2
,
tmp
);
return
v1
*
tmp
;
}
/*!
* \brief Evaluates the scalar product of a vector v2, scaled by
* a scalar m, with a vector v1.
*
* Note: We use DenseVector and DenseMatrix here so that
* it can be used with the statically and dynamically
* allocated Dune Vectors/Matrices. Size mismatch
* assertions are done in the respective Dune classes.
*
* \param v1 The first vector
* \param m The scale factor
* \param v2 The second vector
*/
template
<
class
V1
,
class
FieldScalar
,
class
V2
>
FieldScalar
vtmv
(
const
Dune
::
DenseVector
<
V1
>&
v1
,
const
FieldScalar
m
,
const
Dune
::
DenseVector
<
V2
>&
v2
)
{
return
m
*
(
v1
*
v2
);
}
}
// end namespace Dumux
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment