1 //================================================================================================= 2 /*! 3 // \file blaze/math/functors/Erfc.h 4 // \brief Header file for the Erfc functor 5 // 6 // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved 7 // 8 // This file is part of the Blaze library. You can redistribute it and/or modify it under 9 // the terms of the New (Revised) BSD License. Redistribution and use in source and binary 10 // forms, with or without modification, are permitted provided that the following conditions 11 // are met: 12 // 13 // 1. Redistributions of source code must retain the above copyright notice, this list of 14 // conditions and the following disclaimer. 15 // 2. Redistributions in binary form must reproduce the above copyright notice, this list 16 // of conditions and the following disclaimer in the documentation and/or other materials 17 // provided with the distribution. 18 // 3. Neither the names of the Blaze development group nor the names of its contributors 19 // may be used to endorse or promote products derived from this software without specific 20 // prior written permission. 21 // 22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 23 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 27 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 28 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 31 // DAMAGE. 32 */ 33 //================================================================================================= 34 35 #ifndef _BLAZE_MATH_FUNCTORS_ERFC_H_ 36 #define _BLAZE_MATH_FUNCTORS_ERFC_H_ 37 38 39 //************************************************************************************************* 40 // Includes 41 //************************************************************************************************* 42 43 #include <utility> 44 #include <blaze/math/constraints/SIMDPack.h> 45 #include <blaze/math/shims/Erfc.h> 46 #include <blaze/math/simd/Erfc.h> 47 #include <blaze/math/typetraits/HasSIMDErfc.h> 48 #include <blaze/math/typetraits/IsSymmetric.h> 49 #include <blaze/math/typetraits/IsUniform.h> 50 #include <blaze/math/typetraits/YieldsSymmetric.h> 51 #include <blaze/math/typetraits/YieldsUniform.h> 52 #include <blaze/system/HostDevice.h> 53 #include <blaze/system/Inline.h> 54 55 56 namespace blaze { 57 58 //================================================================================================= 59 // 60 // CLASS DEFINITION 61 // 62 //================================================================================================= 63 64 //************************************************************************************************* 65 /*!\brief Generic wrapper for the erfc() function. 66 // \ingroup functors 67 */ 68 struct Erfc 69 { 70 //********************************************************************************************** 71 /*!\brief Returns the result of the erfc() function for the given object/value. 72 // 73 // \param a The given object/value. 74 // \return The result of the erfc() function for the given object/value. 75 */ 76 template< typename T > decltypeErfc77 BLAZE_ALWAYS_INLINE BLAZE_DEVICE_CALLABLE decltype(auto) operator()( T&& a ) const 78 { 79 return erfc( std::forward<T>( a ) ); 80 } 81 //********************************************************************************************** 82 83 //********************************************************************************************** 84 /*!\brief Returns whether SIMD is enabled for the specified data type \a T. 85 // 86 // \return \a true in case SIMD is enabled for the data type \a T, \a false if not. 87 */ 88 template< typename T > simdEnabledErfc89 static constexpr bool simdEnabled() { return HasSIMDErfc_v<T>; } 90 //********************************************************************************************** 91 92 //********************************************************************************************** 93 /*!\brief Returns whether the operation supports padding, i.e. whether it can deal with zeros. 94 // 95 // \return \a true in case padding is supported, \a false if not. 96 */ paddingEnabledErfc97 static constexpr bool paddingEnabled() { return false; } 98 //********************************************************************************************** 99 100 //********************************************************************************************** 101 /*!\brief Returns the result of the erfc() function for the given SIMD vector. 102 // 103 // \param a The given SIMD vector. 104 // \return The result of the erfc() function for the given SIMD vector. 105 */ 106 template< typename T > decltypeErfc107 BLAZE_ALWAYS_INLINE decltype(auto) load( const T& a ) const 108 { 109 BLAZE_CONSTRAINT_MUST_BE_SIMD_PACK( T ); 110 return erfc( a ); 111 } 112 //********************************************************************************************** 113 }; 114 //************************************************************************************************* 115 116 117 118 119 //================================================================================================= 120 // 121 // YIELDSUNIFORM SPECIALIZATIONS 122 // 123 //================================================================================================= 124 125 //************************************************************************************************* 126 /*! \cond BLAZE_INTERNAL */ 127 template< typename T > 128 struct YieldsUniform<Erfc,T> 129 : public IsUniform<T> 130 {}; 131 /*! \endcond */ 132 //************************************************************************************************* 133 134 135 136 137 //================================================================================================= 138 // 139 // YIELDSSYMMETRIC SPECIALIZATIONS 140 // 141 //================================================================================================= 142 143 //************************************************************************************************* 144 /*! \cond BLAZE_INTERNAL */ 145 template< typename MT > 146 struct YieldsSymmetric<Erfc,MT> 147 : public IsSymmetric<MT> 148 {}; 149 /*! \endcond */ 150 //************************************************************************************************* 151 152 } // namespace blaze 153 154 #endif 155