CMSIS-DSP  
CMSIS DSP Software Library
 
Loading...
Searching...
No Matches
fixed_point.hpp File Reference
#include <cstdint>
#include "arch.hpp"
#include <cstdlib>
#include <type_traits>
#include <iostream>

Data Structures

struct  fixed_storage_type< M, F, s, bool >
 Storage type for a fixed point number. More...
 
struct  fixed_storage_type< M, F, true, test64(M, F, 1)>
 Storage type for a fixed point number representable on int64. More...
 
struct  fixed_storage_type< M, F, false, test64(M, F, 0)>
 Storage type for a fixed point number representable on uint64. More...
 
struct  fixed_storage_type< M, F, true, test32(M, F, 1)>
 Storage type for a fixed point number representable on int32. More...
 
struct  fixed_storage_type< M, F, false, test32(M, F, 0)>
 Storage type for a fixed point number representable on uint32. More...
 
struct  fixed_storage_type< M, F, true, test16(M, F, 1)>
 Storage type for a fixed point number representable on int16. More...
 
struct  fixed_storage_type< M, F, false, test16(M, F, 0)>
 Storage type for a fixed point number representable on uint16. More...
 
struct  fixed_storage_type< M, F, true, test8(M, F, 1)>
 Storage type for a fixed point number representable on int8. More...
 
struct  fixed_storage_type< M, F, false, test8(M, F, 0)>
 Storage type for a fixed point number representable on uint8. More...
 
struct  Q< M, F, S, T >
 Fixed point template. More...
 
struct  Q< M, F, true, int64_t >
 Signed fixed point datatypes on 64 bits. More...
 
struct  Q< M, F, false, uint64_t >
 Unsigned fixed point datatypes on 64 bits. More...
 
struct  Q< M, F, true, int32_t >
 Signed fixed point datatypes on 32 bits. More...
 
struct  Q< M, F, false, uint32_t >
 Unsigned fixed point datatypes on 32 bits. More...
 
struct  Q< M, F, true, int16_t >
 Signed fixed point datatypes on 16 bits. More...
 
struct  Q< M, F, false, uint16_t >
 Unsigned fixed point datatypes on 16 bits. More...
 
struct  Q< M, F, true, int8_t >
 Signed fixed point datatypes on 8 bits. More...
 
struct  Q< M, F, false, uint8_t >
 Unsigned fixed point datatypes on 8 bits. More...
 
struct  FixedCastShift< M, FD, FS, S,(FD >FS)>
 Changed fractional representation of a fixed point number using a shift. More...
 
struct  FixedCastShift< M, FD, FS, S,(FD< FS)>
 Changed fractional representation of a fixed point number using a shift. More...
 
struct  Accumulate< MD, MS, F, S, true >
 Accumulation without saturation. More...
 

Namespaces

namespace  arm_cmsis_dsp
 

Typedefs

using Q63 = Q< 0, 63 >
 Q63 datatype.
 
using Q31 = Q< 0, 31 >
 Q31 datatype.
 
using Q15 = Q< 0, 15 >
 Q15 datatype.
 
using Q7 = Q< 0, 7 >
 Q7 datatype.
 

Functions

constexpr bool test64 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 64 bits.
 
constexpr bool test32 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 32 bits.
 
constexpr bool test16 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 16 bits.
 
constexpr bool test8 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 8 bits.
 
constexpr Q63 operator""_q63 (long double x)
 q63 literal
 
constexpr Q31 operator""_q31 (long double x)
 q31 literal
 
constexpr Q15 operator""_q15 (long double x)
 q15 literal
 
constexpr Q7 operator""_q7 (long double x)
 q7 literal
 
template<int MA, int FA, int MB, int FB, bool SA, bool SB>
Q< MA+MB+1, FA+FB, SA||SB > mult (const Q< MA, FA, SA > &a, const Q< MB, FB, SB > &b)
 Multiplication of two fixed point numbers A and B.
 
template<int M, int F, bool S>
Q< M, F, S > operator+ (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Add two fixed point numbers with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > operator- (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Subtract two fixed point numbers with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > operator- (const Q< M, F, S > &a)
 Negate a fixed point number with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > add (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Add two fixed point numbers without saturation.
 
template<int M, int F, bool S>
Q< M, F, S > sub (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Subtract two fixed point numbers without saturation.
 
template<int M, int F, int N, bool S>
Q< M, F, S > operator>> (const Q< M, F, S > &a, std::integral_constant< int, N >) noexcept
 Shift right a fixed point number with a shift known at build time.
 
template<int M, int F, int N, bool S>
Q< M+N, F, S > operator<< (const Q< M, F, S > &a, std::integral_constant< int, N >) noexcept
 Shift left a fixed point number with a shift known at build time.
 
template<int MD = 0, int MS, int F>
Q< MD, F, true > saturate (const Q< MS, F, true > &src, typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *=nullptr)
 Saturate a signed fixed point number.
 
template<int MD = 0, int MS, int F>
Q< MD, F, false > saturate (const Q< MS, F, false > &src, typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *=nullptr)
 Saturate an unsigned fixed point number.
 
template<int FD, int M, int FS, bool S>
Q< M, FD, S > toFrac (const Q< M, FS, S > &src)
 Convert between different fractional part formats.
 
template<int MD, int MS, int F, bool S>
Q< MD, F, S > accumulate (const Q< MD, F, S > &a, const Q< MS, F, S > &b)
 Accumulate without saturation.
 
Q7 operator* (const Q7 &a, const Q7 &b)
 Multiplication operator.
 
Q15 operator* (const Q15 &a, const Q15 &b)
 Multiplication operator.
 
Q31 operator* (const Q31 &a, const Q31 &b)
 Multiplication operator.
 
template<int M, int F>
bool operator> (const Q< M, F > &a, const Q< M, F > &b)
 Greater-than comparison operator.
 
template<int M, int F>
bool operator< (const Q< M, F > &a, const Q< M, F > &b)
 Less-than comparison operator.
 
template<int M, int F>
bool operator>= (const Q< M, F > &a, const Q< M, F > &b)
 Greater-than-or-equal comparison operator.
 
template<int M, int F>
bool operator<= (const Q< M, F > &a, const Q< M, F > &b)
 Less-than-or-equal comparison operator.
 
template<int M, int F>
bool operator== (const Q< M, F > a, const Q< M, F > b)
 Equality operator.
 
template<int M, int F>
bool operator!= (const Q< M, F > a, const Q< M, F > b)
 Inequality operator.
 
template<int M, int F, bool S>
Q< M, F, S > operator/ (const Q< M, F, S > a, const int32_t b)
 Division operator.
 
template<int M, int F, bool S>
Q< M, F, S > operator+ (const Q< M, F, S > &a)
 No op operator.