From 4c4eb1bd8f003b3b57707badd2dd089ed193a896 Mon Sep 17 00:00:00 2001 From: wukong Date: Fri, 10 Apr 2026 23:46:12 -0700 Subject: renamed fir window generators; minor edits to whitespace and comments for more consistent style; --- lpf.awk | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'lpf.awk') diff --git a/lpf.awk b/lpf.awk index aba92e1..638af3c 100644 --- a/lpf.awk +++ b/lpf.awk @@ -1,7 +1,8 @@ #!/usr/bin/awk -f ### lpf.awk -# Low Pass Filter with Hardcoded FIR Window +# low pass filter with hardcoded FIR window + BEGIN { OFS = FS @@ -20,19 +21,22 @@ BEGIN { window_size = split(H, H_arr, "[ ]*") } + +# column headers NR == 1 { for (y=1; y<=NF; y++) ($y ~ number) ? header[y] = "col" y : header[y] = $y } + +# read input data NF > 0 { - if (NF > nf_max) - nf_max = NF + (NF > nf_max) ? nf_max = NF : nf_max = nf_max input_size = window_size output_size = (input_size + window_size - 1) - ### columns + # columns for (y=1; y<=nf_max; y++) { if ($y == header[y]) printf(header[y] OFS header[y] "_lpf") @@ -75,15 +79,13 @@ NF > 0 { printf(ORS) } - - - } + END { - ### rows + # rows for (x=1; x<=window_size; x++) { - ### columns + # columns for (y=1; y<=nf_max; y++) { # rotate input buffer for (n=1; n<=input_size; n++) { @@ -93,7 +95,7 @@ END { #delete X_arr[y,input_size] #input_size = length(X_arr) #print length(X_arr) - + Y[y] = 0 for (n=1; n<=window_size; n++) { for (m=1; m<=input_size; m++) { @@ -120,7 +122,7 @@ END { printf(OFS) else printf(ORS) - X_arr[input_size] = 0 + X_arr[input_size] = 0 } } } -- cgit v1.2.3