1 // -*- C++ -*-
2 /** @file */
3 #pragma once
4 
5 /** \addtogroup GenericNumber Scalar number definitions
6  *  \ingroup NUMBER
7  *  @{
8  *  \addtogroup GenericDoubleNumber Double
9  *  \ingroup GenericNumber
10  *  @{
11  */
12 
13 
14 /**
15  * @brief      Features for double
16  */
17 template<>
18 struct number_traits<double>
19 {
20    //! It is a float number
21    static constexpr bool is_float = true;
22 
23    //! It is not a fixed point
24    static constexpr bool is_fixed = false;
25 
26    //! Accumulator datatype for this scalar datatype
27    typedef double accumulator;
28 
29    /**
30     * @brief      One for this datatype
31     *
32     * @return     Return 1 representation for this datatype
33     */
onenumber_traits34    static constexpr double one() {return 1.0;};
35 
36    //! Compute datatype for this scalar datatype
37    typedef double compute_type;
38 };
39 
40 /**
41  * @brief      Default vector datatype description for this scalar datatype
42  *
43  * @tparam     arch  Current architecture
44  */
45 template<typename arch>
46 struct vector_traits<double,arch,void> {
47 
48   /**
49    * Scalar datatype
50    */
51   typedef double type;
52 
53   /**
54    * Storage datatype
55    */
56   typedef double storage_type;
57 
58   // No vector type but must still be defined
59 
60   /**
61    * Dummy  datatype. Must be present for building but not used
62    * since by default there is no vector architecture assumed
63    */
64   typedef bool vector;
65 
66   /**
67    * Dummy  datatype. Must be present for building but not used
68    * since by default there is no vector architecture assumed
69    */
70   typedef bool temp_accumulator;
71 
72   /**
73    * Dummy  datatype. Must be present for building but not used
74    * since by default there is no vector architecture assumed
75    */
76   typedef uint32_t predicate_t;
77 
78   /**
79    * By default : no vector architecture assumed
80    */
81   static constexpr bool has_vector = false;
82 
83   //! It is a float
84   static constexpr bool is_float = true;
85   //! Not a fixed point
86   static constexpr bool is_fixed = false;
87   //! No predicated loops
88   static constexpr bool has_predicate = false;
89 };
90 
91 /**
92  * Inner implementation of generic intrinsics
93  * \ingroup GenericNumber
94  */
95 namespace inner {
96    /**
97     * @brief      Convert from accumulator representation
98     *
99     * @param[in]  a     Value
100     *
101     * @return     Accumulator value converted to current datatype
102     */
from_accumulator(const double a)103  __STATIC_FORCEINLINE double from_accumulator(const double a)
104   {
105      return(a);
106   };
107 
108 /**
109  * @brief      Multiply and accumulate for this datatype
110  *
111  * @param[in]  acc   The accumulated value
112  * @param[in]  a     The left hand side
113  * @param[in]  b     The right hand side
114  *
115  * @return     Return acc + a*b
116  */
mac(const double acc,const double a,const double b)117   __STATIC_FORCEINLINE double mac(const double acc,const double a,const double b)
118   {
119      return(acc+a*b);
120   };
121 
122 /**
123  * @brief      Accumulate
124  *
125  * @param      a     Accumulator
126  * @param[in]  b     VAlue to be added
127  */
accumulate(double & a,const double & b)128   __STATIC_FORCEINLINE void accumulate(double &a,const double &b)
129 {
130    a += b;
131 }
132 
133 /**
134  * @brief      Multiply
135  *
136  * @param      a     Left hand side
137  * @param[in]  b     Right hand side
138  *
139  * @return     Return a*b
140  */
mult(double & a,const double & b)141 __STATIC_FORCEINLINE double mult(double &a,const double &b)
142 {
143    return(a*b);
144 }
145 }
146 
147 /*! @} */
148 /*! @} */
149