summaryrefslogtreecommitdiff
path: root/det.awk
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--det.awk14
1 files changed, 10 insertions, 4 deletions
diff --git a/det.awk b/det.awk
index b3e5c1f..e83a9ea 100644
--- a/det.awk
+++ b/det.awk
@@ -5,6 +5,7 @@
# input: square array as delimited text
# output: (scalar) determinant
+
BEGIN {
OFS = "\t"
sign = "[+-]?"
@@ -14,17 +15,21 @@ 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
}
+
+# read input data
NF > 0 {
(NF > nf_max) ? nf_max = NF : nf_max = nf_max
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
- ### rows
+ # rows
if ($y !~ number) {
continue
}
@@ -36,12 +41,13 @@ NF > 0 {
}
}
+
END {
print length(row_sum), length(col_sum)
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
if (y in col_sum) {
- ### rows
+ # rows
for (x=1; x<=NR; x++) {
if (x in row_sum) {
printf("[" OFMT "," OFMT "]" OFS OFMT OFS OFMT,