23namespace vctr::expressions
26template <
size_t extent,
class SrcType>
27requires is::realFloatNumber<ValueType<SrcType>>
33 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (
SignedSqrt, src)
35 VCTR_FORCEDINLINE
constexpr value_type operator[] (
size_t i)
const
37 const auto in = src[i];
40 if (std::is_constant_evaluated())
42 if (in == value_type (0))
45 return in < value_type (0) ? -gcem::sqrt (-in) : gcem::sqrt (in);
49 return std::copysign (std::sqrt (std::abs (in)), in);
54 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
57 const auto* s = src.evalNextVectorOpInExpressionChain (dst);
62 Expression::Accelerate::abs (s, dst, len);
63 Expression::Accelerate::sqrt (dst, dst, len);
64 Expression::Accelerate::copysign (dst, s, dst, len);
69 for (
size_t i = 0; i < size(); ++i)
70 dst[i] = std::copysign (std::sqrt (std::abs (dst[i])), dst[i]);
Definition: SignedSqrt.h:29
A combined concept to check if Apple Accelerate is a suitable option for a real valued floating point...
Definition: ContainerAndExpressionConcepts.h:291
constexpr ExpressionChainBuilder< expressions::SignedSqrt > signedSqrt
Computes the sign-preserving square root of the source values.
Definition: SignedSqrt.h:87
The main namespace of the VCTR project.
Definition: Array.h:24
typename detail::ValueType< std::remove_cvref_t< T > >::Type ValueType
If T is an expression template, it equals its return type, if it's a type that defines value_type as ...
Definition: Traits.h:201
int sizeToInt(size_t size)
Casts the size_t argument to an int.
Definition: PlatformVectorOpsHelpers.h:27
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:170
The base class to every expression template.
Definition: ExpressionTemplate.h:37