#! /bin/bash
# Last edited on 2021-07-31 15:40:49 by jstolfi

nb1="$1"; shift  # Appprox basis has ${nb1} by ${nb1} elements.
nf="$1"; shift   # Target basis has a total of ${nf} elements.

# Plot the window weight function:
plot_sampled_function.sh out/B.txt -3 "weight"

# Plot some elements of the test basis:
kf1=$(( ${nf} / 2 ))
kf2=$(( ${nf} / 4 ))
kf3=0
for kf in ${kf1} ${kf2} ${kf3} ; do
  plot_sampled_function.sh out/F.txt ${kf} "F[${kf}]"
  plot_sampled_function.sh out/R.txt ${kf} "R[${kf}]"
done

# Plot the distinct elemenents of the appromximation basis:
kx=0
while [[ ${kx} -le $(( ${nb1} / 2)) ]]; do
  ky=0
  while [[ ${ky} -le ${kx} ]];  do
    kb=$(( ${kx} * nb1 + ${ky} ))
    plot_sampled_function.sh out/B.txt ${kb} "B[${kb}]"
    plot_sampled_function.sh out/C.txt ${kb} "C[${kb}]"
    ky=$(( ${ky} + 1 ))
  done
  kx=$(( ${kx} + 1 ))
done

# Plot the error map:
plot_sampled_function.sh out/emap.txt 0 "error map"
