@jax-js/jax 0.1.4 → 0.1.5
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/README.md +10 -7
- package/dist/{backend-tngXtWe4.js → backend-DaqL-MNz.js} +96 -7
- package/dist/{backend-Bu9GY6sK.cjs → backend-DziQSaoQ.cjs} +101 -6
- package/dist/index.cjs +737 -141
- package/dist/index.d.cts +238 -9
- package/dist/index.d.ts +238 -9
- package/dist/index.js +737 -141
- package/dist/webgl-ClIYb8jP.cjs +522 -0
- package/dist/webgl-RSuZKvgc.js +522 -0
- package/dist/{webgpu-Oj3Kd-kd.cjs → webgpu-Db2JrNBr.cjs} +296 -3
- package/dist/{webgpu-ChVgx3b6.js → webgpu-Dh7k9io0.js} +296 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -437,10 +437,37 @@ declare enum Routines {
|
|
|
437
437
|
Sort = "Sort",
|
|
438
438
|
/** Returns `int32` indices of the stably sorted array. */
|
|
439
439
|
Argsort = "Argsort",
|
|
440
|
-
/**
|
|
440
|
+
/**
|
|
441
|
+
* Solve a triangular system of equations.
|
|
442
|
+
*
|
|
443
|
+
* The first batch of inputs `A` should be of shape `[..., N, N]` and upper
|
|
444
|
+
* triangular, while the second batch `B` should be of shape `[..., M, N]`.
|
|
445
|
+
*
|
|
446
|
+
* Solves for `X` in the equation `A @ X.T = B.T`, where `A` is the
|
|
447
|
+
* triangular matrix. This is equivalent to `X = B @ A^-T`.
|
|
448
|
+
*/
|
|
441
449
|
TriangularSolve = "TriangularSolve",
|
|
442
|
-
/**
|
|
450
|
+
/**
|
|
451
|
+
* Cholesky decomposition of 2D positive semi-definite matrices.
|
|
452
|
+
*
|
|
453
|
+
* The input batch should be of shape `[..., N, N]`, and the output batch is
|
|
454
|
+
* of the same shape, containing the lower-triangular matrix `L` such that
|
|
455
|
+
* `A = L @ L.T`. Behavior is unspecified if A is not positive semi-definite.
|
|
456
|
+
*/
|
|
443
457
|
Cholesky = "Cholesky",
|
|
458
|
+
/**
|
|
459
|
+
* LU decomposition of 2D rectangular matrices.
|
|
460
|
+
*
|
|
461
|
+
* The input is a batch of shape `[..., M, N]`, and the output is a tuple of
|
|
462
|
+
* three arrays: `LU, Pivots, Permutation`.
|
|
463
|
+
*
|
|
464
|
+
* - `LU` is of shape `[..., M, N]`, containing the combined lower and upper
|
|
465
|
+
* triangular matrices. (lower triangular = implicit unit diagonal)
|
|
466
|
+
* - `Pivots` is of shape `[..., min(M, N)]`, containing the row swaps.
|
|
467
|
+
* - `Permutation` is of shape `[..., M]`, containing the permutation vector
|
|
468
|
+
* such that `P = eye(M).slice(Permutation)` -> `P @ A = L @ U`.
|
|
469
|
+
*/
|
|
470
|
+
LU = "LU",
|
|
444
471
|
}
|
|
445
472
|
interface RoutineType {
|
|
446
473
|
inputShapes: number[][];
|
|
@@ -450,7 +477,7 @@ interface RoutineType {
|
|
|
450
477
|
}
|
|
451
478
|
//#endregion
|
|
452
479
|
//#region src/backend.d.ts
|
|
453
|
-
type Device = "cpu" | "wasm" | "webgpu";
|
|
480
|
+
type Device = "cpu" | "wasm" | "webgpu" | "webgl";
|
|
454
481
|
declare const devices: Device[];
|
|
455
482
|
/** Configure the default device for arrays. */
|
|
456
483
|
declare function defaultDevice(device?: Device): Device;
|
|
@@ -535,7 +562,7 @@ declare function fft(a: ComplexPair, axis?: number): ComplexPair;
|
|
|
535
562
|
*/
|
|
536
563
|
declare function ifft(a: ComplexPair, axis?: number): ComplexPair;
|
|
537
564
|
declare namespace numpy_linalg_d_exports {
|
|
538
|
-
export { cholesky$1 as cholesky, diagonal, lstsq, matmul, matrixTranspose, outer, tensordot, trace, vecdot };
|
|
565
|
+
export { cholesky$1 as cholesky, det, diagonal, inv, lstsq, matmul, matrixPower, matrixTranspose, outer, slogdet, solve, tensordot, trace, vecdot };
|
|
539
566
|
}
|
|
540
567
|
/**
|
|
541
568
|
* Compute the Cholesky decomposition of a (batched) positive-definite matrix.
|
|
@@ -550,6 +577,10 @@ declare function cholesky$1(a: ArrayLike, {
|
|
|
550
577
|
upper?: boolean;
|
|
551
578
|
symmetrizeInput?: boolean;
|
|
552
579
|
}): Array;
|
|
580
|
+
/** Compute the determinant of a square matrix (batched). */
|
|
581
|
+
declare function det(a: ArrayLike): Array;
|
|
582
|
+
/** Compute the inverse of a square matrix (batched). */
|
|
583
|
+
declare function inv(a: ArrayLike): Array;
|
|
553
584
|
/**
|
|
554
585
|
* Return the least-squares solution to a linear equation.
|
|
555
586
|
*
|
|
@@ -564,8 +595,75 @@ declare function cholesky$1(a: ArrayLike, {
|
|
|
564
595
|
* @return least-squares solution of shape `(N,)` or `(N, K)`
|
|
565
596
|
*/
|
|
566
597
|
declare function lstsq(a: ArrayLike, b: ArrayLike): Array;
|
|
598
|
+
/** Raise a square matrix to an integer power, via repeated squarings. */
|
|
599
|
+
declare function matrixPower(a: ArrayLike, n: number): Array;
|
|
600
|
+
/** Return sign and natural logarithm of the determinant of `a`. */
|
|
601
|
+
declare function slogdet(a: ArrayLike): [Array, Array];
|
|
602
|
+
/**
|
|
603
|
+
* Solve a linear system of equations.
|
|
604
|
+
*
|
|
605
|
+
* This solves a (batched) linear system of equations `a @ x = b` for `x` given
|
|
606
|
+
* `a` and `b`. If `a` is singular, this will return `nan` or `inf` values.
|
|
607
|
+
*
|
|
608
|
+
* @param a - Coefficient matrix of shape `(..., N, N)`.
|
|
609
|
+
* @param b - Values of shape `(N,)` or `(..., N, M)`.
|
|
610
|
+
* @returns Solution `x` of shape `(..., N)` or `(..., N, M)`.
|
|
611
|
+
*/
|
|
612
|
+
declare function solve(a: ArrayLike, b: ArrayLike): Array;
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/library/numpy/dtype-info.d.ts
|
|
615
|
+
/** @inline */
|
|
616
|
+
type FInfo = Readonly<{
|
|
617
|
+
/** The number of bits occupied by the type. */
|
|
618
|
+
bits: number;
|
|
619
|
+
/** Returns the _dtype_ for which finfo returns information. */
|
|
620
|
+
dtype: DType;
|
|
621
|
+
/** The difference between 1.0 and the next smallest representable float larger than 1.0. */
|
|
622
|
+
eps: number;
|
|
623
|
+
/** The difference between 1.0 and the next largest representable float smaller than 1.0. */
|
|
624
|
+
epsneg: number;
|
|
625
|
+
/** The exponent that yields `eps`. */
|
|
626
|
+
machep: number;
|
|
627
|
+
/** The largest representable finite number. */
|
|
628
|
+
max: number;
|
|
629
|
+
/** The smallest positive power of the base (2) that causes overflow. */
|
|
630
|
+
maxexp: number;
|
|
631
|
+
/** The smallest representable (most negative) finite number. */
|
|
632
|
+
min: number;
|
|
633
|
+
/** The largest negative power of the base (2) without leading zeros in mantissa. */
|
|
634
|
+
minexp: number;
|
|
635
|
+
/** The exponent that yields `epsneg`. */
|
|
636
|
+
negep: number;
|
|
637
|
+
/** Number of bits in the exponent portion. */
|
|
638
|
+
nexp: number;
|
|
639
|
+
/** Number of bits in the mantissa portion. */
|
|
640
|
+
nmant: number;
|
|
641
|
+
/** The approximate number of decimal digits to which this kind of float is precise. */
|
|
642
|
+
precision: number;
|
|
643
|
+
/** The approximate decimal resolution, i.e., `10 ** -precision`. */
|
|
644
|
+
resolution: number;
|
|
645
|
+
/** The smallest positive normal number. */
|
|
646
|
+
smallestNormal: number;
|
|
647
|
+
/** The smallest positive subnormal number. */
|
|
648
|
+
smallestSubnormal: number;
|
|
649
|
+
}>;
|
|
650
|
+
/** Machine limits for floating-point types. */
|
|
651
|
+
declare function finfo(dtype: DType): FInfo;
|
|
652
|
+
/** @inline */
|
|
653
|
+
type IInfo = Readonly<{
|
|
654
|
+
/** The number of bits occupied by the type. */
|
|
655
|
+
bits: number;
|
|
656
|
+
/** Returns the _dtype_ for which iinfo returns information. */
|
|
657
|
+
dtype: DType;
|
|
658
|
+
/** The largest representable integer. */
|
|
659
|
+
max: number;
|
|
660
|
+
/** The smallest representable integer. */
|
|
661
|
+
min: number;
|
|
662
|
+
}>;
|
|
663
|
+
/** Machine limits for integer types. */
|
|
664
|
+
declare function iinfo(dtype: DType): IInfo;
|
|
567
665
|
declare namespace numpy_d_exports {
|
|
568
|
-
export { Array, ArrayLike, DType, absolute as abs, absolute, acos, arccosh as acosh, add, all, allclose, any, arange, acos as arccos, arccosh, asin as arcsin, arcsinh, atan as arctan, atan2 as arctan2, arctanh, argmax, argmin, argsort, array, asin, arcsinh as asinh, astype, atan, atan2, arctanh as atanh, bool, broadcastArrays, broadcastShapes, broadcastTo, cbrt, ceil, clip, columnStack, concatenate, convolve, corrcoef, correlate, cos, cosh, cov, cumsum, cumsum as cumulativeSum, deg2rad, degrees, diag, diagonal, trueDivide as divide, dot$1 as dot, dstack, e, einsum, equal, eulerGamma, exp, exp2, expandDims, expm1, eye, numpy_fft_d_exports as fft, flip, fliplr, flipud, float16, float32, float64, floor, fmod, frexp, full, fullLike, greater, greaterEqual, hamming, hann, heaviside, hstack, hypot, identity$1 as identity, inf, inner, int32, isfinite, isinf, isnan, isneginf, isposinf, ldexp, less, lessEqual, numpy_linalg_d_exports as linalg, linspace, log, log10, log1p, log2, matmul, matrixTranspose, max, maximum, mean, meshgrid, min, minimum, moveaxis, multiply, nan, ndim, negative, notEqual, ones, onesLike, outer, pad, transpose as permuteDims, pi, positive, power as pow, power, prod, promoteTypes, ptp, rad2deg, radians, ravel, reciprocal, remainder, repeat, reshape, shape$1 as shape, sign, sin, sinh, size, sort, sqrt, square, squeeze, stack, std, subtract, sum, tan, tanh, tensordot, tile, trace, transpose, tri, tril, triu, trueDivide, trunc, uint32, var_, vdot, vecdot, vstack, where, zeros, zerosLike };
|
|
666
|
+
export { Array, ArrayLike, DType, absolute as abs, absolute, acos, arccosh as acosh, add, all, allclose, any, arange, acos as arccos, arccosh, asin as arcsin, arcsinh, atan as arctan, atan2 as arctan2, arctanh, argmax, argmin, argsort, array, asin, arcsinh as asinh, astype, atan, atan2, arctanh as atanh, bool, broadcastArrays, broadcastShapes, broadcastTo, cbrt, ceil, clip, columnStack, concatenate, convolve, corrcoef, correlate, cos, cosh, cov, cumsum, cumsum as cumulativeSum, deg2rad, degrees, diag, diagonal, trueDivide as divide, divmod, dot$1 as dot, dstack, e, einsum, equal, eulerGamma, exp, exp2, expandDims, expm1, eye, numpy_fft_d_exports as fft, finfo, flip, fliplr, flipud, float16, float32, float64, floor, floorDivide, fmod, frexp, full, fullLike, greater, greaterEqual, hamming, hann, heaviside, hstack, hypot, identity$1 as identity, iinfo, inf, inner, int32, isfinite, isinf, isnan, isneginf, isposinf, ldexp, less, lessEqual, numpy_linalg_d_exports as linalg, linspace, log, log10, log1p, log2, logspace, matmul, matrixTranspose, max, maximum, mean, meshgrid, min, minimum, moveaxis, multiply, nan, ndim, negative, notEqual, ones, onesLike, outer, pad, transpose as permuteDims, pi, positive, power as pow, power, prod, promoteTypes, ptp, rad2deg, radians, ravel, reciprocal, remainder, repeat, reshape, shape$1 as shape, sign, sin, sinc, sinh, size, sort, split$1 as split, sqrt, square, squeeze, stack, std, subtract, sum, take, tan, tanh, tensordot, tile, trace, transpose, tri, tril, triu, trueDivide, trunc, uint32, var_, vdot, vecdot, vstack, where, zeros, zerosLike };
|
|
569
667
|
}
|
|
570
668
|
declare const float32 = DType.Float32;
|
|
571
669
|
declare const int32 = DType.Int32;
|
|
@@ -732,6 +830,16 @@ declare function argmax(a: ArrayLike, axis?: number, opts?: ReduceOpts): Array;
|
|
|
732
830
|
declare function cumsum(a: ArrayLike, axis?: number): Array;
|
|
733
831
|
/** Reverse the elements in an array along the given axes. */
|
|
734
832
|
declare function flip(x: ArrayLike, axis?: Axis): Array;
|
|
833
|
+
/**
|
|
834
|
+
* Split an array into multiple sub-arrays along an axis.
|
|
835
|
+
*
|
|
836
|
+
* @param a - The input array to split.
|
|
837
|
+
* @param indicesOrSections - If an integer, it indicates the number of equal
|
|
838
|
+
* sections to create along the specified axis. If a list of integers, it
|
|
839
|
+
* specifies the indices at which to split the array.
|
|
840
|
+
* @param axis - The axis along which to split the array. Default is 0.
|
|
841
|
+
*/
|
|
842
|
+
declare function split$1(a: ArrayLike, indicesOrSections: number | number[], axis?: number): Array[];
|
|
735
843
|
/**
|
|
736
844
|
* Join a sequence of arrays along an existing axis.
|
|
737
845
|
*
|
|
@@ -860,6 +968,13 @@ declare function sort(a: ArrayLike, axis?: number): Array;
|
|
|
860
968
|
* The array is sorted along a specified axis (the last by default).
|
|
861
969
|
*/
|
|
862
970
|
declare function argsort(a: ArrayLike, axis?: number): Array;
|
|
971
|
+
/**
|
|
972
|
+
* Take elements from an array along an axis.
|
|
973
|
+
*
|
|
974
|
+
* This is equivalent to advanced indexing with integer indices over that
|
|
975
|
+
* numbered axis. By default, the flattened array is used.
|
|
976
|
+
*/
|
|
977
|
+
declare function take(a: ArrayLike, indices: ArrayLike, axis?: number | null): Array;
|
|
863
978
|
/** Return if two arrays are element-wise equal within a tolerance. */
|
|
864
979
|
declare function allclose(actual: Parameters<typeof array>[0], expected: Parameters<typeof array>[0], options?: {
|
|
865
980
|
rtol?: number;
|
|
@@ -990,6 +1105,17 @@ declare const heaviside: OwnedFunction<(x1: ArrayLike, x2: ArrayLike) => Array>;
|
|
|
990
1105
|
declare function square(x: ArrayLike): Array;
|
|
991
1106
|
/** Element-wise tangent function (takes radians). */
|
|
992
1107
|
declare function tan(x: ArrayLike): Array;
|
|
1108
|
+
/**
|
|
1109
|
+
* @function
|
|
1110
|
+
* Return the normalized sinc function.
|
|
1111
|
+
*
|
|
1112
|
+
* The sinc function is defined as `sin(πx) / (πx)` for `x != 0`, and `1` for `x = 0`.
|
|
1113
|
+
* This is the normalized sinc function commonly used in signal processing.
|
|
1114
|
+
*
|
|
1115
|
+
* **Note:** JVP is not supported at x=0 due to discontinuous derivative. This
|
|
1116
|
+
* requires a custom JVP rule to handle properly (see JAX implementation).
|
|
1117
|
+
*/
|
|
1118
|
+
declare const sinc: OwnedFunction<(x: ArrayLike) => Array>;
|
|
993
1119
|
/** Element-wise inverse cosine function (inverse of cos). */
|
|
994
1120
|
declare function acos(x: ArrayLike): Array;
|
|
995
1121
|
/**
|
|
@@ -1019,6 +1145,20 @@ declare const atan2: OwnedFunction<(y: ArrayLike, x: ArrayLike) => Array>;
|
|
|
1019
1145
|
declare function subtract(x: ArrayLike, y: ArrayLike): Array;
|
|
1020
1146
|
/** Calculates the floating-point division of x by y element-wise. */
|
|
1021
1147
|
declare function trueDivide(x: ArrayLike, y: ArrayLike): Array;
|
|
1148
|
+
/**
|
|
1149
|
+
* Return the largest integer smaller or equal to the division of the inputs.
|
|
1150
|
+
*
|
|
1151
|
+
* The result is always rounded towards negative infinity.
|
|
1152
|
+
*
|
|
1153
|
+
* For floating-point inputs, this is equivalent to `floor(x / y)`.
|
|
1154
|
+
* For integer inputs, we use `(x - remainder(x, y)) / y` to handle
|
|
1155
|
+
* negative values correctly (note: may overflow near int32 boundaries).
|
|
1156
|
+
*
|
|
1157
|
+
* @param x - Dividend array.
|
|
1158
|
+
* @param y - Divisor array.
|
|
1159
|
+
* @returns Element-wise floor division of x by y.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function floorDivide(x: ArrayLike, y: ArrayLike): Array;
|
|
1022
1162
|
/**
|
|
1023
1163
|
* @function
|
|
1024
1164
|
* Calculate element-wise floating-point modulo operation.
|
|
@@ -1029,6 +1169,16 @@ declare const fmod: OwnedFunction<(x: ArrayLike, y: ArrayLike) => Array>;
|
|
|
1029
1169
|
* Calculate element-wise remainder of the division (matches sign of y).
|
|
1030
1170
|
*/
|
|
1031
1171
|
declare const remainder: OwnedFunction<(x: ArrayLike, y: ArrayLike) => Array>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Return element-wise quotient and remainder simultaneously.
|
|
1174
|
+
*
|
|
1175
|
+
* Equivalent to `[floorDivide(x, y), remainder(x, y)]`.
|
|
1176
|
+
*
|
|
1177
|
+
* @param x - Dividend array.
|
|
1178
|
+
* @param y - Divisor array.
|
|
1179
|
+
* @returns Tuple of [quotient, remainder].
|
|
1180
|
+
*/
|
|
1181
|
+
declare function divmod(x: ArrayLike, y: ArrayLike): [Array, Array];
|
|
1032
1182
|
/** Round input to the nearest integer towards zero. */
|
|
1033
1183
|
declare function trunc(x: ArrayLike): Array;
|
|
1034
1184
|
/**
|
|
@@ -1139,7 +1289,11 @@ declare function std(x: ArrayLike, axis?: Axis, opts?: {
|
|
|
1139
1289
|
correction?: number;
|
|
1140
1290
|
} & ReduceOpts): Array;
|
|
1141
1291
|
/** Estimate the sample covariance of a set of variables. */
|
|
1142
|
-
declare function cov(x: ArrayLike, y?: ArrayLike
|
|
1292
|
+
declare function cov(x: ArrayLike, y?: ArrayLike | null, {
|
|
1293
|
+
rowvar
|
|
1294
|
+
}?: {
|
|
1295
|
+
rowvar?: boolean;
|
|
1296
|
+
}): Array;
|
|
1143
1297
|
/** Compute the Pearson correlation coefficients (in range `[-1, 1]`). */
|
|
1144
1298
|
declare function corrcoef(x: ArrayLike, y?: ArrayLike): Array;
|
|
1145
1299
|
/** Test element-wise for positive or negative infinity, return bool array. */
|
|
@@ -1353,6 +1507,8 @@ declare enum Primitive {
|
|
|
1353
1507
|
PoolTranspose = "pool_transpose",
|
|
1354
1508
|
Compare = "compare",
|
|
1355
1509
|
Where = "where",
|
|
1510
|
+
Concatenate = "concatenate",
|
|
1511
|
+
Split = "split",
|
|
1356
1512
|
RandomBits = "random_bits",
|
|
1357
1513
|
Gather = "gather",
|
|
1358
1514
|
Transpose = "transpose",
|
|
@@ -1369,6 +1525,8 @@ declare enum Primitive {
|
|
|
1369
1525
|
// A is upper triangular, A @ X.T = B.T
|
|
1370
1526
|
Cholesky = "cholesky",
|
|
1371
1527
|
// A is positive-definite, A = L @ L^T
|
|
1528
|
+
LU = "lu",
|
|
1529
|
+
// LU decomposition with partial pivoting
|
|
1372
1530
|
Jit = "jit",
|
|
1373
1531
|
}
|
|
1374
1532
|
interface PrimitiveParamsImpl extends Record<Primitive, Record<string, any>> {
|
|
@@ -1395,6 +1553,13 @@ interface PrimitiveParamsImpl extends Record<Primitive, Record<string, any>> {
|
|
|
1395
1553
|
[Primitive.Compare]: {
|
|
1396
1554
|
op: CompareOp;
|
|
1397
1555
|
};
|
|
1556
|
+
[Primitive.Concatenate]: {
|
|
1557
|
+
axis: number;
|
|
1558
|
+
};
|
|
1559
|
+
[Primitive.Split]: {
|
|
1560
|
+
axis: number;
|
|
1561
|
+
sizes: number[];
|
|
1562
|
+
};
|
|
1398
1563
|
[Primitive.RandomBits]: {
|
|
1399
1564
|
shape: number[];
|
|
1400
1565
|
mode: "xor" | 0 | 1;
|
|
@@ -1570,6 +1735,7 @@ declare abstract class Tracer {
|
|
|
1570
1735
|
neg(): this;
|
|
1571
1736
|
add(other: this | TracerValue): this;
|
|
1572
1737
|
mul(other: this | TracerValue): this;
|
|
1738
|
+
mod(other: this | TracerValue): this;
|
|
1573
1739
|
greater(other: this | TracerValue): this;
|
|
1574
1740
|
less(other: this | TracerValue): this;
|
|
1575
1741
|
equal(other: this | TracerValue): this;
|
|
@@ -1672,6 +1838,7 @@ declare class ShapedArray implements AbstractValue {
|
|
|
1672
1838
|
static fromAval(aval: AbstractValue): ShapedArray;
|
|
1673
1839
|
get ndim(): number;
|
|
1674
1840
|
get size(): number;
|
|
1841
|
+
scalar(): ShapedArray;
|
|
1675
1842
|
toString(): string;
|
|
1676
1843
|
equals(other: ShapedArray): boolean;
|
|
1677
1844
|
}
|
|
@@ -1739,6 +1906,8 @@ declare class Array extends Tracer {
|
|
|
1739
1906
|
toString(): string;
|
|
1740
1907
|
get device(): Device;
|
|
1741
1908
|
get ref(): this;
|
|
1909
|
+
/** Get the current reference count (for debugging memory management). */
|
|
1910
|
+
get refCount(): number;
|
|
1742
1911
|
dispose(): void;
|
|
1743
1912
|
/**
|
|
1744
1913
|
* Convert this array into a primitive value.
|
|
@@ -1887,8 +2056,25 @@ declare function linspace(start: number, stop: number, num?: number, endpoint?:
|
|
|
1887
2056
|
dtype,
|
|
1888
2057
|
device
|
|
1889
2058
|
}?: DTypeAndDevice): Array;
|
|
2059
|
+
/**
|
|
2060
|
+
* Return numbers spaced evenly on a log scale.
|
|
2061
|
+
*
|
|
2062
|
+
* In linear space, the sequence starts at `base ** start` and ends at
|
|
2063
|
+
* `base ** stop` (see `endpoint` below).
|
|
2064
|
+
*
|
|
2065
|
+
* @param start - `base ** start` is the starting value of the sequence.
|
|
2066
|
+
* @param stop - `base ** stop` is the final value of the sequence, unless `endpoint` is false.
|
|
2067
|
+
* @param num - Number of samples to generate. Default is 50.
|
|
2068
|
+
* @param endpoint - If true, `stop` is the last sample. Otherwise, it is not included. Default is true.
|
|
2069
|
+
* @param base - The base of the log space. Default is 10.
|
|
2070
|
+
* @returns Array of evenly spaced values on a log scale.
|
|
2071
|
+
*/
|
|
2072
|
+
declare function logspace(start: number, stop: number, num?: number, endpoint?: boolean, base?: number, {
|
|
2073
|
+
dtype,
|
|
2074
|
+
device
|
|
2075
|
+
}?: DTypeAndDevice): Array;
|
|
1890
2076
|
declare namespace lax_linalg_d_exports {
|
|
1891
|
-
export { cholesky, triangularSolve };
|
|
2077
|
+
export { cholesky, lu, triangularSolve };
|
|
1892
2078
|
}
|
|
1893
2079
|
/**
|
|
1894
2080
|
* Compute the Cholesky decomposition of a symmetric positive-definite matrix.
|
|
@@ -1921,6 +2107,32 @@ declare function cholesky(a: ArrayLike, {
|
|
|
1921
2107
|
}?: {
|
|
1922
2108
|
upper?: boolean;
|
|
1923
2109
|
}): Array;
|
|
2110
|
+
/**
|
|
2111
|
+
* LU decomposition with partial pivoting.
|
|
2112
|
+
*
|
|
2113
|
+
* Computes the matrix decomposition: `P @ A = L @ U`, where `P` is a
|
|
2114
|
+
* permutation of the rows of `A`, `L` is lower-triangular with unit diagonal,
|
|
2115
|
+
* and `U` is upper-triangular.
|
|
2116
|
+
*
|
|
2117
|
+
* @param x - A batch of matrices with shape `[..., m, n]`.
|
|
2118
|
+
*
|
|
2119
|
+
* @returns A tuple `(lu, pivots, permutation)` where:
|
|
2120
|
+
* - `lu`: combined lower and upper triangular matrices.
|
|
2121
|
+
* - `pivots`: an array of pivot indices with shape `[..., min(m, n)]`.
|
|
2122
|
+
* - `permutation`: the permutation generated by pivots with shape `[..., m]`.
|
|
2123
|
+
*
|
|
2124
|
+
* @example
|
|
2125
|
+
* ```ts
|
|
2126
|
+
* import { lax, numpy as np } from "@jax-js/jax";
|
|
2127
|
+
*
|
|
2128
|
+
* const A = np.array([[4., 3.], [6., 3.]]);
|
|
2129
|
+
* const [lu, pivots, permutation] = lax.linalg.lu(A);
|
|
2130
|
+
* // lu ≈ [[6., 3.], [0.6666667, 1.0]]
|
|
2131
|
+
* // pivots = [1, 1]
|
|
2132
|
+
* // permutation = [1, 0]
|
|
2133
|
+
* ```
|
|
2134
|
+
*/
|
|
2135
|
+
declare function lu(x: ArrayLike): [Array, Array, Array];
|
|
1924
2136
|
/**
|
|
1925
2137
|
* Solve a triangular linear system.
|
|
1926
2138
|
*
|
|
@@ -2221,10 +2433,10 @@ declare function standardize(x: ArrayLike, axis?: Axis, opts?: {
|
|
|
2221
2433
|
*/
|
|
2222
2434
|
declare function oneHot(x: Array, numClasses: number): Array;
|
|
2223
2435
|
declare namespace random_d_exports {
|
|
2224
|
-
export { bernoulli, bits, cauchy, exponential, gumbel, key, laplace, normal, split, uniform };
|
|
2436
|
+
export { bernoulli, bits, cauchy, exponential, gumbel, key, laplace, multivariateNormal, normal, split, uniform };
|
|
2225
2437
|
}
|
|
2226
2438
|
/** Create a pseudo-random number generator (PRNG) key from 32-bit integer seed. */
|
|
2227
|
-
declare function key(seed:
|
|
2439
|
+
declare function key(seed: ArrayLike): Array;
|
|
2228
2440
|
/** Splits a PRNG key into `num` new keys by adding a leading axis. */
|
|
2229
2441
|
declare function split(key: Array, num?: number | number[]): Array;
|
|
2230
2442
|
/** Sample uniform bits in the form of unsigned integers. */
|
|
@@ -2271,6 +2483,23 @@ declare const gumbel: OwnedFunction<(key: ArrayLike, shape?: number[] | undefine
|
|
|
2271
2483
|
* Inverting: `x = -sign(u - 0.5) * log(1 - 2 * |u - 0.5|)`.
|
|
2272
2484
|
*/
|
|
2273
2485
|
declare const laplace: OwnedFunction<(key: ArrayLike, shape?: number[] | undefined) => Array>;
|
|
2486
|
+
/**
|
|
2487
|
+
* @function
|
|
2488
|
+
* Sample multivariate normal random values with given mean and covariance.
|
|
2489
|
+
*
|
|
2490
|
+
* The values are returned with the given shape, along with the final dimension
|
|
2491
|
+
* used to represent the n-dimensional multivariate normal factors.
|
|
2492
|
+
*
|
|
2493
|
+
* This uses Cholesky decomposition on the covariance matrix.
|
|
2494
|
+
*
|
|
2495
|
+
* - `key` - PRNG key
|
|
2496
|
+
* - `mean` - Mean vector of shape `[..., n]`
|
|
2497
|
+
* - `cov` - Covariance of shape `[..., n, n]`, must be positive-definite
|
|
2498
|
+
* - `shape` - Result batch shape, must be broadcastable with
|
|
2499
|
+
* `mean.shape[:-1]` and `cov.shape[:-2]`
|
|
2500
|
+
* @returns Random samples of shape `[...shape, n]`
|
|
2501
|
+
*/
|
|
2502
|
+
declare const multivariateNormal: OwnedFunction<(key: ArrayLike, mean: ArrayLike, cov: ArrayLike, shape?: number[] | undefined) => Array>;
|
|
2274
2503
|
/**
|
|
2275
2504
|
* @function
|
|
2276
2505
|
* Sample random values according to `p(x) = 1/sqrt(2pi) * exp(-x^2/2)`.
|