ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
verified.m
Go to the documentation of this file.
1%> \brief
2%> Return ``true`` if and only if the input ``varval`` conforms with the
3%> specified input type ``vartype`` and maximum length ``maxlen``,
4%> otherwise, return ``false``.<br>
5%>
6%> \details
7%> If the input argument ``varval`` is a collection of values and the input ``vartype``
8%> is one of the five basic types (``string``, ``integer``, ``logical``, ``complex``, ``real``),
9%> then each element of the ``varval`` sequence will be tested against the input ``vartype``.<br>
10%>
11%> **Beware** that this algorithm converts input values of type ``char`` to ``string``
12%> before further processing and type checking, that is, the types ``char`` to ``string``
13%> are assumed to be conformable and compatible with each other, like most other sane languages.<br>
14%>
15%> \param[in] varval : The input value whose type and length must be verified.
16%> \param[in] vartype : The input scalar MATLAB string containing the
17%> expected type of the value given by the input ``varval``.<br>
18%> The following type-conformance rules apply:<br>
19%> <ol>
20%> <li> if ``vartype`` is ``"string"``, then ``varval`` can be
21%> either a MATLAB ``string`` or ``char``.<br>
22%> An input value of type ``char`` is always
23%> converted to ``string`` before further processing.<br>
24%> <li> if ``vartype`` is ``"integer"``, then ``varval`` can be
25%> either a MATLAB ``int8``, ``int16``, ``int32``, ``int64``,
26%> or a whole-number ``real`` value.<br>
27%> <li> if ``vartype`` is ``"logical"``, then ``varval`` can be
28%> either a MATLAB ``int8``, ``int16``, ``int32``, ``int64``,
29%> a MATLAB ``real``, or a MATLAB ``logical`` value.<br>
30%> <li> if ``vartype`` is ``"complex"``, then ``varval`` can be
31%> either a MATLAB ``int8``, ``int16``, ``int32``, ``int64``,
32%> a MATLAB ``real``, or a MATLAB ``complex`` value.<br>
33%> <li> if ``vartype`` is ``"real"``, then ``varval`` can be
34%> either a MATLAB ``int8``, ``int16``, ``int32``, ``int64``,
35%> or a MATLAB ``real`` value (e.g., ``float``, ``single``, ``double``).<br>
36%> For all other object types, the type-conformance is verified by
37%> passing the input ``varval`` and ``vartype`` directly to the
38%> MATLAB intrinsic function ``isa()``.<br>
39%> </ol>
40%> @param[in] maxlen : The input positive scalar MATLAB integer representing the
41%> maximum allowed size of the input value ``varval``.<br>
42%> The number of elements of ``varval`` is measured by the
43%> function [pm.introspection.islenleq()](@ref islenleq)<br>
44%>
45%> \return
46%> ``itis`` : The output scalar MATLAB logical that is ``true`` if and only if
47%> the input ``varval`` conforms with the specified input type ``vartype``
48%> and maximum length, otherwise, it is ``false``.<br>
49%>
50%> \interface{verified}
51%> \code{.m}
52%>
53%> itis = pm.introspection.verified(varval, vartype, maxlen)
54%>
55%> \endcode
56%>
57%> \see
58%> [pm.introspection.verify](@ref verify)<br>
59%> [pm.introspection.verified](@ref verified)<br>
60%> [pm.introspection.islenleq](@ref islenleq)<br>
61%> [pm.introspection.istype](@ref istype)<br>
62%>
63%> \example{verified}
64%> \include{lineno} example/introspection/verified/main.m
65%> \output{verified}
66%> \include{lineno} example/introspection/verified/main.out.m
67%>
68%> \final{verified}
69%>
70%> \author
71%> \JoshuaOsborne, May 21 2024, 5:47 PM, University of Texas at Arlington<br>
72%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
73%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
74function itis = verified(varval, vartype, maxlen)
75 itis = pm.introspection.islenleq(varval, maxlen) && pm.introspection.istype(varval, vartype);
76end
function verify(in varval, in vartype, in maxlen, in varname)
Verify the type and number of elements of the input varval match the specified input vartype and maxl...
function islenleq(in varval, in maxlen)
Return true if and only if the input varval has the specified maximum size maxlen,...
function istype(in varval, in vartype)
Return true if and only if the input varval conforms with the specified input type vartype,...
function verified(in varval, in vartype, in maxlen)
Return true if and only if the input varval conforms with the specified input type vartype and maximu...