Mercurial > octave
changeset 24560:1c1adf6ab75d stable
doc: Fix issues in geometry, polynomial, and interpolation chapters (bug #52835).
* geometry.txi: Re-write section on how to calculate Barycentric coordinates.
Correct example code to actually work.
* interp2.m: Rename "extrapval" to "extrap" to match rest of documentation.
* tsearchn.m (cart2bary) : Clean up comments explaining code.
* mkpp.m: Clarify size of output matrix for multi-dimensional interpolation.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 08 Jan 2018 12:24:33 -0800 |
parents | a3a263a26aab |
children | 06e22134d81a 93714122ed59 |
files | doc/interpreter/geometry.txi scripts/general/interp2.m scripts/geometry/tsearchn.m scripts/polynomial/mkpp.m |
diffstat | 4 files changed, 22 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/geometry.txi Mon Jan 08 11:31:22 2018 -0800 +++ b/doc/interpreter/geometry.txi Mon Jan 08 12:24:33 2018 -0800 @@ -102,7 +102,7 @@ @DOCSTRING(tetramesh) -The difference between @code{triplot}, and @code{trimesh} or @code{triplot}, +The difference between @code{triplot}, and @code{trimesh} or @code{trisurf}, is that the former only plots the 2-dimensional triangulation itself, whereas the second two plot the value of a function @code{f (@var{x}, @var{y})}. An example of the use of the @code{triplot} function is @@ -145,21 +145,20 @@ Cartesian coordinates of the point in a parametric form with respect to the N-simplex. This parametric form is called the Barycentric Coordinates of the point. If the points defining the N-simplex are given -by @code{@var{N} + 1} vectors @var{t}(@var{i},:), then the Barycentric +by @var{N} + 1 vectors @code{@var{t}(@var{i},:)}, then the Barycentric coordinates defining the point @var{p} are given by @example -@var{p} = sum (@var{beta}(1:@var{N}+1) * @var{t}(1:@var{N}+1),:) +@var{p} = @var{beta} * @var{t} @end example @noindent -where there are @code{@var{N} + 1} values @code{@var{beta}(@var{i})} -that together as a vector represent the Barycentric coordinates of the -point @var{p}. To ensure a unique solution for the values of -@code{@var{beta}(@var{i})} an additional criteria of +where @var{beta} contains @var{N} + 1 values that together as a vector +represent the Barycentric coordinates of the point @var{p}. To ensure a unique +solution for the values of @var{beta} an additional criteria of @example -sum (@var{beta}(1:@var{N}+1)) == 1 +sum (@var{beta}) == 1 @end example @noindent @@ -168,7 +167,7 @@ @example @group @var{p} - @var{t}(end, :) = @var{beta}(1:end-1) * (@var{t}(1:end-1, :) - - ones (@var{N}, 1) * @var{t}(end, :) + - ones (@var{N}, 1) * @var{t}(end, :) @end group @end example @@ -177,8 +176,8 @@ @example @group -@var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / (@var{t}(1:end-1, :) - - ones (@var{N}, 1) * @var{t}(end, :)) +@var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / + (@var{t}(1:end-1, :) - ones (@var{N}, 1) * @var{t}(end, :)) @var{beta}(end) = sum (@var{beta}(1:end-1)) @end group @end example @@ -212,7 +211,7 @@ @group @var{x} = [-1; -1; 1; 1]; @var{y} = [-1; 1; -1; 1]; -@var{tri} = [1, 2, 3; 2, 3, 1]; +@var{tri} = [1, 2, 3; 2, 3, 4]; @end group @end example
--- a/scripts/general/interp2.m Mon Jan 08 11:31:22 2018 -0800 +++ b/scripts/general/interp2.m Mon Jan 08 12:24:33 2018 -0800 @@ -71,7 +71,7 @@ ## @end table ## ## @var{extrap} is a scalar number. It replaces values beyond the endpoints -## with @var{extrap}. Note that if @var{extrapval} is used, @var{method} must +## with @var{extrap}. Note that if @var{extrap} is used, @var{method} must ## be specified as well. If @var{extrap} is omitted and the @var{method} is ## @qcode{"spline"}, then the extrapolated values of the @qcode{"spline"} are ## used. Otherwise the default @var{extrap} value for any other @var{method}
--- a/scripts/geometry/tsearchn.m Mon Jan 08 11:31:22 2018 -0800 +++ b/scripts/geometry/tsearchn.m Mon Jan 08 12:24:33 2018 -0800 @@ -62,13 +62,13 @@ function Beta = cart2bary (T, P) ## Conversion of Cartesian to Barycentric coordinates. - ## Given a reference simplex in N dimensions represented by a - ## (N+1)-by-(N) matrix, and arbitrary point P in cartesion coordinates, - ## represented by a N-by-1 row vector can be written as + ## Given a reference simplex in N dimensions represented by an + ## N+1-by-N matrix, an arbitrary point P in Cartesian coordinates, + ## represented by an N-by-1 column vector can be written as ## ## P = Beta * T ## - ## Where Beta is a N+1 vector of the barycentric coordinates. A criteria + ## Where Beta is an N+1 vector of the barycentric coordinates. A criteria ## on Beta is that ## ## sum (Beta) == 1 @@ -82,7 +82,7 @@ ## Beta(1:end-1) = (P - T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:)) ## Beta(end) = sum (Beta) ## - ## Note below is generalize for multiple values of P, one per row. + ## Note code below is generalized for multiple values of P, one per row. [M, N] = size (P); Beta = (P - ones (M,1) * T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:)); Beta (:,end+1) = 1 - sum (Beta, 2);
--- a/scripts/polynomial/mkpp.m Mon Jan 08 11:31:22 2018 -0800 +++ b/scripts/polynomial/mkpp.m Mon Jan 08 12:24:33 2018 -0800 @@ -27,7 +27,7 @@ ## intervals is given by @code{@var{ni} = length (@var{breaks}) - 1}. ## ## When @var{m} is the polynomial order @var{coefs} must be of size: -## @var{ni} x @var{m} + 1. +## @w{@var{ni}-by-(@var{m} + 1)}. ## ## The i-th row of @var{coefs}, @code{@var{coefs} (@var{i},:)}, contains the ## coefficients for the polynomial over the @var{i}-th interval, ordered from @@ -35,10 +35,10 @@ ## ## @var{coefs} may also be a multi-dimensional array, specifying a ## vector-valued or array-valued polynomial. In that case the polynomial -## order is defined by the length of the last dimension of @var{coefs}. The -## size of first dimension(s) are given by the scalar or vector @var{d}. If -## @var{d} is not given it is set to @code{1}. In any case @var{coefs} is -## reshaped to a 2-D matrix of size @code{[@var{ni}*prod(@var{d} @var{m})]}. +## order @var{m} is defined by the length of the last dimension of @var{coefs}. +## The size of first dimension(s) are given by the scalar or vector @var{d}. +## If @var{d} is not given it is set to @code{1}. In any case @var{coefs} is +## reshaped to a 2-D matrix of size @code{[@var{ni}*prod(@var{d}) @var{m}]}. ## ## @seealso{unmkpp, ppval, spline, pchip, ppder, ppint, ppjumps} ## @end deftypefn