Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
1a88fb4a
Commit
1a88fb4a
authored
5 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
add hybrid size and num_rows/num_cols for vectors and matrices
parent
be9c1a42
Branches
Branches containing commit
No related tags found
1 merge request
!45
Provide access function for vectors and matrices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/amdis/common/HybridSize.hpp
+175
-0
175 additions, 0 deletions
src/amdis/common/HybridSize.hpp
with
175 additions
and
0 deletions
src/amdis/common/HybridSize.hpp
0 → 100644
+
175
−
0
View file @
1a88fb4a
#pragma once
#include
<utility>
#include
<dune/common/indices.hh>
#include
<dune/common/rangeutilities.hh>
#include
<dune/common/typeutilities.hh>
#include
<amdis/common/Access.hpp>
#include
<amdis/common/Concepts.hpp>
#include
<amdis/common/StaticSize.hpp>
namespace
AMDiS
{
namespace
Concepts
{
template
<
class
V
>
using
DynamicVectorAccessible_t
=
VectorAccessible_t
<
V
,
std
::
size_t
>
;
template
<
class
M
>
using
DynamicMatrixAccessible_t
=
bool_t
<
MatrixAccessible_t
<
M
,
std
::
size_t
,
std
::
size_t
>::
value
||
Callable
<
M
,
std
::
size_t
,
std
::
size_t
>>
;
}
// end namespace Concept
#ifdef DOXYGEN
/// \brief Return the size of the vector `vec`.
/**
* If the vector `vec` can be accessed using (dynamic) indices, the function returns the number
* of entries as integer value. Otherwise a `std::integral_constant` is returned.
**/
template
<
class
Vector
>
implementation
-
defined
hybridSize
(
Vector
const
&
vec
);
/// Return either an IntegralRange or a StaticIntegralRange of the indices to
/// access the vector, depending on the type of \ref hybridSize(vec)
template
<
class
Vector
>
implementation
-
defined
hybridElements
(
Vector
const
&
vec
);
/// \brief Return the number of rows of the matrix `mat`.
/**
* If the matrix `mat` can be accessed using (dynamic) indices, the function returns the number
* of rows as integer value. Otherwise a `std::integral_constant` is returned.
**/
template
<
class
Matrix
>
implementation
-
defined
hybridNumRows
(
Matrix
const
&
mat
);
/// Return either an IntegralRange or a StaticIntegralRange of the indices to
/// access the rows of the matrix, depending on the type of \ref hybridNumRows(mat)
template
<
class
Matrix
>
implementation
-
defined
hybridRows
(
Matrix
const
&
mat
);
/// \brief Return the number of columns of the matrix `mat`.
/**
* If the matrix `mat` can be accessed using (dynamic) indices, the function returns the number
* of columns as integer value. Otherwise a `std::integral_constant` is returned.
**/
template
<
class
Matrix
>
implementation
-
defined
hybridNumCols
(
Matrix
const
&
mat
);
/// Return either an IntegralRange or a StaticIntegralRange of the indices to
/// access the columns of the matrix, depending on the type of \ref hybridNumCols(mat)
template
<
class
Matrix
>
implementation
-
defined
hybridCols
(
Matrix
const
&
mat
);
#else
namespace
Impl
{
template
<
class
Vector
,
REQUIRES
(
Concepts
::
DynamicVectorAccessible_t
<
Vector
>
::
value
)
>
auto
hybridSize
(
Vector
const
&
vec
,
Dune
::
PriorityTag
<
3
>
)
->
decltype
(
vec
.
size
())
{
return
vec
.
size
();
}
template
<
class
Vector
,
REQUIRES
(
not
Concepts
::
DynamicVectorAccessible_t
<
Vector
>
::
value
)
>
constexpr
index_t
<
Vector
::
dimension
>
hybridSize
(
Vector
const
&
vec
,
Dune
::
PriorityTag
<
2
>
)
{
return
{};
}
template
<
class
Vector
,
REQUIRES
(
not
Concepts
::
DynamicVectorAccessible_t
<
Vector
>
::
value
)
>
constexpr
Size_t
<
Vector
>
hybridSize
(
Vector
const
&
vec
,
Dune
::
PriorityTag
<
1
>
)
{
return
{};
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumRows
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
5
>
)
->
decltype
(
mat
.
num_rows
())
{
return
mat
.
num_rows
();
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumRows
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
4
>
)
->
decltype
(
mat
.
N
())
{
return
mat
.
N
();
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumRows
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
3
>
)
->
decltype
(
mat
.
rows
())
{
return
mat
.
rows
();
}
template
<
class
Matrix
,
REQUIRES
(
not
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
constexpr
index_t
<
Matrix
::
rows
>
hybridNumRows
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
2
>
)
{
return
{};
}
template
<
class
Matrix
,
REQUIRES
(
not
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
constexpr
Rows_t
<
Matrix
>
hybridNumRows
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
1
>
)
{
return
{};
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumCols
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
5
>
)
->
decltype
(
mat
.
num_rows
())
{
return
mat
.
num_cols
();
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumCols
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
4
>
)
->
decltype
(
mat
.
M
())
{
return
mat
.
M
();
}
template
<
class
Matrix
,
REQUIRES
(
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
auto
hybridNumCols
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
3
>
)
->
decltype
(
mat
.
cols
())
{
return
mat
.
cols
();
}
template
<
class
Matrix
,
REQUIRES
(
not
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
constexpr
index_t
<
Matrix
::
cols
>
hybridNumCols
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
2
>
)
{
return
{};
}
template
<
class
Matrix
,
REQUIRES
(
not
Concepts
::
DynamicMatrixAccessible_t
<
Matrix
>
::
value
)
>
constexpr
Cols_t
<
Matrix
>
hybridNumCols
(
Matrix
const
&
mat
,
Dune
::
PriorityTag
<
1
>
)
{
return
{};
}
}
// end namespace Impl
template
<
class
Vector
>
auto
hybridSize
(
Vector
const
&
vec
)
{
return
Impl
::
hybridSize
(
vec
,
Dune
::
PriorityTag
<
42
>
{});
}
template
<
class
Vector
>
auto
hybridElements
(
Vector
const
&
vec
)
{
return
Dune
::
range
(
hybridSize
(
vec
));
}
template
<
class
Matrix
>
auto
hybridNumRows
(
Matrix
const
&
mat
)
{
return
Impl
::
hybridNumRows
(
mat
,
Dune
::
PriorityTag
<
42
>
{});
}
template
<
class
Matrix
>
auto
hybridRows
(
Matrix
const
&
mat
)
{
return
Dune
::
range
(
hybridNumRows
(
mat
));
}
template
<
class
Matrix
>
auto
hybridNumCols
(
Matrix
const
&
mat
)
{
return
Impl
::
hybridNumCols
(
mat
,
Dune
::
PriorityTag
<
42
>
{});
}
template
<
class
Matrix
>
auto
hybridCols
(
Matrix
const
&
mat
)
{
return
Dune
::
range
(
hybridNumCols
(
mat
));
}
#endif // DOXYGEN
}
// end namespace AMDiS
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