summaryrefslogtreecommitdiffstats
path: root/tests/misc/perf-script
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:38:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:38:56 +0000
commit6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321 (patch)
treef63ce19d57fad3ac4a15bc26dbfbfa2b834111b5 /tests/misc/perf-script
parentInitial commit. (diff)
downloadbash-upstream/5.2.15.tar.xz
bash-upstream/5.2.15.zip
Adding upstream version 5.2.15.upstream/5.2.15upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/misc/perf-script')
-rw-r--r--tests/misc/perf-script81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/misc/perf-script b/tests/misc/perf-script
new file mode 100644
index 0000000..e1172a9
--- /dev/null
+++ b/tests/misc/perf-script
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+typeset -i m2 m1 M n2 n1 N m n
+typeset -i MM=5 NN=5
+
+case $# in
+ 0) :
+ ;;
+ 1) MM=$1; NN=$1
+ ;;
+ 2) MM=$1; NN=$2
+ ;;
+ *) echo 1>&2 "Usage: $0 [m [n]]"
+ ;;
+esac
+
+EMPTYLINE=: # echo
+echo 'a = { ' # mathematica
+
+let "M=1" # for (M=1; M<=MM; M++)
+while let "M <= MM"; do
+ let "N=1" # for (N=1; N<=NN; N++)
+ while let "N <= NN"; do
+
+ let "m1 = M - 1"
+ let "m2 = M + 1"
+ let "n1 = N - 1"
+ let "n2 = N + 1"
+
+
+ echo -n '{ ' # math
+ let "m=1" # for(m=1; m<=MM; m++)
+ while let "m <= MM"; do
+ let "n=1" # for(n=1; n<=NN; n++)
+ while let "n <= NN"; do
+
+ let "x = (m-m1)*(m-M)*(m-m2)"
+ let "y = (n-n1)*(n-N)*(n-n2)"
+
+ if let "(x*x + (n-N)*(n-N)) * ((m-M)*(m-M) + y*y)"; then
+ echo -n "0,"
+ else # neighbour
+ echo -n "1,"
+ fi
+
+ let "n=n+1"
+ done
+ echo -n " "; let "m=m+1" # ". "
+ done
+ echo '},'
+
+
+ let "N=N+1"
+ $EMPTYLINE
+ done
+ $EMPTYLINE
+ let "M=M+1"
+done
+
+echo '}'
+
+
+
+echo -n 'o = { '
+let "m=1"
+while let "m <= MM"; do
+ let "n=1"
+ while let "n <= NN"; do
+ echo -n "1,"
+ let "n=n+1"
+ done
+ let "m=m+1"
+done
+echo " }"
+
+
+echo 'x = LinearSolve[a,o] '
+
+exit 0
+
+