Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix complex math abs and abs2 issues #3387

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/pmacc/algorithms/math/floatMath/trigo.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct Sinc<float>
HDINLINE float operator( )(const float& value )
{
if(cupla::math::abs(value) < FLT_EPSILON)
return 1.0;
return 1.0f;
else
return cupla::math::sin( value )/value;
}
Expand Down
14 changes: 9 additions & 5 deletions include/pmacc/math/complex/Complex.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ namespace math
}
};

/* Specialize abs2() for complex numbers. */
/** Specialize abs2() for complex numbers.
*
* Note: Abs is specialized in alpaka::math below
*/
template<typename T_Type>
struct Abs2< ::pmacc::math::Complex<T_Type> >
{
Expand Down Expand Up @@ -216,11 +219,12 @@ namespace traits
ALPAKA_FN_HOST_ACC static auto abs(
T_Ctx const & mathConcept,
::pmacc::math::Complex< T_Type > const & other
) -> ::pmacc::math::Complex< T_Type >
) -> T_Type
{
using type = T_Type;
return alpaka::math::abs( mathConcept, other.get_real() )
+ alpaka::math::abs( mathConcept, other.get_imag() );
/* It is not possible to use alpaka::math::sqrt( mathConcept, ... )
* here, as the mathConcept would not match, so go around via cupla
*/
return cupla::math::sqrt( pmacc::math::abs2( other ) );
}
};

Expand Down