@@ -277,6 +277,26 @@ static std::complex<HostT> StdPowF2B(
277277 return std::pow (x, y);
278278}
279279
280+ #ifdef _AIX
281+ extern " C" {
282+ void csqrtf_wrapper (const float [], float []);
283+ void csqrt_wrapper (const double [], double []);
284+ } // extern "C"
285+
286+ template <typename HostT>
287+ static std::complex <HostT> CSQRT (const std::complex <HostT> &x) {
288+ HostT y[2 ]{x.real (), x.imag ()};
289+ HostT r[2 ];
290+ if constexpr (std::is_same_v<HostT, float >) {
291+ csqrtf_wrapper (y, r);
292+ } else if constexpr (std::is_same_v<HostT, double >) {
293+ csqrt_wrapper (y, r);
294+ }
295+ std::complex <HostT> res (r[0 ], r[1 ]);
296+ return res;
297+ }
298+ #endif
299+
280300template <typename HostT>
281301struct HostRuntimeLibrary <std::complex <HostT>, LibraryVersion::Libm> {
282302 using F = FuncPointer<std::complex <HostT>, const std::complex <HostT> &>;
@@ -302,7 +322,11 @@ struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
302322 FolderFactory<F2B, F2B{StdPowF2B}>::Create (" pow" ),
303323 FolderFactory<F, F{std::sin}>::Create (" sin" ),
304324 FolderFactory<F, F{std::sinh}>::Create (" sinh" ),
325+ #ifdef _AIX
326+ FolderFactory<F, F{CSQRT}>::Create (" sqrt" ),
327+ #else
305328 FolderFactory<F, F{std::sqrt}>::Create (" sqrt" ),
329+ #endif
306330 FolderFactory<F, F{std::tan}>::Create (" tan" ),
307331 FolderFactory<F, F{std::tanh}>::Create (" tanh" ),
308332 };
0 commit comments