summaryrefslogtreecommitdiff
path: root/source/application/main/include/PlatformMath.hpp
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2021-10-22 17:35:01 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2021-10-22 17:38:12 +0100
commit14ab8d447c5f12df2ac7fd4217fc0d2005b02dca (patch)
tree79514cdf3298633544c15c54c11675507fb4b6be /source/application/main/include/PlatformMath.hpp
parent5cbcd9e2c85485db1fe8cf7b2445550e9dc36800 (diff)
downloadml-embedded-evaluation-kit-14ab8d447c5f12df2ac7fd4217fc0d2005b02dca.tar.gz
MLECO-2489: Minor addition for PlatformMath
Adding sine function and allowing FFTs to be computed for cases where the FFT len is not a power of 2. In this case, the naive implementation is used. Option for computing FFT for a complex vector has also been added, although, the CMSIS-DSP flow needs to be tested. Change-Id: Iad9902b946f3088de91a5f67acfb4cb3d0b00457
Diffstat (limited to 'source/application/main/include/PlatformMath.hpp')
-rw-r--r--source/application/main/include/PlatformMath.hpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/source/application/main/include/PlatformMath.hpp b/source/application/main/include/PlatformMath.hpp
index 45e6a9e..6804025 100644
--- a/source/application/main/include/PlatformMath.hpp
+++ b/source/application/main/include/PlatformMath.hpp
@@ -36,11 +36,20 @@ namespace arm {
namespace app {
namespace math {
+ enum class FftType {
+ real = 0,
+ complex = 1
+ };
+
struct FftInstance {
#if ARM_DSP_AVAILABLE
- arm_rfft_fast_instance_f32 instance;
+ arm_rfft_fast_instance_f32 m_instanceReal;
+ arm_cfft_instance_f32 m_instanceComplex;
#endif
- bool initialised = false;
+ uint16_t m_fftLen{0};
+ FftType m_type;
+ bool m_optimisedOptionAvailable{false};
+ bool m_initialised{false};
};
/* Class to provide Math functions like FFT, mean, stddev etc.
@@ -59,6 +68,13 @@ namespace math {
static float CosineF32(float radians);
/**
+ * @brief Get the sine value of the argument in floating point.
+ * @param[in] radians Angle in radians.
+ * @return Sine value (floating point).
+ */
+ static float SineF32(float radians);
+
+ /**
* @brief Get the square root of the argument in floating point.
* @param[in] input Value to compute square root of.
* @return Square root (floating point) value.
@@ -90,9 +106,11 @@ namespace math {
* prior to Fft32 function call if built with ARM DSP functions.
* @param[in] fftLen Requested length of the FFT.
* @param[in] fftInstance FFT instance struct to use.
- * @return true if successful, false otherwise.
+ * @param[in] type FFT type (real or complex)
*/
- static bool FftInitF32(const uint16_t fftLen, arm::app::math::FftInstance& fftInstance);
+ static void FftInitF32(const uint16_t fftLen,
+ FftInstance& fftInstance,
+ const FftType type = FftType::real);
/**
* @brief Computes the FFT for the input vector.
@@ -102,7 +120,7 @@ namespace math {
*/
static void FftF32(std::vector<float>& input,
std::vector<float>& fftOutput,
- arm::app::math::FftInstance& fftInstance);
+ FftInstance& fftInstance);
/**
* @brief Computes the natural logarithms of input floating point