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
61 if nargin < 4
62 npnt = [];
63 end
64 if nargin < 3
65 zval = [];
66 end
67 if nargin < 2
68 center = [];
69 end
70 if nargin < 1
71 gramian = [];
72 end
73 if isempty(npnt)
74 if 1 < size(zval, 1)
75 npnt = size(zval, 1);
76 else
77 npnt = 50;
78 end
79 end
80 if isempty(center)
81 center = zeros(2, 1);
82 end
83 if isempty(gramian)
84 gramian = zeros(2, 2, 1);
85 gramian(:, :, 1) = eye(2);
86 end
87
88 nell = max(size(gramian, 3), size(center, 2));
89 asserted = size(gramian, 3) == size(center, 2) || size(gramian, 3) == 1 || size(center, 2) == 1;
90 if ~asserted
91 help("pm.geom.ell2.getBorders")
92 disp("size(gramian)")
93 disp( size(gramian) )
94 disp("size(center)")
95 disp( size(center) )
96 error ( newline ...
97 + "The condition ``size(gramian, 3) == size(center, 2) || size(gramian, 3) == 1 || size(center, 2) == 1`` must hold." + newline ...
98 + "For more information, see the documentation displayed above." + newline ...
99 + newline ...
100 );
101 end
102
103 %%%%
104 %%%% Make the 2D ellipsoid boundaries.
105 %%%%
106
107 if isempty(zval)
108 bcrd = zeros(npnt, 2);
109 for iell = 1 : nell
110 icol = (iell - 1) * 2 + 1;
111 bcrd(:, icol : icol + 1) = pm.geom.ell2.getBorder(gramian(:, :, min(iell, size(gramian, 3))), center(:, min(iell, size(center, 2))), npnt);
112 end
113 else
114 asserted = nell == size(zval, 2) || size(zval, 2) == 1 || (size(gramian, 3) == 1 || size(center, 2) == 1);
115 if ~asserted
116 help("pm.geom.ell2.getBorders")
117 disp("size(gramian, 3)")
118 disp( size(gramian, 3) )
119 disp("size(canter, 2)")
120 disp( size(canter, 2) )
121 disp("size(zval)")
122 disp( size(zval) )
123 error ( newline ...
124 + "The specified number of ellipsoids must be either the same or one in the input ``gramian``, ``center``, and ``zval``." + newline ...
125 + "For more information, see the documentation displayed above." + newline ...
126 + newline ...
127 );
128 end
129 zvalScalar = numel(zval) == 1;
130 nell = max(nell, size(zval, 2));
131 bcrd = zeros(npnt, 3 * nell);
132 for iell = 1 : nell
133 icol = (iell - 1) * 3 + 1;
134 bcrd(:, icol : icol + 1) = pm.geom.ell2.getBorder(gramian(:, :, min(iell, size(gramian, 3))), center(:, min(iell, size(center, 2))), npnt);
135 if zvalScalar
136 bcrd(:, icol + 2) = zval;
137 else
138 bcrd(:, icol + 2) = zval(:, min(iell, size(zval, 2)));
139 end
140 end
141 end
142
143end
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...