1/* Copyright (C) 2011-2012 Povilas Kanapickas <povilas@radix.lt>
2
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef LIBSIMDPP_DETAIL_NULL_COMPARE_H
9#define LIBSIMDPP_DETAIL_NULL_COMPARE_H
10#if SIMDPP_USE_NULL || SIMDPP_USE_NEON || SIMDPP_USE_ALTIVEC
11
12#ifndef LIBSIMDPP_SIMD_H
13 #error "This file must be included through simd.h"
14#endif
15
16#include <simdpp/detail/null/mask.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20namespace detail {
21namespace null {
22
23template<class V> SIMDPP_INL
24typename V::mask_vector_type cmp_eq(const V& a, const V& b)
25{
26 typename V::mask_vector_type r;
27 for (unsigned i = 0; i < V::length; i++) {
28 r.el(i) = (a.el(i) == b.el(i)) ? 1 : 0;
29 }
30 return r;
31}
32
33template<class V> SIMDPP_INL
34typename V::mask_vector_type cmp_neq(const V& a, const V& b)
35{
36 typename V::mask_vector_type r;
37 for (unsigned i = 0; i < V::length; i++) {
38 r.el(i) = (a.el(i) != b.el(i)) ? 1 : 0;
39 }
40 return r;
41}
42
43template<class V> SIMDPP_INL
44typename V::mask_vector_type cmp_lt(const V& a, const V& b)
45{
46 typename V::mask_vector_type r;
47 for (unsigned i = 0; i < V::length; i++) {
48 r.el(i) = (a.el(i) < b.el(i)) ? 1 : 0;
49 }
50 return r;
51}
52
53template<class V> SIMDPP_INL
54typename V::mask_vector_type cmp_le(const V& a, const V& b)
55{
56 typename V::mask_vector_type r;
57 for (unsigned i = 0; i < V::length; i++) {
58 r.el(i) = (a.el(i) <= b.el(i)) ? 1 : 0;
59 }
60 return r;
61}
62
63template<class V> SIMDPP_INL
64typename V::mask_vector_type cmp_gt(const V& a, const V& b)
65{
66 typename V::mask_vector_type r;
67 for (unsigned i = 0; i < V::length; i++) {
68 r.el(i) = (a.el(i) > b.el(i)) ? 1 : 0;
69 }
70 return r;
71}
72
73template<class V> SIMDPP_INL
74typename V::mask_vector_type cmp_ge(const V& a, const V& b)
75{
76 typename V::mask_vector_type r;
77 for (unsigned i = 0; i < V::length; i++) {
78 r.el(i) = (a.el(i) >= b.el(i)) ? 1 : 0;
79 }
80 return r;
81}
82
83} // namespace null
84} // namespace detail
85} // namespace SIMDPP_ARCH_NAMESPACE
86} // namespace simdpp
87
88#endif
89#endif
90