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_MAX_H
9#define LIBSIMDPP_SIMDPP_CORE_F_MAX_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_max.h>
17#include <simdpp/core/detail/scalar_arg_impl.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21
22
23/** Computes maxima of the values of two vectors. If at least one of the values
24 is NaN, or both values are zeroes, it is unspecified which value will be
25 returned.
26
27 @code
28 r0 = max(a0, b0)
29 ...
30 rN = max(aN, bN)
31 @endcode
32
33 @par 256-bit version:
34 @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
35*/
36template<unsigned N, class E1, class E2> SIMDPP_INL
37float32<N,expr_empty> max(const float32<N,E1>& a, const float32<N,E2>& b)
38{
39 return detail::insn::i_max(a.eval(), b.eval());
40}
41
42SIMDPP_SCALAR_ARG_IMPL_VEC(max, float32, float32)
43
44/** Computes maxima of the values of two vectors. If at least one of the values
45 is NaN, or both values are zeroes, it is unspecified which value will be
46 returned.
47
48 @code
49 r0 = max(a0, b0)
50 ...
51 rN = max(aN, bN)
52 @endcode
53
54 @par 128-bit version:
55 @novec{NEON, ALTIVEC}
56
57 @par 256-bit version:
58 @icost{SSE2-SSE4.1, 2}
59 @novec{NEON, ALTIVEC}
60*/
61template<unsigned N, class E1, class E2> SIMDPP_INL
62float64<N,expr_empty> max(const float64<N,E1>& a, const float64<N,E2>& b)
63{
64 return detail::insn::i_max(a.eval(), b.eval());
65}
66
67SIMDPP_SCALAR_ARG_IMPL_VEC(max, float64, float64)
68
69} // namespace SIMDPP_ARCH_NAMESPACE
70} // namespace simdpp
71
72#endif
73
74