#!/bin/bash ### hamming.sh # Convolve input vector with 3-element Hamming window [0.23, 0.54, 0.23] # note: bash built-in $(( )) constructs only support integer arithmetic # floating point operation will require another language such as awk, perl, or # python. ### input vector as array X=($1) echo ${#X[@]} ### Hamming window vector H=(0.23 0.54 0.23) echo ${#H[@]} ### length of output L=$(( ${#X[@]} + ${#H[@]} - 1 )) ### iterate over both vectors for N in $( seq 0 1 $L ) ; do for M in $( seq 0 1 $(( ${#H[@]} - 1 )) ) ; do if [ $(( $N >= $M )) ] ; then printf "N=$N\tM=$M\tN-M=$(( $N - $M ))\n" else continue fi done done