53#ifndef VSPLINE_VC_SIMD_TYPE_H
54#define VSPLINE_VC_SIMD_TYPE_H
73template <
typename _value_type ,
76:
private Vc::SimdArray < _value_type , _vsize >
78 typedef Vc::SimdArray < _value_type , _vsize >
base_t ;
84 return (
reinterpret_cast < base_t &
> ( *
this ) ) ;
89 return (
reinterpret_cast < const base_t &
> ( *
this ) ) ;
118 using typename base_t::index_type ;
119 using typename base_t::mask_type ;
121 using typename base_t::IndexType ;
122 using typename base_t::MaskType ;
131 using base_t::operator[] ;
187 template <
typename U >
191 template <
typename U >
196 template <
typename U >
203 template <
typename U >
215 to_base().load ( (
unsigned char * ) ( & rhs ) ) ;
224 to_base().load ( (
unsigned char * ) ( & rhs ) ) ;
258 #define BUILD_FROM_CONTAINER(SIZE_TYPE,VSZ) \
259 template < typename U , template < typename , SIZE_TYPE > class V > \
260 vc_simd_type & operator= ( const V < U , VSZ > & rhs ) \
262 static_assert ( vsize == VSZ , "incompatible vector size" ) ; \
263 for ( size_type i = 0 ; i < vsize ; i++ ) \
264 (*this) [ i ] = rhs [ i ] ; \
267 template < typename U , template < typename , SIZE_TYPE > class V > \
268 vc_simd_type ( const V < U , VSZ > & ini ) \
276 #undef BUILD_FROM_CONTAINER
280 using base_t::IndexesFromZero ;
288 return IndexesFromZero() ;
297 return ( ( IndexesFromZero() * step ) + start ) ;
304 return ( ( IndexesFromZero() * step ) ) ;
330 using base_t::store ;
336 const index_type & indexes )
338 to_base().gather ( p_src , indexes ) ;
342 const index_type & indexes )
const
344 to_base().scatter ( p_trg , indexes ) ;
347 template <
typename _index_type >
349 const _index_type & _indexes )
351 to_base().gather ( p_src , _indexes.to_base() ) ;
354 template <
typename _index_type >
356 const _index_type & _indexes )
const
358 to_base().scatter ( p_trg , _indexes.to_base() ) ;
363 template <
typename index_type >
365 const index_type & indexes )
367 gather ( p_src , indexes ) ;
392 #define BROADCAST_STD_FUNC(FUNC) \
393 friend vc_simd_type FUNC ( const vc_simd_type & arg ) \
395 return FUNC ( arg.to_base() ) ; \
414 #undef BROADCAST_STD_FUNC
421 Vc::sincos ( arg.
to_base() , &sin , &cos ) ;
422 auto result = sin / cos ;
423 result ( cos == 0 ) = M_PI_2 ;
427 #define BROADCAST_STD_FUNC2(FUNC) \
428 friend vc_simd_type FUNC ( const vc_simd_type & arg1 , \
429 const vc_simd_type & arg2 ) \
431 return FUNC ( arg1.to_base() , arg2.to_base() ) ; \
436 #undef BROADCAST_STD_FUNC2
452 #define INTEGRAL_ONLY \
453 static_assert ( std::is_integral < value_type > :: value , \
454 "this operation is only allowed for integral types" ) ;
457 static_assert ( std::is_same < value_type , bool > :: value , \
458 "this operation is only allowed for booleans" ) ;
466 #define OPEQ_FUNC(OPFUNC,OPEQ,CONSTRAINT) \
467 vc_simd_type & OPFUNC ( const value_type & rhs ) \
470 to_base() OPEQ rhs ; \
473 vc_simd_type & OPFUNC ( const vc_simd_type & rhs ) \
476 to_base() OPEQ rhs.to_base() ; \
501#define C_PROMOTE(A,B) \
502typename std::conditional \
503 < std::is_same < A , B > :: value , \
505 decltype ( std::declval < A > () \
506 + std::declval < B > () ) \
510#define OP_FUNC(OPFUNC,OP,CONSTRAINT) \
511 template < typename RHST , \
512 typename = typename std::enable_if \
513 < std::is_fundamental < RHST > :: value \
516 vc_simd_type < C_PROMOTE ( value_type , RHST ) , size() > \
517 OPFUNC ( vc_simd_type < RHST , vsize > rhs ) const \
520 vc_simd_type < C_PROMOTE ( value_type , RHST ) , vsize > help ( *this ) ; \
521 return help.to_base() OP rhs.to_base() ; \
523 template < typename RHST , \
524 typename = typename std::enable_if \
525 < std::is_fundamental < RHST > :: value \
528 vc_simd_type < C_PROMOTE ( value_type , RHST ) , vsize > \
529 OPFUNC ( RHST rhs ) const \
532 vc_simd_type < C_PROMOTE ( value_type , RHST ) , vsize > help ( *this ) ; \
533 return help.to_base() OP rhs ; \
535 template < typename LHST , \
536 typename = typename std::enable_if \
537 < std::is_fundamental < LHST > :: value \
540 friend vc_simd_type < C_PROMOTE ( LHST , value_type ) , vsize > \
541 OPFUNC ( LHST lhs , vc_simd_type rhs ) \
544 vc_simd_type < C_PROMOTE ( LHST , value_type ) , vsize > help ( lhs ) ; \
545 return help.to_base() OP rhs.to_base() ; \
586 #define OP_FUNC(OPFUNC,OP,CONSTRAINT) \
587 vc_simd_type OPFUNC() const \
589 return OP to_base() ; \
601 #define COMPARE_FUNC(OP,OPFUNC) \
602 friend mask_type OPFUNC ( const vc_simd_type & lhs , \
603 const vc_simd_type & rhs ) \
605 return lhs.to_base() OP rhs.to_base() ; \
607 friend mask_type OPFUNC ( const vc_simd_type & lhs , \
608 const value_type & rhs ) \
610 return lhs.to_base() OP rhs ; \
612 friend mask_type OPFUNC ( const value_type & lhs , \
613 const vc_simd_type & rhs ) \
615 return lhs OP rhs.to_base() ; \
656 #define OPEQ_FUNC(OPFUNC,OPEQ,CONSTRAINT) \
657 vc_simd_type & OPFUNC ( const value_type & rhs ) \
660 whither.to_base() ( whether ) OPEQ rhs ; \
663 vc_simd_type & OPFUNC ( const vc_simd_type & rhs ) \
666 whither.to_base() ( whether ) OPEQ rhs.to_base() ; \
707 #define CLAMP(FNAME,REL) \
708 vc_simd_type FNAME ( const vc_simd_type & threshold ) const \
710 return REL ( to_base() , threshold.to_base() ) ; \
712 vc_simd_type FNAME ( const value_type & threshold ) const \
714 return REL ( to_base() , threshold ) ; \
717 CLAMP(at_least,Vc::max)
718 CLAMP(at_most,Vc::min)
732template <
typename T , std::
size_t N >
735 typedef Vc::Allocator < vc_simd_type < T , N > >
class template simd_type provides a fixed-size container type for small sets of fundamentals which ar...
Vc::Allocator< vc_simd_type< T, N > > type
vspline creates vigra::MultiArrays of vectorized types. As long as the vectorized types are Vc::SimdA...
masked_type(const mask_type &_whether, vc_simd_type &_whither)
class template vc_simd_type provides a fixed-size SIMD type. This implementation of vspline::vc_simd_...
vc_simd_type(const vc_simd_type< U, vsize > &&ini)
static const vc_simd_type iota()
vc_simd_type(const value_type &ini)
friend std::istream & operator>>(std::istream &isr, vc_simd_type it)
void gather(const value_type *const p_src, const index_type &indexes)
void scatter(value_type *const p_trg, const _index_type &_indexes) const
vc_simd_type & operator=(const value_type &rhs)
vc_simd_type(const simd_type< unsigned char, vsize > &&ini)
friend std::ostream & operator<<(std::ostream &osr, vc_simd_type it)
masked_type operator()(const mask_type &mask)
COMPARE_FUNC(<=, operator<=)
COMPARE_FUNC(<, operator<)
COMPARE_FUNC(!=, operator!=)
void rscatter(value_type *p_trg, const index_ele_type &step) const
friend vc_simd_type tan(const vc_simd_type &arg)
Vc::SimdArray< _value_type, _vsize > base_t
vc_simd_type(const base_t &&ini)
index_type::value_type index_ele_type
void gather(const value_type *const p_src, const _index_type &_indexes)
COMPARE_FUNC(==, operator==)
void scatter(value_type *const p_trg, const index_type &indexes) const
vc_simd_type(const base_t &ini)
vc_simd_type(const vc_simd_type< U, vsize > &ini)
COMPARE_FUNC(>=, operator>=)
static const index_type IndexesFrom(const index_ele_type &step)
vc_simd_type(const vc_simd_type &)=default
void rgather(const value_type *const p_src, const index_ele_type &step)
static constexpr size_type size()
const base_t & to_base() const
vc_simd_type(const simd_type< unsigned char, vsize > &ini)
vc_simd_type(const value_type *const p_src, const index_type &indexes)
vc_simd_type(vc_simd_type &&)=default
static const size_type vsize
static const index_type IndexesFrom(const index_ele_type &start, const index_ele_type &step)
vc_simd_type(const value_type &&ini)
friend vc_simd_type pow(const vc_simd_type &base, const vc_simd_type &exponent)
COMPARE_FUNC(>, operator>)
#define BUILD_FROM_CONTAINER(SIZE_TYPE, VSZ)
#define OPEQ_FUNC(OPFUNC, OPEQ, CONSTRAINT)
#define BROADCAST_STD_FUNC(FUNC)
#define OP_FUNC(OPFUNC, OP, CONSTRAINT)
#define CLAMP(FNAME, REL)
#define BROADCAST_STD_FUNC2(FUNC)