ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
mex.m
Go to the documentation of this file.
1%> \brief
2%> Return the vector of MATLAB strings containing the
3%> path(s) to the ParaMonte library MEX shared files.
4%>
5%> \param[in] mexname : The input scalar MATLAB string containing
6%> the (partial) name of a MEX file name without MEX extension.<br>
7%> (**optional**. If missing, all detected paths will be returned.)
8%>
9%> \param[in] config : The input scalar (or vector of) MATLAB string(s) containing the
10%> (set of) keyword(s) to match in the identified MEX files paths.<br>
11%> (**optional**. If missing, all detected paths will be returned.)
12%>
13%> \return
14%> ``mexpaths`` : The output vector of MATLAB strings containing the
15%> path(s) to the ParaMonte library MEX shared files.<br>
16%> The output ``mexpaths`` will be an empty list
17%> if no such paths are found.<br>
18%>
19%> \interface{mex}
20%> \code{.m}
21%>
22%> mexpaths = pm.lib.path.mex()
23%> mexpaths = pm.lib.path.mex([])
24%> mexpaths = pm.lib.path.mex([], [])
25%> mexpaths = pm.lib.path.mex(mexname)
26%> mexpaths = pm.lib.path.mex([], config)
27%> mexpaths = pm.lib.path.mex(mexname, [])
28%> mexpaths = pm.lib.path.mex(mexname, config)
29%>
30%> \endcode
31%>
32%> \example{mex}
33%> \include{lineno} example/lib/path/mex/main.m
34%> \output{mex}
35%> \include{lineno} example/lib/path/mex/main.out.m
36%>
37%> \final{mex}
38%>
39%> \author
40%> \JoshuaOsborne, May 21 2024, 7:41 PM, University of Texas at Arlington<br>
41%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
42%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
43function mexpaths = mex(mexname, config)
44 if nargin < 2
45 config = [];
46 end
47 if nargin < 1
48 mexname = [];
49 end
50 if ~isempty(config)
51 pm.introspection.verify(config, "string", 255, "config");
52 %configList = strsplit(config, ":");
53 configList = string(config);
54 else
55 configList = [];
56 end
57 if ~isempty(mexname)
58 pm.introspection.verify(mexname, "string", 1, "mexname");
59 else
60 mexname = "";
61 end
62 libdir = pm.lib.path.lib();
63 mexpaths = pm.sys.path.glob(fullfile(libdir, "**" + mexname + "*" + mexext));
64 if ~isempty(configList) && ~isempty(mexpaths)
65 libdirlen = length(libdir{1});
66 indices = [];
67 for i = 1 : length(mexpaths)
68 path = mexpaths{i};
69 matching = true;
70 for j = 1 : length(configList)
71 key = configList{j};
72 if ~contains(path(libdirlen + 1 : end), key)
73 matching = false;
74 break;
75 end
76 end
77 if matching
78 indices = [indices, i];
79 end
80 end
81 mexpaths = mexpaths(indices);
82 end
83end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function mex(in mexname, in config)
Return the vector of MATLAB strings containing the path(s) to the ParaMonte library MEX shared files.