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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
apminaei
dune-matrix-vector
Commits
5ced4fff
Commit
5ced4fff
authored
7 years ago
by
Max Kahnt
Browse files
Options
Downloads
Patches
Plain Diff
Refactorization:
- smoothen docu - name helper struct - add implementation namespace
parent
7eefb642
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/matrix-vector/genericvectortools.hh
+23
-13
23 additions, 13 deletions
dune/matrix-vector/genericvectortools.hh
with
23 additions
and
13 deletions
dune/matrix-vector/genericvectortools.hh
+
23
−
13
View file @
5ced4fff
#ifndef DUNE_MATRIX_VECTOR_GENERICVECTORTOOLS_HH
#
ifndef
DUNE_MATRIX_VECTOR_GENERICVECTORTOOLS_HH
#define DUNE_MATRIX_VECTOR_GENERICVECTORTOOLS_HH
/** \file
\brief Various tools for working with istl vectors of arbitrary nesting depth
*/
*
\brief Various tools for working with istl vectors of arbitrary nesting depth
*/
#include
<iostream>
#include
<dune/common/fvector.hh>
#include
<dune/common/hybridutilities.hh>
#include
<dune/matrix-vector/algorithm.hh>
#include
<iostream>
#include
<dune/matrix-vector/algorithm.hh>
/** \brief Various tools for working with istl vectors of arbitrary nesting depth
*/
//! \brief Various tools for working with istl vectors of arbitrary nesting depth
namespace
Dune
{
namespace
MatrixVector
{
namespace
Generic
{
// TODO change namespace name
// forward declaration for helper struct
namespace
Impl
{
template
<
class
Vector
,
typename
Enable
=
void
>
struct
Helper
;
struct
ScalarSwitch
;
}
// end namespace Impl
//! Write vector to given stream
template
<
class
Vector
>
void
writeBinary
(
std
::
ostream
&
s
,
const
Vector
&
v
)
{
Helper
<
Vector
>::
writeBinary
(
s
,
v
);
Impl
::
ScalarSwitch
<
Vector
>::
writeBinary
(
s
,
v
);
}
//! Read vector from given stream
template
<
class
Vector
>
void
readBinary
(
std
::
istream
&
s
,
Vector
&
v
)
{
Helper
<
Vector
>::
readBinary
(
s
,
v
);
Impl
::
ScalarSwitch
<
Vector
>::
readBinary
(
s
,
v
);
}
//! Truncate vector by given bit set
template
<
class
Vector
,
class
BitVector
>
void
truncate
(
Vector
&
v
,
const
BitVector
&
tr
)
{
Helper
<
Vector
>::
truncate
(
v
,
tr
);
Impl
::
ScalarSwitch
<
Vector
>::
truncate
(
v
,
tr
);
}
namespace
Impl
{
//! recursion helper for scalars nested in iterables (vectors)
template
<
class
Vector
>
struct
Helper
<
Vector
,
typename
std
::
enable_if_t
<
not
IsNumber
<
Vector
>::
value
>>
{
struct
ScalarSwitch
<
Vector
,
typename
std
::
enable_if_t
<
not
IsNumber
<
Vector
>::
value
>>
{
using
This
=
ScalarSwitch
<
Vector
>
;
static
void
writeBinary
(
std
::
ostream
&
s
,
const
Vector
&
v
)
{
Hybrid
::
forEach
(
v
,
[
&
s
](
auto
&&
vi
)
{
Generic
::
writeBinary
(
s
,
vi
);
});
}
...
...
@@ -58,7 +65,8 @@ struct Helper<Vector, typename std::enable_if_t<not IsNumber<Vector>::value>> {
//! recursion anchors for scalars
template
<
class
Scalar
>
struct
Helper
<
Scalar
,
typename
std
::
enable_if_t
<
IsNumber
<
Scalar
>::
value
>>
{
struct
ScalarSwitch
<
Scalar
,
typename
std
::
enable_if_t
<
IsNumber
<
Scalar
>::
value
>>
{
static
void
writeBinary
(
std
::
ostream
&
s
,
const
Scalar
&
v
)
{
s
.
write
(
reinterpret_cast
<
const
char
*>
(
&
v
),
sizeof
(
Scalar
));
}
...
...
@@ -75,6 +83,8 @@ struct Helper<Scalar, typename std::enable_if_t<IsNumber<Scalar>::value>> {
}
};
}
// end namespace Impl
}
// end namespace Generic
}
// end namespace MatrixVector
}
// end namespace Dune
...
...
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