Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IP
elsa
Commits
84988350
Commit
84988350
authored
Mar 21, 2022
by
David Frank
Browse files
Prefer bass by const reference to avoid unnecessary copies
parent
a849243a
Changes
4
Hide whitespace changes
Inline
Side-by-side
elsa/core/DataContainer.cpp
View file @
84988350
...
...
@@ -125,7 +125,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
DataContainer
<
data_t
>::
at
(
IndexVector_t
coordinate
)
const
data_t
DataContainer
<
data_t
>::
at
(
const
IndexVector_t
&
coordinate
)
const
{
const
auto
arr
=
coordinate
.
array
();
if
((
arr
<
0
).
any
()
...
...
@@ -133,22 +133,22 @@ namespace elsa
return
0
;
}
return
(
*
this
)[
_dataDescriptor
->
getIndexFromCoordinate
(
std
::
move
(
coordinate
)
)
];
return
(
*
this
)[
_dataDescriptor
->
getIndexFromCoordinate
(
coordinate
)];
}
template
<
typename
data_t
>
data_t
&
DataContainer
<
data_t
>::
operator
()(
IndexVector_t
coordinate
)
data_t
&
DataContainer
<
data_t
>::
operator
()(
const
IndexVector_t
&
coordinate
)
{
// const auto arr = coordinate.array();
// const auto shape = _dataDescriptor->getNumberOfCoefficientsPerDimension().array();
// ELSA_VERIFY((arr >= 0).all());
// ELSA_VERIFY((arr < shape).all());
return
(
*
this
)[
_dataDescriptor
->
getIndexFromCoordinate
(
std
::
move
(
coordinate
)
)
];
return
(
*
this
)[
_dataDescriptor
->
getIndexFromCoordinate
(
coordinate
)];
}
template
<
typename
data_t
>
const
data_t
&
DataContainer
<
data_t
>::
operator
()(
IndexVector_t
coordinate
)
const
const
data_t
&
DataContainer
<
data_t
>::
operator
()(
const
IndexVector_t
&
coordinate
)
const
{
// const auto arr = coordinate.array();
// const auto shape = _dataDescriptor->getNumberOfCoefficientsPerDimension().array();
...
...
elsa/core/DataContainer.h
View file @
84988350
...
...
@@ -172,12 +172,12 @@ namespace elsa
const
data_t
&
operator
[](
index_t
index
)
const
;
/// return an element by n-dimensional coordinate (not bounds-checked!)
data_t
&
operator
()(
IndexVector_t
coordinate
);
data_t
&
operator
()(
const
IndexVector_t
&
coordinate
);
/// return an element by n-dimensional coordinate as read-only (not bounds-checked!)
const
data_t
&
operator
()(
IndexVector_t
coordinate
)
const
;
const
data_t
&
operator
()(
const
IndexVector_t
&
coordinate
)
const
;
data_t
at
(
IndexVector_t
coordinate
)
const
;
data_t
at
(
const
IndexVector_t
&
coordinate
)
const
;
/// return an element by its coordinates (not bounds-checked!)
template
<
typename
idx0_t
,
typename
...
idx_t
,
...
...
elsa/core/Descriptors/DataDescriptor.cpp
View file @
84988350
...
...
@@ -74,7 +74,7 @@ namespace elsa
RealVector_t
DataDescriptor
::
getLocationOfOrigin
()
const
{
return
_locationOfOrigin
;
}
index_t
DataDescriptor
::
getIndexFromCoordinate
(
elsa
::
IndexVector_t
coordinate
)
const
index_t
DataDescriptor
::
getIndexFromCoordinate
(
const
elsa
::
IndexVector_t
&
coordinate
)
const
{
// sanity check
if
(
coordinate
.
size
()
!=
_productOfCoefficientsPerDimension
.
size
())
...
...
elsa/core/Descriptors/DataDescriptor.h
View file @
84988350
...
...
@@ -79,7 +79,7 @@ namespace elsa
* _numberOfCoefficientsPerDimension[i]-1 for every dimension i = 0,...,_numberOfDimensions.
* Linearization is assumed to be done in order of the dimensions.
*/
index_t
getIndexFromCoordinate
(
IndexVector_t
coordinate
)
const
;
index_t
getIndexFromCoordinate
(
const
elsa
::
IndexVector_t
&
coordinate
)
const
;
/**
* @brief computes the local coordinates from a linearized index
...
...
@@ -88,8 +88,9 @@ namespace elsa
* @return the local coordinate corresponding to the index
*
* The local coordinates are integers, running from 0 to
* _numberOfCoefficientsPerDimension[i]-1 for every dimension i = 0,...,_numberOfDimensions.
* Linearization is assumed to be done in order of the dimensions.
* _numberOfCoefficientsPerDimension[i]-1 for every dimension i =
* 0,...,_numberOfDimensions. Linearization is assumed to be done in order of the
* dimensions.
*/
IndexVector_t
getCoordinateFromIndex
(
index_t
index
)
const
;
...
...
Write
Preview
Markdown
is supported
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