ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
getBorders.m
Go to the documentation of this file.
1%> \brief
2%> Return a matrix of MATLAB doubles of shape ``[npnt, 2 * nell]``
3%> (or ``[npnt, 3 * nell]`` if the input ``zval`` is present)
4%> containing the 2D (or 3D) coordinates of a set of points on the boundary
5%> of a set of 2D ellipsoids whose Gramian matrices and centers are specified
6%> as input argument.<br>
7%>
8%> \details
9%> Here ``nell`` refers to the number of ellipsoids which
10%> is equal to ``2 * max(1, size(gramian, 3), size(center, 2))``.
11%>
12%> \param[in] gramian : The input matrix of MATLAB doubles of shape ``[2, 2, nell]``
13%> containing the Gramian matrices of the ``nell`` 2D ellipsoids
14%> whose boundary points are to be returned.<br>
15%> (**optional**, default = ``eye(2, 2, 1)``)
16%> \param[in] center : The input matrix of MATLAB doubles of shape ``[2, nell]`` containing
17%> the 2D coordinates of the centers of the ``nell`` 2D ellipsoids
18%> whose boundary points are to be returned.<br>
19%> (**optional**, default = ``zeros(2, 1)``)
20%> \param[in] zval : The input scalar (or matrix of shape ``[npnt, nell]`` of) MATLAB double(s)
21%> containing the z-axis coordinates of the points on the borders of the ``nell`` 2D ellipsoids.<br>
22%> If present, the specified value(s) will occupy the ``[1 : 2 : 3 * nell]`` columns of the output ``bcrd``.<br>
23%> This argument is present for the sake of convenience and better performance of the algorithm to avoid further reallocations.<br>
24%> (**optional**. If not present or empty, it will not be present in the output.)
25%> \param[in] npnt : The input scalar MATLAB whole number containing the number of points to return on the boundary of the target 2D ellipsoid.<br>
26%> (**optional**, default = ``50``)
27%>
28%> \return
29%> ``bcrd`` : The output matrix of MATLAB doubles of shape ``[npnt, 2 * nell]``
30%> (or ``[npnt, 3 * nell]`` if the input argument ``zval`` is present)
31%> containing the coordinates of a set of ``npnt`` points on
32%> the boundary of the target 2D ellipsoid.
33%>
34%> \interface{getBorders}
35%> \code{.m}
36%>
37%> pm.geom.ell2.getBorders()
38%> pm.geom.ell2.getBorders(gramian)
39%> pm.geom.ell2.getBorders(gramian, center)
40%> pm.geom.ell2.getBorders(gramian, center, zval)
41%> pm.geom.ell2.getBorders(gramian, center, zval, npnt)
42%>
43%> \endcode
44%>
45%> \warning
46%> The condition ``npnt == size(zval, 1)`` must hold for the corresponding input arguments.
47%>
48%> \example{getBorders}
49%> \include{lineno} example/geom/ell2/getBorders/main.m
50%> \vis{getBorders}
51%> \image html example/geom/ell2/getBorders/getBorders.2d.png width=700
52%> \image html example/geom/ell2/getBorders/getBorders.3d.png width=700
53%>
54%> \final{getBorders}
55%>
56%> \author
57%> \JoshuaOsborne, May 21 2024, 5:33 PM, University of Texas at Arlington<br>
58%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
59function bcrd = getBorders(gramian, center, zval, npnt)
60 if nargin < 4
61 npnt = [];
62 end
63 if nargin < 3
64 zval = [];
65 end
66 if nargin < 2
67 center = [];
68 end
69 if nargin < 1
70 gramian = [];
71 end
72 if isempty(npnt)
73 if 1 < size(zval, 1)
74 npnt = size(zval, 1);
75 else
76 npnt = 50;
77 end
78 end
79 if isempty(center)
80 center = zeros(2, 1);
81 end
82 if isempty(gramian)
83 gramian = zeros(2, 2, 1);
84 gramian(:, :, 1) = eye(2);
85 end
86 nell = max(size(gramian, 3), size(center, 2));
87 asserted = size(gramian, 3) == size(center, 2) || size(gramian, 3) == 1 || size(center, 2) == 1;
88 if ~asserted
89 help("pm.geom.ell2.getBorders")
90 disp("size(gramian)")
91 disp( size(gramian) )
92 disp("size(center)")
93 disp( size(center) )
94 error ( newline ...
95 + "The condition ``size(gramian, 3) == size(center, 2) || size(gramian, 3) == 1 || size(center, 2) == 1`` must hold." + newline ...
96 + "For more information, see the documentation displayed above." + newline ...
97 + newline ...
98 );
99 end
100 %%%% Make the 2D ellipsoid boundaries.
101 if ~isempty(zval)
102 asserted = nell == size(zval, 2) || size(zval, 2) == 1 || (size(gramian, 3) == 1 || size(center, 2) == 1);
103 if ~asserted
104 help("pm.geom.ell2.getBorders")
105 disp("size(gramian, 3)")
106 disp( size(gramian, 3) )
107 disp("size(canter, 3)")
108 disp( size(canter, 3) )
109 disp("size(zval)")
110 disp( size(zval) )
111 error ( newline ...
112 + "The specified number of ellipsoids must be either the same or one in the input ``gramian``, ``center``, and ``zval``." + newline ...
113 + "For more information, see the documentation displayed above." + newline ...
114 + newline ...
115 );
116 end
117 zvalScalar = numel(zval) == 1;
118 nell = max(nell, size(zval, 2));
119 bcrd = zeros(npnt, 3);
120 for iell = 1 : nell
121 icol = (iell - 1) * 3 + 1;
122 bcrd(:, icol : icol + 1) = pm.geom.ell2.getBorder(gramian(:, :, min(iell, size(gramian, 3))), center(:, min(iell, size(center, 2))), npnt);
123 if zvalScalar
124 bcrd(:, icol + 2) = zval;
125 else
126 bcrd(:, icol + 2) = zval(:, min(iell, size(zval, 2)));
127 end
128 end
129 else
130 bcrd = zeros(npnt, 2);
131 for iell = 1 : nell
132 icol = (iell - 1) * 2 + 1;
133 bcrd(:, icol : icol + 1) = pm.geom.ell2.getBorder(gramian(:, :, min(iell, size(gramian, 3))), center(:, min(iell, size(center, 2))), npnt);
134 end
135 end
136end
function getBorder(in gramian, in center, in npnt)
Return a matrix of MATLAB doubles of shape [npnt, 2] containing the coordinates of a set of points on...
function getBorders(in gramian, in center, in zval, in npnt)
Return a matrix of MATLAB doubles of shape [npnt, 2 * nell] (or [npnt, 3 * nell] if the input zval is...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...