From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- noao/twodspec/multispec/armsr.x | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 noao/twodspec/multispec/armsr.x (limited to 'noao/twodspec/multispec/armsr.x') 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 -- cgit