mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
1,132 lines • 71.5 kB
TypeScript
import { CharString } from './CharString';
import { ComplexType } from './Complex';
import { type ElementType, MultiArray } from './MultiArray';
import { type BuiltInFunctionSignature, type NodeReturnList, type FunctionSignatureEntry } from './AST';
/**
* Core MATLAB/Octave built-ins that are independent of heavy numerical
* algorithms.
*
* This module owns shape predicates, type predicates, structure/object
* introspection helpers, concatenation guards, and other functions that the
* interpreter should register before optional linear-algebra functionality.
* Each public built-in has adjacent signature metadata so call validation and
* implementation stay synchronized.
*/
declare abstract class CoreFunctions {
/**
* Reject cell arrays for built-ins that only accept ordinary arrays.
*
* @param name Built-in name used in diagnostics.
* @param M Candidate value.
* @throws Error when `M` is a cell array.
*/
static readonly throwErrorIfCellArray: (name: string, M: MultiArray | ComplexType) => void;
/**
* Extract class instances from a scalar or array value.
*
* @param value Runtime value to inspect.
* @returns Class instances in linear order.
*/
private static readonly classInstancesIn;
/**
* Enforce homogeneous object-array concatenation.
*
* MATLAB object arrays are homogeneous. This guard rejects concatenations
* that would mix unrelated class definitions before the array is built.
*
* @param name Built-in/operator name used in diagnostics.
* @param values Values that will be concatenated.
* @throws Error when object instances have different classes.
*/
private static readonly validateObjectArrayConcatenation;
/** Signature metadata for `isempty`. */
static readonly isemptySignature: BuiltInFunctionSignature;
/**
* Test whether a value is empty.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isempty: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isscalar`. */
static readonly isscalarSignature: BuiltInFunctionSignature;
/**
* Return true if X is a scalar.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isscalar: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `ismatrix`. */
static readonly ismatrixSignature: BuiltInFunctionSignature;
/**
* Return true if X is a 2-D array.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly ismatrix: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isvector`. */
static readonly isvectorSignature: BuiltInFunctionSignature;
/**
* Return true if X is a vector.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isvector: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `iscell`. */
static readonly iscellSignature: BuiltInFunctionSignature;
/**
* Return true if X is a cell array object.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly iscell: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `issparse`. */
static readonly issparseSignature: BuiltInFunctionSignature;
/**
* Return whether a value uses sparse storage.
*
* MathJSLab intentionally keeps array storage dense for browser/runtime
* efficiency. Sparse-related APIs are compatibility facades, so current
* runtime values are never sparse.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical false for every currently representable value.
*/
static readonly issparse: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `full`. */
static readonly fullSignature: BuiltInFunctionSignature;
/**
* Convert a sparse value to dense storage.
*
* Since runtime storage is already dense, this returns a value copy.
*
* @param X Value to materialize densely.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Dense copy of `X`.
*/
static readonly full: (X?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Test whether an element contributes to sparse/nonzero APIs.
*
* @param value Candidate runtime element.
* @returns `true` when the element is nonzero or nonempty text/object data.
*/
static readonly isNonzeroElement: (value: ElementType) => boolean;
/** Signature metadata for `nnz`. */
static readonly nnzSignature: BuiltInFunctionSignature;
/**
* Count nonzero elements in a dense-compatible value.
*
* @param X Value to inspect.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Number of nonzero elements.
*/
static readonly nnz: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `nzmax`. */
static readonly nzmaxSignature: BuiltInFunctionSignature;
/**
* Return sparse allocation capacity for compatibility.
*
* Without sparse storage, allocated sparse capacity is represented by the
* number of nonzero dense elements.
*
* @param X Value to inspect.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Dense-compatible nonzero capacity.
*/
static readonly nzmax: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `nonzeros`. */
static readonly nonzerosSignature: BuiltInFunctionSignature;
/**
* Return nonzero values as a column vector.
*
* @param X Value to inspect.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Column vector of nonzero elements.
*/
static readonly nonzeros: (X?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Extract one nonnegative integer dimension from a scalar argument.
*
* @param value Candidate dimension value.
* @param name Function name used in diagnostics.
* @param index One-based argument index.
* @returns Integer dimension.
*/
private static readonly sparseDimension;
/**
* Expand scalar/vector sparse constructor inputs to a common triplet count.
*
* @param value Subscript or value input.
* @param count Common triplet count.
* @param name Function name used in diagnostics.
* @param index One-based argument index.
* @returns Linearized values expanded to `count`.
*/
private static readonly sparseTripletValues;
/**
* Extract sparse constructor subscripts.
*
* @param value Subscript scalar or vector.
* @param count Common triplet count.
* @param name Function name used in diagnostics.
* @param index One-based argument index.
* @returns One-based positive integer subscripts.
*/
private static readonly sparseSubscripts;
/** Signature metadata for `sparse`. */
static readonly sparseSignature: BuiltInFunctionSignature;
/**
* Sparse constructor compatibility facade.
*
* The returned value is a dense matrix equivalent to the sparse matrix that
* MATLAB/Octave would construct for supported forms.
*
* @param args Sparse constructor arguments.
* @returns Dense equivalent of the requested sparse matrix.
*/
static readonly sparse: (...args: ElementType[]) => ElementType;
/** Signature metadata for `spalloc`. */
static readonly spallocSignature: BuiltInFunctionSignature;
/**
* Allocate a sparse-compatible all-zero matrix over dense storage.
*
* MathJSLab does not allocate sparse backing storage. The `nz` capacity is
* validated for MATLAB/Octave API compatibility and intentionally ignored.
*
* @param m Number of rows.
* @param n Number of columns.
* @param nz Requested sparse nonzero capacity.
* @param typename Optional sparse storage class name.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Dense all-zero matrix with the requested shape.
*/
static readonly spalloc: (m?: ElementType, n?: ElementType, nz?: ElementType, typename?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `isrow`. */
static readonly isrowSignature: BuiltInFunctionSignature;
/**
* Return true if X is a row vector.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isrow: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `iscolumn`. */
static readonly iscolumnSignature: BuiltInFunctionSignature;
/**
* Return true if X is a column vector.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly iscolumn: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isstruct`. */
static readonly isstructSignature: BuiltInFunctionSignature;
/**
* Return true if X is a structure scalar or structure array.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isstruct: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `ischar`. */
static readonly ischarSignature: BuiltInFunctionSignature;
static readonly ischar: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isstring`. */
static readonly isstringSignature: BuiltInFunctionSignature;
static readonly isstring: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `iscellstr`. */
static readonly iscellstrSignature: BuiltInFunctionSignature;
/**
* Test whether a value is a cell array of character vectors.
*
* Empty cell arrays are accepted, matching MATLAB/Octave's structural
* interpretation of cellstr arrays.
*/
static readonly iscellstr: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `cellstr`. */
static readonly cellstrSignature: BuiltInFunctionSignature;
/**
* Convert char arrays and string arrays to cell arrays of character
* vectors.
*/
static readonly cellstr: (X?: ElementType, ...rest: unknown[]) => MultiArray;
/** Signature metadata for `char`. */
static readonly charSignature: BuiltInFunctionSignature;
/**
* Convert numeric arrays and character values to MATLAB-style character
* arrays.
*
* @param args Values to convert and stack as rows.
* @returns Character vector or character array.
*/
static readonly char: (...args: ElementType[]) => ElementType;
/**
* Convert a scalar array element to a character scalar for `char`.
*
* @param value Element to convert.
* @param quote Quote style to preserve.
* @returns Character scalar.
*/
private static readonly charElement;
/**
* Convert a runtime value into character rows.
*
* @param value Value accepted by `char`.
* @returns Character rows.
*/
private static readonly charRows;
/**
* Extract cellstr contents if the value is a cell array of char vectors.
*/
private static readonly cellStringElements;
/** Signature metadata for `double`. */
static readonly doubleSignature: BuiltInFunctionSignature;
/**
* Convert numeric/logical and character values to double-precision values.
*
* @param X Value to convert.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Numeric scalar or array.
*/
static readonly double: (X?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Convert a scalar value accepted by `double`.
*
* @param value Scalar runtime value.
* @returns Numeric scalar.
*/
private static readonly doubleElement;
/** Signature metadata for `logical`. */
static readonly logicalSignature: BuiltInFunctionSignature;
/**
* Convert numeric/logical and character values to logical values.
*
* @param X Value to convert.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar or array.
*/
static readonly logical: (X?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Convert a scalar value accepted by `logical`.
*
* @param value Scalar runtime value.
* @returns Logical scalar.
*/
private static readonly logicalElement;
/**
* Apply a numeric classification predicate to scalars, arrays, and text.
*
* @param name Built-in name used for diagnostics.
* @param X Value to classify.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @param predicate Scalar predicate.
* @returns Logical scalar or array.
*/
private static readonly numericClassification;
/**
* Convert an accepted scalar element for numeric classification.
*
* @param name Built-in name used for diagnostics.
* @param value Scalar value to classify.
* @returns Numeric scalar.
*/
private static readonly numericClassificationElement;
/** Signature metadata for `isnan`. */
static readonly isnanSignature: BuiltInFunctionSignature;
/**
* Test for NaN values.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar or array.
*/
static readonly isnan: (X?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `isinf`. */
static readonly isinfSignature: BuiltInFunctionSignature;
/**
* Test for infinite values.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar or array.
*/
static readonly isinf: (X?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `isfinite`. */
static readonly isfiniteSignature: BuiltInFunctionSignature;
/**
* Test for finite values.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar or array.
*/
static readonly isfinite: (X?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `isfloat`. */
static readonly isfloatSignature: BuiltInFunctionSignature;
/**
* Return true if X is a floating-point array.
*
* The current numeric runtime represents floating-point numeric values as
* `double`; logical values are deliberately excluded.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isfloat: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isinteger`. */
static readonly isintegerSignature: BuiltInFunctionSignature;
/**
* Return true if X is an integer-typed array.
*
* Integer storage classes are not represented yet, so double values that
* happen to have integer-valued contents correctly return false.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical false for the currently supported value model.
*/
static readonly isinteger: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isnumeric`. */
static readonly isnumericSignature: BuiltInFunctionSignature;
static readonly isnumeric: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `islogical`. */
static readonly islogicalSignature: BuiltInFunctionSignature;
static readonly islogical: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isreal`. */
static readonly isrealSignature: BuiltInFunctionSignature;
static readonly isreal: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `isvalid`. */
static readonly isvalidSignature: BuiltInFunctionSignature;
/**
* Return true for valid handle class instances.
*
* @param X Handle object, listener, or array.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar or logical array.
*/
static readonly isvalid: (X?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `isobject`. */
static readonly isobjectSignature: BuiltInFunctionSignature;
/**
* Return true if X is an object or object array.
*
* @param X Value to test.
* @param rest Extra arguments, rejected for MATLAB-compatible arity.
* @returns Logical scalar.
*/
static readonly isobject: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/**
* Resolve class metadata from class definitions, instances, enumeration
* values, meta.class objects, or arrays containing those values.
*
* @param value Value supplied to an introspection built-in.
* @param name Built-in name used in diagnostics.
* @returns Class metadata.
* @throws EvalError when the value is not class-related.
*/
private static readonly classDefinitionFromValue;
/**
* Build a MATLAB-like cell column vector of strings.
*
* @param names Names to wrap.
* @returns Cell column vector.
*/
private static readonly stringCellColumn;
/**
* Return sorted member names accepted by a user-facing introspection
* predicate.
*
* MATLAB listing functions expose public, non-hidden class members instead
* of raw metadata lists.
*
* @param members Member metadata list.
* @param predicate Compatibility predicate for the listing function.
* @returns Sorted visible names.
*/
private static readonly listedNames;
static readonly propertiesSignature: BuiltInFunctionSignature;
static readonly properties: (X?: ElementType, ...rest: unknown[]) => MultiArray;
static readonly fieldnamesSignature: BuiltInFunctionSignature;
static readonly fieldnames: (X?: ElementType, ...rest: unknown[]) => MultiArray;
static readonly isfieldSignature: BuiltInFunctionSignature;
static readonly isfield: (X?: ElementType, fieldName?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `numfields`. */
static readonly numfieldsSignature: BuiltInFunctionSignature;
/** Count fields in a structure scalar or array. */
static readonly numfields: (X?: ElementType, ...rest: unknown[]) => ComplexType;
/** Signature metadata for `getfield`. */
static readonly getfieldSignature: BuiltInFunctionSignature;
/**
* Get a nested structure field using string field names.
*/
static readonly getfield: (X?: ElementType, ...fields: ElementType[]) => ElementType;
/** Signature metadata for `setfield`. */
static readonly setfieldSignature: BuiltInFunctionSignature;
/**
* Return a copy of a structure with a nested field assigned.
*/
static readonly setfield: (X?: ElementType, ...fieldsAndValue: ElementType[]) => ElementType;
/** Signature metadata for `rmfield`. */
static readonly rmfieldSignature: BuiltInFunctionSignature;
/**
* Return a copy of a structure with top-level fields removed.
*/
static readonly rmfield: (X?: ElementType, fields?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `orderfields`. */
static readonly orderfieldsSignature: BuiltInFunctionSignature;
/**
* Return a copy of a structure with alphabetically ordered top-level fields.
*/
static readonly orderfields: (X?: ElementType, ...rest: unknown[]) => ElementType;
/** Signature metadata for `struct2cell`. */
static readonly struct2cellSignature: BuiltInFunctionSignature;
/**
* Convert a structure scalar or array into a cell array of field values.
*
* The first dimension of the result enumerates fields; remaining
* dimensions mirror the structure array dimensions.
*/
static readonly struct2cell: (X?: ElementType, ...rest: unknown[]) => MultiArray;
/** Signature metadata for `cell2struct`. */
static readonly cell2structSignature: BuiltInFunctionSignature;
/**
* Convert a cell array into a structure array using one dimension as field
* names.
*/
static readonly cell2struct: (C?: ElementType, fields?: ElementType, dimension?: ElementType, ...rest: unknown[]) => ElementType;
static readonly methodsSignature: BuiltInFunctionSignature;
static readonly methods: (X?: ElementType, ...rest: unknown[]) => MultiArray;
static readonly eventsSignature: BuiltInFunctionSignature;
static readonly events: (X?: ElementType, ...rest: unknown[]) => MultiArray;
static readonly enumerationSignature: BuiltInFunctionSignature;
static readonly enumeration: (X?: ElementType, ...rest: unknown[]) => MultiArray;
static readonly superclassesSignature: BuiltInFunctionSignature;
static readonly superclasses: (X?: ElementType, ...rest: unknown[]) => MultiArray;
private static readonly stringArgument;
/**
* Normalize a single field name or cellstr list for field-list functions.
*
* @param value Runtime field-name argument.
* @param name Function name used in diagnostics.
* @param index One-based argument index used in diagnostics.
* @returns Field names in linear order.
*/
private static readonly fieldNameArguments;
/**
* Narrow a value to the concrete structure representations accepted by
* field-manipulation helpers.
*/
private static readonly structureArgument;
static readonly ispropSignature: BuiltInFunctionSignature;
static readonly isprop: (X?: ElementType, propertyName?: ElementType, ...rest: unknown[]) => ElementType;
static readonly ismethodSignature: BuiltInFunctionSignature;
static readonly ismethod: (X?: ElementType, methodName?: ElementType, ...rest: unknown[]) => ComplexType;
static readonly isequalSignature: BuiltInFunctionSignature;
/**
* Return true if all input values are equal under MATLAB-like `isequal`
* semantics.
*
* @param first First value to compare.
* @param rest Additional values that must equal `first`.
* @returns Logical scalar result.
*/
static readonly isequal: (first?: ElementType, ...rest: ElementType[]) => ComplexType;
/**
* Compare two runtime values using the same semantics exposed by
* `isequal`.
*
* This helper remains as a compatibility facade for callers that still
* access equality through the built-in module.
*
* @param left Left value.
* @param right Right value.
* @returns `true` when the values are equal.
*/
static readonly valuesEqual: (left: ElementType, right: ElementType) => boolean;
static readonly ndimsSignature: BuiltInFunctionSignature;
/**
* Return the number of logical dimensions of a runtime value.
*
* Scalars and text values use their MATLAB-compatible array dimensions,
* while arrays preserve their stored rank after singleton-tail
* normalization.
*
* @param M Value whose dimensions should be inspected.
* @returns Number of dimensions as a complex scalar.
*/
static readonly ndims: (M?: ElementType, ...rest: unknown[]) => ComplexType;
static readonly rowsSignature: BuiltInFunctionSignature;
/**
* Return the first logical dimension of a runtime value.
*
* @param M Value whose row count should be inspected.
* @returns Row count as a complex scalar.
*/
static readonly rows: (M?: ElementType, ...rest: unknown[]) => ComplexType;
static readonly columnsSignature: BuiltInFunctionSignature;
/**
* Return the second logical dimension of a runtime value.
*
* @param M Value whose column count should be inspected.
* @returns Column count as a complex scalar.
*/
static readonly columns: (M?: ElementType, ...rest: unknown[]) => ComplexType;
static readonly lengthSignature: BuiltInFunctionSignature;
/**
* Return the length of the object M. The length is the number of elements
* along the largest dimension.
*
* @param M Value whose largest dimension should be inspected.
* @returns Largest dimension as a complex scalar.
*/
static readonly Length: (M?: ElementType, ...rest: unknown[]) => ComplexType;
static readonly numelSignature: BuiltInFunctionSignature;
/**
* Return the number of selected elements.
*
* With no index arguments this is the product of the runtime dimensions.
* With index arguments it follows MATLAB's `numel(A, idx...)` contract used
* by comma-separated-list expansion and overloaded indexing: `":"` selects
* the corresponding dimension length, vector indices contribute their
* number of elements, and scalar-like indices contribute one element.
*
* @param M Value being indexed.
* @param IDX Optional indexing arguments.
* @returns Element count as a complex scalar.
*/
static readonly numel: (M: ElementType, ...IDX: ElementType[]) => ComplexType;
static readonly findSignature: BuiltInFunctionSignature;
/**
* Find indices and values of nonzero elements.
* @param M Input value.
* @param args Optional count and direction.
* @returns Linear indices or row/column/value return list.
*/
static readonly find: (M: ElementType, ...args: ElementType[]) => NodeReturnList;
static readonly sortSignature: BuiltInFunctionSignature;
/**
* Sort elements along a dimension.
* @param M Input value.
* @param args Optional dimension and direction.
* @returns Sorted values and sorting indices.
*/
static readonly sort: (M: ElementType, ...args: ElementType[]) => NodeReturnList;
static readonly ind2subSignature: BuiltInFunctionSignature;
/**
* Convert linear indices to subscripts.
* @param DIMS
* @param IND
* @returns
*/
static readonly ind2sub: (DIMS?: ElementType, IND?: ElementType) => NodeReturnList;
static readonly sub2indSignature: BuiltInFunctionSignature;
/**
* Convert subscripts to linear indices.
* @param DIMS
* @param S
* @returns
*/
static readonly sub2ind: (DIMS: ElementType, ...S: ElementType[]) => ElementType;
static readonly sizeSignature: BuiltInFunctionSignature;
/**
* Returns array dimensions.
* @param M MultiArray
* @param DIM Dimensions
* @returns Dimensions of `M` parameter.
*/
static readonly size: (M?: ElementType, ...DIM: ElementType[]) => ElementType;
static readonly colonSignature: BuiltInFunctionSignature;
/**
* Return the result of the colon expression.
* @param args
* @returns
*/
static readonly colon: (...args: ElementType[]) => ElementType;
static readonly linspaceSignature: BuiltInFunctionSignature;
/**
* Return linearly spaced samples between start and end values.
*
* Accepted forms mirror MATLAB/Octave `linspace(START, END)` and
* `linspace(START, END, N)`. Vector starts and ends are accepted when they
* have the same number of elements, producing one row per pair.
*
* @param args Start, end, and optional sample-count arguments.
* @returns Row vector or matrix of linearly spaced samples.
*/
static readonly linspace: (...args: ElementType[]) => ElementType;
static readonly logspaceSignature: BuiltInFunctionSignature;
/**
* Return logarithmically spaced samples between powers of ten.
*
* Accepted forms mirror MATLAB/Octave `logspace(START, END)` and
* `logspace(START, END, N)`, including the special `END == pi` handling
* traditionally provided by Octave/MATLAB.
*
* @param args Start exponent, end exponent, and optional sample count.
* @returns Row vector or matrix of logarithmically spaced samples.
*/
static readonly logspace: (...args: ElementType[]) => ElementType;
static readonly meshgridSignature: BuiltInFunctionSignature;
/**
* Generate 2-D and 3-D grids.
* @param args
* @returns
*/
static readonly meshgrid: (...args: ElementType[]) => NodeReturnList;
static readonly ndgridSignature: BuiltInFunctionSignature;
/**
* Given n vectors X1, ..., Xn, returns n arrays of n dimensions.
* @returns
*/
static readonly ndgrid: (...args: ElementType[]) => NodeReturnList;
static readonly repmatSignature: BuiltInFunctionSignature;
/**
* Repeat N-D array.
* @param A
* @param dim
* @returns
*/
static readonly repmat: (A: ElementType, ...dim: ElementType[]) => ElementType;
/**
* Repeat a cell array without reducing it through ordinary concatenation.
*/
private static readonly repmatCellArray;
static readonly reshapeSignature: BuiltInFunctionSignature;
/**
* Return a matrix with the specified dimensions whose elements are taken from the matrix M.
* @param M
* @param dimension
* @returns
*/
static readonly reshape: (M: ElementType, ...dimension: ElementType[]) => ElementType;
static readonly squeezeSignature: BuiltInFunctionSignature;
/**
* Remove singleton dimensions.
* @param args
* @returns
*/
static readonly squeeze: (...args: ElementType[]) => ElementType;
static readonly flipSignature: BuiltInFunctionSignature;
/**
* Reverse array elements along the first non-singleton dimension, or along
* the explicit one-based dimension.
*/
static readonly flip: (A?: ElementType, dimension?: ElementType, ...rest: unknown[]) => ElementType;
static readonly fliplrSignature: BuiltInFunctionSignature;
/**
* Reverse array columns on each page.
*/
static readonly fliplr: (A?: ElementType, ...rest: unknown[]) => ElementType;
static readonly flipudSignature: BuiltInFunctionSignature;
/**
* Reverse array rows on each page.
*/
static readonly flipud: (A?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Shared implementation for dimension-wise flips.
*/
private static readonly flipArray;
static readonly rot90Signature: BuiltInFunctionSignature;
/**
* Rotate arrays counterclockwise by K quarter-turns in the first two dimensions.
*/
static readonly rot90: (A?: ElementType, k?: ElementType, ...rest: unknown[]) => ElementType;
static readonly permuteSignature: BuiltInFunctionSignature;
/**
* Rearrange array dimensions according to a one-based permutation vector.
*/
static readonly permute: (A?: ElementType, order?: ElementType, ...rest: unknown[]) => ElementType;
static readonly ipermuteSignature: BuiltInFunctionSignature;
/**
* Inverse operation of `permute` for a one-based permutation vector.
*/
static readonly ipermute: (A?: ElementType, order?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Shared implementation for `permute` and `ipermute`.
*/
private static readonly permuteArray;
/**
* Validate and normalize the dimension order argument for permutation.
*/
private static readonly permutationOrder;
/**
* Return the inverse permutation that maps input axes back to source axes.
*/
private static readonly inversePermutation;
static readonly circshiftSignature: BuiltInFunctionSignature;
/**
* Circularly shift array elements along one or more dimensions.
*/
static readonly circshift: (A?: ElementType, shifts?: ElementType, dimension?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Apply circular shifts to an ordinary or cell array.
*/
private static readonly circularShiftArray;
static readonly shiftdimSignature: BuiltInFunctionSignature;
/**
* Shift array dimensions left or right.
*
* With one input, leading singleton dimensions are removed and a second
* output reports how many were removed. With two inputs, positive `N`
* rotates dimensions left and negative `N` prepends singleton dimensions.
*/
static readonly shiftdim: (A?: ElementType, n?: ElementType, ...rest: unknown[]) => ElementType | NodeReturnList;
/**
* Count removable leading singleton dimensions using MATLAB's two-minimum
* dimension convention.
*/
private static readonly leadingSingletonDimensions;
/**
* Shift dimensions left or prepend singleton dimensions for `shiftdim`.
*/
private static readonly shiftDimensions;
/**
* Extract an integer vector from a runtime value.
*/
private static readonly integerVector;
/**
* Extract an integer scalar from a runtime value.
*/
private static readonly integerScalar;
/**
* Extract a positive integer scalar from a runtime value.
*/
private static readonly positiveIntegerScalar;
/**
* Create MultiArray with all elements equals `fill` parameter.
* @param fill Value to fill MultiArray.
* @param dimension Dimensions of created MultiArray.
* @returns MultiArray filled with `fill` parameter.
*/
private static readonly newFilled;
/**
* Create MultiArray with all elements filled with `fillFunction` result.
* The parameter passed to `fillFunction` is a linear index of element.
* @param fillFunction Function to be called and the result fills element of MultiArray created.
* @param dimension Dimensions of created MultiArray.
* @returns MultiArray filled with `fillFunction` results for each element.
*/
private static readonly newFilledEach;
static readonly zerosSignature: BuiltInFunctionSignature;
/**
* Create array of all zeros.
* @param dimension
* @returns
*/
static readonly zeros: (...dimension: ElementType[]) => ElementType;
static readonly onesSignature: BuiltInFunctionSignature;
/**
* Create array of all ones.
* @param dimension
* @returns
*/
static readonly ones: (...dimension: ElementType[]) => ElementType;
/** Signature metadata for `cell`. */
static readonly cellSignature: BuiltInFunctionSignature;
/**
* Create a cell array whose cells are initialized with empty arrays.
*
* Unlike numeric constructors, a 1-by-1 cell remains a cell array rather
* than reducing to the contained empty value.
*
* @param dimension Cell array dimensions.
* @returns Cell array filled with empty arrays.
*/
static readonly cell: (...dimension: ElementType[]) => MultiArray;
/** Signature metadata for `num2cell`. */
static readonly num2cellSignature: BuiltInFunctionSignature;
/**
* Convert an array into a cell array, optionally grouping selected
* dimensions into each cell.
*
* @param value Source value.
* @param dimensions Dimensions to keep inside each cell.
* @returns Cell array containing scalar elements or grouped subarrays.
*/
static readonly num2cell: (value?: ElementType, dimensions?: ElementType, ...rest: unknown[]) => MultiArray;
/** Signature metadata for `cell2mat`. */
static readonly cell2matSignature: BuiltInFunctionSignature;
/**
* Convert a cell array of ordinary arrays into one concatenated array.
*
* This mirrors MATLAB/Octave's common `cell2mat` path for numeric,
* character, logical, structure, and object contents. Nested cell contents
* are rejected because the result must be an ordinary array.
*/
static readonly cell2mat: (C?: ElementType, ...rest: unknown[]) => ElementType;
/**
* Convert a cell element to the ordinary block consumed by `cell2mat`.
*/
private static readonly cell2matBlock;
/**
* Compose N-D cell blocks into one ordinary array.
*
* Block sizes may vary along the corresponding cell-array dimension, but
* must be consistent across all other dimensions.
*/
private static readonly cell2matCompose;
/** Signature metadata for `mat2cell`. */
static readonly mat2cellSignature: BuiltInFunctionSignature;
/**
* Convert an ordinary array into a cell array of blocks.
*
* Each dimension-size vector partitions the matching source dimension.
* The number of partition arguments must match the source dimensionality.
*/
static readonly mat2cell: (value?: ElementType, ...dimensionSizes: ElementType[]) => MultiArray;
/**
* Normalize one `mat2cell` partition vector and validate its sum.
*/
private static readonly mat2cellPartition;
static readonly randSignature: BuiltInFunctionSignature;
/**
* Uniformly distributed pseudorandom numbers distributed on the
* interval (0, 1).
* @param dimension
* @returns
*/
static readonly rand: (...dimension: ElementType[]) => ElementType;
static readonly randiSignature: BuiltInFunctionSignature;
/**
* Uniformly distributed pseudorandom integers.
* @param imax
* @param args
* @returns
*/
static readonly randi: (range: ElementType, ...dimension: ElementType[]) => ElementType;
static readonly catSignature: BuiltInFunctionSignature;
/**
* Return the concatenation of N-D array objects, ARRAY1, ARRAY2, ...,
* ARRAYN along dimension `DIM`.
* @param DIM Dimension of concatenation.
* @param ARRAY Arrays to concatenate.
* @returns Concatenated arrays along dimension `DIM`.
*/
static readonly cat: (DIM: ElementType, ...ARRAY: ElementType[]) => MultiArray;
static readonly horzcatSignature: BuiltInFunctionSignature;
/**
* Concatenate arrays horizontally.
* @param ARRAY Arrays to concatenate horizontally.
* @returns Concatenated arrays horizontally.
*/
static readonly horzcat: (...ARRAY: ElementType[]) => MultiArray;
static readonly vertcatSignature: BuiltInFunctionSignature;
/**
* Concatenate arrays vertically.
* @param ARRAY Arrays to concatenate vertically.
* @returns Concatenated arrays vertically.
*/
static readonly vertcat: (...ARRAY: ElementType[]) => MultiArray;
static readonly allSignature: BuiltInFunctionSignature;
static readonly all: ((M: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined, DIM?: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) => (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) | ((...args: ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>[]) => MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | {
type: "RETLIST";
selector: (evaluated: {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>, index: number) => ElementType;
handler?: (length: number) => {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>;
parent?: unknown;
} | undefined);
static readonly anySignature: BuiltInFunctionSignature;
static readonly any: ((M: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined, DIM?: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) => (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) | ((...args: ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>[]) => MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | {
type: "RETLIST";
selector: (evaluated: {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>, index: number) => ElementType;
handler?: (length: number) => {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>;
parent?: unknown;
} | undefined);
static readonly sumSignature: BuiltInFunctionSignature;
static readonly sum: ((M: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined, DIM?: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) => (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) | ((...args: ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>[]) => MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | {
type: "RETLIST";
selector: (evaluated: {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>, index: number) => ElementType;
handler?: (length: number) => {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>;
parent?: unknown;
} | undefined);
static readonly prodSignature: BuiltInFunctionSignature;
static readonly prod: ((M: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined, DIM?: (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) => (import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})) | MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | null | undefined) | ((...args: ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>[]) => MultiArray<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})> | {
type: "RETLIST";
selector: (evaluated: {
length: number;
} & Record<string, number | ElementType<import("./ComplexInterface").ComplexInterface<import("./Complex").RealType, number, unknown> | CharString | (object & {
type: number;
parent?: unknown;
copy?: () => unknown;
})>>, index: number) => ElementType;
handler?: (length: number) => {
length: number;
} & Record<string, number | ElementType<import("./ComplexInter