2012-08-04 19:12:36 -03:00
|
|
|
/*
|
|
|
|
* norm.c
|
|
|
|
*
|
|
|
|
* Code generation for function 'norm'
|
|
|
|
*
|
2012-10-16 13:02:28 -03:00
|
|
|
* C source code generated on: Tue Oct 16 15:27:58 2012
|
2012-08-04 19:12:36 -03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Include files */
|
|
|
|
#include "rt_nonfinite.h"
|
|
|
|
#include "attitudeKalmanfilter.h"
|
|
|
|
#include "norm.h"
|
|
|
|
|
|
|
|
/* Type Definitions */
|
|
|
|
|
|
|
|
/* Named Constants */
|
|
|
|
|
|
|
|
/* Variable Declarations */
|
|
|
|
|
|
|
|
/* Variable Definitions */
|
|
|
|
|
|
|
|
/* Function Declarations */
|
|
|
|
|
|
|
|
/* Function Definitions */
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
real32_T norm(const real32_T x[3])
|
|
|
|
{
|
|
|
|
real32_T y;
|
|
|
|
real32_T scale;
|
|
|
|
int32_T k;
|
|
|
|
real32_T absxk;
|
|
|
|
real32_T t;
|
|
|
|
y = 0.0F;
|
2012-10-16 06:10:09 -03:00
|
|
|
scale = 1.17549435E-38F;
|
2012-08-04 19:12:36 -03:00
|
|
|
for (k = 0; k < 3; k++) {
|
2012-10-16 06:10:09 -03:00
|
|
|
absxk = (real32_T)fabs(x[k]);
|
|
|
|
if (absxk > scale) {
|
|
|
|
t = scale / absxk;
|
|
|
|
y = 1.0F + y * t * t;
|
|
|
|
scale = absxk;
|
|
|
|
} else {
|
|
|
|
t = absxk / scale;
|
|
|
|
y += t * t;
|
2012-08-04 19:12:36 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-16 06:10:09 -03:00
|
|
|
return scale * (real32_T)sqrt(y);
|
2012-08-04 19:12:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of code generation (norm.c) */
|