summaryrefslogtreecommitdiff
path: root/cov.awk
diff options
context:
space:
mode:
authorwukong <wukong@longaeva>2026-04-10 23:46:12 -0700
committerwukong <wukong@longaeva>2026-04-10 23:46:12 -0700
commit4c4eb1bd8f003b3b57707badd2dd089ed193a896 (patch)
tree15b62907fffd70c46a9b4369df93ab33c6aa88ac /cov.awk
parente7d1781578e846a7b1d634cd43c8fab00a67b883 (diff)
renamed fir window generators;
minor edits to whitespace and comments for more consistent style;
Diffstat (limited to '')
-rw-r--r--cov.awk23
1 files changed, 14 insertions, 9 deletions
diff --git a/cov.awk b/cov.awk
index c06a447..92e92a8 100644
--- a/cov.awk
+++ b/cov.awk
@@ -3,6 +3,7 @@
### cov.awk
# online covariance algorithm
+
BEGIN {
OFS = FS
sign = "[+-]?"
@@ -12,18 +13,20 @@ BEGIN {
number = "^" sign "(" decimal "|" fraction ")" exponent "$"
}
+
+# column headers
NR == 1 {
- for (y=1; y<=NF; y++)
- ($y ~ number) ? header[y] = "col" y : header[y] = $y
+ for (n=1; n<=NF; n++)
+ ($n ~ number) ? header[n] = "col" n : header[n] = $n
}
+
NF > 0 {
- if (NF > nf_max)
- nf_max = NF
+ (NF > nf_max) ? nf_max = NF : nf_max = nf_max
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
- ### rows
+ # rows
for (x=1; x<=nf_max; x++) {
if ($x !~ number || $x == header[x])
continue
@@ -39,18 +42,19 @@ NF > 0 {
}
}
+
END {
- ### column headers
+ # column headers
printf("cov")
for (y=1; y<=nf_max; y++) {
printf(OFS header[y])
}
printf(ORS)
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
printf(header[y] OFS)
- ### rows
+ # rows
for (x=1; x<=nf_max; x++) {
printf(OFMT, cov_samp[x,y])
if (x < nf_max)
@@ -59,3 +63,4 @@ END {
printf(ORS)
}
}
+