1/* Copyright (C) 2013-2014 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_SIMDPP_CORE_F_MIN_H
9#define LIBSIMDPP_SIMDPP_CORE_F_MIN_H
10
11#ifndef LIBSIMDPP_SIMD_H
12 #error "This file must be included through simd.h"
13#endif
14
15#include <simdpp/types.h>
16#include <simdpp/detail/insn/f_min.h>
17#include <simdpp/core/detail/scalar_arg_impl.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21
22// note: SSE doesn't provide a way to propagate NaNs in min/max
23/** Computes minimum of the values in two vectors. If at least one of the
24 values is NaN, or both values are zeroes, it is unspecified which value
25 will be returned.
26
27 @code
28 r0 = min(a0, b0)
29 ...
30 rN = min(aN, bN)
31
32 @endcode
33
34 @par 256-bit version:
35 @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
36*/
37template<unsigned N, class E1, class E2> SIMDPP_INL
38float32<N,expr_empty> min(const float32<N,E1>& a, const float32<N,E2>& b)
39{
40 return detail::insn::i_min(a.eval(), b.eval());
41}
42
43SIMDPP_SCALAR_ARG_IMPL_VEC(min, float32, float32)
44
45/** Computes minima of the values in two vectors. If at least one of the values
46 is NaN, or both values are zeroes, it is unspecified which value will be
47 returned.
48
49 @code
50 r0 = min(a0, b0)
51 ...
52 rN = min(aN, bN)
53 @endcode
54
55 @par 128-bit version:
56 @novec{NEON, ALTIVEC}
57
58 @par 256-bit version:
59 @novec{NEON, ALTIVEC}
60 @icost{SSE2-SSE4.1, 2}
61*/
62template<unsigned N, class E1, class E2> SIMDPP_INL
63float64<N,expr_empty> min(const float64<N,E1>& a, const float64<N,E2>& b)
64{
65 return detail::insn::i_min(a.eval(), b.eval());
66}
67
68SIMDPP_SCALAR_ARG_IMPL_VEC(min, float64, float64)
69
70} // namespace SIMDPP_ARCH_NAMESPACE
71} // namespace simdpp
72
73#endif
74
75