From 361232161aaf9179e8c4b1e9cbec40fd27a2d31b Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Sat, 5 Oct 2024 17:51:23 +0200 Subject: [PATCH 1/7] Started a FixMath version of map() --- src/FixMathMapper.h | 77 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/FixMathMapper.h diff --git a/src/FixMathMapper.h b/src/FixMathMapper.h new file mode 100644 index 0000000..94466af --- /dev/null +++ b/src/FixMathMapper.h @@ -0,0 +1,77 @@ +#ifndef FIXMATH_MAPPER_H +#define FIXMATH_MAPPER_H + +#include "FixMath.h" + +//enum precision { FAST, ACCURATE, FULL }; + +template + class FixMathMapper +{ + + public: + /** Constructor + */ + FixMathMapper() {;} + /** +Constructor +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + FixMathMapper(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + setBounds(_in_min,_in_max,_out_min,_out_max); + } + + + /** +Set the bounds of the mapper +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) + { + in_min = _in_min; + in_max = _in_max; + out_min = _out_min; + out_max = _out_max; + compute_coef(); + } + + + /** +Map an input to the output range +@param in the input + */ + out_type map(in_type in) const + { + return /*out_type*/(/*in_type*/(in - in_min) * coef) + out_min; + //return out_type(0); + } + + + private: + + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + in_type in_min, in_max; + out_type out_min, out_max; + + void compute_coef() + { + coef = (out_max-out_min)*(in_max-in_min).invFull(); + } + +}; + + + + + +#endif From 63e0c8d2daf169857483358ae7350b1d83153ac4 Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Tue, 4 Feb 2025 22:43:14 +0100 Subject: [PATCH 2/7] Added Mappers for all division type --- src/FixMathMapper.h | 160 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 151 insertions(+), 9 deletions(-) diff --git a/src/FixMathMapper.h b/src/FixMathMapper.h index 94466af..7f97fef 100644 --- a/src/FixMathMapper.h +++ b/src/FixMathMapper.h @@ -3,16 +3,18 @@ #include "FixMath.h" -//enum precision { FAST, ACCURATE, FULL }; - +/** +A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. +This version uses invFull() to perform the calculations. The biggest precision available, at the cost of some speed (platform and use-case dependent) +*/ template - class FixMathMapper + class FixMathMapperFull { public: /** Constructor */ - FixMathMapper() {;} + FixMathMapperFull() {;} /** Constructor @param _in_min the lower bound of the input @@ -22,7 +24,7 @@ Constructor @note should work if they are not in increasing order but more testing needed to confirm @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapper(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { setBounds(_in_min,_in_max,_out_min,_out_max); } @@ -52,13 +54,11 @@ Map an input to the output range */ out_type map(in_type in) const { - return /*out_type*/(/*in_type*/(in - in_min) * coef) + out_min; - //return out_type(0); + return ((in - in_min) * coef) + out_min; } private: - decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; in_type in_min, in_max; out_type out_min, out_max; @@ -66,12 +66,154 @@ Map an input to the output range void compute_coef() { coef = (out_max-out_min)*(in_max-in_min).invFull(); + } +}; + + + + + + + +/** +A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. +This version uses invAccurate() to perform the calculations. The nearly biggest precision available, at the cost of some speed (platform and use-case dependent) +*/ +template + class FixMathMapperAccurate +{ + + public: + /** Constructor + */ + FixMathMapperAccurate() {;} + /** +Constructor +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + setBounds(_in_min,_in_max,_out_min,_out_max); + } + + + /** +Set the bounds of the mapper +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) + { + in_min = _in_min; + in_max = _in_max; + out_min = _out_min; + out_max = _out_max; + compute_coef(); } - + + + /** +Map an input to the output range +@param in the input + */ + out_type map(in_type in) const + { + return ((in - in_min) * coef) + out_min; + } + + + private: + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + in_type in_min, in_max; + out_type out_min, out_max; + + void compute_coef() + { + coef = (out_max-out_min)*(in_max-in_min).invAccurate(); + } }; + + + +/** +A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. +This version uses invAccurate() to perform the calculations. The biggest speed available to represent the whole target range, at the cost of some precision +*/ +template + class FixMathMapperFast +{ + + public: + /** Constructor + */ + FixMathMapperFast() {;} + /** +Constructor +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + setBounds(_in_min,_in_max,_out_min,_out_max); + } + + + /** +Set the bounds of the mapper +@param _in_min the lower bound of the input +@param _in_max the higher bound of the input +@param _out_min the lower bound of the output +@param _out_max the higher bound of the output +@note should work if they are not in increasing order but more testing needed to confirm +@note _in_min will be mapped to _out_min and _in_max to _out_max + */ + void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) + { + in_min = _in_min; + in_max = _in_max; + out_min = _out_min; + out_max = _out_max; + compute_coef(); + } + + + /** +Map an input to the output range +@param in the input + */ + out_type map(in_type in) const + { + return ((in - in_min) * coef) + out_min; + } + + + private: + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + in_type in_min, in_max; + out_type out_min, out_max; + + void compute_coef() + { + coef = (out_max-out_min)*(in_max-in_min).invFast(); + } +}; + + + #endif From d3f27215728a6ad44c1b71d473663101b5bfc8ef Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Tue, 4 Feb 2025 22:56:49 +0100 Subject: [PATCH 3/7] Added small mapper example --- examples/Mappers/Mappers.ino | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/Mappers/Mappers.ino diff --git a/examples/Mappers/Mappers.ino b/examples/Mappers/Mappers.ino new file mode 100644 index 0000000..1ee43c5 --- /dev/null +++ b/examples/Mappers/Mappers.ino @@ -0,0 +1,33 @@ +/* + * FixMath Library - Example demonstrating the use of FixMathMappers. + * This example code is in the public domain CONTRARY TO THE LIBRARY itself, + * which is licensed the GNU Lesser General Public Licence + * + */ + +#include +#include + +UFix<10, 0> input; +SFix<6, 2> output; + + +/* Three mappers are available, depending on their expected speed and precision. All of them only have a division on the setBounds() part, making the map() highly efficient as it only uses multiplications. + - FixMathMapperFull is the most accurate and uses invFull. It is the slowest (depending on platforms/types used, this might be equivalent). + - FixMathMapperAccurate might be faster the FixMapperFull in some cases, with only a slight loss of precision. + - FixMathMapperFast is the fastest, but might heavily digitize the output... Pick your weapon! + */ +FixMathMapperFull, SFix<6, 2>> mapper; // this declares a mapper between a UFix<10,0> and a SFix<6,2>. + +void setup() { + Serial.begin(115200); + mapper.setBounds(0, 1000, -64, 64); // the input is that case is not going full range of the 10 bits available, like a sensor could be, but should outputted on the full range of a SFix<6,2>. +} + +void loop() { + input = input + UFixAuto<1>(); + if (input > UFix<10, 0>(1000)) input = 0; + Serial.print(input.asFloat()); + Serial.print(" -> "); + Serial.println(mapper.map(input).asFloat()); // The .map() performs the mapping, and conversion. +} From 0f92ed77a5f8e5a809ba2ed2c16d50d742b9c2d8 Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Tue, 4 Feb 2025 22:57:54 +0100 Subject: [PATCH 4/7] Updated doc --- docs/html/FixMath_8h.html | 9 + docs/html/annotated.html | 17 +- .../classFixMathMapperAccurate-members.html | 81 +++++ docs/html/classFixMathMapperAccurate.html | 287 ++++++++++++++++++ docs/html/classFixMathMapperFast-members.html | 81 +++++ docs/html/classFixMathMapperFast.html | 287 ++++++++++++++++++ docs/html/classFixMathMapperFull-members.html | 81 +++++ docs/html/classFixMathMapperFull.html | 287 ++++++++++++++++++ docs/html/classes.html | 9 +- docs/html/files.html | 3 +- docs/html/functions.html | 23 ++ docs/html/functions_func.html | 23 ++ docs/html/menudata.js | 2 + docs/html/search/all_2.js | 7 +- docs/html/search/all_3.js | 6 +- docs/html/search/all_4.js | 22 +- docs/html/search/all_5.js | 9 +- docs/html/search/all_6.js | 11 +- docs/html/search/all_7.js | 8 +- docs/html/search/classes_0.js | 4 +- docs/html/search/classes_1.js | 10 +- docs/html/search/classes_2.js | 8 +- docs/html/search/files_0.js | 2 +- docs/html/search/functions_0.js | 12 +- docs/html/search/functions_1.js | 5 +- docs/html/search/functions_2.js | 6 +- docs/html/search/functions_3.js | 8 +- docs/html/search/functions_4.js | 9 +- docs/html/search/functions_5.js | 11 +- docs/html/search/functions_6.js | 8 +- docs/html/search/functions_7.js | 6 +- docs/html/search/namespaces_0.js | 2 +- docs/html/search/searchdata.js | 6 +- docs/latex/FixMath_8h.tex | 8 + docs/latex/annotated.tex | 3 + docs/latex/files.tex | 1 + docs/latex/refman.tex | 3 + 37 files changed, 1277 insertions(+), 88 deletions(-) create mode 100644 docs/html/classFixMathMapperAccurate-members.html create mode 100644 docs/html/classFixMathMapperAccurate.html create mode 100644 docs/html/classFixMathMapperFast-members.html create mode 100644 docs/html/classFixMathMapperFast.html create mode 100644 docs/html/classFixMathMapperFull-members.html create mode 100644 docs/html/classFixMathMapperFull.html diff --git a/docs/html/FixMath_8h.html b/docs/html/FixMath_8h.html index 1883e8e..23c85e2 100644 --- a/docs/html/FixMath_8h.html +++ b/docs/html/FixMath_8h.html @@ -88,6 +88,15 @@ +
+This graph shows which files directly or indirectly include this file:
+
+
+ + + + +

Go to the source code of this file.

diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 305db57..1aa95d7 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -70,13 +70,16 @@ - - - - - - - + + + + + + + + + +
 NFixMathPrivate
 CBitCounter
 CBitCounter< value, 0 >
 CIntegerType
 CIntegerType< 1 >
 CIntegerType< 2 >
 CIntegerType< 4 >
 CIntegerType< 8 >
 CSFix
 CUFix
 CFixMathMapperAccurate
 CFixMathMapperFast
 CFixMathMapperFull
 CIntegerType
 CIntegerType< 1 >
 CIntegerType< 2 >
 CIntegerType< 4 >
 CIntegerType< 8 >
 CSFix
 CUFix
diff --git a/docs/html/classFixMathMapperAccurate-members.html b/docs/html/classFixMathMapperAccurate-members.html new file mode 100644 index 0000000..70c1c2f --- /dev/null +++ b/docs/html/classFixMathMapperAccurate-members.html @@ -0,0 +1,81 @@ + + + + + + + +FixMath: Member List + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+
+
FixMathMapperAccurate< in_type, out_type > Member List
+
+
+ +

This is the complete list of members for FixMathMapperAccurate< in_type, out_type >, including all inherited members.

+ + + + + +
FixMathMapperAccurate()FixMathMapperAccurate< in_type, out_type >inline
FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperAccurate< in_type, out_type >inline
map(in_type in) constFixMathMapperAccurate< in_type, out_type >inline
setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperAccurate< in_type, out_type >inline
+ + + + diff --git a/docs/html/classFixMathMapperAccurate.html b/docs/html/classFixMathMapperAccurate.html new file mode 100644 index 0000000..b1b86a2 --- /dev/null +++ b/docs/html/classFixMathMapperAccurate.html @@ -0,0 +1,287 @@ + + + + + + + +FixMath: FixMathMapperAccurate< in_type, out_type > Class Template Reference + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
+
FixMathMapperAccurate< in_type, out_type > Class Template Reference
+
+
+ +

#include <FixMathMapper.h>

+ + + + + + + + + + +

+Public Member Functions

 FixMathMapperAccurate ()
 
 FixMathMapperAccurate (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
void setBounds (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
out_type map (in_type in) const
 
+

Detailed Description

+

template<typename in_type, typename out_type>
+class FixMathMapperAccurate< in_type, out_type >

+ +

A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invAccurate() to perform the calculations. The nearly biggest precision available, at the cost of some speed (platform and use-case dependent)

+

Constructor & Destructor Documentation

+ +

◆ FixMathMapperAccurate() [1/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + +
FixMathMapperAccurate< in_type, out_type >::FixMathMapperAccurate ()
+
+inline
+
+

Constructor

+ +
+
+ +

◆ FixMathMapperAccurate() [2/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FixMathMapperAccurate< in_type, out_type >::FixMathMapperAccurate (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Constructor

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+

Member Function Documentation

+ +

◆ map()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + +
out_type FixMathMapperAccurate< in_type, out_type >::map (in_type in) const
+
+inline
+
+

Map an input to the output range

Parameters
+ + +
inthe input
+
+
+ +
+
+ +

◆ setBounds()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void FixMathMapperAccurate< in_type, out_type >::setBounds (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Set the bounds of the mapper

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + diff --git a/docs/html/classFixMathMapperFast-members.html b/docs/html/classFixMathMapperFast-members.html new file mode 100644 index 0000000..bf0f312 --- /dev/null +++ b/docs/html/classFixMathMapperFast-members.html @@ -0,0 +1,81 @@ + + + + + + + +FixMath: Member List + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+
+
FixMathMapperFast< in_type, out_type > Member List
+
+
+ +

This is the complete list of members for FixMathMapperFast< in_type, out_type >, including all inherited members.

+ + + + + +
FixMathMapperFast()FixMathMapperFast< in_type, out_type >inline
FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperFast< in_type, out_type >inline
map(in_type in) constFixMathMapperFast< in_type, out_type >inline
setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperFast< in_type, out_type >inline
+ + + + diff --git a/docs/html/classFixMathMapperFast.html b/docs/html/classFixMathMapperFast.html new file mode 100644 index 0000000..609ae52 --- /dev/null +++ b/docs/html/classFixMathMapperFast.html @@ -0,0 +1,287 @@ + + + + + + + +FixMath: FixMathMapperFast< in_type, out_type > Class Template Reference + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
+
FixMathMapperFast< in_type, out_type > Class Template Reference
+
+
+ +

#include <FixMathMapper.h>

+ + + + + + + + + + +

+Public Member Functions

 FixMathMapperFast ()
 
 FixMathMapperFast (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
void setBounds (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
out_type map (in_type in) const
 
+

Detailed Description

+

template<typename in_type, typename out_type>
+class FixMathMapperFast< in_type, out_type >

+ +

A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invAccurate() to perform the calculations. The biggest speed available to represent the whole target range, at the cost of some precision

+

Constructor & Destructor Documentation

+ +

◆ FixMathMapperFast() [1/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + +
FixMathMapperFast< in_type, out_type >::FixMathMapperFast ()
+
+inline
+
+

Constructor

+ +
+
+ +

◆ FixMathMapperFast() [2/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FixMathMapperFast< in_type, out_type >::FixMathMapperFast (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Constructor

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+

Member Function Documentation

+ +

◆ map()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + +
out_type FixMathMapperFast< in_type, out_type >::map (in_type in) const
+
+inline
+
+

Map an input to the output range

Parameters
+ + +
inthe input
+
+
+ +
+
+ +

◆ setBounds()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void FixMathMapperFast< in_type, out_type >::setBounds (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Set the bounds of the mapper

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + diff --git a/docs/html/classFixMathMapperFull-members.html b/docs/html/classFixMathMapperFull-members.html new file mode 100644 index 0000000..701d248 --- /dev/null +++ b/docs/html/classFixMathMapperFull-members.html @@ -0,0 +1,81 @@ + + + + + + + +FixMath: Member List + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+
+
FixMathMapperFull< in_type, out_type > Member List
+
+
+ +

This is the complete list of members for FixMathMapperFull< in_type, out_type >, including all inherited members.

+ + + + + +
FixMathMapperFull()FixMathMapperFull< in_type, out_type >inline
FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperFull< in_type, out_type >inline
map(in_type in) constFixMathMapperFull< in_type, out_type >inline
setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)FixMathMapperFull< in_type, out_type >inline
+ + + + diff --git a/docs/html/classFixMathMapperFull.html b/docs/html/classFixMathMapperFull.html new file mode 100644 index 0000000..450a1a1 --- /dev/null +++ b/docs/html/classFixMathMapperFull.html @@ -0,0 +1,287 @@ + + + + + + + +FixMath: FixMathMapperFull< in_type, out_type > Class Template Reference + + + + + + + + + +
+
+ + + + + + +
+
FixMath +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
+
FixMathMapperFull< in_type, out_type > Class Template Reference
+
+
+ +

#include <FixMathMapper.h>

+ + + + + + + + + + +

+Public Member Functions

 FixMathMapperFull ()
 
 FixMathMapperFull (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
void setBounds (in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
 
out_type map (in_type in) const
 
+

Detailed Description

+

template<typename in_type, typename out_type>
+class FixMathMapperFull< in_type, out_type >

+ +

A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invFull() to perform the calculations. The biggest precision available, at the cost of some speed (platform and use-case dependent)

+

Constructor & Destructor Documentation

+ +

◆ FixMathMapperFull() [1/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + +
FixMathMapperFull< in_type, out_type >::FixMathMapperFull ()
+
+inline
+
+

Constructor

+ +
+
+ +

◆ FixMathMapperFull() [2/2]

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FixMathMapperFull< in_type, out_type >::FixMathMapperFull (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Constructor

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+

Member Function Documentation

+ +

◆ map()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + +
out_type FixMathMapperFull< in_type, out_type >::map (in_type in) const
+
+inline
+
+

Map an input to the output range

Parameters
+ + +
inthe input
+
+
+ +
+
+ +

◆ setBounds()

+ +
+
+
+template<typename in_type , typename out_type >
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void FixMathMapperFull< in_type, out_type >::setBounds (in_type _in_min,
in_type _in_max,
out_type _out_min,
out_type _out_max 
)
+
+inline
+
+

Set the bounds of the mapper

Parameters
+ + + + + +
_in_minthe lower bound of the input
_in_maxthe higher bound of the input
_out_minthe lower bound of the output
_out_maxthe higher bound of the output
+
+
+
Note
should work if they are not in increasing order but more testing needed to confirm
+
+_in_min will be mapped to _out_min and _in_max to _out_max
+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + diff --git a/docs/html/classes.html b/docs/html/classes.html index 3701586..42fbd52 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -65,18 +65,21 @@
Class Index
-
B | I | S | U
+
B | F | I | S | U
diff --git a/docs/html/files.html b/docs/html/files.html index e6843d3..9f7956d 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -69,7 +69,8 @@ - + +
 FixMath.h
 FixMath_Autotests.h
 IntegerType.h
 FixMathMapper.h
 IntegerType.h
diff --git a/docs/html/functions.html b/docs/html/functions.html index 6b3a0c9..8b2e41e 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -90,6 +90,15 @@

- a -

    - f -

      +
    • FixMathMapperAccurate() +: FixMathMapperAccurate< in_type, out_type > +
    • +
    • FixMathMapperFast() +: FixMathMapperFast< in_type, out_type > +
    • +
    • FixMathMapperFull() +: FixMathMapperFull< in_type, out_type > +
    • fromRaw() : SFix< NI, NF, RANGE > , UFix< NI, NF, RANGE > @@ -133,6 +142,15 @@

      - i -

      +

      - m -

      + +

      - o -

      • operator!=() : SFix< NI, NF, RANGE > @@ -170,6 +188,11 @@

        - o -

          - s -

            +
          • setBounds() +: FixMathMapperAccurate< in_type, out_type > +, FixMathMapperFast< in_type, out_type > +, FixMathMapperFull< in_type, out_type > +
          • SFix() : SFix< NI, NF, RANGE >
          • diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 150978f..0604884 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -90,6 +90,15 @@

            - a -

              - f -

                +
              • FixMathMapperAccurate() +: FixMathMapperAccurate< in_type, out_type > +
              • +
              • FixMathMapperFast() +: FixMathMapperFast< in_type, out_type > +
              • +
              • FixMathMapperFull() +: FixMathMapperFull< in_type, out_type > +
              • fromRaw() : SFix< NI, NF, RANGE > , UFix< NI, NF, RANGE > @@ -133,6 +142,15 @@

                - i -

                +

                - m -

                + +

                - o -

                • operator!=() : SFix< NI, NF, RANGE > @@ -170,6 +188,11 @@

                  - o -

                    - s -

                      +
                    • setBounds() +: FixMathMapperAccurate< in_type, out_type > +, FixMathMapperFast< in_type, out_type > +, FixMathMapperFull< in_type, out_type > +
                    • SFix() : SFix< NI, NF, RANGE >
                    • diff --git a/docs/html/menudata.js b/docs/html/menudata.js index f50b36e..1d92cfc 100644 --- a/docs/html/menudata.js +++ b/docs/html/menudata.js @@ -35,6 +35,7 @@ var menudata={children:[ {text:"f",url:"functions.html#index_f"}, {text:"g",url:"functions.html#index_g"}, {text:"i",url:"functions.html#index_i"}, +{text:"m",url:"functions.html#index_m"}, {text:"o",url:"functions.html#index_o"}, {text:"s",url:"functions.html#index_s"}, {text:"u",url:"functions.html#index_u"}]}, @@ -43,6 +44,7 @@ var menudata={children:[ {text:"f",url:"functions_func.html#index_f"}, {text:"g",url:"functions_func.html#index_g"}, {text:"i",url:"functions_func.html#index_i"}, +{text:"m",url:"functions_func.html#index_m"}, {text:"o",url:"functions_func.html#index_o"}, {text:"s",url:"functions_func.html#index_s"}, {text:"u",url:"functions_func.html#index_u"}]}]}]}, diff --git a/docs/html/search/all_2.js b/docs/html/search/all_2.js index 8f7bc46..896c473 100644 --- a/docs/html/search/all_2.js +++ b/docs/html/search/all_2.js @@ -1,6 +1,9 @@ var searchData= [ ['fixmath_2eh_8',['FixMath.h',['../FixMath_8h.html',1,'']]], - ['fixmathprivate_9',['FixMathPrivate',['../namespaceFixMathPrivate.html',1,'']]], - ['fromraw_10',['fromRaw',['../classUFix.html#addb9e008fc41495e651b03c77aed89d0',1,'UFix::fromRaw()'],['../classSFix.html#a0108a2ff808131b2bbcecee4d0c9b618',1,'SFix::fromRaw()']]] + ['fixmathmapperaccurate_9',['FixMathMapperAccurate',['../classFixMathMapperAccurate.html',1,'FixMathMapperAccurate< in_type, out_type >'],['../classFixMathMapperAccurate.html#a64fae365e8ea7cef96d4c4d3178974e6',1,'FixMathMapperAccurate::FixMathMapperAccurate()'],['../classFixMathMapperAccurate.html#a980337696cda502e721e1bd86ed6d7db',1,'FixMathMapperAccurate::FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fixmathmapperfast_10',['FixMathMapperFast',['../classFixMathMapperFast.html',1,'FixMathMapperFast< in_type, out_type >'],['../classFixMathMapperFast.html#a546d13eda4c3b271f29b03b1d42cc183',1,'FixMathMapperFast::FixMathMapperFast()'],['../classFixMathMapperFast.html#a75c8fe5f3ecd48f62c31454628fa93dd',1,'FixMathMapperFast::FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fixmathmapperfull_11',['FixMathMapperFull',['../classFixMathMapperFull.html',1,'FixMathMapperFull< in_type, out_type >'],['../classFixMathMapperFull.html#a5ab4dbd6e93500bf8ad7d6999834a66c',1,'FixMathMapperFull::FixMathMapperFull()'],['../classFixMathMapperFull.html#a94f428ba87eb2fc7b7bf1ff94c236c6b',1,'FixMathMapperFull::FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fixmathprivate_12',['FixMathPrivate',['../namespaceFixMathPrivate.html',1,'']]], + ['fromraw_13',['fromRaw',['../classUFix.html#addb9e008fc41495e651b03c77aed89d0',1,'UFix::fromRaw()'],['../classSFix.html#a0108a2ff808131b2bbcecee4d0c9b618',1,'SFix::fromRaw()']]] ]; diff --git a/docs/html/search/all_3.js b/docs/html/search/all_3.js index 2b26c21..1abc8a0 100644 --- a/docs/html/search/all_3.js +++ b/docs/html/search/all_3.js @@ -1,6 +1,6 @@ var searchData= [ - ['getnf_11',['getNF',['../classUFix.html#a900f594b8b95f377fff38c49f5149866',1,'UFix::getNF()'],['../classSFix.html#a319ae49f75636efec3999140a31fc85c',1,'SFix::getNF()']]], - ['getni_12',['getNI',['../classUFix.html#aa17a66aaaeed2e67163f2bc8bbf2ce08',1,'UFix::getNI()'],['../classSFix.html#a8e26f89e3aa2969906d9ff3deaa53328',1,'SFix::getNI()']]], - ['getrange_13',['getRANGE',['../classUFix.html#a7ed462de594b84eb5c816cdbd7dca1d4',1,'UFix::getRANGE()'],['../classSFix.html#a89df92655a3e9760b2954582043aaea7',1,'SFix::getRANGE()']]] + ['getnf_14',['getNF',['../classUFix.html#a900f594b8b95f377fff38c49f5149866',1,'UFix::getNF()'],['../classSFix.html#a319ae49f75636efec3999140a31fc85c',1,'SFix::getNF()']]], + ['getni_15',['getNI',['../classUFix.html#aa17a66aaaeed2e67163f2bc8bbf2ce08',1,'UFix::getNI()'],['../classSFix.html#a8e26f89e3aa2969906d9ff3deaa53328',1,'SFix::getNI()']]], + ['getrange_16',['getRANGE',['../classUFix.html#a7ed462de594b84eb5c816cdbd7dca1d4',1,'UFix::getRANGE()'],['../classSFix.html#a89df92655a3e9760b2954582043aaea7',1,'SFix::getRANGE()']]] ]; diff --git a/docs/html/search/all_4.js b/docs/html/search/all_4.js index 06b7545..39911a0 100644 --- a/docs/html/search/all_4.js +++ b/docs/html/search/all_4.js @@ -1,14 +1,14 @@ var searchData= [ - ['integertype_14',['IntegerType',['../structIntegerType.html',1,'']]], - ['integertype_3c_201_20_3e_15',['IntegerType< 1 >',['../structIntegerType_3_011_01_4.html',1,'']]], - ['integertype_3c_202_20_3e_16',['IntegerType< 2 >',['../structIntegerType_3_012_01_4.html',1,'']]], - ['integertype_3c_204_20_3e_17',['IntegerType< 4 >',['../structIntegerType_3_014_01_4.html',1,'']]], - ['integertype_3c_208_20_3e_18',['IntegerType< 8 >',['../structIntegerType_3_018_01_4.html',1,'']]], - ['integertype_3c_20fixmathprivate_3a_3asbitstobytes_28ni_2bnf_29_3e_19',['IntegerType< FixMathPrivate::sBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], - ['integertype_3c_20fixmathprivate_3a_3aubitstobytes_28ni_2bnf_29_3e_20',['IntegerType< FixMathPrivate::uBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], - ['inv_21',['inv',['../classUFix.html#adfa277fb8de13ef075c2f01048b0b302',1,'UFix::inv()'],['../classSFix.html#a9a77192383382e2ba7496c614db81343',1,'SFix::inv()']]], - ['invaccurate_22',['invAccurate',['../classUFix.html#a85cbf1c2c1d3096dbe079b09feacebb0',1,'UFix::invAccurate()'],['../classSFix.html#a7937916cb7c7aae5fbb33165df113445',1,'SFix::invAccurate()']]], - ['invfast_23',['invFast',['../classUFix.html#aa958c40d69f0926ea9d0ee187ed16006',1,'UFix::invFast()'],['../classSFix.html#ac02cc3a7746ce0550428095d8cba9eba',1,'SFix::invFast()']]], - ['invfull_24',['invFull',['../classUFix.html#a89807c8de3c6f82ef6c2f65b2903bc95',1,'UFix::invFull()'],['../classSFix.html#a35ca66653e6de4958b0ccb22b644f66e',1,'SFix::invFull()']]] + ['integertype_17',['IntegerType',['../structIntegerType.html',1,'']]], + ['integertype_3c_201_20_3e_18',['IntegerType< 1 >',['../structIntegerType_3_011_01_4.html',1,'']]], + ['integertype_3c_202_20_3e_19',['IntegerType< 2 >',['../structIntegerType_3_012_01_4.html',1,'']]], + ['integertype_3c_204_20_3e_20',['IntegerType< 4 >',['../structIntegerType_3_014_01_4.html',1,'']]], + ['integertype_3c_208_20_3e_21',['IntegerType< 8 >',['../structIntegerType_3_018_01_4.html',1,'']]], + ['integertype_3c_20fixmathprivate_3a_3asbitstobytes_28ni_2bnf_29_3e_22',['IntegerType< FixMathPrivate::sBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], + ['integertype_3c_20fixmathprivate_3a_3aubitstobytes_28ni_2bnf_29_3e_23',['IntegerType< FixMathPrivate::uBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], + ['inv_24',['inv',['../classUFix.html#adfa277fb8de13ef075c2f01048b0b302',1,'UFix::inv()'],['../classSFix.html#a9a77192383382e2ba7496c614db81343',1,'SFix::inv()']]], + ['invaccurate_25',['invAccurate',['../classUFix.html#a85cbf1c2c1d3096dbe079b09feacebb0',1,'UFix::invAccurate()'],['../classSFix.html#a7937916cb7c7aae5fbb33165df113445',1,'SFix::invAccurate()']]], + ['invfast_26',['invFast',['../classUFix.html#aa958c40d69f0926ea9d0ee187ed16006',1,'UFix::invFast()'],['../classSFix.html#ac02cc3a7746ce0550428095d8cba9eba',1,'SFix::invFast()']]], + ['invfull_27',['invFull',['../classUFix.html#a89807c8de3c6f82ef6c2f65b2903bc95',1,'UFix::invFull()'],['../classSFix.html#a35ca66653e6de4958b0ccb22b644f66e',1,'SFix::invFull()']]] ]; diff --git a/docs/html/search/all_5.js b/docs/html/search/all_5.js index 7f3c3ef..2494947 100644 --- a/docs/html/search/all_5.js +++ b/docs/html/search/all_5.js @@ -1,11 +1,4 @@ var searchData= [ - ['operator_21_3d_25',['operator!=',['../classSFix.html#a22e6b735d20ac94a07bd6ae1b6bc0c0c',1,'SFix::operator!=()'],['../FixMath_8h.html#a0fa4c56f004c4bcf800359a3907a42ef',1,'operator!=(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#aae4dc21682154845652c89a69a48ca18',1,'operator!=(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a170d50e511f622186082af600e069609',1,'UFix::operator!=()']]], - ['operator_2a_26',['operator*',['../classSFix.html#a0378525fe44b041e160eb32038bf30bf',1,'SFix::operator*()'],['../classUFix.html#ac6d297515c30a6e4f2895a3c73e8aa2f',1,'UFix::operator*(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#ae08634f2ec6f686e781e0805aa8c8c69',1,'UFix::operator*(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a25b81f170bb1348644459843c23dc0c6',1,'SFix::operator*()']]], - ['operator_2b_27',['operator+',['../classUFix.html#ae855ab54e2b28c755c41ad0941fbe33a',1,'UFix::operator+(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#acc26f823f4151d244bce276d8e39c985',1,'UFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a6897e22fd904f54fdb7555b7bee852f6',1,'SFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#ac991db0bee7ebb63e091582d41e9c766',1,'SFix::operator+(const UFix< _NI, _NF, _RANGE > &op2) const']]], - ['operator_2d_28',['operator-',['../classUFix.html#a20414eb474cfb24b9c0da72ce507d5fe',1,'UFix::operator-()'],['../classSFix.html#ae72d489b35d6ec78315735a0a411b39a',1,'SFix::operator-() const'],['../classSFix.html#aecff8ee0cac43d3262f1453b03c17fd5',1,'SFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a8eabdb5d47e38190bf7d25430c7a8256',1,'SFix::operator-(const SFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#aefe821e3f4919ee8407aac4ef4ae6cb1',1,'UFix::operator-(const SFix< _NI, _NF, _RANGE > &op2) const'],['../classUFix.html#a59470679dbbaa691a12b09554195fd45',1,'UFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const']]], - ['operator_3c_29',['operator<',['../FixMath_8h.html#ab773f1f3dca60ecd08756268c4e1581d',1,'operator<(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#ad70883fc4f0dc62c55a831a506602d96',1,'operator<(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a8a55813939a59bc8840315de126bfe50',1,'UFix::operator<()'],['../classSFix.html#a3919f181cdf1a9789b0a4ddc3c7350df',1,'SFix::operator<(const SFix< _NI, _NF > &op) const']]], - ['operator_3d_3d_30',['operator==',['../classSFix.html#adbf8ca8954a76ec1569dc1ed968e57c8',1,'SFix::operator==()'],['../classUFix.html#ae66992644d158a7efeb8e521497a3a13',1,'UFix::operator==()'],['../FixMath_8h.html#a8b8bf5f8934ac98afb345f29feefb712',1,'operator==(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a5352a505056ab3e61f3364a6f43f33bf',1,'operator==(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], - ['operator_3e_31',['operator>',['../classSFix.html#a2713361a7c85c7c5fb1479a85fa767f5',1,'SFix::operator>()'],['../classUFix.html#addd4204bb434debae918c859da069012',1,'UFix::operator>()'],['../FixMath_8h.html#a85ff3e79510e17f13056c58a2191be18',1,'operator>(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a771e19acc8c3adaa3296148c1e6ebdde',1,'operator>(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], - ['operator_3e_3e_32',['operator>>',['../classUFix.html#a38e656ca44e325c3f384917d53a7882d',1,'UFix::operator>>()'],['../classSFix.html#a660b7f1ecb5c41cdd95ad2f7105b9cdf',1,'SFix::operator>>()']]] + ['map_28',['map',['../classFixMathMapperFull.html#ac0369876b0a7945b9a45634d6d38befc',1,'FixMathMapperFull::map()'],['../classFixMathMapperAccurate.html#a1607c7a09e773cf424d27b8a59981bff',1,'FixMathMapperAccurate::map()'],['../classFixMathMapperFast.html#ad4a98cd13396ca2e69c04aca27b578c7',1,'FixMathMapperFast::map()']]] ]; diff --git a/docs/html/search/all_6.js b/docs/html/search/all_6.js index bb3c02e..3c1b13c 100644 --- a/docs/html/search/all_6.js +++ b/docs/html/search/all_6.js @@ -1,6 +1,11 @@ var searchData= [ - ['sfix_33',['SFix',['../classSFix.html',1,'SFix< NI, NF, RANGE >'],['../classSFix.html#a0c98bb108b044af13a6329142c7b2de6',1,'SFix::SFix()'],['../classSFix.html#a29b24255334b013518c060354dad8128',1,'SFix::SFix(float fl)'],['../classSFix.html#af205019d40489f55d3be4ae1ffe603c5',1,'SFix::SFix(double fl)'],['../classSFix.html#ae677662a0546de5535c93121e7bc1762',1,'SFix::SFix(T value, bool as_raw=false)'],['../classSFix.html#a2e1a7033339c03de9ceab22962740ed9',1,'SFix::SFix(const SFix< _NI, _NF, _RANGE > &sf)'],['../classSFix.html#a164116927fa8b7664a7a4423efc50e96',1,'SFix::SFix(const UFix< _NI, _NF, _RANGE > &uf)']]], - ['sl_34',['sL',['../classUFix.html#add741555c674d50504ae2999080c80e1',1,'UFix::sL()'],['../classSFix.html#aff21f36dcf756d3ae806b38af577066c',1,'SFix::sL()']]], - ['sr_35',['sR',['../classUFix.html#a9835b0be256af62795f14aa454a1ab0c',1,'UFix::sR()'],['../classSFix.html#aadca956470c845c976ac25d43870d0da',1,'SFix::sR()']]] + ['operator_21_3d_29',['operator!=',['../classSFix.html#a22e6b735d20ac94a07bd6ae1b6bc0c0c',1,'SFix::operator!=()'],['../FixMath_8h.html#a0fa4c56f004c4bcf800359a3907a42ef',1,'operator!=(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#aae4dc21682154845652c89a69a48ca18',1,'operator!=(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a170d50e511f622186082af600e069609',1,'UFix::operator!=()']]], + ['operator_2a_30',['operator*',['../classSFix.html#a0378525fe44b041e160eb32038bf30bf',1,'SFix::operator*()'],['../classUFix.html#ac6d297515c30a6e4f2895a3c73e8aa2f',1,'UFix::operator*(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#ae08634f2ec6f686e781e0805aa8c8c69',1,'UFix::operator*(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a25b81f170bb1348644459843c23dc0c6',1,'SFix::operator*()']]], + ['operator_2b_31',['operator+',['../classUFix.html#ae855ab54e2b28c755c41ad0941fbe33a',1,'UFix::operator+(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#acc26f823f4151d244bce276d8e39c985',1,'UFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a6897e22fd904f54fdb7555b7bee852f6',1,'SFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#ac991db0bee7ebb63e091582d41e9c766',1,'SFix::operator+(const UFix< _NI, _NF, _RANGE > &op2) const']]], + ['operator_2d_32',['operator-',['../classUFix.html#a20414eb474cfb24b9c0da72ce507d5fe',1,'UFix::operator-()'],['../classSFix.html#ae72d489b35d6ec78315735a0a411b39a',1,'SFix::operator-() const'],['../classSFix.html#aecff8ee0cac43d3262f1453b03c17fd5',1,'SFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a8eabdb5d47e38190bf7d25430c7a8256',1,'SFix::operator-(const SFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#aefe821e3f4919ee8407aac4ef4ae6cb1',1,'UFix::operator-(const SFix< _NI, _NF, _RANGE > &op2) const'],['../classUFix.html#a59470679dbbaa691a12b09554195fd45',1,'UFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const']]], + ['operator_3c_33',['operator<',['../FixMath_8h.html#ab773f1f3dca60ecd08756268c4e1581d',1,'operator<(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#ad70883fc4f0dc62c55a831a506602d96',1,'operator<(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a8a55813939a59bc8840315de126bfe50',1,'UFix::operator<()'],['../classSFix.html#a3919f181cdf1a9789b0a4ddc3c7350df',1,'SFix::operator<(const SFix< _NI, _NF > &op) const']]], + ['operator_3d_3d_34',['operator==',['../classSFix.html#adbf8ca8954a76ec1569dc1ed968e57c8',1,'SFix::operator==()'],['../classUFix.html#ae66992644d158a7efeb8e521497a3a13',1,'UFix::operator==()'],['../FixMath_8h.html#a8b8bf5f8934ac98afb345f29feefb712',1,'operator==(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a5352a505056ab3e61f3364a6f43f33bf',1,'operator==(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], + ['operator_3e_35',['operator>',['../classSFix.html#a2713361a7c85c7c5fb1479a85fa767f5',1,'SFix::operator>()'],['../classUFix.html#addd4204bb434debae918c859da069012',1,'UFix::operator>()'],['../FixMath_8h.html#a85ff3e79510e17f13056c58a2191be18',1,'operator>(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a771e19acc8c3adaa3296148c1e6ebdde',1,'operator>(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], + ['operator_3e_3e_36',['operator>>',['../classUFix.html#a38e656ca44e325c3f384917d53a7882d',1,'UFix::operator>>()'],['../classSFix.html#a660b7f1ecb5c41cdd95ad2f7105b9cdf',1,'SFix::operator>>()']]] ]; diff --git a/docs/html/search/all_7.js b/docs/html/search/all_7.js index 7c3fe0e..b802f09 100644 --- a/docs/html/search/all_7.js +++ b/docs/html/search/all_7.js @@ -1,7 +1,7 @@ var searchData= [ - ['tosfraction_36',['toSFraction',['../FixMath_8h.html#aac7fece5e8162407f033d0fbf022ad15',1,'FixMath.h']]], - ['tosint_37',['toSInt',['../FixMath_8h.html#ac479196160eb99ddf534e0768e3f1990',1,'FixMath.h']]], - ['toufraction_38',['toUFraction',['../FixMath_8h.html#ab6c690d265da5284fa40b19574b286cb',1,'FixMath.h']]], - ['touint_39',['toUInt',['../FixMath_8h.html#a0dda76ba96e4ae059e3872b080b6c681',1,'FixMath.h']]] + ['setbounds_37',['setBounds',['../classFixMathMapperFull.html#ade3da77f70abc086774625f3137d0707',1,'FixMathMapperFull::setBounds()'],['../classFixMathMapperAccurate.html#a8ed52d98bfdf5e5d0c95366a3f259a34',1,'FixMathMapperAccurate::setBounds()'],['../classFixMathMapperFast.html#a984c4197b8907f4e5d5cc9f688faaaa5',1,'FixMathMapperFast::setBounds()']]], + ['sfix_38',['SFix',['../classSFix.html',1,'SFix< NI, NF, RANGE >'],['../classSFix.html#a0c98bb108b044af13a6329142c7b2de6',1,'SFix::SFix()'],['../classSFix.html#a29b24255334b013518c060354dad8128',1,'SFix::SFix(float fl)'],['../classSFix.html#af205019d40489f55d3be4ae1ffe603c5',1,'SFix::SFix(double fl)'],['../classSFix.html#ae677662a0546de5535c93121e7bc1762',1,'SFix::SFix(T value, bool as_raw=false)'],['../classSFix.html#a2e1a7033339c03de9ceab22962740ed9',1,'SFix::SFix(const SFix< _NI, _NF, _RANGE > &sf)'],['../classSFix.html#a164116927fa8b7664a7a4423efc50e96',1,'SFix::SFix(const UFix< _NI, _NF, _RANGE > &uf)']]], + ['sl_39',['sL',['../classUFix.html#add741555c674d50504ae2999080c80e1',1,'UFix::sL()'],['../classSFix.html#aff21f36dcf756d3ae806b38af577066c',1,'SFix::sL()']]], + ['sr_40',['sR',['../classUFix.html#a9835b0be256af62795f14aa454a1ab0c',1,'UFix::sR()'],['../classSFix.html#aadca956470c845c976ac25d43870d0da',1,'SFix::sR()']]] ]; diff --git a/docs/html/search/classes_0.js b/docs/html/search/classes_0.js index 9815c79..be5a225 100644 --- a/docs/html/search/classes_0.js +++ b/docs/html/search/classes_0.js @@ -1,5 +1,5 @@ var searchData= [ - ['bitcounter_42',['BitCounter',['../structFixMathPrivate_1_1BitCounter.html',1,'FixMathPrivate']]], - ['bitcounter_3c_20value_2c_200_20_3e_43',['BitCounter< value, 0 >',['../structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html',1,'FixMathPrivate']]] + ['bitcounter_47',['BitCounter',['../structFixMathPrivate_1_1BitCounter.html',1,'FixMathPrivate']]], + ['bitcounter_3c_20value_2c_200_20_3e_48',['BitCounter< value, 0 >',['../structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html',1,'FixMathPrivate']]] ]; diff --git a/docs/html/search/classes_1.js b/docs/html/search/classes_1.js index 0485565..c81403f 100644 --- a/docs/html/search/classes_1.js +++ b/docs/html/search/classes_1.js @@ -1,10 +1,6 @@ var searchData= [ - ['integertype_44',['IntegerType',['../structIntegerType.html',1,'']]], - ['integertype_3c_201_20_3e_45',['IntegerType< 1 >',['../structIntegerType_3_011_01_4.html',1,'']]], - ['integertype_3c_202_20_3e_46',['IntegerType< 2 >',['../structIntegerType_3_012_01_4.html',1,'']]], - ['integertype_3c_204_20_3e_47',['IntegerType< 4 >',['../structIntegerType_3_014_01_4.html',1,'']]], - ['integertype_3c_208_20_3e_48',['IntegerType< 8 >',['../structIntegerType_3_018_01_4.html',1,'']]], - ['integertype_3c_20fixmathprivate_3a_3asbitstobytes_28ni_2bnf_29_3e_49',['IntegerType< FixMathPrivate::sBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], - ['integertype_3c_20fixmathprivate_3a_3aubitstobytes_28ni_2bnf_29_3e_50',['IntegerType< FixMathPrivate::uBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]] + ['fixmathmapperaccurate_49',['FixMathMapperAccurate',['../classFixMathMapperAccurate.html',1,'']]], + ['fixmathmapperfast_50',['FixMathMapperFast',['../classFixMathMapperFast.html',1,'']]], + ['fixmathmapperfull_51',['FixMathMapperFull',['../classFixMathMapperFull.html',1,'']]] ]; diff --git a/docs/html/search/classes_2.js b/docs/html/search/classes_2.js index aafe055..d9b5ec3 100644 --- a/docs/html/search/classes_2.js +++ b/docs/html/search/classes_2.js @@ -1,4 +1,10 @@ var searchData= [ - ['sfix_51',['SFix',['../classSFix.html',1,'']]] + ['integertype_52',['IntegerType',['../structIntegerType.html',1,'']]], + ['integertype_3c_201_20_3e_53',['IntegerType< 1 >',['../structIntegerType_3_011_01_4.html',1,'']]], + ['integertype_3c_202_20_3e_54',['IntegerType< 2 >',['../structIntegerType_3_012_01_4.html',1,'']]], + ['integertype_3c_204_20_3e_55',['IntegerType< 4 >',['../structIntegerType_3_014_01_4.html',1,'']]], + ['integertype_3c_208_20_3e_56',['IntegerType< 8 >',['../structIntegerType_3_018_01_4.html',1,'']]], + ['integertype_3c_20fixmathprivate_3a_3asbitstobytes_28ni_2bnf_29_3e_57',['IntegerType< FixMathPrivate::sBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]], + ['integertype_3c_20fixmathprivate_3a_3aubitstobytes_28ni_2bnf_29_3e_58',['IntegerType< FixMathPrivate::uBitsToBytes(NI+NF)>',['../structIntegerType.html',1,'']]] ]; diff --git a/docs/html/search/files_0.js b/docs/html/search/files_0.js index 397da38..a13f587 100644 --- a/docs/html/search/files_0.js +++ b/docs/html/search/files_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['fixmath_2eh_54',['FixMath.h',['../FixMath_8h.html',1,'']]] + ['fixmath_2eh_62',['FixMath.h',['../FixMath_8h.html',1,'']]] ]; diff --git a/docs/html/search/functions_0.js b/docs/html/search/functions_0.js index 0a7bd3a..5a3d9de 100644 --- a/docs/html/search/functions_0.js +++ b/docs/html/search/functions_0.js @@ -1,9 +1,9 @@ var searchData= [ - ['asfloat_55',['asFloat',['../classUFix.html#aeaabe601fa4fa53d39ef5026f644d36f',1,'UFix::asFloat()'],['../classSFix.html#a3bd75c2f6a196e16854ca189e8769624',1,'SFix::asFloat()']]], - ['asint_56',['asInt',['../classUFix.html#a72bfc5596616a080c133a7075ba1815b',1,'UFix::asInt()'],['../classSFix.html#a7471ac4241e86f15f263db7c65478b20',1,'SFix::asInt()']]], - ['asraw_57',['asRaw',['../classUFix.html#a390542b7d93844ec88b66c6827775e81',1,'UFix::asRaw()'],['../classSFix.html#a30667c56d94bf030fbe51d4ed9950b08',1,'SFix::asRaw()']]], - ['assertsize_58',['assertSize',['../classUFix.html#a4cce7ec1619e8b6d158e69ad437168c3',1,'UFix::assertSize()'],['../classSFix.html#a59bd681b9d4bfaa3141d9d96e05728a2',1,'SFix::assertSize()']]], - ['assfix_59',['asSFix',['../classUFix.html#ad3d368e0eca82acd2e8088d4fe6114af',1,'UFix']]], - ['asufix_60',['asUFix',['../classSFix.html#a0ae56f253ada7f3b73756616eac13e91',1,'SFix']]] + ['asfloat_63',['asFloat',['../classUFix.html#aeaabe601fa4fa53d39ef5026f644d36f',1,'UFix::asFloat()'],['../classSFix.html#a3bd75c2f6a196e16854ca189e8769624',1,'SFix::asFloat()']]], + ['asint_64',['asInt',['../classUFix.html#a72bfc5596616a080c133a7075ba1815b',1,'UFix::asInt()'],['../classSFix.html#a7471ac4241e86f15f263db7c65478b20',1,'SFix::asInt()']]], + ['asraw_65',['asRaw',['../classUFix.html#a390542b7d93844ec88b66c6827775e81',1,'UFix::asRaw()'],['../classSFix.html#a30667c56d94bf030fbe51d4ed9950b08',1,'SFix::asRaw()']]], + ['assertsize_66',['assertSize',['../classUFix.html#a4cce7ec1619e8b6d158e69ad437168c3',1,'UFix::assertSize()'],['../classSFix.html#a59bd681b9d4bfaa3141d9d96e05728a2',1,'SFix::assertSize()']]], + ['assfix_67',['asSFix',['../classUFix.html#ad3d368e0eca82acd2e8088d4fe6114af',1,'UFix']]], + ['asufix_68',['asUFix',['../classSFix.html#a0ae56f253ada7f3b73756616eac13e91',1,'SFix']]] ]; diff --git a/docs/html/search/functions_1.js b/docs/html/search/functions_1.js index 01998f9..4afc5a7 100644 --- a/docs/html/search/functions_1.js +++ b/docs/html/search/functions_1.js @@ -1,4 +1,7 @@ var searchData= [ - ['fromraw_61',['fromRaw',['../classUFix.html#addb9e008fc41495e651b03c77aed89d0',1,'UFix::fromRaw()'],['../classSFix.html#a0108a2ff808131b2bbcecee4d0c9b618',1,'SFix::fromRaw()']]] + ['fixmathmapperaccurate_69',['FixMathMapperAccurate',['../classFixMathMapperAccurate.html#a64fae365e8ea7cef96d4c4d3178974e6',1,'FixMathMapperAccurate::FixMathMapperAccurate()'],['../classFixMathMapperAccurate.html#a980337696cda502e721e1bd86ed6d7db',1,'FixMathMapperAccurate::FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fixmathmapperfast_70',['FixMathMapperFast',['../classFixMathMapperFast.html#a546d13eda4c3b271f29b03b1d42cc183',1,'FixMathMapperFast::FixMathMapperFast()'],['../classFixMathMapperFast.html#a75c8fe5f3ecd48f62c31454628fa93dd',1,'FixMathMapperFast::FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fixmathmapperfull_71',['FixMathMapperFull',['../classFixMathMapperFull.html#a5ab4dbd6e93500bf8ad7d6999834a66c',1,'FixMathMapperFull::FixMathMapperFull()'],['../classFixMathMapperFull.html#a94f428ba87eb2fc7b7bf1ff94c236c6b',1,'FixMathMapperFull::FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)']]], + ['fromraw_72',['fromRaw',['../classUFix.html#addb9e008fc41495e651b03c77aed89d0',1,'UFix::fromRaw()'],['../classSFix.html#a0108a2ff808131b2bbcecee4d0c9b618',1,'SFix::fromRaw()']]] ]; diff --git a/docs/html/search/functions_2.js b/docs/html/search/functions_2.js index f4cd38a..70992cd 100644 --- a/docs/html/search/functions_2.js +++ b/docs/html/search/functions_2.js @@ -1,6 +1,6 @@ var searchData= [ - ['getnf_62',['getNF',['../classUFix.html#a900f594b8b95f377fff38c49f5149866',1,'UFix::getNF()'],['../classSFix.html#a319ae49f75636efec3999140a31fc85c',1,'SFix::getNF()']]], - ['getni_63',['getNI',['../classUFix.html#aa17a66aaaeed2e67163f2bc8bbf2ce08',1,'UFix::getNI()'],['../classSFix.html#a8e26f89e3aa2969906d9ff3deaa53328',1,'SFix::getNI()']]], - ['getrange_64',['getRANGE',['../classUFix.html#a7ed462de594b84eb5c816cdbd7dca1d4',1,'UFix::getRANGE()'],['../classSFix.html#a89df92655a3e9760b2954582043aaea7',1,'SFix::getRANGE()']]] + ['getnf_73',['getNF',['../classUFix.html#a900f594b8b95f377fff38c49f5149866',1,'UFix::getNF()'],['../classSFix.html#a319ae49f75636efec3999140a31fc85c',1,'SFix::getNF()']]], + ['getni_74',['getNI',['../classUFix.html#aa17a66aaaeed2e67163f2bc8bbf2ce08',1,'UFix::getNI()'],['../classSFix.html#a8e26f89e3aa2969906d9ff3deaa53328',1,'SFix::getNI()']]], + ['getrange_75',['getRANGE',['../classUFix.html#a7ed462de594b84eb5c816cdbd7dca1d4',1,'UFix::getRANGE()'],['../classSFix.html#a89df92655a3e9760b2954582043aaea7',1,'SFix::getRANGE()']]] ]; diff --git a/docs/html/search/functions_3.js b/docs/html/search/functions_3.js index f0cfda2..3f1addc 100644 --- a/docs/html/search/functions_3.js +++ b/docs/html/search/functions_3.js @@ -1,7 +1,7 @@ var searchData= [ - ['inv_65',['inv',['../classUFix.html#adfa277fb8de13ef075c2f01048b0b302',1,'UFix::inv()'],['../classSFix.html#a9a77192383382e2ba7496c614db81343',1,'SFix::inv()']]], - ['invaccurate_66',['invAccurate',['../classUFix.html#a85cbf1c2c1d3096dbe079b09feacebb0',1,'UFix::invAccurate()'],['../classSFix.html#a7937916cb7c7aae5fbb33165df113445',1,'SFix::invAccurate()']]], - ['invfast_67',['invFast',['../classUFix.html#aa958c40d69f0926ea9d0ee187ed16006',1,'UFix::invFast()'],['../classSFix.html#ac02cc3a7746ce0550428095d8cba9eba',1,'SFix::invFast()']]], - ['invfull_68',['invFull',['../classUFix.html#a89807c8de3c6f82ef6c2f65b2903bc95',1,'UFix::invFull()'],['../classSFix.html#a35ca66653e6de4958b0ccb22b644f66e',1,'SFix::invFull()']]] + ['inv_76',['inv',['../classUFix.html#adfa277fb8de13ef075c2f01048b0b302',1,'UFix::inv()'],['../classSFix.html#a9a77192383382e2ba7496c614db81343',1,'SFix::inv()']]], + ['invaccurate_77',['invAccurate',['../classUFix.html#a85cbf1c2c1d3096dbe079b09feacebb0',1,'UFix::invAccurate()'],['../classSFix.html#a7937916cb7c7aae5fbb33165df113445',1,'SFix::invAccurate()']]], + ['invfast_78',['invFast',['../classUFix.html#aa958c40d69f0926ea9d0ee187ed16006',1,'UFix::invFast()'],['../classSFix.html#ac02cc3a7746ce0550428095d8cba9eba',1,'SFix::invFast()']]], + ['invfull_79',['invFull',['../classUFix.html#a89807c8de3c6f82ef6c2f65b2903bc95',1,'UFix::invFull()'],['../classSFix.html#a35ca66653e6de4958b0ccb22b644f66e',1,'SFix::invFull()']]] ]; diff --git a/docs/html/search/functions_4.js b/docs/html/search/functions_4.js index 60d573e..33bbc05 100644 --- a/docs/html/search/functions_4.js +++ b/docs/html/search/functions_4.js @@ -1,11 +1,4 @@ var searchData= [ - ['operator_21_3d_69',['operator!=',['../classSFix.html#a22e6b735d20ac94a07bd6ae1b6bc0c0c',1,'SFix::operator!=()'],['../FixMath_8h.html#a0fa4c56f004c4bcf800359a3907a42ef',1,'operator!=(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#aae4dc21682154845652c89a69a48ca18',1,'operator!=(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a170d50e511f622186082af600e069609',1,'UFix::operator!=()']]], - ['operator_2a_70',['operator*',['../classSFix.html#a0378525fe44b041e160eb32038bf30bf',1,'SFix::operator*()'],['../classUFix.html#ac6d297515c30a6e4f2895a3c73e8aa2f',1,'UFix::operator*(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#ae08634f2ec6f686e781e0805aa8c8c69',1,'UFix::operator*(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a25b81f170bb1348644459843c23dc0c6',1,'SFix::operator*()']]], - ['operator_2b_71',['operator+',['../classUFix.html#ae855ab54e2b28c755c41ad0941fbe33a',1,'UFix::operator+(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#acc26f823f4151d244bce276d8e39c985',1,'UFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a6897e22fd904f54fdb7555b7bee852f6',1,'SFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#ac991db0bee7ebb63e091582d41e9c766',1,'SFix::operator+(const UFix< _NI, _NF, _RANGE > &op2) const']]], - ['operator_2d_72',['operator-',['../classUFix.html#a20414eb474cfb24b9c0da72ce507d5fe',1,'UFix::operator-()'],['../classSFix.html#ae72d489b35d6ec78315735a0a411b39a',1,'SFix::operator-() const'],['../classSFix.html#aecff8ee0cac43d3262f1453b03c17fd5',1,'SFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a8eabdb5d47e38190bf7d25430c7a8256',1,'SFix::operator-(const SFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#aefe821e3f4919ee8407aac4ef4ae6cb1',1,'UFix::operator-(const SFix< _NI, _NF, _RANGE > &op2) const'],['../classUFix.html#a59470679dbbaa691a12b09554195fd45',1,'UFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const']]], - ['operator_3c_73',['operator<',['../FixMath_8h.html#ab773f1f3dca60ecd08756268c4e1581d',1,'operator<(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#ad70883fc4f0dc62c55a831a506602d96',1,'operator<(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a8a55813939a59bc8840315de126bfe50',1,'UFix::operator<()'],['../classSFix.html#a3919f181cdf1a9789b0a4ddc3c7350df',1,'SFix::operator<(const SFix< _NI, _NF > &op) const']]], - ['operator_3d_3d_74',['operator==',['../classSFix.html#adbf8ca8954a76ec1569dc1ed968e57c8',1,'SFix::operator==()'],['../classUFix.html#ae66992644d158a7efeb8e521497a3a13',1,'UFix::operator==()'],['../FixMath_8h.html#a8b8bf5f8934ac98afb345f29feefb712',1,'operator==(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a5352a505056ab3e61f3364a6f43f33bf',1,'operator==(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], - ['operator_3e_75',['operator>',['../classSFix.html#a2713361a7c85c7c5fb1479a85fa767f5',1,'SFix::operator>()'],['../classUFix.html#addd4204bb434debae918c859da069012',1,'UFix::operator>()'],['../FixMath_8h.html#a85ff3e79510e17f13056c58a2191be18',1,'operator>(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a771e19acc8c3adaa3296148c1e6ebdde',1,'operator>(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], - ['operator_3e_3e_76',['operator>>',['../classUFix.html#a38e656ca44e325c3f384917d53a7882d',1,'UFix::operator>>()'],['../classSFix.html#a660b7f1ecb5c41cdd95ad2f7105b9cdf',1,'SFix::operator>>()']]] + ['map_80',['map',['../classFixMathMapperFull.html#ac0369876b0a7945b9a45634d6d38befc',1,'FixMathMapperFull::map()'],['../classFixMathMapperAccurate.html#a1607c7a09e773cf424d27b8a59981bff',1,'FixMathMapperAccurate::map()'],['../classFixMathMapperFast.html#ad4a98cd13396ca2e69c04aca27b578c7',1,'FixMathMapperFast::map()']]] ]; diff --git a/docs/html/search/functions_5.js b/docs/html/search/functions_5.js index e7b76ee..f008d24 100644 --- a/docs/html/search/functions_5.js +++ b/docs/html/search/functions_5.js @@ -1,6 +1,11 @@ var searchData= [ - ['sfix_77',['SFix',['../classSFix.html#a0c98bb108b044af13a6329142c7b2de6',1,'SFix::SFix()'],['../classSFix.html#a29b24255334b013518c060354dad8128',1,'SFix::SFix(float fl)'],['../classSFix.html#af205019d40489f55d3be4ae1ffe603c5',1,'SFix::SFix(double fl)'],['../classSFix.html#ae677662a0546de5535c93121e7bc1762',1,'SFix::SFix(T value, bool as_raw=false)'],['../classSFix.html#a2e1a7033339c03de9ceab22962740ed9',1,'SFix::SFix(const SFix< _NI, _NF, _RANGE > &sf)'],['../classSFix.html#a164116927fa8b7664a7a4423efc50e96',1,'SFix::SFix(const UFix< _NI, _NF, _RANGE > &uf)']]], - ['sl_78',['sL',['../classUFix.html#add741555c674d50504ae2999080c80e1',1,'UFix::sL()'],['../classSFix.html#aff21f36dcf756d3ae806b38af577066c',1,'SFix::sL()']]], - ['sr_79',['sR',['../classUFix.html#a9835b0be256af62795f14aa454a1ab0c',1,'UFix::sR()'],['../classSFix.html#aadca956470c845c976ac25d43870d0da',1,'SFix::sR()']]] + ['operator_21_3d_81',['operator!=',['../classSFix.html#a22e6b735d20ac94a07bd6ae1b6bc0c0c',1,'SFix::operator!=()'],['../FixMath_8h.html#a0fa4c56f004c4bcf800359a3907a42ef',1,'operator!=(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#aae4dc21682154845652c89a69a48ca18',1,'operator!=(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a170d50e511f622186082af600e069609',1,'UFix::operator!=()']]], + ['operator_2a_82',['operator*',['../classSFix.html#a0378525fe44b041e160eb32038bf30bf',1,'SFix::operator*()'],['../classUFix.html#ac6d297515c30a6e4f2895a3c73e8aa2f',1,'UFix::operator*(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#ae08634f2ec6f686e781e0805aa8c8c69',1,'UFix::operator*(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a25b81f170bb1348644459843c23dc0c6',1,'SFix::operator*()']]], + ['operator_2b_83',['operator+',['../classUFix.html#ae855ab54e2b28c755c41ad0941fbe33a',1,'UFix::operator+(const UFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#acc26f823f4151d244bce276d8e39c985',1,'UFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a6897e22fd904f54fdb7555b7bee852f6',1,'SFix::operator+(const SFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#ac991db0bee7ebb63e091582d41e9c766',1,'SFix::operator+(const UFix< _NI, _NF, _RANGE > &op2) const']]], + ['operator_2d_84',['operator-',['../classUFix.html#a20414eb474cfb24b9c0da72ce507d5fe',1,'UFix::operator-()'],['../classSFix.html#ae72d489b35d6ec78315735a0a411b39a',1,'SFix::operator-() const'],['../classSFix.html#aecff8ee0cac43d3262f1453b03c17fd5',1,'SFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const'],['../classSFix.html#a8eabdb5d47e38190bf7d25430c7a8256',1,'SFix::operator-(const SFix< _NI, _NF, _RANGE > &op) const'],['../classUFix.html#aefe821e3f4919ee8407aac4ef4ae6cb1',1,'UFix::operator-(const SFix< _NI, _NF, _RANGE > &op2) const'],['../classUFix.html#a59470679dbbaa691a12b09554195fd45',1,'UFix::operator-(const UFix< _NI, _NF, _RANGE > &op) const']]], + ['operator_3c_85',['operator<',['../FixMath_8h.html#ab773f1f3dca60ecd08756268c4e1581d',1,'operator<(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#ad70883fc4f0dc62c55a831a506602d96',1,'operator<(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h'],['../classUFix.html#a8a55813939a59bc8840315de126bfe50',1,'UFix::operator<()'],['../classSFix.html#a3919f181cdf1a9789b0a4ddc3c7350df',1,'SFix::operator<(const SFix< _NI, _NF > &op) const']]], + ['operator_3d_3d_86',['operator==',['../classSFix.html#adbf8ca8954a76ec1569dc1ed968e57c8',1,'SFix::operator==()'],['../classUFix.html#ae66992644d158a7efeb8e521497a3a13',1,'UFix::operator==()'],['../FixMath_8h.html#a8b8bf5f8934ac98afb345f29feefb712',1,'operator==(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a5352a505056ab3e61f3364a6f43f33bf',1,'operator==(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], + ['operator_3e_87',['operator>',['../classSFix.html#a2713361a7c85c7c5fb1479a85fa767f5',1,'SFix::operator>()'],['../classUFix.html#addd4204bb434debae918c859da069012',1,'UFix::operator>()'],['../FixMath_8h.html#a85ff3e79510e17f13056c58a2191be18',1,'operator>(const SFix< NI, NF > &op1, const UFix< _NI, _NF > &op2): FixMath.h'],['../FixMath_8h.html#a771e19acc8c3adaa3296148c1e6ebdde',1,'operator>(const UFix< NI, NF > &op1, const SFix< _NI, _NF > &op2): FixMath.h']]], + ['operator_3e_3e_88',['operator>>',['../classUFix.html#a38e656ca44e325c3f384917d53a7882d',1,'UFix::operator>>()'],['../classSFix.html#a660b7f1ecb5c41cdd95ad2f7105b9cdf',1,'SFix::operator>>()']]] ]; diff --git a/docs/html/search/functions_6.js b/docs/html/search/functions_6.js index cf272ed..0ecae7d 100644 --- a/docs/html/search/functions_6.js +++ b/docs/html/search/functions_6.js @@ -1,7 +1,7 @@ var searchData= [ - ['tosfraction_80',['toSFraction',['../FixMath_8h.html#aac7fece5e8162407f033d0fbf022ad15',1,'FixMath.h']]], - ['tosint_81',['toSInt',['../FixMath_8h.html#ac479196160eb99ddf534e0768e3f1990',1,'FixMath.h']]], - ['toufraction_82',['toUFraction',['../FixMath_8h.html#ab6c690d265da5284fa40b19574b286cb',1,'FixMath.h']]], - ['touint_83',['toUInt',['../FixMath_8h.html#a0dda76ba96e4ae059e3872b080b6c681',1,'FixMath.h']]] + ['setbounds_89',['setBounds',['../classFixMathMapperFull.html#ade3da77f70abc086774625f3137d0707',1,'FixMathMapperFull::setBounds()'],['../classFixMathMapperAccurate.html#a8ed52d98bfdf5e5d0c95366a3f259a34',1,'FixMathMapperAccurate::setBounds()'],['../classFixMathMapperFast.html#a984c4197b8907f4e5d5cc9f688faaaa5',1,'FixMathMapperFast::setBounds()']]], + ['sfix_90',['SFix',['../classSFix.html#a0c98bb108b044af13a6329142c7b2de6',1,'SFix::SFix()'],['../classSFix.html#a29b24255334b013518c060354dad8128',1,'SFix::SFix(float fl)'],['../classSFix.html#af205019d40489f55d3be4ae1ffe603c5',1,'SFix::SFix(double fl)'],['../classSFix.html#ae677662a0546de5535c93121e7bc1762',1,'SFix::SFix(T value, bool as_raw=false)'],['../classSFix.html#a2e1a7033339c03de9ceab22962740ed9',1,'SFix::SFix(const SFix< _NI, _NF, _RANGE > &sf)'],['../classSFix.html#a164116927fa8b7664a7a4423efc50e96',1,'SFix::SFix(const UFix< _NI, _NF, _RANGE > &uf)']]], + ['sl_91',['sL',['../classUFix.html#add741555c674d50504ae2999080c80e1',1,'UFix::sL()'],['../classSFix.html#aff21f36dcf756d3ae806b38af577066c',1,'SFix::sL()']]], + ['sr_92',['sR',['../classUFix.html#a9835b0be256af62795f14aa454a1ab0c',1,'UFix::sR()'],['../classSFix.html#aadca956470c845c976ac25d43870d0da',1,'SFix::sR()']]] ]; diff --git a/docs/html/search/functions_7.js b/docs/html/search/functions_7.js index 4ae1321..ead2eb2 100644 --- a/docs/html/search/functions_7.js +++ b/docs/html/search/functions_7.js @@ -1,5 +1,7 @@ var searchData= [ - ['ufix_84',['UFix',['../classUFix.html#a7d909dea6bd0d94f1e159450f46df265',1,'UFix::UFix()'],['../classUFix.html#a432caf716e07f7d69e8f06b49b0dc477',1,'UFix::UFix(float fl)'],['../classUFix.html#a58949c734f134faf346be3f7379f4ed8',1,'UFix::UFix(double fl)'],['../classUFix.html#a7390119d769ae15f450a5d4fefb50d32',1,'UFix::UFix(T value, bool as_raw=false)'],['../classUFix.html#ae17e095fb2fa03aa8f4d3e61643edcf4',1,'UFix::UFix(const UFix< _NI, _NF, _RANGE > &uf)'],['../classUFix.html#af3838a6723b019a40df100732ec1bd9b',1,'UFix::UFix(const SFix< _NI, _NF, _RANGE > &uf)']]], - ['ufixauto_85',['UFixAuto',['../FixMath_8h.html#a0217a77f6a6d862840d6f610a92c9f65',1,'FixMath.h']]] + ['tosfraction_93',['toSFraction',['../FixMath_8h.html#aac7fece5e8162407f033d0fbf022ad15',1,'FixMath.h']]], + ['tosint_94',['toSInt',['../FixMath_8h.html#ac479196160eb99ddf534e0768e3f1990',1,'FixMath.h']]], + ['toufraction_95',['toUFraction',['../FixMath_8h.html#ab6c690d265da5284fa40b19574b286cb',1,'FixMath.h']]], + ['touint_96',['toUInt',['../FixMath_8h.html#a0dda76ba96e4ae059e3872b080b6c681',1,'FixMath.h']]] ]; diff --git a/docs/html/search/namespaces_0.js b/docs/html/search/namespaces_0.js index 360a0ab..f64c0fe 100644 --- a/docs/html/search/namespaces_0.js +++ b/docs/html/search/namespaces_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['fixmathprivate_53',['FixMathPrivate',['../namespaceFixMathPrivate.html',1,'']]] + ['fixmathprivate_61',['FixMathPrivate',['../namespaceFixMathPrivate.html',1,'']]] ]; diff --git a/docs/html/search/searchdata.js b/docs/html/search/searchdata.js index 85ec60c..432a340 100644 --- a/docs/html/search/searchdata.js +++ b/docs/html/search/searchdata.js @@ -1,10 +1,10 @@ var indexSectionsWithContent = { - 0: "abfgiostu", - 1: "bisu", + 0: "abfgimostu", + 1: "bfisu", 2: "f", 3: "f", - 4: "afgiostu" + 4: "afgimostu" }; var indexSectionNames = diff --git a/docs/latex/FixMath_8h.tex b/docs/latex/FixMath_8h.tex index 11caf68..430a34f 100644 --- a/docs/latex/FixMath_8h.tex +++ b/docs/latex/FixMath_8h.tex @@ -10,6 +10,14 @@ \includegraphics[width=323pt]{FixMath_8h__incl} \end{center} \end{figure} +This graph shows which files directly or indirectly include this file\+: +\nopagebreak +\begin{figure}[H] +\begin{center} +\leavevmode +\includegraphics[width=181pt]{FixMath_8h__dep__incl} +\end{center} +\end{figure} \doxysubsection*{Classes} \begin{DoxyCompactItemize} \item diff --git a/docs/latex/annotated.tex b/docs/latex/annotated.tex index e3d26ff..0b2473b 100644 --- a/docs/latex/annotated.tex +++ b/docs/latex/annotated.tex @@ -2,6 +2,9 @@ Here are the classes, structs, unions and interfaces with brief descriptions\+:\begin{DoxyCompactList} \item\contentsline{section}{\mbox{\hyperlink{structFixMathPrivate_1_1BitCounter}{Fix\+Math\+Private\+::\+Bit\+Counter$<$ value, bits $>$}} }{\pageref{structFixMathPrivate_1_1BitCounter}}{} \item\contentsline{section}{\mbox{\hyperlink{structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4}{Fix\+Math\+Private\+::\+Bit\+Counter$<$ value, 0 $>$}} }{\pageref{structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4}}{} +\item\contentsline{section}{\mbox{\hyperlink{classFixMathMapperAccurate}{Fix\+Math\+Mapper\+Accurate$<$ in\+\_\+type, out\+\_\+type $>$}} }{\pageref{classFixMathMapperAccurate}}{} +\item\contentsline{section}{\mbox{\hyperlink{classFixMathMapperFast}{Fix\+Math\+Mapper\+Fast$<$ in\+\_\+type, out\+\_\+type $>$}} }{\pageref{classFixMathMapperFast}}{} +\item\contentsline{section}{\mbox{\hyperlink{classFixMathMapperFull}{Fix\+Math\+Mapper\+Full$<$ in\+\_\+type, out\+\_\+type $>$}} }{\pageref{classFixMathMapperFull}}{} \item\contentsline{section}{\mbox{\hyperlink{structIntegerType}{Integer\+Type$<$ BYTES $>$}} }{\pageref{structIntegerType}}{} \item\contentsline{section}{\mbox{\hyperlink{structIntegerType_3_011_01_4}{Integer\+Type$<$ 1 $>$}} }{\pageref{structIntegerType_3_011_01_4}}{} \item\contentsline{section}{\mbox{\hyperlink{structIntegerType_3_012_01_4}{Integer\+Type$<$ 2 $>$}} }{\pageref{structIntegerType_3_012_01_4}}{} diff --git a/docs/latex/files.tex b/docs/latex/files.tex index 87ad577..68f82b7 100644 --- a/docs/latex/files.tex +++ b/docs/latex/files.tex @@ -2,5 +2,6 @@ Here is a list of all documented files with brief descriptions\+:\begin{DoxyCompactList} \item\contentsline{section}{\mbox{\hyperlink{FixMath_8h}{Fix\+Math.\+h}} }{\pageref{FixMath_8h}}{} \item\contentsline{section}{{\bfseries Fix\+Math\+\_\+\+Autotests.\+h} }{\pageref{FixMath__Autotests_8h}}{} +\item\contentsline{section}{{\bfseries Fix\+Math\+Mapper.\+h} }{\pageref{FixMathMapper_8h}}{} \item\contentsline{section}{{\bfseries Integer\+Type.\+h} }{\pageref{IntegerType_8h}}{} \end{DoxyCompactList} diff --git a/docs/latex/refman.tex b/docs/latex/refman.tex index d888563..78a07de 100644 --- a/docs/latex/refman.tex +++ b/docs/latex/refman.tex @@ -182,6 +182,9 @@ \chapter{Namespace Documentation} \chapter{Class Documentation} \input{structFixMathPrivate_1_1BitCounter} \input{structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4} +\input{classFixMathMapperAccurate} +\input{classFixMathMapperFast} +\input{classFixMathMapperFull} \input{structIntegerType} \input{structIntegerType_3_011_01_4} \input{structIntegerType_3_012_01_4} From 269146bfb89b499e0fc79540b9a58e33b73b7318 Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Tue, 4 Feb 2025 22:58:37 +0100 Subject: [PATCH 5/7] Updated doc --- docs/html/FixMathMapper_8h_source.html | 229 ++++++++++++++++++ docs/html/FixMath_8h__dep__incl.map | 4 + docs/html/FixMath_8h__dep__incl.md5 | 1 + docs/html/FixMath_8h__dep__incl.png | Bin 0 -> 2711 bytes docs/html/search/all_8.html | 37 +++ docs/html/search/all_8.js | 7 + docs/html/search/all_9.html | 37 +++ docs/html/search/all_9.js | 5 + docs/html/search/classes_3.html | 37 +++ docs/html/search/classes_3.js | 4 + docs/html/search/classes_4.html | 37 +++ docs/html/search/classes_4.js | 4 + docs/html/search/functions_8.html | 37 +++ docs/html/search/functions_8.js | 5 + ...tFixMathPrivate_1_1BitCounter-members.html | 82 +++++++ .../structFixMathPrivate_1_1BitCounter.html | 91 +++++++ ...Counter_3_01value_00_010_01_4-members.html | 82 +++++++ ...e_1_1BitCounter_3_01value_00_010_01_4.html | 91 +++++++ 18 files changed, 790 insertions(+) create mode 100644 docs/html/FixMathMapper_8h_source.html create mode 100644 docs/html/FixMath_8h__dep__incl.map create mode 100644 docs/html/FixMath_8h__dep__incl.md5 create mode 100644 docs/html/FixMath_8h__dep__incl.png create mode 100644 docs/html/search/all_8.html create mode 100644 docs/html/search/all_8.js create mode 100644 docs/html/search/all_9.html create mode 100644 docs/html/search/all_9.js create mode 100644 docs/html/search/classes_3.html create mode 100644 docs/html/search/classes_3.js create mode 100644 docs/html/search/classes_4.html create mode 100644 docs/html/search/classes_4.js create mode 100644 docs/html/search/functions_8.html create mode 100644 docs/html/search/functions_8.js create mode 100644 docs/html/structFixMathPrivate_1_1BitCounter-members.html create mode 100644 docs/html/structFixMathPrivate_1_1BitCounter.html create mode 100644 docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4-members.html create mode 100644 docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html diff --git a/docs/html/FixMathMapper_8h_source.html b/docs/html/FixMathMapper_8h_source.html new file mode 100644 index 0000000..288e4da --- /dev/null +++ b/docs/html/FixMathMapper_8h_source.html @@ -0,0 +1,229 @@ + + + + + + + +FixMath: FixMathMapper.h Source File + + + + + + + + + +
                      +
                      + + + + + + +
                      +
                      FixMath +
                      +
                      +
                      + + + + + + + + +
                      +
                      + + +
                      + +
                      + + +
                      +
                      +
                      +
                      FixMathMapper.h
                      +
                      +
                      +
                      1 #ifndef FIXMATH_MAPPER_H
                      +
                      2 #define FIXMATH_MAPPER_H
                      +
                      3 
                      +
                      4 #include "FixMath.h"
                      +
                      5 
                      +
                      10 template<typename in_type, typename out_type>
                      + +
                      12 {
                      +
                      13 
                      +
                      14  public:
                      + +
                      27  FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) {
                      +
                      28  setBounds(_in_min,_in_max,_out_min,_out_max);
                      +
                      29  }
                      +
                      30 
                      +
                      31 
                      +
                      41  void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      +
                      42  {
                      +
                      43  in_min = _in_min;
                      +
                      44  in_max = _in_max;
                      +
                      45  out_min = _out_min;
                      +
                      46  out_max = _out_max;
                      +
                      47  compute_coef();
                      +
                      48  }
                      +
                      49 
                      +
                      50 
                      +
                      55  out_type map(in_type in) const
                      +
                      56  {
                      +
                      57  return ((in - in_min) * coef) + out_min;
                      +
                      58  }
                      +
                      59 
                      +
                      60 
                      +
                      61  private:
                      +
                      62  decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0;
                      +
                      63  in_type in_min, in_max;
                      +
                      64  out_type out_min, out_max;
                      +
                      65 
                      +
                      66  void compute_coef()
                      +
                      67  {
                      +
                      68  coef = (out_max-out_min)*(in_max-in_min).invFull();
                      +
                      69  }
                      +
                      70 };
                      +
                      71 
                      +
                      72 
                      +
                      73 
                      +
                      74 
                      +
                      75 
                      +
                      76 
                      +
                      77 
                      +
                      82 template<typename in_type, typename out_type>
                      + +
                      84 {
                      +
                      85 
                      +
                      86  public:
                      + +
                      99  FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) {
                      +
                      100  setBounds(_in_min,_in_max,_out_min,_out_max);
                      +
                      101  }
                      +
                      102 
                      +
                      103 
                      +
                      113  void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      +
                      114  {
                      +
                      115  in_min = _in_min;
                      +
                      116  in_max = _in_max;
                      +
                      117  out_min = _out_min;
                      +
                      118  out_max = _out_max;
                      +
                      119  compute_coef();
                      +
                      120  }
                      +
                      121 
                      +
                      122 
                      +
                      127  out_type map(in_type in) const
                      +
                      128  {
                      +
                      129  return ((in - in_min) * coef) + out_min;
                      +
                      130  }
                      +
                      131 
                      +
                      132 
                      +
                      133  private:
                      +
                      134  decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0;
                      +
                      135  in_type in_min, in_max;
                      +
                      136  out_type out_min, out_max;
                      +
                      137 
                      +
                      138  void compute_coef()
                      +
                      139  {
                      +
                      140  coef = (out_max-out_min)*(in_max-in_min).invAccurate();
                      +
                      141  }
                      +
                      142 };
                      +
                      143 
                      +
                      144 
                      +
                      145 
                      +
                      146 
                      +
                      147 
                      +
                      148 
                      +
                      149 
                      +
                      150 
                      +
                      155 template<typename in_type, typename out_type>
                      + +
                      157 {
                      +
                      158 
                      +
                      159  public:
                      + +
                      172  FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) {
                      +
                      173  setBounds(_in_min,_in_max,_out_min,_out_max);
                      +
                      174  }
                      +
                      175 
                      +
                      176 
                      +
                      186  void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      +
                      187  {
                      +
                      188  in_min = _in_min;
                      +
                      189  in_max = _in_max;
                      +
                      190  out_min = _out_min;
                      +
                      191  out_max = _out_max;
                      +
                      192  compute_coef();
                      +
                      193  }
                      +
                      194 
                      +
                      195 
                      +
                      200  out_type map(in_type in) const
                      +
                      201  {
                      +
                      202  return ((in - in_min) * coef) + out_min;
                      +
                      203  }
                      +
                      204 
                      +
                      205 
                      +
                      206  private:
                      +
                      207  decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0;
                      +
                      208  in_type in_min, in_max;
                      +
                      209  out_type out_min, out_max;
                      +
                      210 
                      +
                      211  void compute_coef()
                      +
                      212  {
                      +
                      213  coef = (out_max-out_min)*(in_max-in_min).invFast();
                      +
                      214  }
                      +
                      215 };
                      +
                      216 
                      +
                      217 
                      +
                      218 
                      +
                      219 #endif
                      + +
                      Definition: FixMathMapper.h:84
                      +
                      out_type map(in_type in) const
                      Definition: FixMathMapper.h:127
                      +
                      FixMathMapperAccurate()
                      Definition: FixMathMapper.h:89
                      +
                      void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:113
                      +
                      FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:99
                      +
                      Definition: FixMathMapper.h:157
                      +
                      FixMathMapperFast()
                      Definition: FixMathMapper.h:162
                      +
                      FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:172
                      +
                      void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:186
                      +
                      out_type map(in_type in) const
                      Definition: FixMathMapper.h:200
                      +
                      Definition: FixMathMapper.h:12
                      +
                      FixMathMapperFull()
                      Definition: FixMathMapper.h:17
                      +
                      FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:27
                      +
                      out_type map(in_type in) const
                      Definition: FixMathMapper.h:55
                      +
                      void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max)
                      Definition: FixMathMapper.h:41
                      +
                      + + + + diff --git a/docs/html/FixMath_8h__dep__incl.map b/docs/html/FixMath_8h__dep__incl.map new file mode 100644 index 0000000..989a21b --- /dev/null +++ b/docs/html/FixMath_8h__dep__incl.map @@ -0,0 +1,4 @@ + + + + diff --git a/docs/html/FixMath_8h__dep__incl.md5 b/docs/html/FixMath_8h__dep__incl.md5 new file mode 100644 index 0000000..28fa777 --- /dev/null +++ b/docs/html/FixMath_8h__dep__incl.md5 @@ -0,0 +1 @@ +72a8d382556802b03241cf6a03b9df29 \ No newline at end of file diff --git a/docs/html/FixMath_8h__dep__incl.png b/docs/html/FixMath_8h__dep__incl.png new file mode 100644 index 0000000000000000000000000000000000000000..b0ba13efe4b2dc5535a2d546c2402a519d418a1d GIT binary patch literal 2711 zcmcIm_g7Qd8of%DqUb;n2M`q)AT)`FP?Q=YA%I8|L5K{B(np%~p#>9^-dh9=-3%Ct z5R@iOr3nuZDMBEChR|EU@b36#z4sTqbJktwo*(Wy-`#tEdmsD_Q2damwVP@;m`U7AZGw z7*x5}B$I05P)7~!TS*x53J=bh92uuQu3OlM)mRApp-J4(USLpEcrNfBm3khj7XUml zipp)}dBlCTTP);bVd>h^u5xdcEU5Nm5|_?FsG55^ZF zCT44Ij|mWliSn)ddik8JY%!T^`j#5@gEcodx4G$S;)+C}_F1fCc@Gbdf`Wo;*RILP z$b9>bi;eYZu=ny>k-uho;gS{yz!wx!en~hL8t5PM_sn zPtUORxt`arU#CHB>S}797#3DmDst2Ijc|7}o0|{c1nqnAE^Tj4Pv$L~}jg6`FPM#Bz($dmnV`IFWkveT*k!@k)yNr_O1l3J3n|(T2-YgC53J46cfPZ zOwY>7 zs;F>7qu+z2u(rM<&nG!~-n)0t!NCEA>KYq64Pbk-FPAr}!eAHF1q20;0H^SVRJ9@Q zA2f_0r=GNoOaqk~;OA%Z*x|COmX`UR_lMJS%*;)y-Z z&gmikF`}%ltTT@uJpv(CgTX+GdKWg9mzO=<-G%w9J~Ide!kUQ8sbhLVot>Q&mwr!A zPY5q3olbWiiR9uRA0KyC%ZiAI$R?{eH0{o`#~NoSFRe}wiokYW1hWqU!@|NsLYhD( zQ&NVQlT;dw)`MrpD&DS<)7CyFh9R!eF{`7cQw8DSX&7l!>V(zEZ2kcye4kl0Xjp~8*D?p)TZjM(>Op-6V z2`t?X3E%oA67%wxVGw;e0ah1Q(RwUbBfX|m_g~c{SBYo`_AX6Fd#c$$pS|@#Wiwwh z^*M2r5*g_-=U66Oq6L{OitS^w?W}L@iUU%R1S_lB0f~6#pn;2sNVuS&5dcu`U*zLE zvv?e}vseHtsJc6%$PMT!r2W{oqb)9~H(vO3kwtfRp0l(43@zK-r+zwx-`trlW0{`3 zvzSBq^r_fu`o;Pkf%a(qY@P99pUvK^8@Kwg2Zu2=7+gli;bjCu|M%;fsK0UrkH=eD z)hbL*|H3J!)>@mB$ z)eYKhxw)s!(AAG?>UZK|xGaz!nFIZPp}?P{`J|5@vB$gcOkLju_Qz*BCqUnla#@Y| zuZjJiHs=UB^h_erEC8X|-re2T(vr%Q^W{kBvKYS9x>L5*lPj5+on4-)7D36=3NSTR z<$Wf^%ZZj>4EpJ;U{Oa%u-|?w0o67r(eYx?YE07ylyG`l8mVGL$aSDItG-^n7}%?H zNxCi!fo!+mCOG6|XR8XpE?(TboA7<)CG`&)4j1uol*{meMqgoJ;hf4E+SvGVWygIA zOigW$Dkdi84!5HM4;YdDzS`>k0ReWmZgsmX4-DKeGc()s!G(r~?(gptuZHpgyI@~0 zf2nV8Zx{J>ZDXTd^=T^>>~?8c+2rPq+Ta}~4u=cf-@bbqEb&^p`@@H8>+4QxSryhV zgLYR7nz)u50RW+)k%#!hsU0VXksa#jK(YlMSuKIh`;0(%RaXax!8SHF+`POpG8Q)W zBqb$_i;Dx86Xu%e^0s_&+9)|}w<%f4u1+ogt;oH_J9ZQ(U0dmEFC)G8QA`JHbC# zet}0&C=?W00lLD>%*?xYhLE@z+O9Cw+t)W&Cp-*^jJc(FHJq)T(sQu8R+R0lobjDT z8yXprg~TODXwexA#gv}z^*D%9IhmY}CZY4n`RuM}OPW1gMjN{jM)>*oc)46S^>VL< zj`#KT4G-5eHQ84~i2Wo~7Y@5|%=JMr>@MCn=7WSU+tEs7}=g*&mu?I3F-eqB7 zLHe}PoZ64YD4QyQ%1D&G4&tA#e5YJta(q0y6}!2!1I=fH!&&Uq=fkRS;SSZsU{5{`V+(R9b1f!I8k*tTtU)t>%kxw zAO)&xjn-vgU?49q4`OPsY-81!mL?M0e(cz>haMghVq#?#6|_eUU^JCctE#GcbJX2V zQ|OChwn!urjV9YuNV)FxDKdL+r1wsrlI3tE8;#@Y=f|dy~O%4-O7Kd-g0O&Tny`ATd$M zz@WYC9sHOusvfr^6@)J;`rXttp1w4M>tpH(U5ddm6*mg-BNl7A_E@Ov)UEKj?J+IdP0p5^4^P^nZW!qin7DnW1b=XL9! bkJ + + + + + + + + + +
                      +
                      Loading...
                      +
                      + +
                      Searching...
                      +
                      No Matches
                      + +
                      + + diff --git a/docs/html/search/all_8.js b/docs/html/search/all_8.js new file mode 100644 index 0000000..3321c69 --- /dev/null +++ b/docs/html/search/all_8.js @@ -0,0 +1,7 @@ +var searchData= +[ + ['tosfraction_41',['toSFraction',['../FixMath_8h.html#aac7fece5e8162407f033d0fbf022ad15',1,'FixMath.h']]], + ['tosint_42',['toSInt',['../FixMath_8h.html#ac479196160eb99ddf534e0768e3f1990',1,'FixMath.h']]], + ['toufraction_43',['toUFraction',['../FixMath_8h.html#ab6c690d265da5284fa40b19574b286cb',1,'FixMath.h']]], + ['touint_44',['toUInt',['../FixMath_8h.html#a0dda76ba96e4ae059e3872b080b6c681',1,'FixMath.h']]] +]; diff --git a/docs/html/search/all_9.html b/docs/html/search/all_9.html new file mode 100644 index 0000000..1e263c1 --- /dev/null +++ b/docs/html/search/all_9.html @@ -0,0 +1,37 @@ + + + + + + + + + + +
                      +
                      Loading...
                      +
                      + +
                      Searching...
                      +
                      No Matches
                      + +
                      + + diff --git a/docs/html/search/all_9.js b/docs/html/search/all_9.js new file mode 100644 index 0000000..6cadb48 --- /dev/null +++ b/docs/html/search/all_9.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['ufix_45',['UFix',['../classUFix.html',1,'UFix< NI, NF, RANGE >'],['../classUFix.html#a7d909dea6bd0d94f1e159450f46df265',1,'UFix::UFix()'],['../classUFix.html#a432caf716e07f7d69e8f06b49b0dc477',1,'UFix::UFix(float fl)'],['../classUFix.html#a58949c734f134faf346be3f7379f4ed8',1,'UFix::UFix(double fl)'],['../classUFix.html#a7390119d769ae15f450a5d4fefb50d32',1,'UFix::UFix(T value, bool as_raw=false)'],['../classUFix.html#ae17e095fb2fa03aa8f4d3e61643edcf4',1,'UFix::UFix(const UFix< _NI, _NF, _RANGE > &uf)'],['../classUFix.html#af3838a6723b019a40df100732ec1bd9b',1,'UFix::UFix(const SFix< _NI, _NF, _RANGE > &uf)']]], + ['ufixauto_46',['UFixAuto',['../FixMath_8h.html#a0217a77f6a6d862840d6f610a92c9f65',1,'FixMath.h']]] +]; diff --git a/docs/html/search/classes_3.html b/docs/html/search/classes_3.html new file mode 100644 index 0000000..d33343b --- /dev/null +++ b/docs/html/search/classes_3.html @@ -0,0 +1,37 @@ + + + + + + + + + + +
                      +
                      Loading...
                      +
                      + +
                      Searching...
                      +
                      No Matches
                      + +
                      + + diff --git a/docs/html/search/classes_3.js b/docs/html/search/classes_3.js new file mode 100644 index 0000000..72a529a --- /dev/null +++ b/docs/html/search/classes_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['sfix_59',['SFix',['../classSFix.html',1,'']]] +]; diff --git a/docs/html/search/classes_4.html b/docs/html/search/classes_4.html new file mode 100644 index 0000000..8430b07 --- /dev/null +++ b/docs/html/search/classes_4.html @@ -0,0 +1,37 @@ + + + + + + + + + + +
                      +
                      Loading...
                      +
                      + +
                      Searching...
                      +
                      No Matches
                      + +
                      + + diff --git a/docs/html/search/classes_4.js b/docs/html/search/classes_4.js new file mode 100644 index 0000000..130eeb6 --- /dev/null +++ b/docs/html/search/classes_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['ufix_60',['UFix',['../classUFix.html',1,'']]] +]; diff --git a/docs/html/search/functions_8.html b/docs/html/search/functions_8.html new file mode 100644 index 0000000..31a1d95 --- /dev/null +++ b/docs/html/search/functions_8.html @@ -0,0 +1,37 @@ + + + + + + + + + + +
                      +
                      Loading...
                      +
                      + +
                      Searching...
                      +
                      No Matches
                      + +
                      + + diff --git a/docs/html/search/functions_8.js b/docs/html/search/functions_8.js new file mode 100644 index 0000000..04af144 --- /dev/null +++ b/docs/html/search/functions_8.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['ufix_97',['UFix',['../classUFix.html#a7d909dea6bd0d94f1e159450f46df265',1,'UFix::UFix()'],['../classUFix.html#a432caf716e07f7d69e8f06b49b0dc477',1,'UFix::UFix(float fl)'],['../classUFix.html#a58949c734f134faf346be3f7379f4ed8',1,'UFix::UFix(double fl)'],['../classUFix.html#a7390119d769ae15f450a5d4fefb50d32',1,'UFix::UFix(T value, bool as_raw=false)'],['../classUFix.html#ae17e095fb2fa03aa8f4d3e61643edcf4',1,'UFix::UFix(const UFix< _NI, _NF, _RANGE > &uf)'],['../classUFix.html#af3838a6723b019a40df100732ec1bd9b',1,'UFix::UFix(const SFix< _NI, _NF, _RANGE > &uf)']]], + ['ufixauto_98',['UFixAuto',['../FixMath_8h.html#a0217a77f6a6d862840d6f610a92c9f65',1,'FixMath.h']]] +]; diff --git a/docs/html/structFixMathPrivate_1_1BitCounter-members.html b/docs/html/structFixMathPrivate_1_1BitCounter-members.html new file mode 100644 index 0000000..133cb02 --- /dev/null +++ b/docs/html/structFixMathPrivate_1_1BitCounter-members.html @@ -0,0 +1,82 @@ + + + + + + + +FixMath: Member List + + + + + + + + + +
                      +
                      + + + + + + +
                      +
                      FixMath +
                      +
                      +
                      + + + + + + + + +
                      +
                      + + +
                      + +
                      + + +
                      +
                      +
                      +
                      FixMathPrivate::BitCounter< value, bits > Member List
                      +
                      +
                      + +

                      This is the complete list of members for FixMathPrivate::BitCounter< value, bits >, including all inherited members.

                      + + +
                      bitsNeeded() (defined in FixMathPrivate::BitCounter< value, bits >)FixMathPrivate::BitCounter< value, bits >inlinestatic
                      + + + + diff --git a/docs/html/structFixMathPrivate_1_1BitCounter.html b/docs/html/structFixMathPrivate_1_1BitCounter.html new file mode 100644 index 0000000..be69b76 --- /dev/null +++ b/docs/html/structFixMathPrivate_1_1BitCounter.html @@ -0,0 +1,91 @@ + + + + + + + +FixMath: FixMathPrivate::BitCounter< value, bits > Struct Template Reference + + + + + + + + + +
                      +
                      + + + + + + +
                      +
                      FixMath +
                      +
                      +
                      + + + + + + + + +
                      +
                      + + +
                      + +
                      + + +
                      +
                      + +
                      +
                      FixMathPrivate::BitCounter< value, bits > Struct Template Reference
                      +
                      +
                      + + + + +

                      +Static Public Member Functions

                      +static constexpr int8_t bitsNeeded ()
                       
                      +
                      The documentation for this struct was generated from the following file: +
                      + + + + diff --git a/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4-members.html b/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4-members.html new file mode 100644 index 0000000..b1236f1 --- /dev/null +++ b/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4-members.html @@ -0,0 +1,82 @@ + + + + + + + +FixMath: Member List + + + + + + + + + +
                      +
                      + + + + + + +
                      +
                      FixMath +
                      +
                      +
                      + + + + + + + + +
                      +
                      + + +
                      + +
                      + + +
                      +
                      +
                      +
                      FixMathPrivate::BitCounter< value, 0 > Member List
                      +
                      +
                      + +

                      This is the complete list of members for FixMathPrivate::BitCounter< value, 0 >, including all inherited members.

                      + + +
                      bitsNeeded() (defined in FixMathPrivate::BitCounter< value, 0 >)FixMathPrivate::BitCounter< value, 0 >inlinestatic
                      + + + + diff --git a/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html b/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html new file mode 100644 index 0000000..fa6a8a1 --- /dev/null +++ b/docs/html/structFixMathPrivate_1_1BitCounter_3_01value_00_010_01_4.html @@ -0,0 +1,91 @@ + + + + + + + +FixMath: FixMathPrivate::BitCounter< value, 0 > Struct Template Reference + + + + + + + + + +
                      +
                      + + + + + + +
                      +
                      FixMath +
                      +
                      +
                      + + + + + + + + +
                      +
                      + + +
                      + +
                      + + +
                      +
                      + +
                      +
                      FixMathPrivate::BitCounter< value, 0 > Struct Template Reference
                      +
                      +
                      + + + + +

                      +Static Public Member Functions

                      +static constexpr int8_t bitsNeeded ()
                       
                      +
                      The documentation for this struct was generated from the following file: +
                      + + + + From 085d6c5c8dd163ea1834cb37a4f9598ae6b82dee Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Thu, 6 Feb 2025 21:34:51 +0100 Subject: [PATCH 6/7] Refractoring of Mappers --- src/FixMathMapper.h | 237 ++++++++++++++++++-------------------------- 1 file changed, 99 insertions(+), 138 deletions(-) diff --git a/src/FixMathMapper.h b/src/FixMathMapper.h index 7f97fef..3fdfa0c 100644 --- a/src/FixMathMapper.h +++ b/src/FixMathMapper.h @@ -3,42 +3,41 @@ #include "FixMath.h" + /** -A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. -This version uses invFull() to perform the calculations. The biggest precision available, at the cost of some speed (platform and use-case dependent) + Abstract class to help refractoring the code of the different Mappers */ template - class FixMathMapperFull +class FixMathMapper { - - public: +public: /** Constructor */ - FixMathMapperFull() {;} + FixMathMapper() {;} + /** -Constructor -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max + Constructor + @param _in_min the lower bound of the input + @param _in_max the higher bound of the input + @param _out_min the lower bound of the output + @param _out_max the higher bound of the output + @note should work if they are not in increasing order but more testing needed to confirm + @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + FixMathMapper(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { setBounds(_in_min,_in_max,_out_min,_out_max); - } - + } /** -Set the bounds of the mapper -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max + Set the bounds of the mapper + @param _in_min the lower bound of the input + @param _in_max the higher bound of the input + @param _out_min the lower bound of the output + @param _out_max the higher bound of the output + @note should work if they are not in increasing order but more testing needed to confirm + @note _in_min will be mapped to _out_min and _in_max to _out_max */ - void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) + void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { in_min = _in_min; in_max = _in_max; @@ -47,173 +46,135 @@ Set the bounds of the mapper compute_coef(); } - - /** -Map an input to the output range -@param in the input - */ - out_type map(in_type in) const - { - return ((in - in_min) * coef) + out_min; - } - - - private: - decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; +protected: in_type in_min, in_max; out_type out_min, out_max; - - void compute_coef() - { - coef = (out_max-out_min)*(in_max-in_min).invFull(); - } + virtual void compute_coef() = 0; }; - - - - /** -A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. -This version uses invAccurate() to perform the calculations. The nearly biggest precision available, at the cost of some speed (platform and use-case dependent) + A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. + This version uses invFull() to perform the calculations. The biggest precision available, at the cost of some speed (platform and use-case dependent) */ template - class FixMathMapperAccurate +class FixMathMapperFull: public FixMathMapper { - public: +public: /** Constructor */ - FixMathMapperAccurate() {;} + FixMathMapperFull() {;} /** -Constructor -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max + Constructor + @param _in_min the lower bound of the input + @param _in_max the higher bound of the input + @param _out_min the lower bound of the output + @param _out_max the higher bound of the output + @note should work if they are not in increasing order but more testing needed to confirm + @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { setBounds(_in_min,_in_max,_out_min,_out_max); - } - - - /** -Set the bounds of the mapper -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max - */ - void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) - { - in_min = _in_min; - in_max = _in_max; - out_min = _out_min; - out_max = _out_max; - compute_coef(); } - /** -Map an input to the output range -@param in the input + Map an input to the output range + @param in the input */ - out_type map(in_type in) const + out_type map(in_type in) const { - return ((in - in_min) * coef) + out_min; + return ((in -this->in_min) * coef) + this->out_min; } - - private: +private: decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; - in_type in_min, in_max; - out_type out_min, out_max; - - void compute_coef() - { - coef = (out_max-out_min)*(in_max-in_min).invAccurate(); - } + void compute_coef() { coef = (this->out_max-this->out_min)*(this->in_max-this->in_min).invFull();} }; +/** + A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. + This version uses invAccurate() to perform the calculations. The nearly biggest precision available, at the cost of some speed (platform and use-case dependent) +*/ +template +class FixMathMapperAccurate: public FixMathMapper +{ +public: + /** Constructor + */ + FixMathMapperAccurate() {;} + /** + Constructor + @param _in_min the lower bound of the input + @param _in_max the higher bound of the input + @param _out_min the lower bound of the output + @param _out_max the higher bound of the output + @note should work if they are not in increasing order but more testing needed to confirm + @note _in_min will be mapped to _out_min and _in_max to _out_max + */ + FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + setBounds(_in_min,_in_max,_out_min,_out_max); + } + /** + Map an input to the output range + @param in the input + */ + out_type map(in_type in) const + { + return ((in -this->in_min) * coef) + this->out_min; + } - +private: + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + void compute_coef() { coef = (this->out_max-this->out_min)*(this->in_max-this->in_min).invAccurate();} +}; /** -A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. -This version uses invAccurate() to perform the calculations. The biggest speed available to represent the whole target range, at the cost of some precision + A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. + This version uses invFast() to perform the calculations. The biggest speed available to represent the whole target range, at the cost of some precision */ template - class FixMathMapperFast +class FixMathMapperFast: public FixMathMapper { - public: +public: /** Constructor */ FixMathMapperFast() {;} /** -Constructor -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max + Constructor + @param _in_min the lower bound of the input + @param _in_max the higher bound of the input + @param _out_min the lower bound of the output + @param _out_max the higher bound of the output + @note should work if they are not in increasing order but more testing needed to confirm + @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { + FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { setBounds(_in_min,_in_max,_out_min,_out_max); - } - - - /** -Set the bounds of the mapper -@param _in_min the lower bound of the input -@param _in_max the higher bound of the input -@param _out_min the lower bound of the output -@param _out_max the higher bound of the output -@note should work if they are not in increasing order but more testing needed to confirm -@note _in_min will be mapped to _out_min and _in_max to _out_max - */ - void setBounds(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) - { - in_min = _in_min; - in_max = _in_max; - out_min = _out_min; - out_max = _out_max; - compute_coef(); } - /** -Map an input to the output range -@param in the input + Map an input to the output range + @param in the input */ - out_type map(in_type in) const + out_type map(in_type in) const { - return ((in - in_min) * coef) + out_min; + return ((in -this->in_min) * coef) + this->out_min; } - - private: +private: decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; - in_type in_min, in_max; - out_type out_min, out_max; - - void compute_coef() - { - coef = (out_max-out_min)*(in_max-in_min).invFast(); - } + void compute_coef() { coef = (this->out_max-this->out_min)*(this->in_max-this->in_min).invFast();} }; + + #endif From 759394b8f4dc442a1265ebc286fb551bb4a444dc Mon Sep 17 00:00:00 2001 From: tomcombriat Date: Thu, 6 Feb 2025 22:22:55 +0100 Subject: [PATCH 7/7] Added possibility to constrain a mapper to a range, whatever the input --- examples/Mappers/Mappers.ino | 12 ++++---- src/FixMathMapper.h | 56 ++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/examples/Mappers/Mappers.ino b/examples/Mappers/Mappers.ino index 1ee43c5..ba3177e 100644 --- a/examples/Mappers/Mappers.ino +++ b/examples/Mappers/Mappers.ino @@ -13,11 +13,11 @@ SFix<6, 2> output; /* Three mappers are available, depending on their expected speed and precision. All of them only have a division on the setBounds() part, making the map() highly efficient as it only uses multiplications. - - FixMathMapperFull is the most accurate and uses invFull. It is the slowest (depending on platforms/types used, this might be equivalent). - - FixMathMapperAccurate might be faster the FixMapperFull in some cases, with only a slight loss of precision. - - FixMathMapperFast is the fastest, but might heavily digitize the output... Pick your weapon! - */ -FixMathMapperFull, SFix<6, 2>> mapper; // this declares a mapper between a UFix<10,0> and a SFix<6,2>. + - FixMathMapperFull is the most accurate and uses invFull. It is the slowest (depending on platforms/types used, this might be equivalent). + - FixMathMapperAccurate might be faster the FixMapperFull in some cases, with only a slight loss of precision. + - FixMathMapperFast is the fastest, but might heavily digitize the output... Pick your weapon! +*/ +FixMathMapperFast, SFix<6, 2>, true> mapper; // this declares a *constrained* mapper between a UFix<10,0> and a SFix<6,2>. void setup() { Serial.begin(115200); @@ -26,7 +26,7 @@ void setup() { void loop() { input = input + UFixAuto<1>(); - if (input > UFix<10, 0>(1000)) input = 0; + if (input > UFix<10, 0>(1200)) input = 0; Serial.print(input.asFloat()); Serial.print(" -> "); Serial.println(mapper.map(input).asFloat()); // The .map() performs the mapping, and conversion. diff --git a/src/FixMathMapper.h b/src/FixMathMapper.h index 3fdfa0c..9267722 100644 --- a/src/FixMathMapper.h +++ b/src/FixMathMapper.h @@ -7,13 +7,13 @@ /** Abstract class to help refractoring the code of the different Mappers */ -template +template class FixMathMapper { public: /** Constructor */ - FixMathMapper() {;} + FixMathMapper() {;} /** Constructor @@ -50,6 +50,11 @@ class FixMathMapper in_type in_min, in_max; out_type out_min, out_max; virtual void compute_coef() = 0; + in_type fmm_constrain(in_type in) const { + if (in < in_min) in = in_min; + else if (in > in_max) in = in_max; + return in; + } }; @@ -57,15 +62,18 @@ class FixMathMapper /** A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invFull() to perform the calculations. The biggest precision available, at the cost of some speed (platform and use-case dependent) +@tparam in_type the input type +@tparam out_type the out type +@tparam constrained=false if set to true, the output will not exceed the output bounds */ -template -class FixMathMapperFull: public FixMathMapper +template +class FixMathMapperFull: public FixMathMapper { public: /** Constructor */ - FixMathMapperFull() {;} + FixMathMapperFull(): FixMathMapper() {} /** Constructor @param _in_min the lower bound of the input @@ -75,9 +83,7 @@ class FixMathMapperFull: public FixMathMapper @note should work if they are not in increasing order but more testing needed to confirm @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { - setBounds(_in_min,_in_max,_out_min,_out_max); - } + FixMathMapperFull(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max): FixMathMapper(_in_min, _in_max, _out_min, _out_max) {} /** Map an input to the output range @@ -85,6 +91,7 @@ class FixMathMapperFull: public FixMathMapper */ out_type map(in_type in) const { + if constexpr (constrained) in = this->fmm_constrain(in); return ((in -this->in_min) * coef) + this->out_min; } @@ -97,15 +104,18 @@ class FixMathMapperFull: public FixMathMapper /** A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invAccurate() to perform the calculations. The nearly biggest precision available, at the cost of some speed (platform and use-case dependent) +@tparam in_type the input type +@tparam out_type the out type +@tparam constrained=false if set to true, the output will not exceed the output bounds */ -template -class FixMathMapperAccurate: public FixMathMapper +template +class FixMathMapperAccurate: public FixMathMapper { public: /** Constructor */ - FixMathMapperAccurate() {;} + FixMathMapperAccurate(): FixMathMapper() {} /** Constructor @param _in_min the lower bound of the input @@ -115,9 +125,7 @@ class FixMathMapperAccurate: public FixMathMapper @note should work if they are not in increasing order but more testing needed to confirm @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { - setBounds(_in_min,_in_max,_out_min,_out_max); - } + FixMathMapperAccurate(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max): FixMathMapper(_in_min, _in_max, _out_min, _out_max) {} /** Map an input to the output range @@ -125,27 +133,32 @@ class FixMathMapperAccurate: public FixMathMapper */ out_type map(in_type in) const { + if constexpr (constrained) in = this->fmm_constrain(in); return ((in -this->in_min) * coef) + this->out_min; } private: - decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invAccurate()) coef=0; void compute_coef() { coef = (this->out_max-this->out_min)*(this->in_max-this->in_min).invAccurate();} }; + /** A mapper, intended to work as Arduino's map, but faster as division is involved only when setBounds() is called, as custom-made for FixMath's types. This version uses invFast() to perform the calculations. The biggest speed available to represent the whole target range, at the cost of some precision +@tparam in_type the input type +@tparam out_type the out type +@tparam constrained=false if set to true, the output will not exceed the output bounds */ -template -class FixMathMapperFast: public FixMathMapper +template +class FixMathMapperFast: public FixMathMapper { public: /** Constructor */ - FixMathMapperFast() {;} + FixMathMapperFast(): FixMathMapper() {} /** Constructor @param _in_min the lower bound of the input @@ -155,9 +168,7 @@ class FixMathMapperFast: public FixMathMapper @note should work if they are not in increasing order but more testing needed to confirm @note _in_min will be mapped to _out_min and _in_max to _out_max */ - FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max) { - setBounds(_in_min,_in_max,_out_min,_out_max); - } + FixMathMapperFast(in_type _in_min, in_type _in_max, out_type _out_min, out_type _out_max): FixMathMapper(_in_min, _in_max, _out_min, _out_max) {} /** Map an input to the output range @@ -165,11 +176,12 @@ class FixMathMapperFast: public FixMathMapper */ out_type map(in_type in) const { + if constexpr (constrained) in = this->fmm_constrain(in); return ((in -this->in_min) * coef) + this->out_min; } private: - decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFull()) coef=0; + decltype((out_type(1)-out_type(0)) * (in_type(1)-in_type(0)).invFast()) coef=0; void compute_coef() { coef = (this->out_max-this->out_min)*(this->in_max-this->in_min).invFast();} };