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_SQRT_H
9#define LIBSIMDPP_SIMDPP_CORE_F_SQRT_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_sqrt.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20
21
22/** Computes square root.
23
24 @code
25 r0 = sqrt(a0)
26 ...
27 rN = sqrt(aN)
28 @endcode
29
30 @par 128-bit version:
31 @icost{NEON, 5}
32 @icost{ALTIVEC, 5-7}
33
34 @par 256-bit version:
35 @icost{SSE2-SSE4.1, 2}
36 @icost{NEON, 10}
37 @icost{ALTIVEC, 10-12}
38*/
39template<unsigned N, class E1> SIMDPP_INL
40float32<N,expr_empty> sqrt(const float32<N,E1>& a)
41{
42 return detail::insn::i_sqrt(a.eval());
43}
44
45/** Computes square root.
46
47 @code
48 r0 = sqrt(a0)
49 ...
50 rN = sqrt(aN)
51 @endcode
52
53 @par 128-bit version:
54 @novec{NEON, ALTIVEC}
55
56 @par 256-bit version:
57 @icost{SSE2-SSE4.1, 2}
58 @novec{NEON, ALTIVEC}
59*/
60template<unsigned N, class E1> SIMDPP_INL
61float64<N,expr_empty> sqrt(const float64<N,E1>& a)
62{
63 return detail::insn::i_sqrt(a.eval());
64}
65
66} // namespace SIMDPP_ARCH_NAMESPACE
67} // namespace simdpp
68
69#endif
70
71