From 165dd5c1d3bf75450e93c8ced539aaae0f7d66f7 Mon Sep 17 00:00:00 2001 From: Prawien Kanhai <61232842+pakanhai@users.noreply.github.com> Date: Wed, 20 Oct 2021 23:05:57 +0200 Subject: [PATCH] - Fixed svd function with min (#2790) --- sw/airborne/math/pprz_matrix_decomp_float.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sw/airborne/math/pprz_matrix_decomp_float.c b/sw/airborne/math/pprz_matrix_decomp_float.c index 6175397093..8f6e0edc3d 100644 --- a/sw/airborne/math/pprz_matrix_decomp_float.c +++ b/sw/airborne/math/pprz_matrix_decomp_float.c @@ -141,6 +141,9 @@ static inline float pythag(float a, float b) } +int min(int num1, int num2) { + return (num1 > num2 ) ? num2 : num1; +} /** SVD decomposition * * --------------------------------------------------------------------- * @@ -295,7 +298,7 @@ int pprz_svd_float(float **a, float *w, float **v, int m, int n) } /* Accumulation of left-hand transformations. */ - for (i = n - 1; i >= 0; --i) { + for (i = min(m,n) - 1; i >= 0; --i) { l = i + 1; G = w[i]; if (i < (n - 1)) {