numbl 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cli/cli.js +2363 -220
- package/dist-graphics/graphics/FigureView.d.ts +6 -0
- package/dist-graphics/graphics/SurfView.d.ts +18 -0
- package/dist-graphics/graphics/axisLimits.d.ts +23 -0
- package/dist-graphics/graphics/drawPlot.d.ts +2 -0
- package/dist-graphics/graphics/exportFigureHdf5.d.ts +21 -0
- package/dist-graphics/graphics/figureHashTransport.d.ts +24 -0
- package/dist-graphics/graphics/figureHdf5Schema.d.ts +19 -0
- package/dist-graphics/graphics/figureUpload.d.ts +45 -0
- package/dist-graphics/graphics/figuresReducer.d.ts +86 -0
- package/dist-graphics/graphics/importFigureHdf5.d.ts +9 -0
- package/dist-graphics/graphics/openInFigureViewer.d.ts +26 -0
- package/dist-graphics/graphics/plotHelpers.d.ts +6 -0
- package/dist-graphics/graphics/plotLegend.d.ts +2 -0
- package/dist-graphics/graphics/plotMarkers.d.ts +2 -0
- package/dist-graphics/graphics/restoreNaNs.d.ts +2 -0
- package/dist-graphics/graphics/surfColormap.d.ts +2 -0
- package/dist-graphics/graphics/types.d.ts +423 -0
- package/dist-graphics/graphics/uihtmlSrcDoc.d.ts +23 -0
- package/dist-graphics/graphics-lib.d.ts +21 -0
- package/dist-graphics/index.js +35334 -0
- package/dist-lib/lib.js +2349 -216
- package/dist-lib/numbl-core/interpreter/builtins/gallery.d.ts +7 -0
- package/dist-lib/numbl-core/interpreter/builtins/geometry.d.ts +3 -3
- package/dist-lib/numbl-core/interpreter/builtins/graph.d.ts +29 -0
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +2 -0
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +14 -1
- package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/types.d.ts +13 -0
- package/dist-lib/numbl-core/lowering/classInfo.d.ts +19 -2
- package/dist-lib/numbl-core/native/geometry-bridge.d.ts +10 -0
- package/dist-lib/numbl-core/parser/ArgumentsParser.d.ts +6 -1
- package/dist-lib/numbl-core/runtime/constructors.d.ts +2 -1
- package/dist-lib/numbl-core/runtime/runtime.d.ts +2 -1
- package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +1 -1
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-plot-viewer/assets/hdf5_hl-C9YUKPMe.js +24296 -0
- package/dist-plot-viewer/assets/index-YeXWXIxH.js +4504 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/assets/hdf5_hl-C9YUKPMe.js +24296 -0
- package/dist-site-viewer/assets/index-RucHpf4b.js +4826 -0
- package/dist-site-viewer/assets/numbl-worker-IO39kohI.js +5228 -0
- package/dist-site-viewer/index.html +1 -1
- package/native/lapack_svd.cpp +50 -0
- package/package.json +21 -2
- package/dist-plot-viewer/assets/index-D4grNz8m.js +0 -4504
- package/dist-site-viewer/assets/index-B2mCFC55.js +0 -4826
- package/dist-site-viewer/assets/numbl-worker-DWZE29ck.js +0 -5116
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interpreter IBuiltins for computational geometry functions: delaunay,
|
|
3
|
-
* delaunayn, inpolygon.
|
|
3
|
+
* delaunayn, convhull, convhulln, inpolygon.
|
|
4
4
|
*
|
|
5
|
-
* delaunay/delaunayn are backed by the qhull WASM module,
|
|
6
|
-
*
|
|
5
|
+
* delaunay/delaunayn/convhull/convhulln are backed by the qhull WASM module,
|
|
6
|
+
* installed at startup (see geometry-bridge.ts and the qhull-node /
|
|
7
7
|
* qhull-browser loaders). The backend must be installed before these builtins
|
|
8
8
|
* run; otherwise they throw.
|
|
9
9
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undirected graph object (`graph`) and a subset of its methods.
|
|
3
|
+
*
|
|
4
|
+
* MATLAB's `graph` is a value class representing an undirected graph. Here a
|
|
5
|
+
* graph is a class_instance with className="graph" and three internal fields:
|
|
6
|
+
* _n number of nodes
|
|
7
|
+
* _A symmetric weighted adjacency as a RuntimeSparseMatrix
|
|
8
|
+
* _weighted whether the graph carries edge weights
|
|
9
|
+
*
|
|
10
|
+
* Supported constructors:
|
|
11
|
+
* graph() empty graph
|
|
12
|
+
* graph(A) adjacency matrix (A must be symmetric)
|
|
13
|
+
* graph(A, 'omitselfloops') drop the diagonal
|
|
14
|
+
* graph(A, 'upper' | 'lower') read one triangle of A
|
|
15
|
+
* graph(s, t) edge list (unweighted)
|
|
16
|
+
* graph(s, t, w) edge list (weighted)
|
|
17
|
+
* graph(s, t, w, num) edge list, num nodes
|
|
18
|
+
*
|
|
19
|
+
* Supported methods (called as functions, e.g. conncomp(G)):
|
|
20
|
+
* conncomp(G) / [bins, sizes] = conncomp(G) connected components
|
|
21
|
+
* laplacian(G) graph Laplacian (unweighted)
|
|
22
|
+
* addedge(G, s, t [, w]) add edges, returns a new graph
|
|
23
|
+
* numnodes(G), numedges(G) counts
|
|
24
|
+
* degree(G) per-node degree (column vector)
|
|
25
|
+
*
|
|
26
|
+
* Note: laplacian ignores edge weights (uses the binary adjacency and the
|
|
27
|
+
* node-degree count), matching MATLAB.
|
|
28
|
+
*/
|
|
29
|
+
export {};
|
|
@@ -34,6 +34,10 @@ export declare class Interpreter {
|
|
|
34
34
|
workspaceEnv: Environment | undefined;
|
|
35
35
|
/** @internal The caller's environment — for evalin/assignin('caller', ...) */
|
|
36
36
|
callerEnv: Environment | undefined;
|
|
37
|
+
/** @internal Call-site variable names for the next user-function call, set
|
|
38
|
+
* by `evalFuncCall` and consumed by `callUserFunction` to support
|
|
39
|
+
* `inputname`. One-shot: cleared as soon as it is consumed. */
|
|
40
|
+
pendingInputNames: string[] | undefined;
|
|
37
41
|
/** @internal Stack of [base, dimIndex, numIndices] for resolving `end` keyword in indexing. */
|
|
38
42
|
endContextStack: Array<{
|
|
39
43
|
base: unknown;
|
|
@@ -157,6 +161,7 @@ export declare class Interpreter {
|
|
|
157
161
|
switchMatch: (switchVal: unknown, caseVal: unknown) => boolean;
|
|
158
162
|
isOutputExpr: (expr: Expr) => boolean;
|
|
159
163
|
callFunction: (name: string, args: unknown[], nargout: number) => unknown;
|
|
164
|
+
declaredNargin: (name: string) => number | undefined;
|
|
160
165
|
interpretTarget: (target: ResolvedTarget, args: unknown[], nargout: number) => unknown;
|
|
161
166
|
interpretLocalFunction: (target: Extract<ResolvedTarget, {
|
|
162
167
|
kind: "localFunction";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Stmt, Expr, LValue } from "../parser/types.js";
|
|
6
6
|
import type { RuntimeValue } from "../runtime/types.js";
|
|
7
|
-
import { type ControlSignal } from "./types.js";
|
|
7
|
+
import { Environment, type ControlSignal } from "./types.js";
|
|
8
8
|
import type { Interpreter } from "./interpreter.js";
|
|
9
9
|
export declare function execStmt(this: Interpreter, stmt: Stmt): ControlSignal | null;
|
|
10
10
|
export declare function execStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
|
|
@@ -16,6 +16,19 @@ export declare function execStmts(this: Interpreter, stmts: Stmt[]): ControlSign
|
|
|
16
16
|
export declare function execBlockStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
|
|
17
17
|
export declare function evalExpr(this: Interpreter, expr: Expr): unknown;
|
|
18
18
|
export declare function evalExprNargout(this: Interpreter, expr: Expr, nargout: number): unknown;
|
|
19
|
+
/** Compute the call-site variable names for `inputname`, aligned to the
|
|
20
|
+
* argument expressions. Entry i is the name of the variable passed as
|
|
21
|
+
* argument i+1, or '' if that argument is not a plain workspace variable.
|
|
22
|
+
*
|
|
23
|
+
* Per MATLAB: an argument that uses cell `{}` or dot `.` indexing produces
|
|
24
|
+
* a comma-separated list, making the position of every following argument
|
|
25
|
+
* dynamic — so that argument and all subsequent ones report ''. Plain
|
|
26
|
+
* literals, expressions, and paren-indexing report '' only for themselves.
|
|
27
|
+
*
|
|
28
|
+
* The returned array may be shorter than the flattened arg count (when an
|
|
29
|
+
* argument expanded to a CSL); callers treat out-of-range indices as ''.
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeInputNames(argExprs: Expr[], callerEnv: Environment): string[];
|
|
19
32
|
export declare function evalArgs(this: Interpreter, argExprs: Expr[]): unknown[];
|
|
20
33
|
export declare function evalBinary(this: Interpreter, expr: Extract<Expr, {
|
|
21
34
|
type: "Binary";
|
|
@@ -8,6 +8,12 @@ import type { ClassInfo } from "../lowering/classInfo.js";
|
|
|
8
8
|
import { Environment, type FunctionDef } from "./types.js";
|
|
9
9
|
import type { Interpreter } from "./interpreter.js";
|
|
10
10
|
export declare function callFunction(this: Interpreter, name: string, args: unknown[], nargout: number): unknown;
|
|
11
|
+
/** Declared input count of the user function a `@name` handle points to,
|
|
12
|
+
* resolved the same way a call to `name` would resolve. Returns undefined
|
|
13
|
+
* when the target is a builtin or otherwise has no resolvable user-function
|
|
14
|
+
* AST (caller falls back to probing / 0). Used to populate
|
|
15
|
+
* `nargin(@name)`. */
|
|
16
|
+
export declare function declaredNargin(this: Interpreter, name: string): number | undefined;
|
|
11
17
|
export declare function interpretTarget(this: Interpreter, target: ResolvedTarget, args: unknown[], nargout: number): unknown;
|
|
12
18
|
export declare function interpretJsUserFunction(this: Interpreter, target: Extract<ResolvedTarget, {
|
|
13
19
|
kind: "jsUserFunction";
|
|
@@ -25,6 +25,10 @@ export interface InterpreterContext {
|
|
|
25
25
|
kind: "function" | "jsfunction" | "class";
|
|
26
26
|
source: string;
|
|
27
27
|
} | undefined;
|
|
28
|
+
/** Public (GetAccess public) property names of a class, including inherited
|
|
29
|
+
* ones, in declaration order. Returns undefined if `className` is not a
|
|
30
|
+
* known class. Backs `properties(obj)`. */
|
|
31
|
+
classPublicProperties: (className: string) => string[] | undefined;
|
|
28
32
|
}
|
|
29
33
|
export declare const FALL_THROUGH: unique symbol;
|
|
30
34
|
export type InterpreterSpecialBuiltinHandler = (ctx: InterpreterContext, args: unknown[], nargout: number) => unknown | typeof FALL_THROUGH;
|
|
@@ -41,12 +41,25 @@ export declare class Environment {
|
|
|
41
41
|
set persistentNames(v: Set<string>);
|
|
42
42
|
/** Function ID for persistent variable storage */
|
|
43
43
|
persistentFuncId: string | undefined;
|
|
44
|
+
/** Call-site variable names of this frame's arguments, for `inputname`.
|
|
45
|
+
* Entry i is the name of the variable passed as argument i+1, or '' if
|
|
46
|
+
* that argument was not a plain variable. Undefined when the call did
|
|
47
|
+
* not originate from an interpreted call expression (e.g. feval, JIT).
|
|
48
|
+
* Read directly off the executing frame — the interpreter has only
|
|
49
|
+
* function-level scoping, so `this.env` is the frame while a body runs. */
|
|
50
|
+
inputArgNames: string[] | undefined;
|
|
44
51
|
/** Back-reference to the runtime (needed for global/persistent access) */
|
|
45
52
|
rt: Runtime | null;
|
|
46
53
|
/** Set when a `@nestedFn` handle has been created that captures this env
|
|
47
54
|
* (or an ancestor). Tells the function-exit cleanup that clearing this
|
|
48
55
|
* env would strand the handle's closure, so locals must be left alive. */
|
|
49
56
|
nestedHandleCreated: boolean;
|
|
57
|
+
/** For a nested-function frame: the names of this function's own formal
|
|
58
|
+
* input/output arguments. These are always local — a write must never be
|
|
59
|
+
* redirected to a same-named variable in the parent, even before the
|
|
60
|
+
* output has been assigned. (MATLAB scopes a nested function's formal
|
|
61
|
+
* arguments to that function; only other variables are shared.) */
|
|
62
|
+
nestedLocalNames: Set<string> | undefined;
|
|
50
63
|
constructor(parent?: Environment | undefined);
|
|
51
64
|
get(name: string): RuntimeValue | undefined;
|
|
52
65
|
/** Set variable — for nested scopes, writes to parent if variable
|
|
@@ -18,9 +18,10 @@ export interface ClassInfo {
|
|
|
18
18
|
methodNames: Set<string>;
|
|
19
19
|
staticMethodNames: Set<string>;
|
|
20
20
|
constructorName: string | null;
|
|
21
|
-
ast: Stmt & {
|
|
21
|
+
ast: (Stmt & {
|
|
22
22
|
type: "ClassDef";
|
|
23
|
-
};
|
|
23
|
+
}) | null;
|
|
24
|
+
isOldStyle?: boolean;
|
|
24
25
|
inferiorClasses: string[];
|
|
25
26
|
externalMethodFiles: Map<string, {
|
|
26
27
|
fileName: string;
|
|
@@ -34,3 +35,19 @@ export interface ClassInfo {
|
|
|
34
35
|
export declare function extractClassInfo(classDef: Stmt & {
|
|
35
36
|
type: "ClassDef";
|
|
36
37
|
}, qualifiedName: string, fileName: string, source: string): ClassInfo;
|
|
38
|
+
/**
|
|
39
|
+
* Build ClassInfo for an old-style (pre-classdef) `@ClassName` folder class.
|
|
40
|
+
* There is no classdef AST: the constructor is the `@Name/Name.m` plain
|
|
41
|
+
* function (which calls `obj = class(struct, 'Name')`), and every other `.m`
|
|
42
|
+
* in the folder is an external method dispatched on instances. Fields are
|
|
43
|
+
* dynamic (defined by the constructor's struct), so there are no declared
|
|
44
|
+
* property names.
|
|
45
|
+
*/
|
|
46
|
+
export declare function makeOldStyleClassInfo(qualifiedName: string, baseName: string, constructorFile: {
|
|
47
|
+
fileName: string;
|
|
48
|
+
source: string;
|
|
49
|
+
}, methodFiles: {
|
|
50
|
+
name: string;
|
|
51
|
+
fileName: string;
|
|
52
|
+
source: string;
|
|
53
|
+
}[]): ClassInfo;
|
|
@@ -23,7 +23,17 @@
|
|
|
23
23
|
* point indices.
|
|
24
24
|
*/
|
|
25
25
|
export type DelaunayBackend = (points: number[][], dim: number) => number[][];
|
|
26
|
+
/**
|
|
27
|
+
* Compute the convex hull of `points` (an array of dim-dimensional tuples).
|
|
28
|
+
* Returns an array of simplicial facets, each a list of `dim` 0-based input
|
|
29
|
+
* point indices (edges in 2-D, triangles in 3-D).
|
|
30
|
+
*/
|
|
31
|
+
export type ConvexHullBackend = (points: number[][], dim: number) => number[][];
|
|
26
32
|
/** Install (or clear, with null) the Delaunay backend. */
|
|
27
33
|
export declare function setDelaunayBackend(fn: DelaunayBackend | null): void;
|
|
28
34
|
/** Get the current Delaunay backend, or null if none is installed. */
|
|
29
35
|
export declare function getDelaunayBackend(): DelaunayBackend | null;
|
|
36
|
+
/** Install (or clear, with null) the convex-hull backend. */
|
|
37
|
+
export declare function setConvexHullBackend(fn: ConvexHullBackend | null): void;
|
|
38
|
+
/** Get the current convex-hull backend, or null if none is installed. */
|
|
39
|
+
export declare function getConvexHullBackend(): ConvexHullBackend | null;
|
|
@@ -14,7 +14,12 @@ export declare class ArgumentsParser extends ControlFlowParser {
|
|
|
14
14
|
*/
|
|
15
15
|
private parseArgDimensions;
|
|
16
16
|
/**
|
|
17
|
-
* Parse validator list: {mustBeNumeric, mustBePositive}
|
|
17
|
+
* Parse validator list: {mustBeNumeric, mustBePositive}. Validators may be
|
|
18
|
+
* full function calls with arguments, e.g.
|
|
19
|
+
* `{mustBeMember(x,["a","b"]), mustBeInRange(x,0,7)}`. The validator bodies
|
|
20
|
+
* are not enforced at runtime, so we capture the top-level validator name
|
|
21
|
+
* tokens and skip past any nested `(...)`, `[...]`, `{...}` so parsing
|
|
22
|
+
* resumes correctly at the default value (`= expr`) or end of line.
|
|
18
23
|
*/
|
|
19
24
|
private parseArgValidators;
|
|
20
25
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* RuntimeValue constructor helpers (the RTV namespace).
|
|
3
3
|
*/
|
|
4
4
|
import { ItemType } from "../lowering/itemTypes.js";
|
|
5
|
-
import { type RuntimeNumber, RuntimeTensor, type RuntimeString, RuntimeChar, type RuntimeLogical, RuntimeCell, RuntimeStruct, RuntimeFunction, RuntimeClassInstance, RuntimeComplexNumber, RuntimeDummyHandle, RuntimeGraphicsHandle, RuntimeStructArray, RuntimeSparseMatrix, RuntimeDictionary, type RuntimeValue } from "./types.js";
|
|
5
|
+
import { type RuntimeNumber, RuntimeTensor, type RuntimeString, RuntimeChar, type RuntimeLogical, RuntimeCell, RuntimeStruct, RuntimeFunction, RuntimeClassInstance, RuntimeClassInstanceArray, RuntimeComplexNumber, RuntimeDummyHandle, RuntimeGraphicsHandle, RuntimeStructArray, RuntimeSparseMatrix, RuntimeDictionary, type RuntimeValue } from "./types.js";
|
|
6
6
|
export declare const RTV: {
|
|
7
7
|
num(value: number): RuntimeNumber;
|
|
8
8
|
tensor(data: Float64Array | number[], shape: number[], imag?: Float64Array | number[]): RuntimeTensor;
|
|
@@ -23,6 +23,7 @@ export declare const RTV: {
|
|
|
23
23
|
struct(fields: Map<string, RuntimeValue> | Record<string, RuntimeValue>): RuntimeStruct;
|
|
24
24
|
func(name: string, impl: "builtin" | "user", captures?: RuntimeValue[]): RuntimeFunction;
|
|
25
25
|
classInstance(className: string, propertyNames: string[], isHandleClass?: boolean, defaults?: Map<string, RuntimeValue>): RuntimeClassInstance;
|
|
26
|
+
classInstanceArray(className: string, elements: RuntimeClassInstance[], shape?: [number, number]): RuntimeClassInstanceArray;
|
|
26
27
|
complex(re: number, im: number): RuntimeComplexNumber;
|
|
27
28
|
dummyHandle(): RuntimeDummyHandle;
|
|
28
29
|
graphicsHandle(trace: Record<string, unknown>, traceType: string): RuntimeGraphicsHandle;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type RuntimeValue, type RuntimeLogical, type RuntimeTensor, type RuntimeStruct, type RuntimeString, type RuntimeFunction, RuntimeError, type CallFrame } from "../runtime/index.js";
|
|
14
14
|
import { RefScope } from "./refcount.js";
|
|
15
|
-
import { RuntimeChar, RuntimeCell, type RuntimeComplexNumber, type RuntimeClassInstance } from "../runtime/types.js";
|
|
15
|
+
import { RuntimeChar, RuntimeCell, RuntimeClassInstanceArray, type RuntimeComplexNumber, type RuntimeClassInstance } from "../runtime/types.js";
|
|
16
16
|
import { type ItemType } from "../lowering/itemTypes.js";
|
|
17
17
|
import type { PlotInstruction } from "../../graphics/types.js";
|
|
18
18
|
import type { ExecOptions } from "../executeCode.js";
|
|
@@ -84,6 +84,7 @@ export declare class Runtime {
|
|
|
84
84
|
struct(fields: Map<string, RuntimeValue> | Record<string, RuntimeValue>): RuntimeStruct;
|
|
85
85
|
func(name: string, impl: "builtin" | "user", captures?: RuntimeValue[]): RuntimeFunction;
|
|
86
86
|
classInstance(className: string, propertyNames: string[], isHandleClass?: boolean, defaults?: Map<string, RuntimeValue>): RuntimeClassInstance;
|
|
87
|
+
classInstanceArray(className: string, elements: RuntimeClassInstance[], shape?: [number, number]): RuntimeClassInstanceArray;
|
|
87
88
|
complex(re: number, im: number): RuntimeComplexNumber;
|
|
88
89
|
dummyHandle(): import("../runtime/types.js").RuntimeDummyHandle;
|
|
89
90
|
graphicsHandle(trace: Record<string, unknown>, traceType: string): import("../runtime/types.js").RuntimeGraphicsHandle;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { type RuntimeValue } from "../runtime/index.js";
|
|
5
5
|
import type { Runtime } from "./runtime.js";
|
|
6
6
|
export declare function getMember(rt: Runtime, base: unknown, name: string): unknown;
|
|
7
|
-
export declare function getMemberDynamic(base: unknown, nameExpr: unknown): RuntimeValue;
|
|
7
|
+
export declare function getMemberDynamic(rt: Runtime, base: unknown, nameExpr: unknown): RuntimeValue;
|
|
8
8
|
export declare function getMemberOrEmpty(base: unknown, name: string): RuntimeValue;
|
|
9
9
|
export declare function setMemberReturn(rt: Runtime, base: unknown, name: string, rhs: unknown): unknown;
|
|
10
10
|
export declare function setMemberDynamicReturn(rt: Runtime, base: unknown, nameExpr: unknown, rhs: unknown): RuntimeValue;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Numbl version, used for JIT disk cache invalidation. */
|
|
2
|
-
export declare const NUMBL_VERSION = "0.4.
|
|
2
|
+
export declare const NUMBL_VERSION = "0.4.7";
|