]> gitweb.michael.orlitzky.com - octave.git/blob - partition.m
Add tests for the steepest descent method, based on the PCGM tests.
[octave.git] / partition.m
1 function [p,delta] = partition(integerN, a, b)
2 % Partition the interval [a,b] into integerN subintervals. We do not
3 % require that a<b.
4 %
5 % INPUTS:
6 %
7 % * ``integerN`` - The number of subintervals.
8 %
9 % * ``a`` - The "left" endpoint of the interval to partition.
10 %
11 % * ``b`` - The "right" endpoint of the interval to partition.
12 %
13 %
14 % OUTPUTS:
15 %
16 % * ``p`` - The resulting partition, as a vector of length integerN+1.
17 %
18 % * ``delta`` - The distance between x_i and x_{i+1} in the partition.
19 %
20 %
21
22 % We don't use abs() here because `b` might be less than `a`. In that
23 % case, we want delta negative so that when we add it to `a`, we move
24 % towards `b`.
25 delta = (b - a)/integerN;
26
27 p = [a : delta : b];
28 end