nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
Data Types and Structures (datatypes)

Numeric type casting, struct arrays, cell arrays, map/dictionary containers, and type introspection (isa, isnumeric). More...

Files

file  datatypes.hpp
 Data type construction, inspection, structures, cell arrays, and limits.
file  cell.hpp
file  containers.hpp
file  struct.hpp

Functions

Value nk::builtin::isfield (const Value &s, const std::string &field, std::pmr::memory_resource *mr=nullptr)
 Tests if structure contains field by string name (isfield(s, field)).
Value nk::builtin::getfield (const Value &s, const std::string &field, std::pmr::memory_resource *mr=nullptr)
 Gets value of structure field by string name (getfield(s, field)).
Value nk::builtin::setfield (const Value &s, const std::string &field, const Value &val, std::pmr::memory_resource *mr=nullptr)
 Sets value of structure field by string name (setfield(s, field, val)).
Value nk::builtin::rmfield (const Value &s, const std::string &field, std::pmr::memory_resource *mr=nullptr)
 Removes field from structure by string name (rmfield(s, field)).
Value nk::builtin::toDouble (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to double-precision floating point (double(x)).
Value nk::builtin::single (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to single-precision floating point (single(x)).
Value nk::builtin::int8 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 8-bit signed integer (int8(x)).
Value nk::builtin::int16 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 16-bit signed integer (int16(x)).
Value nk::builtin::int32 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 32-bit signed integer (int32(x)).
Value nk::builtin::int64 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 64-bit signed integer (int64(x)).
Value nk::builtin::uint8 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 8-bit unsigned integer (uint8(x)).
Value nk::builtin::uint16 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 16-bit unsigned integer (uint16(x)).
Value nk::builtin::uint32 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 32-bit unsigned integer (uint32(x)).
Value nk::builtin::uint64 (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to 64-bit unsigned integer (uint64(x)).
Value nk::builtin::logical (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Converts input array to logical boolean array (logical(x)).
Value nk::builtin::iscell (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a cell array (iscell(v)).
Value nk::builtin::isstruct (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a structure (isstruct(v)).
Value nk::builtin::isnumeric (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is numeric (double, single, integer) (isnumeric(v)).
Value nk::builtin::isfloat (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a floating-point type (single or double) (isfloat(v)).
Value nk::builtin::isinteger (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is an integer class (isinteger(v)).
Value nk::builtin::islogical (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is logical type (islogical(v)).
Value nk::builtin::ischar (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is character array (ischar(v)).
Value nk::builtin::isstring (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is string array (isstring(v)).
Value nk::builtin::isnan (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests array elements for NaN (isnan(v)).
Value nk::builtin::isinf (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests array elements for Infinity (isinf(v)).
Value nk::builtin::isfinite (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests array elements for finiteness (isfinite(v)).
Value nk::builtin::isempty (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if array is empty (any dimension is 0) (isempty(v)).
Value nk::builtin::isscalar (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a 1x1 scalar (isscalar(v)).
Value nk::builtin::isvector (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a 1-D vector (1xN or Nx1) (isvector(v)).
Value nk::builtin::isrow (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a 1xN row vector (isrow(v)).
Value nk::builtin::iscolumn (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is an Nx1 column vector (iscolumn(v)).
Value nk::builtin::ismatrix (const Value &v, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a 2-D matrix (ismatrix(v)).
Value nk::builtin::issingle (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Tests if input is single-precision floating point (issingle(x)).
Value nk::builtin::issparse (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Tests if input is a sparse array (issparse(x)).
Value nk::builtin::ismissing (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Finds missing entries in array using default standard missing indicators (ismissing(x)).
Value nk::builtin::ismissing (const Value &x, const Value &indicator, std::pmr::memory_resource *mr=nullptr)
 Finds missing entries in array matching user-specified indicators (ismissing(x, indicator)).
Value nk::builtin::issorted (const Value &x, const Value &mode=Value::Empty, std::pmr::memory_resource *mr=nullptr)
 Determines if array elements are sorted in ascending or descending order (issorted(x, mode)).
Value nk::builtin::isequal (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
 Determines if arrays are strictly identical in type, shape, and values (isequal(a, b)).
Value nk::builtin::isequaln (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
 Determines if arrays are equal, treating NaNs as equal (isequaln(a, b)).
Value nk::builtin::cast (const Value &v, const std::string &targetType, std::pmr::memory_resource *mr=nullptr)
 Casts input array to target type name (cast(v, targetType)).
Value nk::builtin::standardizeMissing (const Value &x, const Value &indicator, std::pmr::memory_resource *mr=nullptr)
 Replaces specified indicator values with standard missing values (standardizeMissing(x, indicator)).
Value nk::builtin::anymissing (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Tests if array contains any missing entries (anymissing(x)).
Value nk::builtin::isuniform (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Tests if array has uniform element spacing (isuniform(x)).
Value nk::builtin::classOf (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Returns the class name of an object or array (class(x)).
Value nk::builtin::swapbytes (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Swaps byte order of array elements between little-endian and big-endian (swapbytes(x)).
Value nk::builtin::typecast (const Value &x, const std::string &datatype, std::pmr::memory_resource *mr=nullptr)
 Reinterprets binary data between datatypes without changing underlying bytes (typecast(x, datatype)).
Value nk::builtin::allfinite (const Value &x, std::pmr::memory_resource *mr=nullptr)
 True if all elements are finite numbers (allfinite(x)).
Value nk::builtin::anynan (const Value &x, std::pmr::memory_resource *mr=nullptr)
 True if any array element is NaN (anynan(x)).
Value nk::builtin::realmin (const std::string &className="double", std::pmr::memory_resource *mr=nullptr)
 Smallest positive normalized floating-point number (realmin(className)).
Value nk::builtin::realmin (const Value &t, std::pmr::memory_resource *mr=nullptr)
 Smallest positive normalized floating-point number (realmin(t)).
Value nk::builtin::realmax (const std::string &className="double", std::pmr::memory_resource *mr=nullptr)
 Largest finite floating-point number (realmax(className)).
Value nk::builtin::realmax (const Value &t, std::pmr::memory_resource *mr=nullptr)
 Largest finite floating-point number (realmax(t)).
Value nk::builtin::intmin (const std::string &className="int32", std::pmr::memory_resource *mr=nullptr)
 Smallest integer value for specified integer class (intmin(className)).
Value nk::builtin::intmin (const Value &t, std::pmr::memory_resource *mr=nullptr)
 Smallest integer value for specified integer class value (intmin(t)).
Value nk::builtin::intmax (const std::string &className="int32", std::pmr::memory_resource *mr=nullptr)
 Largest integer value for specified integer class (intmax(className)).
Value nk::builtin::intmax (const Value &t, std::pmr::memory_resource *mr=nullptr)
 Largest integer value for specified integer class value (intmax(t)).
Value nk::builtin::flintmax (const std::string &className="double", std::pmr::memory_resource *mr=nullptr)
 Largest consecutive integer accurately representable in floating-point format (flintmax(className)).
Value nk::builtin::flintmax (const Value &t, std::pmr::memory_resource *mr=nullptr)
 Largest consecutive integer accurately representable in floating-point format (flintmax(t)).
void nk::runtime::registerCellsRuntime (Engine &engine)
void nk::runtime::registerCellfunCallbackBuiltin (Engine &engine)
Value nk::runtime::cell (size_t n, std::pmr::memory_resource *mr=nullptr)
 Square cell array (c = cell(n)).
Value nk::runtime::cell (size_t rows, size_t cols, std::pmr::memory_resource *mr=nullptr)
 Rectangular cell array (c = cell(rows, cols)).
Value nk::runtime::cell (size_t rows, size_t cols, size_t pages, std::pmr::memory_resource *mr=nullptr)
 3-D cell array (c = cell(rows, cols, pages)).
Value nk::runtime::cellfun (FnHandle fn, const Value &c, bool uniformOutput, std::pmr::memory_resource *mr=nullptr)
 Apply a callback to each cell (y = cellfun(fn, c, uniformOutput)).
Value nk::runtime::num2cell (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Wrap each element in a scalar cell (c = num2cell(A)).
Value nk::runtime::cell2mat (const Value &c, std::pmr::memory_resource *mr=nullptr)
 Concatenate cells into a matrix (A = cell2mat(c)).
Value nk::runtime::iscellstr (const Value &c, std::pmr::memory_resource *mr=nullptr)
 Test whether a cell array holds only char rows (tf = iscellstr(c)).
Value nk::runtime::cellstr (const Value &x, std::pmr::memory_resource *mr=nullptr)
 Convert to cell-of-strings (c = cellstr(x)).
Value nk::runtime::mat2cell (const Value &x, const Value &rowSizes, const Value &colSizes=Value::Empty, std::pmr::memory_resource *mr=nullptr)
 Split a matrix into a cell array of blocks (c = mat2cell(A, R, C)).
void nk::runtime::registerContainersRuntime (Engine &engine)
 Registers containers.Map and dictionary builtins in the engine.
Value nk::runtime::containers::map (std::pmr::memory_resource *mr=nullptr)
 Creates an empty containers.Map (handle semantics: copies alias shared state).
Value nk::runtime::containers::dictionary (std::pmr::memory_resource *mr=nullptr)
 Creates an empty dictionary (value semantics: copies are independent).
void nk::runtime::containers::set (Value &m, const Value &key, const Value &val)
 Inserts or updates key-value pair in container in place.
Value nk::runtime::containers::get (const Value &m, const Value &key)
 Looks up value associated with specified key (throws if key absent).
bool nk::runtime::containers::isKey (const Value &m, const Value &key)
 Checks whether specified key exists in container.
void nk::runtime::containers::remove (Value &m, const Value &key)
 Removes specified key and its associated value from container.
std::size_t nk::runtime::containers::count (const Value &m)
 Returns the number of key-value pairs in container.
Value nk::runtime::containers::keys (const Value &m, std::pmr::memory_resource *mr=nullptr)
 Extracts all keys from container as a column array.
Value nk::runtime::containers::values (const Value &m, std::pmr::memory_resource *mr=nullptr)
 Extracts all values from container as an array or cell array.
void nk::runtime::registerStructuresRuntime (Engine &engine)
void nk::runtime::registerStructfunCallbackBuiltin (Engine &engine)
Value nk::runtime::structure (std::pmr::memory_resource *mr=nullptr)
 Empty struct scalar (s = struct()).
Value nk::runtime::structure (Span< const Value > nameValuePairs, std::pmr::memory_resource *mr=nullptr)
 Struct from {name, value, …} pairs (s = struct(name1, val1, name2, val2, …)).
Value nk::runtime::fieldnames (const Value &s, std::pmr::memory_resource *mr=nullptr)
 Field names of a struct (fn = fieldnames(s)).
Value nk::runtime::isfield (const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
 Test for field existence (tf = isfield(s, name)).
Value nk::runtime::rmfield (const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
 Remove a field from a struct (s2 = rmfield(s, name)).
Value nk::runtime::structfun (FnHandle fn, const Value &s, bool uniformOutput, std::pmr::memory_resource *mr=nullptr)
 Apply a function handle to every field of a struct (y = structfun(fn, s, uniformOutput)).
Value nk::runtime::getfield (const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
 Gets the value of specified field in structure (v = getfield(s, 'field')).
Value nk::runtime::setfield (const Value &s, const Value &name, const Value &value, std::pmr::memory_resource *mr=nullptr)
 Sets the value of specified field in structure (s = setfield(s, 'field', val)).
Value nk::runtime::orderfields (const Value &s, std::pmr::memory_resource *mr=nullptr)
 Orders fields of structure array alphabetically (s = orderfields(s)).
Value nk::runtime::struct2cell (const Value &s, std::pmr::memory_resource *mr=nullptr)
 Converts structure array to cell array of field values (c = struct2cell(s)).

Detailed Description

Numeric type casting, struct arrays, cell arrays, map/dictionary containers, and type introspection (isa, isnumeric).

Function Documentation

◆ allfinite()

Value nk::builtin::allfinite ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

True if all elements are finite numbers (allfinite(x)).

Parameters
xInput array.
mrMemory resource.
Returns
Logical scalar.

◆ anymissing()

Value nk::builtin::anymissing ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Tests if array contains any missing entries (anymissing(x)).

Parameters
xInput array.
mrMemory resource.
Returns
Logical true if any element is missing.

◆ anynan()

Value nk::builtin::anynan ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

True if any array element is NaN (anynan(x)).

Parameters
xInput array.
mrMemory resource.
Returns
Logical scalar.

◆ cast()

Value nk::builtin::cast ( const Value & v,
const std::string & targetType,
std::pmr::memory_resource * mr = nullptr )

Casts input array to target type name (cast(v, targetType)).

Parameters
vInput array.
targetTypeTarget class name (e.g. 'double', 'single', 'int32', 'uint8', 'logical').
mrMemory resource.
Returns
Casted array.

◆ cell() [1/3]

Value nk::runtime::cell ( size_t n,
std::pmr::memory_resource * mr = nullptr )

Square cell array (c = cell(n)).

cell(n) builds an n × n cell of empty matrices.

Parameters
nSide length.
mrMemory resource (nullptr → process default).
Returns
n × n empty cell array.
See also
cell(rows, cols, mr), cell(rows, cols, pages, mr)

◆ cell() [2/3]

Value nk::runtime::cell ( size_t rows,
size_t cols,
size_t pages,
std::pmr::memory_resource * mr = nullptr )

3-D cell array (c = cell(rows, cols, pages)).

pages > 0 produces a 3-D cell; pages == 0 returns the 2-D form.

Parameters
rowsNumber of rows.
colsNumber of columns.
pagesNumber of pages (0 → 2-D).
mrMemory resource (nullptr → process default).
Returns
Empty cell array.

◆ cell() [3/3]

Value nk::runtime::cell ( size_t rows,
size_t cols,
std::pmr::memory_resource * mr = nullptr )

Rectangular cell array (c = cell(rows, cols)).

Parameters
rowsNumber of rows.
colsNumber of columns.
mrMemory resource (nullptr → process default).
Returns
rows × cols empty cell array.

◆ cell2mat()

Value nk::runtime::cell2mat ( const Value & c,
std::pmr::memory_resource * mr = nullptr )

Concatenate cells into a matrix (A = cell2mat(c)).

Fast path for cells of DOUBLE scalars; general case is horzcat of each row followed by vertcat.

Parameters
cCell array (each cell numeric, shape-compatible).
mrMemory resource (nullptr → process default).
Returns
Concatenated matrix.
See also
num2cell, mat2cell

◆ cellfun()

Value nk::runtime::cellfun ( FnHandle fn,
const Value & c,
bool uniformOutput,
std::pmr::memory_resource * mr = nullptr )

Apply a callback to each cell (y = cellfun(fn, c, uniformOutput)).

The callback is invoked once per cell with a 1-element args holding c.cellAt(i) and writes a single Value into outs[0].

uniformOutput = true packs scalar results into a numeric or LOGICAL array of the same shape as c (type chosen from the first result). uniformOutput = false packs results into a cell of the same shape.

Engine-side fast path for built-in handles (@numel, @isempty, @sum, @class, …) is handled by the engine adapter — it pre-resolves to a direct C++ helper and wraps that in the same callback signature before calling this function.

Parameters
fnCallback.
cCell array input.
uniformOutputSee above.
mrMemory resource (nullptr → process default).
Returns
Per-cell results (shape depends on uniformOutput).
Exceptions
ErrorNon-cell c, or non-scalar result in uniform mode.

◆ cellstr()

Value nk::runtime::cellstr ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Convert to cell-of-strings (c = cellstr(x)).

  • Char row → 1 × 1 cell containing the row.
  • String array → N × 1 cell of strings.
  • Cell-of-strings → identity passthrough.
Parameters
xInput Value.
mrMemory resource (nullptr → process default).
Returns
Cell-of-strings.

◆ classOf()

Value nk::builtin::classOf ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Returns the class name of an object or array (class(x)).

Parameters
xInput value.
mrMemory resource.
Returns
String representing datatype class name.

◆ count()

std::size_t nk::runtime::containers::count ( const Value & m)

Returns the number of key-value pairs in container.

Parameters
mContainer Value object.
Returns
Number of entries.

◆ dictionary()

Value nk::runtime::containers::dictionary ( std::pmr::memory_resource * mr = nullptr)

Creates an empty dictionary (value semantics: copies are independent).

Parameters
mrMemory resource for container state.
Returns
Dictionary Value object.
See also
map

◆ fieldnames()

Value nk::runtime::fieldnames ( const Value & s,
std::pmr::memory_resource * mr = nullptr )

Field names of a struct (fn = fieldnames(s)).

Parameters
sStruct Value.
mrMemory resource (nullptr → process default).
Returns
1-column cell array of field names in insertion order.
Exceptions
Errors is not a struct (m:fieldnames:notStruct).

◆ flintmax() [1/2]

Value nk::builtin::flintmax ( const std::string & className = "double",
std::pmr::memory_resource * mr = nullptr )

Largest consecutive integer accurately representable in floating-point format (flintmax(className)).

Parameters
classNameFloating-point class name ("double" for 2^53, "single" for 2^24).
mrMemory resource.
Returns
Maximum consecutive float integer.

◆ flintmax() [2/2]

Value nk::builtin::flintmax ( const Value & t,
std::pmr::memory_resource * mr = nullptr )

Largest consecutive integer accurately representable in floating-point format (flintmax(t)).

Parameters
tType name value.
mrMemory resource.
Returns
Maximum consecutive float integer.

◆ get()

Value nk::runtime::containers::get ( const Value & m,
const Value & key )

Looks up value associated with specified key (throws if key absent).

Parameters
mContainer Value object.
keyKey Value to search.
Returns
Value associated with key.
See also
isKey

◆ getfield() [1/2]

Value nk::builtin::getfield ( const Value & s,
const std::string & field,
std::pmr::memory_resource * mr = nullptr )

Gets value of structure field by string name (getfield(s, field)).

Parameters
sStructure value.
fieldField name string.
mrMemory resource.
Returns
Value contained in structure field.
See also
isfield, setfield, rmfield

◆ getfield() [2/2]

Value nk::runtime::getfield ( const Value & s,
const Value & name,
std::pmr::memory_resource * mr = nullptr )

Gets the value of specified field in structure (v = getfield(s, 'field')).

Parameters
sStructure array.
nameField name string.
mrMemory resource for output allocation.
Returns
Field value.
See also
setfield, rmfield, isfield

◆ int16()

Value nk::builtin::int16 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 16-bit signed integer (int16(x)).

Parameters
xInput array.
mrMemory resource.
Returns
16-bit signed integer array.

◆ int32()

Value nk::builtin::int32 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 32-bit signed integer (int32(x)).

Parameters
xInput array.
mrMemory resource.
Returns
32-bit signed integer array.

◆ int64()

Value nk::builtin::int64 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 64-bit signed integer (int64(x)).

Parameters
xInput array.
mrMemory resource.
Returns
64-bit signed integer array.

◆ int8()

Value nk::builtin::int8 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 8-bit signed integer (int8(x)).

Parameters
xInput array.
mrMemory resource.
Returns
8-bit signed integer array.

◆ intmax() [1/2]

Value nk::builtin::intmax ( const std::string & className = "int32",
std::pmr::memory_resource * mr = nullptr )

Largest integer value for specified integer class (intmax(className)).

Parameters
classNameInteger class name.
mrMemory resource.
Returns
Largest integer value.
See also
intmin

◆ intmax() [2/2]

Value nk::builtin::intmax ( const Value & t,
std::pmr::memory_resource * mr = nullptr )

Largest integer value for specified integer class value (intmax(t)).

Parameters
tInteger class value.
mrMemory resource.
Returns
Largest integer value.

◆ intmin() [1/2]

Value nk::builtin::intmin ( const std::string & className = "int32",
std::pmr::memory_resource * mr = nullptr )

Smallest integer value for specified integer class (intmin(className)).

Parameters
classNameInteger class name (e.g. "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64").
mrMemory resource.
Returns
Smallest integer value.
See also
intmax

◆ intmin() [2/2]

Value nk::builtin::intmin ( const Value & t,
std::pmr::memory_resource * mr = nullptr )

Smallest integer value for specified integer class value (intmin(t)).

Parameters
tInteger class value.
mrMemory resource.
Returns
Smallest integer value.

◆ iscell()

Value nk::builtin::iscell ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a cell array (iscell(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isstruct, isnumeric

◆ iscellstr()

Value nk::runtime::iscellstr ( const Value & c,
std::pmr::memory_resource * mr = nullptr )

Test whether a cell array holds only char rows (tf = iscellstr(c)).

Parameters
cInput Value.
mrMemory resource (nullptr → process default).
Returns
LOGICAL scalar.

◆ ischar()

Value nk::builtin::ischar ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is character array (ischar(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isstring

◆ iscolumn()

Value nk::builtin::iscolumn ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is an Nx1 column vector (iscolumn(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isrow, isvector

◆ isempty()

Value nk::builtin::isempty ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if array is empty (any dimension is 0) (isempty(v)).

Parameters
vInput array.
mrMemory resource.
Returns
Logical scalar.

◆ isequal()

Value nk::builtin::isequal ( const Value & a,
const Value & b,
std::pmr::memory_resource * mr = nullptr )

Determines if arrays are strictly identical in type, shape, and values (isequal(a, b)).

Parameters
aFirst value.
bSecond value.
mrMemory resource.
Returns
Logical scalar (NaNs are treated as not equal).
See also
isequaln

◆ isequaln()

Value nk::builtin::isequaln ( const Value & a,
const Value & b,
std::pmr::memory_resource * mr = nullptr )

Determines if arrays are equal, treating NaNs as equal (isequaln(a, b)).

Parameters
aFirst value.
bSecond value.
mrMemory resource.
Returns
Logical scalar (NaNs in matching positions are treated as equal).
See also
isequal

◆ isfield() [1/2]

Value nk::builtin::isfield ( const Value & s,
const std::string & field,
std::pmr::memory_resource * mr = nullptr )

Tests if structure contains field by string name (isfield(s, field)).

Parameters
sStructure value.
fieldField name string.
mrMemory resource for allocations (nullptr for default).
Returns
Logical true if field exists.
See also
getfield, setfield, rmfield

◆ isfield() [2/2]

Value nk::runtime::isfield ( const Value & s,
const Value & name,
std::pmr::memory_resource * mr = nullptr )

Test for field existence (tf = isfield(s, name)).

Returns false (not error) if s is not a struct.

Parameters
sStruct (or any Value).
nameField name (CHAR / STRING) or cell array of names — broadcasts elementwise over cell entries.
mrMemory resource (nullptr → process default).
Returns
LOGICAL result: scalar (single name) or array (cell name).

◆ isfinite()

Value nk::builtin::isfinite ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests array elements for finiteness (isfinite(v)).

Parameters
vInput array.
mrMemory resource.
Returns
Logical array matching shape of v.
See also
isnan, isinf

◆ isfloat()

Value nk::builtin::isfloat ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a floating-point type (single or double) (isfloat(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isnumeric, isinteger

◆ isinf()

Value nk::builtin::isinf ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests array elements for Infinity (isinf(v)).

Parameters
vInput array.
mrMemory resource.
Returns
Logical array matching shape of v.
See also
isnan, isfinite

◆ isinteger()

Value nk::builtin::isinteger ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is an integer class (isinteger(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isfloat, isnumeric

◆ isKey()

bool nk::runtime::containers::isKey ( const Value & m,
const Value & key )

Checks whether specified key exists in container.

Parameters
mContainer Value object.
keyKey Value to search.
Returns
True if key exists, false otherwise.
See also
get

◆ islogical()

Value nk::builtin::islogical ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is logical type (islogical(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.

◆ ismatrix()

Value nk::builtin::ismatrix ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a 2-D matrix (ismatrix(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isvector, isscalar

◆ ismissing() [1/2]

Value nk::builtin::ismissing ( const Value & x,
const Value & indicator,
std::pmr::memory_resource * mr = nullptr )

Finds missing entries in array matching user-specified indicators (ismissing(x, indicator)).

Parameters
xInput array.
indicatorValue or cell array of values treated as missing indicators.
mrMemory resource.
Returns
Logical array matching shape of x.

◆ ismissing() [2/2]

Value nk::builtin::ismissing ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Finds missing entries in array using default standard missing indicators (ismissing(x)).

Parameters
xInput array.
mrMemory resource.
Returns
Logical array where true indicates missing values (NaN, NaT, missing string/cell).

◆ isnan()

Value nk::builtin::isnan ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests array elements for NaN (isnan(v)).

Parameters
vInput array.
mrMemory resource.
Returns
Logical array matching shape of v.
See also
isinf, isfinite

◆ isnumeric()

Value nk::builtin::isnumeric ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is numeric (double, single, integer) (isnumeric(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isfloat, isinteger

◆ isrow()

Value nk::builtin::isrow ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a 1xN row vector (isrow(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
iscolumn, isvector

◆ isscalar()

Value nk::builtin::isscalar ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a 1x1 scalar (isscalar(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isvector, ismatrix

◆ issingle()

Value nk::builtin::issingle ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Tests if input is single-precision floating point (issingle(x)).

Parameters
xInput array or value.
mrMemory resource.
Returns
Logical scalar.

◆ issorted()

Value nk::builtin::issorted ( const Value & x,
const Value & mode = Value::Empty,
std::pmr::memory_resource * mr = nullptr )

Determines if array elements are sorted in ascending or descending order (issorted(x, mode)).

Parameters
xInput array.
modeSorting direction (e.g. 'ascend', 'descend').
mrMemory resource.
Returns
Logical scalar.

◆ issparse()

Value nk::builtin::issparse ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a sparse array (issparse(x)).

Parameters
xInput value.
mrMemory resource.
Returns
Logical scalar.

◆ isstring()

Value nk::builtin::isstring ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is string array (isstring(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
ischar

◆ isstruct()

Value nk::builtin::isstruct ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a structure (isstruct(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
iscell, isfield

◆ isuniform()

Value nk::builtin::isuniform ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Tests if array has uniform element spacing (isuniform(x)).

Parameters
xInput vector.
mrMemory resource.
Returns
Logical scalar.

◆ isvector()

Value nk::builtin::isvector ( const Value & v,
std::pmr::memory_resource * mr = nullptr )

Tests if input is a 1-D vector (1xN or Nx1) (isvector(v)).

Parameters
vInput value.
mrMemory resource.
Returns
Logical scalar.
See also
isrow, iscolumn, isscalar

◆ keys()

Value nk::runtime::containers::keys ( const Value & m,
std::pmr::memory_resource * mr = nullptr )

Extracts all keys from container as a column array.

Parameters
mContainer Value object.
mrMemory resource for output allocation.
Returns
Keys array (string, numeric, or cell).
See also
values

◆ logical()

Value nk::builtin::logical ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to logical boolean array (logical(x)).

Parameters
xInput array.
mrMemory resource.
Returns
Logical array where nonzero elements become true.

◆ map()

Value nk::runtime::containers::map ( std::pmr::memory_resource * mr = nullptr)

Creates an empty containers.Map (handle semantics: copies alias shared state).

Parameters
mrMemory resource for container state.
Returns
Container Value object.
See also
dictionary

◆ mat2cell()

Value nk::runtime::mat2cell ( const Value & x,
const Value & rowSizes,
const Value & colSizes = Value::Empty,
std::pmr::memory_resource * mr = nullptr )

Split a matrix into a cell array of blocks (c = mat2cell(A, R, C)).

Vector input: split into a 1 × N cell where element i is A(..., R(i)). 2-D input: split rows by R and columns by C. sum(R) == size(A, 1), sum(C) == size(A, 2). Block (i, j) has shape R(i) × C(j).

Parameters
xInput matrix.
rowSizesRow partition sizes (non-negative vector).
colSizesColumn partition sizes (Value::Empty for vector mode).
mrMemory resource (nullptr → process default).
Returns
Cell array of blocks.
Exceptions
ErrorPartition sums don't match input size (m:mat2cell:rowSum / m:mat2cell:colSum).
See also
cell2mat

◆ num2cell()

Value nk::runtime::num2cell ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Wrap each element in a scalar cell (c = num2cell(A)).

Parameters
xInput array.
mrMemory resource (nullptr → process default).
Returns
Cell array of the same shape, each cell holding one element.
See also
cell2mat

◆ orderfields()

Value nk::runtime::orderfields ( const Value & s,
std::pmr::memory_resource * mr = nullptr )

Orders fields of structure array alphabetically (s = orderfields(s)).

Parameters
sStructure array.
mrMemory resource for output allocation.
Returns
Structure array with sorted field names.
See also
fieldnames, isfield

◆ realmax() [1/2]

Value nk::builtin::realmax ( const std::string & className = "double",
std::pmr::memory_resource * mr = nullptr )

Largest finite floating-point number (realmax(className)).

Parameters
classNameFloating-point class name ("double" or "single").
mrMemory resource.
Returns
Largest finite float.
See also
realmin, intmax

◆ realmax() [2/2]

Value nk::builtin::realmax ( const Value & t,
std::pmr::memory_resource * mr = nullptr )

Largest finite floating-point number (realmax(t)).

Parameters
tType name value.
mrMemory resource.
Returns
Largest finite float.

◆ realmin() [1/2]

Value nk::builtin::realmin ( const std::string & className = "double",
std::pmr::memory_resource * mr = nullptr )

Smallest positive normalized floating-point number (realmin(className)).

Parameters
classNameFloating-point class name ("double" or "single").
mrMemory resource.
Returns
Smallest positive normalized float.
See also
realmax, eps

◆ realmin() [2/2]

Value nk::builtin::realmin ( const Value & t,
std::pmr::memory_resource * mr = nullptr )

Smallest positive normalized floating-point number (realmin(t)).

Parameters
tType name value.
mrMemory resource.
Returns
Smallest positive float.

◆ registerContainersRuntime()

void nk::runtime::registerContainersRuntime ( Engine & engine)

Registers containers.Map and dictionary builtins in the engine.

Parameters
engineEngine instance.

◆ remove()

void nk::runtime::containers::remove ( Value & m,
const Value & key )

Removes specified key and its associated value from container.

Parameters
mContainer Value object.
keyKey Value to remove.

◆ rmfield() [1/2]

Value nk::builtin::rmfield ( const Value & s,
const std::string & field,
std::pmr::memory_resource * mr = nullptr )

Removes field from structure by string name (rmfield(s, field)).

Parameters
sStructure value.
fieldField name string to remove.
mrMemory resource.
Returns
Structure with field removed.

◆ rmfield() [2/2]

Value nk::runtime::rmfield ( const Value & s,
const Value & name,
std::pmr::memory_resource * mr = nullptr )

Remove a field from a struct (s2 = rmfield(s, name)).

Silently ignores missing field names.

Parameters
sStruct Value.
nameField name (or cell array of names) to remove.
mrMemory resource (nullptr → process default).
Returns
Copy of s with the requested fields removed.
Exceptions
Errors is not a struct (m:rmfield:notStruct).

◆ set()

void nk::runtime::containers::set ( Value & m,
const Value & key,
const Value & val )

Inserts or updates key-value pair in container in place.

Parameters
mContainer Value object.
keyKey Value (string, scalar, or numeric).
valValue to store.

◆ setfield() [1/2]

Value nk::builtin::setfield ( const Value & s,
const std::string & field,
const Value & val,
std::pmr::memory_resource * mr = nullptr )

Sets value of structure field by string name (setfield(s, field, val)).

Parameters
sStructure value.
fieldField name string.
valNew field value.
mrMemory resource.
Returns
Updated structure value.
See also
getfield, isfield, rmfield

◆ setfield() [2/2]

Value nk::runtime::setfield ( const Value & s,
const Value & name,
const Value & value,
std::pmr::memory_resource * mr = nullptr )

Sets the value of specified field in structure (s = setfield(s, 'field', val)).

Parameters
sStructure array.
nameField name string.
valueNew field value.
mrMemory resource for output allocation.
Returns
Updated structure array.
See also
getfield, rmfield, isfield

◆ single()

Value nk::builtin::single ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to single-precision floating point (single(x)).

Parameters
xInput array or scalar.
mrMemory resource.
Returns
Single-precision array.

◆ standardizeMissing()

Value nk::builtin::standardizeMissing ( const Value & x,
const Value & indicator,
std::pmr::memory_resource * mr = nullptr )

Replaces specified indicator values with standard missing values (standardizeMissing(x, indicator)).

Parameters
xInput array.
indicatorValue or array of values to convert into standard missing representation.
mrMemory resource.
Returns
Array with values replaced by NaNs / empty strings.

◆ struct2cell()

Value nk::runtime::struct2cell ( const Value & s,
std::pmr::memory_resource * mr = nullptr )

Converts structure array to cell array of field values (c = struct2cell(s)).

Parameters
sStructure array.
mrMemory resource for output allocation.
Returns
Cell array containing all field contents.
See also
cell2struct, structfun

◆ structfun()

Value nk::runtime::structfun ( FnHandle fn,
const Value & s,
bool uniformOutput,
std::pmr::memory_resource * mr = nullptr )

Apply a function handle to every field of a struct (y = structfun(fn, s, uniformOutput)).

Built-in fast-path set matches cellfun.

The callback is invoked once per field with a 1-element args holding the field value and writes a single Value into outs[0].

Parameters
fnCallback.
sStruct Value.
uniformOutputtrue → numeric column vector of length numFields (type from first result); false → numFields × 1 cell column.
mrMemory resource (nullptr → process default).
Returns
Per-field results (shape depends on uniformOutput).
Exceptions
ErrorNon-struct s, or non-scalar result in

◆ structure() [1/2]

Value nk::runtime::structure ( Span< const Value > nameValuePairs,
std::pmr::memory_resource * mr = nullptr )

Struct from {name, value, …} pairs (s = struct(name1, val1, name2, val2, …)).

Odd arg count silently drops the trailing unmatched name. Non-char names throw.

Parameters
nameValuePairsAlternating name (CHAR / STRING) and value pairs.
mrMemory resource (nullptr → process default).
Returns
Scalar struct with the requested fields.
Exceptions
ErrorNon-char name in the pair list (m:struct:badName).

◆ structure() [2/2]

Value nk::runtime::structure ( std::pmr::memory_resource * mr = nullptr)

Empty struct scalar (s = struct()).

struct() (no args) returns a 1×1 scalar struct with no fields. C++ name is structure because struct is a keyword (registered name remains struct).

Parameters
mrMemory resource (nullptr → process default).
Returns
Empty scalar struct.
See also
structure(nameValuePairs, mr)

◆ swapbytes()

Value nk::builtin::swapbytes ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Swaps byte order of array elements between little-endian and big-endian (swapbytes(x)).

Parameters
xInput integer or floating-point array.
mrMemory resource.
Returns
Array with reversed byte order per element.

◆ toDouble()

Value nk::builtin::toDouble ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to double-precision floating point (double(x)).

Parameters
xInput array or scalar.
mrMemory resource.
Returns
Double-precision array.

◆ typecast()

Value nk::builtin::typecast ( const Value & x,
const std::string & datatype,
std::pmr::memory_resource * mr = nullptr )

Reinterprets binary data between datatypes without changing underlying bytes (typecast(x, datatype)).

Parameters
xInput numeric array.
datatypeTarget data type name.
mrMemory resource.
Returns
Typecasted array.

◆ uint16()

Value nk::builtin::uint16 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 16-bit unsigned integer (uint16(x)).

Parameters
xInput array.
mrMemory resource.
Returns
16-bit unsigned integer array.

◆ uint32()

Value nk::builtin::uint32 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 32-bit unsigned integer (uint32(x)).

Parameters
xInput array.
mrMemory resource.
Returns
32-bit unsigned integer array.

◆ uint64()

Value nk::builtin::uint64 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 64-bit unsigned integer (uint64(x)).

Parameters
xInput array.
mrMemory resource.
Returns
64-bit unsigned integer array.

◆ uint8()

Value nk::builtin::uint8 ( const Value & x,
std::pmr::memory_resource * mr = nullptr )

Converts input array to 8-bit unsigned integer (uint8(x)).

Parameters
xInput array.
mrMemory resource.
Returns
8-bit unsigned integer array.

◆ values()

Value nk::runtime::containers::values ( const Value & m,
std::pmr::memory_resource * mr = nullptr )

Extracts all values from container as an array or cell array.

Parameters
mContainer Value object.
mrMemory resource for output allocation.
Returns
Values array (homogeneous array or cell).
See also
keys