From 0ad87f0c978c85d420f422dda6d83a7f0539aa2d Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Thu, 17 Feb 2022 19:03:56 +0000 Subject: [PATCH] Optimised sumVector --- system_template_de1_soc/software/hello_world/hello_world.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system_template_de1_soc/software/hello_world/hello_world.c b/system_template_de1_soc/software/hello_world/hello_world.c index ac00753..d5690cc 100644 --- a/system_template_de1_soc/software/hello_world/hello_world.c +++ b/system_template_de1_soc/software/hello_world/hello_world.c @@ -48,8 +48,8 @@ void generateVector(float x[N]){ float sumVector(float x[], int M){ float y = 0.0; - for(int i = 0; i < M; i++){ - y += 0.5 * x[i] + x[i] * x[i] * cos((x[i] - 128.0) / 128.0); + for(int i = 0;i<=M;i++){ + y += (float)((int)x[i]>>1) + x[i]*x[i]*cosf((x[i]-128)*0.0078125); } return y; }