mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
EKF: Eliminate use of power function to square numbers
Use of the power function to square a number can be very inefficient depending on processor and compiler. Replace with an inlined function that multiplies the number by itself. This has not been put into the maths library because the use of the sq() function is peculiar to the autocode generated for the EKF and an inlined function was desired.
This commit is contained in:
parent
42a943b37e
commit
2c8c6efb45
@ -44,8 +44,6 @@
|
||||
#include <math.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
#define sq(_arg) powf(_arg, 2.0f)
|
||||
|
||||
void Ekf::initialiseCovariance()
|
||||
{
|
||||
for (unsigned i = 0; i < _k_num_states; i++) {
|
||||
|
||||
@ -42,8 +42,6 @@
|
||||
|
||||
#include "estimator_interface.h"
|
||||
|
||||
#define sq(_arg) powf(_arg, 2.0f)
|
||||
|
||||
class Ekf : public EstimatorInterface
|
||||
{
|
||||
public:
|
||||
@ -202,4 +200,10 @@ private:
|
||||
|
||||
// Determine if we are airborne or motors are armed
|
||||
void calculateVehicleStatus();
|
||||
|
||||
// return the square of two foating point numbers - used in autocoded sections
|
||||
inline float sq(float var)
|
||||
{
|
||||
return var * var;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user