2%> Return the lists of values and indices of elements
3%> of the input ``strlist`` that match the input scalar
4%> (or vector of)
string(s) or integer(s)
index ``keylist``.<br>
7%> Beware that all specified values in the input ``keylist``
8%> must exist in the input argument ``strlist``, otherwise,
9%> the procedure will interrupt the program by raising an exception.
11%> \param[in] strlist : The input scalar (or vector of) MATLAB string(s).<br>
12%> \param[in] keylist : The input scalar (or vector of) MATLAB string(s)
13%> or cell array of
char vectors or vector of MATLAB
14%> integers or a cell array of mix of the element
15%> types to match the input ``strlist``.<br>
18%> ``loclist`` : The output scalar (or vector of same size as ``keylist`` of)
19%> MATLAB integer(s) containing the location(s) of the occurrence(s)
20%> of the input ``keylist``.<br>
22%> ``namlist`` : The output scalar (or vector of same size as ``keylist`` of)
23%> MATLAB string(s) containing the
name(s) of the occurrence(s)
24%> of the input ``keylist``.<br>
29%> [loclist, namlist] = pm.str.locname(strlist, keylist)
34%> \include{lineno} example/str/
locname/main.m
36%> \include{lineno} example/str/
locname/main.out.m
41%> \JoshuaOsborne, May 21 2024, 4:38 AM, University of Texas at Arlington<br>
42%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
43%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
44function [loclist, namlist] =
locname(strlist, keylist)
46 keylistLen = pm.array.len(keylist);
47 strlist = string(strlist);
49 loclist = 1 : 1 : length(strlist);
55 strlistLen = length(strlist);
56 for i = keylistLen : -1 : 1
62 if isa(key,
"string") || isa(key,
"char")
64 for j = 1 : strlistLen
65 if strcmpi(key, strlist(j))
66 namlist(i) = strlist(j);
73 % This situation happens because of automatic conversion of numbers
74 % to strings in MATLAB array constructs like a = [
"paramonte", 1];
75 key = str2double(key);
78 failed = key < 1 || strlistLen < key;
81 namlist(i) = strlist(key);
87 failed = strlistLen < loclist(i);
89 namlist(i) = string(strlist{loclist(i)});
98 help(
"pm.str.locname");
104 +
"The element #" +
string(i) +
" of the input ``keylist`` above" + newline ...
105 +
"argument does not match any elements of the input ``strlist`` above." + newline ...
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.
function isnumeric(in str)
Return a scalar MATLAB logical that is true if and only if the input string can be converted to a sca...
function locname(in strlist, in keylist)
Return the lists of values and indices of elements of the input strlist that match the input scalar (...