NDWasmOptimize
- Description:
Namespace for Optimization functions using Go WASM.
- Source:
Methods
(static) linearRegression(x, y) → {Object}
- Description:
Fits a simple linear regression model: Y = alpha + beta*X.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
x |
NDArray | The independent variable (1D NDArray of float64). |
y |
NDArray | The dependent variable (1D NDArray of float64). |
Throws:
-
If WASM runtime is not loaded or inputs are invalid.
- Type
- Error
Returns:
- An object containing the intercept (alpha) and slope (beta) of the fitted line.
- Type
- Object
(static) linprog(c, G, h, A, b, bounds) → {Object}
- Description:
Provides Optimization capabilities by wrapping Go WASM functions. minimize cᵀ * x s.t G * x <= h A * x = b lower <= x <= upper
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
c |
NDArray | Coefficient vector for the objective function (1D NDArray of float64). |
G |
NDArray | null | Coefficient matrix for inequality constraints (2D NDArray of float64). |
h |
NDArray | null | Right-hand side vector for inequality constraints (1D NDArray of float64). |
A |
NDArray | null | Coefficient matrix for equality constraints (2D NDArray of float64). |
b |
NDArray | null | Right-hand side vector for equality constraints (1D NDArray of float64). |
bounds |
Array | Optional variable bounds as an array of [lower, upper] pairs. Use null for unbounded. [0, null] for all for default. |
Throws:
-
If WASM runtime is not loaded or inputs are invalid.
- Type
- Error
Returns:
- The optimization result.
- Type
- Object
(static) minimize(func, x0, optionsopt) → {Object}
- Description:
Finds the minimum of a scalar function of one or more variables using an L-BFGS optimizer.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
func |
function | The objective function to be minimized. It must take a 1D |
|||||||||
x0 |
NDArray | The initial guess for the optimization (1D NDArray of float64). |
|||||||||
options |
Object |
<optional> |
Optional parameters. Properties
|
Returns:
The optimization result.
- Type
- Object
(static) ode15s(odefun, tspan, y0, options)
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
odefun |
function | (t, y, f_out, m_out) |
|||||||||||||||||||||
tspan |
Array | NDArray | [t0, tfinal] |
|||||||||||||||||||||
y0 |
Array | NDArray | Initial state |
|||||||||||||||||||||
options |
Object | {absTol, relTol, initialStep, hasM, jac} Properties
|
(static) ode45(odefun, tspan, y0, options)
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
odefun |
function | (t, y, f_out, m_out) |
|||||||||||||||||||||
tspan |
Array | NDArray | [t0, tfinal] |
|||||||||||||||||||||
y0 |
Array | NDArray | Initial state |
|||||||||||||||||||||
options |
Object | {absTol, relTol, initialStep, hasM, jac} Properties
|
(static) odeSolve(odefun, tspan, y0, options)
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
odefun |
function | (t, y, f_out, m_out) |
|||||||||||||||||||||
tspan |
Array | NDArray | [t0, tfinal] |
|||||||||||||||||||||
y0 |
Array | NDArray | Initial state |
|||||||||||||||||||||
options |
Object | {absTol, relTol, initialStep, method: 'ode45'|'ode15s', hasM, jac} Properties
|
(static) pdepe(m, pdefun, icfun, bcfun, xmesh, tspan, options) → {NDArray|null}
- Description:
Solve 1D Parabolic and Elliptic PDEs using the method of lines with an underlying ODE15s integrator.
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
m |
number | Symmetry parameter: 0 (slab), 1 (cylinder), 2 (sphere) |
|||||||||||||||||||||
pdefun |
function | (x, t, u, dudx, c_out, f_out, s_out) |
|||||||||||||||||||||
icfun |
function | (x) => returns initial conditions as Array or NDArray |
|||||||||||||||||||||
bcfun |
function | (xl, ul, xr, ur, t, pl_out, ql_out, pr_out, qr_out) |
|||||||||||||||||||||
xmesh |
Array | NDArray | Spatial grid points [x0, ..., xN] |
|||||||||||||||||||||
tspan |
Array | NDArray | Time output points [t0, ..., tM] |
|||||||||||||||||||||
options |
Object | {absTol: 1e-5, relTol: 1e-4} Properties
|
Returns:
3D Tensor of shape [length(tspan), length(xmesh), dim]
- Type
- NDArray | null
(static) polyfit(x, y, degree) → {Float64Array}
- Description:
Fits a polynomial of the specified degree to a set of 2D points using least squares. Model: Y = c0 + c1X + c2X^2 + ... + cd*X^d
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
x |
NDArray | The independent variable (1D NDArray of float64). |
y |
NDArray | The dependent variable (1D NDArray of float64). |
degree |
number | The degree of the polynomial to fit (non-negative integer). |
Throws:
-
If WASM runtime is not loaded, inputs are invalid, or degree is negative.
- Type
- Error
Returns:
- An array of coefficients in ascending order of degree [c0, c1, ..., cd].
- Type
- Float64Array