]> gitweb.michael.orlitzky.com - octave.git/blobdiff - central_difference.m
Replace ##-style comments with %-style comments in all non-test code.
[octave.git] / central_difference.m
index ad58fd44546fcd3031ef2d5e7514ecd5d0c6c08b..ec9c7ed45fd41c4ee3b5f056e09f9bd7118baf98 100644 (file)
@@ -1,34 +1,34 @@
 function coefficients = central_difference(xs, x)
-  ##
-  ## The first order central difference at x1 is,
-  ##
-  ##   f'(x1) = (f(x2) - f(x0))/2
-  ##
-  ## where the index x1 is of course arbitrary but x2, x0 are adjacent
-  ## to x1. The coefficients we seek are the coefficients of f(xj) for
-  ## j = 1,...,N-2, where N is the length of ``xs``. We omit the first
-  ## and last coefficient because at x0 and xN, the previous/next
-  ## value is not available.
-  ##
-  ## This should probably take an 'order' parameter as well; see
-  ## forward_euler().
-  ##
-  ## INPUT:
-  ##
-  ##   * ``xs`` - The vector of x-coordinates.
-  ##
-  ##   * ``x`` - The point `x` at which you'd like to evaluate the
-  ##   derivative of the specified `integer_order`. This should be an
-  ##   element of `xs`.
-  ##
-  ## OUTPUT:
-  ##
-  ##   * ``coefficients`` - The vector of coefficients, in order, of
-  ##   f(x0), f(x1), ..., f(xn).
-  ##
+  %
+  % The first order central difference at x1 is,
+  %
+  %   f'(x1) = (f(x2) - f(x0))/2
+  %
+  % where the index x1 is of course arbitrary but x2, x0 are adjacent
+  % to x1. The coefficients we seek are the coefficients of f(xj) for
+  % j = 1,...,N-2, where N is the length of ``xs``. We omit the first
+  % and last coefficient because at x0 and xN, the previous/next
+  % value is not available.
+  %
+  % This should probably take an 'order' parameter as well; see
+  % forward_euler().
+  %
+  % INPUT:
+  %
+  %   * ``xs`` - The vector of x-coordinates.
+  %
+  %   * ``x`` - The point `x` at which you'd like to evaluate the
+  %   derivative of the specified `integer_order`. This should be an
+  %   element of `xs`.
+  %
+  % OUTPUT:
+  %
+  %   * ``coefficients`` - The vector of coefficients, in order, of
+  %   f(x0), f(x1), ..., f(xn).
+  %
 
   if (length(xs) < 3)
-    ## We need at least one point other than the first and last.
+    % We need at least one point other than the first and last.
     coefficients = NA;
     return;
   end
@@ -36,16 +36,16 @@ function coefficients = central_difference(xs, x)
   x_idx = find(xs == x);
 
   if (x_idx == 1 || x_idx == length(xs))
-    ## You asked for the difference at the first or last element, which
-    ## we can't do.
+    % You asked for the difference at the first or last element, which
+    % we can't do.
     coefficients = NA;
     return;
   end
 
-  ## Start with a vector of zeros.
+  % Start with a vector of zeros.
   coefficients = zeros(1, length(xs));
 
-  ## And fill in the two values that we know.
+  % And fill in the two values that we know.
   coefficients(x_idx - 1) = -1/2;
   coefficients(x_idx + 1) = 1/2;
 end