2015-07-30 11:12:42 -07:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2007 Julien Pommier
|
|
|
|
|
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2016-04-28 14:33:09 -03:00
|
|
|
// Copyright (C) 2016 Konstantinos Margaritis <markos@freevec.org>
|
2015-07-30 11:12:42 -07:00
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H
|
|
|
|
|
#define EIGEN_MATH_FUNCTIONS_ALTIVEC_H
|
|
|
|
|
|
2021-09-10 19:12:26 +00:00
|
|
|
#include "../../InternalHeaderCheck.h"
|
|
|
|
|
|
2015-07-30 11:12:42 -07:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
2023-03-10 22:02:23 +00:00
|
|
|
EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet4f)
|
|
|
|
|
#ifdef EIGEN_VECTORIZE_VSX
|
|
|
|
|
EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet2d)
|
|
|
|
|
#endif
|
2023-02-21 03:14:05 +00:00
|
|
|
|
2023-01-12 16:33:33 +00:00
|
|
|
#ifdef EIGEN_VECTORIZE_VSX
|
2022-03-03 20:19:33 +00:00
|
|
|
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
2023-01-31 19:40:24 +00:00
|
|
|
Packet4f psqrt<Packet4f>(const Packet4f& x)
|
2016-04-28 14:33:09 -03:00
|
|
|
{
|
2023-01-31 19:40:24 +00:00
|
|
|
return vec_sqrt(x);
|
2016-04-28 14:33:09 -03:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:19:33 +00:00
|
|
|
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
2023-01-31 19:40:24 +00:00
|
|
|
Packet2d psqrt<Packet2d>(const Packet2d& x)
|
2016-04-28 14:33:09 -03:00
|
|
|
{
|
2023-01-31 19:40:24 +00:00
|
|
|
return vec_sqrt(x);
|
2016-04-28 14:33:09 -03:00
|
|
|
}
|
2022-10-03 22:06:58 +00:00
|
|
|
|
2023-01-31 19:40:24 +00:00
|
|
|
#if !EIGEN_COMP_CLANG
|
2022-10-03 22:06:58 +00:00
|
|
|
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
2023-01-31 19:40:24 +00:00
|
|
|
Packet4f prsqrt<Packet4f>(const Packet4f& x)
|
2022-10-03 22:06:58 +00:00
|
|
|
{
|
2023-01-31 19:40:24 +00:00
|
|
|
return pset1<Packet4f>(1.0f) / psqrt<Packet4f>(x);
|
|
|
|
|
// vec_rsqrt returns different results from the generic version
|
|
|
|
|
// return vec_rsqrt(x);
|
2022-10-03 22:06:58 +00:00
|
|
|
}
|
2016-04-28 14:33:09 -03:00
|
|
|
|
2022-03-03 20:19:33 +00:00
|
|
|
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
2023-01-31 19:40:24 +00:00
|
|
|
Packet2d prsqrt<Packet2d>(const Packet2d& x)
|
2016-04-28 14:33:09 -03:00
|
|
|
{
|
2023-01-31 19:40:24 +00:00
|
|
|
return pset1<Packet2d>(1.0) / psqrt<Packet2d>(x);
|
|
|
|
|
// vec_rsqrt returns different results from the generic version
|
|
|
|
|
// return vec_rsqrt(x);
|
2016-04-28 14:33:09 -03:00
|
|
|
}
|
|
|
|
|
|
2023-01-31 19:40:24 +00:00
|
|
|
#endif
|
2016-04-28 14:33:09 -03:00
|
|
|
|
2022-08-08 18:18:17 +00:00
|
|
|
template<> EIGEN_STRONG_INLINE Packet8bf psqrt<Packet8bf> (const Packet8bf& a){
|
|
|
|
|
BF16_TO_F32_UNARY_OP_WRAPPER(psqrt<Packet4f>, a);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 18:58:34 +00:00
|
|
|
#if !EIGEN_COMP_CLANG
|
2022-08-08 18:18:17 +00:00
|
|
|
template<> EIGEN_STRONG_INLINE Packet8bf prsqrt<Packet8bf> (const Packet8bf& a){
|
|
|
|
|
BF16_TO_F32_UNARY_OP_WRAPPER(prsqrt<Packet4f>, a);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
|
|
|
|
Packet4f psqrt<Packet4f>(const Packet4f& x)
|
|
|
|
|
{
|
|
|
|
|
Packet4f a;
|
|
|
|
|
for (Index i = 0; i < packet_traits<float>::size; i++) {
|
|
|
|
|
a[i] = numext::sqrt(x[i]);
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}
|
2015-07-30 11:12:42 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} // end namespace internal
|
|
|
|
|
|
|
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
|
|
|
|
#endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H
|