summaryrefslogtreecommitdiff
path: root/lupd.awk
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lupd.awk13
1 files changed, 9 insertions, 4 deletions
diff --git a/lupd.awk b/lupd.awk
index 39bf00c..08e1e30 100644
--- a/lupd.awk
+++ b/lupd.awk
@@ -9,6 +9,7 @@
# note, matrix indexing begins with 1 and uses i=row, j=col
# lu = L + U - I
+
# solve A[n,n] * x[n] = b[n]
function lu_solve(A, b, n) {
@@ -56,6 +57,7 @@ function lu_solve(A, b, n) {
}
+
# regex to identify strings that look like numbers
BEGIN {
OFS = FS
@@ -66,19 +68,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
}
@@ -90,12 +94,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,