~ubuntu-branches/ubuntu/raring/vc/raring-proposed

« back to all changes in this revision

Viewing changes to common/trigonometric.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-03-08 12:50:59 UTC
  • Revision ID: package-import@ubuntu.com-20130308125059-2vpu3hm02kgrqv96
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the Vc library.
 
2
 
 
3
    Copyright (C) 2009-2012 Matthias Kretz <kretz@kde.org>
 
4
 
 
5
    Vc is free software: you can redistribute it and/or modify
 
6
    it under the terms of the GNU Lesser General Public License as
 
7
    published by the Free Software Foundation, either version 3 of
 
8
    the License, or (at your option) any later version.
 
9
 
 
10
    Vc is distributed in the hope that it will be useful, but
 
11
    WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU Lesser General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU Lesser General Public
 
16
    License along with Vc.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
*/
 
19
 
 
20
#ifndef VC_COMMON_TRIGONOMETRIC_H
 
21
#define VC_COMMON_TRIGONOMETRIC_H
 
22
 
 
23
#ifndef VC__USE_NAMESPACE
 
24
#error "Do not include Vc/common/trigonometric.h outside of Vc itself"
 
25
#endif
 
26
 
 
27
#include "macros.h"
 
28
namespace Vc
 
29
{
 
30
namespace
 
31
{
 
32
    using Vc::VC__USE_NAMESPACE::Vector;
 
33
} // namespace
 
34
 
 
35
namespace Internal
 
36
{
 
37
template<Vc::Implementation Impl> struct MapImpl { enum Dummy { Value = Impl }; };
 
38
template<> struct MapImpl<Vc::SSE42Impl> { enum Dummy { Value = MapImpl<Vc::SSE41Impl>::Value }; };
 
39
typedef ImplementationT<MapImpl<VC_IMPL>::Value
 
40
#if defined(VC_IMPL_XOP) && defined(VC_IMPL_FMA4)
 
41
    + Vc::XopInstructions
 
42
    + Vc::Fma4Instructions
 
43
#endif
 
44
    > TrigonometricImplementation;
 
45
} // namespace Internal
 
46
 
 
47
template<typename Impl> struct Trigonometric
 
48
{
 
49
    template<typename T> static Vector<T> sin(const Vector<T> &_x);
 
50
    template<typename T> static Vector<T> cos(const Vector<T> &_x);
 
51
    template<typename T> static void sincos(const Vector<T> &_x, Vector<T> *_sin, Vector<T> *_cos);
 
52
    template<typename T> static Vector<T> asin (const Vector<T> &_x);
 
53
    template<typename T> static Vector<T> atan (const Vector<T> &_x);
 
54
    template<typename T> static Vector<T> atan2(const Vector<T> &y, const Vector<T> &x);
 
55
};
 
56
namespace VC__USE_NAMESPACE
 
57
#undef VC__USE_NAMESPACE
 
58
{
 
59
    template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> sin(const Vector<T> &_x) {
 
60
        return Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::sin(_x);
 
61
    }
 
62
    template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> cos(const Vector<T> &_x) {
 
63
        return Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::cos(_x);
 
64
    }
 
65
    template<typename T> static Vc_ALWAYS_INLINE void sincos(const Vector<T> &_x, Vector<T> *_sin, Vector<T> *_cos) {
 
66
        Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::sincos(_x, _sin, _cos);
 
67
    }
 
68
    template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> asin (const Vector<T> &_x) {
 
69
        return Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::asin(_x);
 
70
    }
 
71
    template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> atan (const Vector<T> &_x) {
 
72
        return Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::atan(_x);
 
73
    }
 
74
    template<typename T> static Vc_ALWAYS_INLINE Vc_PURE Vector<T> atan2(const Vector<T> &y, const Vector<T> &x) {
 
75
        return Vc::Trigonometric<Vc::Internal::TrigonometricImplementation>::atan2(y, x);
 
76
    }
 
77
} // namespace VC__USE_NAMESPACE
 
78
} // namespace Vc
 
79
 
 
80
#include "undomacros.h"
 
81
#endif // VC_COMMON_TRIGONOMETRIC_H