@@ -166,6 +166,19 @@ struct flipSign_helper<FloatingPoint, Bool NBL_PARTIAL_REQ_BOT(concepts::Floatin
166166	}
167167};
168168
169+ template <typename FloatingPoint>
170+ NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeScalar<FloatingPoint>)
171+ struct  flipSign_helper<FloatingPoint, FloatingPoint NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeScalar<FloatingPoint>) >
172+ {
173+ 	static  FloatingPoint __call (FloatingPoint val, FloatingPoint flip)
174+ 	{
175+ 		using AsFloat = typename float_of_size<sizeof (FloatingPoint)>::type;
176+ 		using AsUint = typename unsigned_integer_of_size<sizeof (FloatingPoint)>::type;
177+ 		const  AsUint asUint = ieee754::impl::bitCastToUintType (val);
178+ 		return  bit_cast<FloatingPoint>(asUint ^ (ieee754::traits<AsFloat>::signMask && flip));
179+ 	}
180+ };
181+ 
169182template <typename Vectorial, typename Bool>
170183NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeVectorial<Vectorial> && concepts::BooleanScalar<Bool>)
171184struct  flipSign_helper<Vectorial, Bool NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeVectorial<Vectorial> && concepts::BooleanScalar<Bool>) >
@@ -203,6 +216,24 @@ struct flipSign_helper<Vectorial, BoolVector NBL_PARTIAL_REQ_BOT(concepts::Float
203216		return  output;
204217	}
205218};
219+ 
220+ template <typename Vectorial>
221+ NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeVectorial<Vectorial>)
222+ struct  flipSign_helper<Vectorial, Vectorial NBL_PARTIAL_REQ_BOT (concepts::FloatingPointLikeVectorial<Vectorial>) >
223+ {
224+ 	static  Vectorial __call (Vectorial val, Vectorial flip)
225+ 	{
226+ 		using traits_v = hlsl::vector_traits<Vectorial>;
227+ 		array_get<Vectorial, typename traits_v::scalar_type> getter_v;
228+ 		array_set<Vectorial, typename traits_v::scalar_type> setter;
229+ 
230+ 		Vectorial output;
231+ 		for  (uint32_t i = 0 ; i < traits_v::Dimension; ++i)
232+ 			setter (output, i, flipSign_helper<typename traits_v::scalar_type, typename traits_v::scalar_type>::__call (getter_v (val, i), getter_v (flip, i)));
233+ 
234+ 		return  output;
235+ 	}
236+ };
206237}
207238
208239template <typename T, typename U>
@@ -211,6 +242,12 @@ NBL_CONSTEXPR_INLINE_FUNC T flipSign(T val, U flip)
211242	return  impl::flipSign_helper<T, U>::__call (val, flip);
212243}
213244
245+ template <typename T>
246+ NBL_CONSTEXPR_INLINE_FUNC T flipSignIfRHSNegative (T val, T flip)
247+ {
248+ 	return  impl::flipSign_helper<T, T>::__call (val, flip);
249+ }
250+ 
214251}
215252}
216253}
0 commit comments