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