From 992e51cf8b3017b3015c441a48c4aa93060a5ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=88=D0=AB=D0=B4=D1=89=D0=BA=D0=B2?= Date: Thu, 23 Jan 2020 22:05:32 +0300 Subject: [PATCH] Optimize size of groupdelay_from_array function --- plot.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plot.c b/plot.c index 44cc3c6..730290d 100644 --- a/plot.c +++ b/plot.c @@ -501,6 +501,7 @@ cartesian_scale(float re, float im, int *xp, int *yp, float scale) float groupdelay_from_array(int i, float array[101][2]) { +/* if (i == 0) { float deltaf = frequencies[1] - frequencies[0]; return groupdelay(array[0], array[1], deltaf); @@ -511,6 +512,11 @@ groupdelay_from_array(int i, float array[101][2]) float deltaf = frequencies[i+1] - frequencies[i-1]; return groupdelay(array[i-1], array[i+1], deltaf); } +*/ + int bottom = (i == 0) ? 0 : i - 1; + int top = (i == 100) ? 100 : i + 1; + float deltaf = frequencies[top] - frequencies[bottom]; + return groupdelay(array[bottom], array[top], deltaf); } uint32_t