aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/multispec/armsr.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/twodspec/multispec/armsr.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/twodspec/multispec/armsr.x')
-rw-r--r--noao/twodspec/multispec/armsr.x44
1 files changed, 44 insertions, 0 deletions
diff --git a/noao/twodspec/multispec/armsr.x b/noao/twodspec/multispec/armsr.x
new file mode 100644
index 00000000..2f9ce657
--- /dev/null
+++ b/noao/twodspec/multispec/armsr.x
@@ -0,0 +1,44 @@
+# ARMSR -- Compute the rms of an array.
+
+real procedure armsr (a, npoints)
+
+real a[ARB] # Return rms of this array
+int npoints # Number of points in the array
+
+int i
+real avg, rms
+
+begin
+ avg = 0.
+ rms = 0.
+ do i = 1, npoints {
+ avg = avg + a[i]
+ rms = rms + a[i] * a[i]
+ }
+ rms = sqrt ((npoints * rms - avg * avg) / (npoints * (npoints - 1)))
+
+ return (rms)
+end
+
+
+# ARMSRR -- Compute the vector rms between two real arrays.
+
+real procedure armsrr (a, b, npoints)
+
+real a[ARB] # First array
+real b[ARB] # Second array
+int npoints # Number of points
+
+int i
+real residual, rms
+
+begin
+ rms = 0.
+ do i = 1, npoints {
+ residual = a[i] - b[i]
+ rms = rms + residual ** 2
+ }
+ rms = sqrt (rms / npoints)
+
+ return (rms)
+end