Return true
if and only if the input varval
conforms with the specified input type vartype
and maximum length maxlen
, otherwise, return false
.
If the input argument varval
is a collection of values and the input vartype
is one of the five basic types (string
, integer
, logical
, complex
, real
), then each element of the varval
sequence will be tested against the input vartype
.
Beware that this algorithm converts input values of type char
to string
before further processing and type checking, that is, the types char
to string
are assumed to be conformable and compatible with each other, like most other sane languages.
- Parameters
-
[in] | varval | : The input value whose type and length must be verified. |
[in] | vartype | : The input scalar MATLAB string containing the expected type of the value given by the input varval .
The following type-conformance rules apply:
-
if
vartype is "string" , then varval can be either a MATLAB string or char .
An input value of type char is always converted to string before further processing.
-
if
vartype is "integer" , then varval can be either a MATLAB int8 , int16 , int32 , int64 , or a whole-number real value.
-
if
vartype is "logical" , then varval can be either a MATLAB int8 , int16 , int32 , int64 , a MATLAB real , or a MATLAB logical value.
-
if
vartype is "complex" , then varval can be either a MATLAB int8 , int16 , int32 , int64 , a MATLAB real , or a MATLAB complex value.
-
if
vartype is "real" , then varval can be either a MATLAB int8 , int16 , int32 , int64 , or a MATLAB real value (e.g., float , single , double ).
For all other object types, the type-conformance is verified by passing the input varval and vartype directly to the MATLAB intrinsic function isa() .
|
[in] | maxlen | : The input positive scalar MATLAB integer representing the maximum allowed size of the input value varval .
The number of elements of varval is measured by the function pm.introspection.islenleq()
|
- Returns
itis
: The output scalar MATLAB logical that is true
if and only if the input varval
conforms with the specified input type vartype
and maximum length, otherwise, it is false
.
Possible calling interfaces ⛓
itis = pm.introspection.verified(varval, vartype, maxlen)
- See also
- pm.introspection.verify
pm.introspection.verified
pm.introspection.islenleq
pm.introspection.istype
Example usage ⛓
1cd(fileparts(mfilename(
'fullpath'))); % Change working directory to source code directory.
2addpath(
'../../../'); % Add the ParaMonte library
root directory to the search path.
4disp(
'pm.introspection.verified(10000, "integer", 1)')
5disp( pm.introspection.verified(10000,
"integer", 1) )
7disp('pm.introspection.
verified([10000, 12], "integer", 1)')
8disp( pm.introspection.
verified([10000, 12], "integer", 1) )
10disp('pm.introspection.
verified([10000, 12], "integer", 2)')
11disp( pm.introspection.
verified([10000, 12], "integer", 2) )
13disp('pm.introspection.
verified([1, 0], "
double", 1)')
14disp( pm.introspection.
verified([1, 0], "
double", 1) )
16disp('pm.introspection.
verified([1, 0], "
double", 2)')
17disp( pm.introspection.
verified([1, 0], "
double", 2) )
19disp('pm.introspection.
verified([1, 0], "
double", 3)')
20disp( pm.introspection.
verified([1, 0], "
double", 3) )
22disp('pm.introspection.
verified(false, "logical", 2)')
23disp( pm.introspection.
verified(false, "logical", 2) )
25disp('pm.introspection.
verified("This is the description", "
string", 0)')
26disp( pm.introspection.
verified("This is the description", "
string", 0) )
28disp('pm.introspection.
verified("This is the description", "
string", 1)')
29disp( pm.introspection.
verified("This is the description", "
string", 1) )
31disp('pm.introspection.
verified("value", "cell", 1)')
32disp( pm.introspection.
verified("value", "cell", 1) )
34disp('pm.introspection.
verified([1, 2], "complex", 1)')
35disp( pm.introspection.
verified([1, 2], "complex", 1) )
37disp('pm.introspection.
verified([1, 2], "complex", 2)')
38disp( pm.introspection.
verified([1, 2], "complex", 2) )
40disp('pm.introspection.
verified(1 + 2i, "complex", 1)')
41disp( pm.introspection.
verified(1 + 2i, "complex", 1) )
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
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...
Example output ⛓ 1pm.introspection.verified(10000,
"integer", 1)
3pm.introspection.verified([10000, 12],
"integer", 1)
5pm.introspection.verified([10000, 12],
"integer", 2)
7pm.introspection.verified([1, 0],
"double", 1)
9pm.introspection.verified([1, 0],
"double", 2)
11pm.introspection.verified([1, 0],
"double", 3)
13pm.introspection.verified(
false,
"logical", 2)
15pm.introspection.verified(
"This is the description",
"string", 0)
17pm.introspection.verified(
"This is the description",
"string", 1)
19pm.introspection.verified(
"value",
"cell", 1)
21pm.introspection.verified([1, 2],
"complex", 1)
23pm.introspection.verified([1, 2],
"complex", 2)
25pm.introspection.verified(1 + 2i,
"complex", 1)
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Joshua Alexander Osborne, May 21 2024, 5:47 PM, University of Texas at Arlington
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin