Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
The container registry cleanup task is now completed and the registry can be used normally.
Open sidebar
IP
elsa
Commits
e17c8b9b
Commit
e17c8b9b
authored
Jul 23, 2021
by
Andi Braimllari
Committed by
Tobias Lasser
Jul 23, 2021
Browse files
add cwiseAbs() functionality to DataContainer
parent
dd5c3310
Pipeline
#645854
passed with stages
in 21 minutes and 49 seconds
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
elsa/core/DataContainer.h
View file @
e17c8b9b
...
...
@@ -577,6 +577,19 @@ namespace elsa
}
}
/// Element-wise absolute value operation
template
<
typename
Operand
,
typename
=
std
::
enable_if_t
<
isDcOrExpr
<
Operand
>
>>
auto
cwiseAbs
(
Operand
const
&
operand
)
{
auto
abs
=
[](
auto
const
&
operand
)
{
return
(
operand
.
array
().
abs
()).
matrix
();
};
#ifdef ELSA_CUDA_VECTOR
auto
absGPU
=
[](
auto
const
&
operand
,
bool
)
{
return
quickvec
::
cwiseAbs
(
operand
);
};
return
Expression
{
Callables
{
abs
,
absGPU
},
operand
};
#else
return
Expression
{
abs
,
operand
};
#endif
}
/// Element-wise square operation
template
<
typename
Operand
,
typename
=
std
::
enable_if_t
<
isDcOrExpr
<
Operand
>
>>
auto
square
(
Operand
const
&
operand
)
...
...
elsa/core/tests/test_DataContainer.cpp
View file @
e17c8b9b
...
...
@@ -279,6 +279,10 @@ TEST_CASE_TEMPLATE_DEFINE("DataContainer: Testing element-wise access", TestType
THEN
(
"the element-wise unary operations work as expected"
)
{
DataContainer
dcAbs
=
cwiseAbs
(
dc
);
for
(
index_t
i
=
0
;
i
<
dc
.
getSize
();
++
i
)
REQUIRE_UNARY
(
checkApproxEq
(
dcAbs
[
i
],
randVec
.
array
().
abs
()[
i
]));
DataContainer
dcSquare
=
square
(
dc
);
for
(
index_t
i
=
0
;
i
<
dc
.
getSize
();
++
i
)
REQUIRE_UNARY
(
checkApproxEq
(
dcSquare
[
i
],
randVec
.
array
().
square
()[
i
]));
...
...
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