]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Split the partition function into partition/partition_delta.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 17 Dec 2012 20:25:32 +0000 (15:25 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 17 Dec 2012 20:25:32 +0000 (15:25 -0500)
partition.m
partition_delta.m [new file with mode: 0644]

index 96ded5e194103e5a5ecaf92b0203ad74b97a87f7..6568be38b39ba0580abef16b63d189ff4121e2fe 100644 (file)
@@ -1,21 +1,21 @@
 function [p,delta] = partition(integerN, a, b)
   ## Partition the interval [a,b] into integerN subintervals. We do not
 function [p,delta] = partition(integerN, a, b)
   ## Partition the interval [a,b] into integerN subintervals. We do not
-  ## requite that a<b.
+  ## require that a<b.
   ##
   ## INPUTS:
   ##
   ##
   ## INPUTS:
   ##
-  ##   * integerN - The number of subintervals.
+  ##   * ``integerN`` - The number of subintervals.
   ##
   ##
-  ##   * a - The "left" endpoint of the interval to partition.
+  ##   * ``a`` - The "left" endpoint of the interval to partition.
   ##
   ##
-  ##   * b - The "right" endpoint of the interval to partition.
+  ##   * ``b`` - The "right" endpoint of the interval to partition.
   ##
   ##
   ## OUTPUTS:
   ##
   ##
   ##
   ## OUTPUTS:
   ##
-  ##   * p - The resulting partition, as a vector of length integerN+1.
+  ##   * ``p`` - The resulting partition, as a vector of length integerN+1.
   ##
   ##
-  ##   * delta - The distance between x_i and x_{i+1} in the partition.
+  ##   * ``delta`` - The distance between x_i and x_{i+1} in the partition.
   ##
   ##
 
   ##
   ##
 
@@ -24,5 +24,5 @@ function [p,delta] = partition(integerN, a, b)
   ## towards `b`.
   delta = (b - a)/integerN;
 
   ## towards `b`.
   delta = (b - a)/integerN;
 
-  p = [a : delta : b];
+  p = partition_delta(a,b,delta);
 end
 end
diff --git a/partition_delta.m b/partition_delta.m
new file mode 100644 (file)
index 0000000..7823941
--- /dev/null
@@ -0,0 +1,19 @@
+function [p] = partition_delta(a, b, delta)
+  ## Partition the interval [a,b] into subintervals of length delta. We
+  ## do not require that a<b.
+  ##
+  ## INPUTS:
+  ##
+  ##   * ``a`` - The "left" endpoint of the interval to partition.
+  ##
+  ##   * ``b`` - The "right" endpoint of the interval to partition.
+  ##
+  ##   * ``delta`` - The length of the subintervals. 
+  ##
+  ## OUTPUTS:
+  ##
+  ##   * ``p`` - The resulting partition, as a vector of length (b-a)/delta.
+  ##
+
+  p = [a : delta : b];
+end