@numero-uno-jpn/rstats 0.11.0 → 0.11.1
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/CHANGELOG.md +13 -0
- package/README.ja.md +5 -4
- package/README.md +6 -4
- package/dist/chunks/{chunk-YSWGDOWK.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-F5EDJFEO.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-7GQMKH3Z.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-JWBO5WVN.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-EZWBRCJL.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-EZAFN5CD.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-5WDJPHYY.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/{chunk-AHHS6AC4.js → chunk-LAUYSGV4.js} +2 -2
- package/dist/chunks/{chunk-ALM3VHFP.js → chunk-M6GDXKKS.js} +1 -1
- package/dist/chunks/{chunk-C5XTWMGB.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-TOGXTCZO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-X2AWQSVS.js} +2 -2
- package/dist/chunks/{chunk-Y5CNQ266.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +33 -12
- package/dist/data/grouping.js +2 -0
- package/dist/descriptive/basic.d.ts +130 -17
- package/dist/descriptive/basic.js +115 -14
- package/dist/descriptive/cov.d.ts +22 -12
- package/dist/descriptive/dataFrames.d.ts +39 -11
- package/dist/descriptive/dataFrames.js +14 -6
- package/dist/descriptive/factanal.d.ts +26 -6
- package/dist/descriptive/factanal.js +7 -3
- package/dist/descriptive/hist.d.ts +27 -6
- package/dist/descriptive/hist.js +9 -3
- package/dist/descriptive/missing.d.ts +13 -6
- package/dist/descriptive/missing.js +4 -2
- package/dist/descriptive/moments.d.ts +91 -13
- package/dist/descriptive/moments.js +66 -9
- package/dist/descriptive/omega.d.ts +28 -6
- package/dist/descriptive/omega.js +16 -4
- package/dist/descriptive/pivot.d.ts +22 -6
- package/dist/descriptive/pivot.js +7 -3
- package/dist/descriptive/quantile.d.ts +33 -5
- package/dist/descriptive/quantile.js +20 -2
- package/dist/descriptive/rank.d.ts +12 -2
- package/dist/descriptive/rank.js +2 -0
- package/dist/descriptive/table.d.ts +55 -7
- package/dist/descriptive/table.js +38 -4
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.d.ts +40 -5
- package/dist/distributions/arcsine.js +35 -4
- package/dist/distributions/beta.d.ts +12 -0
- package/dist/distributions/beta.js +12 -0
- package/dist/distributions/binomial.d.ts +18 -0
- package/dist/distributions/binomial.js +18 -0
- package/dist/distributions/bvnorm.d.ts +4 -1
- package/dist/distributions/bvnorm.js +4 -1
- package/dist/distributions/cauchy.d.ts +24 -0
- package/dist/distributions/cauchy.js +24 -0
- package/dist/distributions/chisq.d.ts +18 -0
- package/dist/distributions/chisq.js +18 -0
- package/dist/distributions/exponential.d.ts +29 -1
- package/dist/distributions/exponential.js +24 -0
- package/dist/distributions/f.d.ts +18 -0
- package/dist/distributions/f.js +18 -0
- package/dist/distributions/gamma.d.ts +20 -0
- package/dist/distributions/gamma.js +18 -0
- package/dist/distributions/geometric.d.ts +24 -0
- package/dist/distributions/geometric.js +24 -0
- package/dist/distributions/hypergeometric.d.ts +24 -0
- package/dist/distributions/hypergeometric.js +24 -0
- package/dist/distributions/invgamma.d.ts +32 -4
- package/dist/distributions/invgamma.js +27 -3
- package/dist/distributions/kumaraswamy.d.ts +31 -3
- package/dist/distributions/kumaraswamy.js +31 -3
- package/dist/distributions/laplace.d.ts +36 -4
- package/dist/distributions/laplace.js +31 -3
- package/dist/distributions/logistic.d.ts +29 -1
- package/dist/distributions/logistic.js +24 -0
- package/dist/distributions/lognormal.d.ts +29 -1
- package/dist/distributions/lognormal.js +24 -0
- package/dist/distributions/multinomial.d.ts +7 -1
- package/dist/distributions/multinomial.js +2 -0
- package/dist/distributions/negbinomial.d.ts +29 -1
- package/dist/distributions/negbinomial.js +24 -0
- package/dist/distributions/normal.d.ts +11 -1
- package/dist/distributions/normal.js +6 -0
- package/dist/distributions/pareto.d.ts +36 -4
- package/dist/distributions/pareto.js +31 -3
- package/dist/distributions/poisson.d.ts +18 -0
- package/dist/distributions/poisson.js +18 -0
- package/dist/distributions/signrank.d.ts +24 -0
- package/dist/distributions/signrank.js +24 -0
- package/dist/distributions/summary.d.ts +20 -2
- package/dist/distributions/summary.js +4 -0
- package/dist/distributions/t.d.ts +18 -0
- package/dist/distributions/t.js +18 -0
- package/dist/distributions/triangular.d.ts +36 -4
- package/dist/distributions/triangular.js +31 -3
- package/dist/distributions/tukey.d.ts +15 -1
- package/dist/distributions/tukey.js +10 -0
- package/dist/distributions/uniform.d.ts +29 -1
- package/dist/distributions/uniform.js +24 -0
- package/dist/distributions/weibull.d.ts +29 -1
- package/dist/distributions/weibull.js +24 -0
- package/dist/distributions/wilcox.d.ts +24 -0
- package/dist/distributions/wilcox.js +24 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +1 -1
- package/dist/entries/numerics.d.ts +1 -1
- package/dist/entries/tests.js +1 -1
- package/dist/htest/agreement.d.ts +61 -23
- package/dist/htest/agreement.js +19 -9
- package/dist/htest/ansariTest.d.ts +8 -2
- package/dist/htest/aov.d.ts +43 -10
- package/dist/htest/aov.js +17 -3
- package/dist/htest/binomTest.d.ts +12 -2
- package/dist/htest/binomTest.js +2 -0
- package/dist/htest/brunnerMunzelTest.d.ts +9 -3
- package/dist/htest/brunnerMunzelTest.js +4 -2
- package/dist/htest/chisqTest.d.ts +19 -3
- package/dist/htest/cor.d.ts +20 -4
- package/dist/htest/effectSize.d.ts +70 -12
- package/dist/htest/effectSize.js +40 -7
- package/dist/htest/fisherTest.d.ts +9 -1
- package/dist/htest/fisherTest.js +2 -0
- package/dist/htest/groups.d.ts +5 -1
- package/dist/htest/ksTest.d.ts +20 -3
- package/dist/htest/leveneTest.d.ts +15 -4
- package/dist/htest/leveneTest.js +5 -2
- package/dist/htest/mantelhaenTest.d.ts +25 -3
- package/dist/htest/mantelhaenTest.js +15 -1
- package/dist/htest/mcnemarTest.d.ts +14 -4
- package/dist/htest/mcnemarTest.js +4 -2
- package/dist/htest/multipleComparisons.d.ts +173 -29
- package/dist/htest/multipleComparisons.js +123 -19
- package/dist/htest/normalityTests.d.ts +56 -9
- package/dist/htest/normalityTests.js +40 -6
- package/dist/htest/onewayTest.d.ts +32 -3
- package/dist/htest/onewayTest.js +10 -0
- package/dist/htest/pAdjust.d.ts +9 -1
- package/dist/htest/pAdjust.js +2 -0
- package/dist/htest/pairwise.d.ts +50 -5
- package/dist/htest/pairwise.js +25 -0
- package/dist/htest/poissonTest.d.ts +12 -2
- package/dist/htest/poissonTest.js +2 -0
- package/dist/htest/polycor.d.ts +29 -10
- package/dist/htest/power.d.ts +60 -6
- package/dist/htest/power.js +6 -0
- package/dist/htest/propTest.d.ts +13 -2
- package/dist/htest/propTest.js +2 -0
- package/dist/htest/pwr.d.ts +286 -36
- package/dist/htest/pwr.js +116 -15
- package/dist/htest/rankTests.d.ts +80 -12
- package/dist/htest/rankTests.js +11 -2
- package/dist/htest/tTest.d.ts +13 -3
- package/dist/htest/trendTests.d.ts +29 -8
- package/dist/htest/trendTests.js +8 -4
- package/dist/htest/types.d.ts +14 -2
- package/dist/htest/varTest.d.ts +25 -8
- package/dist/htest/wilcoxTest.d.ts +10 -2
- package/dist/internal/dpq.d.ts +4 -0
- package/dist/internal/noncentral.d.ts +2 -0
- package/dist/internal/vectorize.d.ts +4 -0
- package/dist/linalg/basic.d.ts +39 -5
- package/dist/linalg/basic.js +15 -0
- package/dist/linalg/chol.d.ts +26 -5
- package/dist/linalg/chol.js +7 -0
- package/dist/linalg/eigen.d.ts +16 -7
- package/dist/linalg/eigen.js +6 -5
- package/dist/linalg/expm.d.ts +15 -5
- package/dist/linalg/expm.js +5 -3
- package/dist/linalg/kappa.d.ts +21 -1
- package/dist/linalg/kappa.js +16 -0
- package/dist/linalg/lu.d.ts +30 -6
- package/dist/linalg/lu.js +15 -3
- package/dist/linalg/matrix.d.ts +4 -0
- package/dist/linalg/norm.d.ts +16 -1
- package/dist/linalg/norm.js +9 -0
- package/dist/linalg/ops.d.ts +156 -35
- package/dist/linalg/ops.js +96 -15
- package/dist/linalg/qr.d.ts +87 -12
- package/dist/linalg/qr.js +31 -0
- package/dist/linalg/schur.d.ts +8 -2
- package/dist/linalg/schur.js +3 -1
- package/dist/linalg/solve.d.ts +42 -6
- package/dist/linalg/solve.js +22 -0
- package/dist/linalg/svd.d.ts +12 -2
- package/dist/linalg/svd.js +2 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +26 -4
- package/dist/models/anovaSequential.js +3 -1
- package/dist/models/aovEz.d.ts +29 -6
- package/dist/models/aovEz.js +5 -2
- package/dist/models/aovStrata.d.ts +12 -2
- package/dist/models/carAnova.d.ts +9 -3
- package/dist/models/carAnova.js +4 -2
- package/dist/models/coxph.d.ts +33 -7
- package/dist/models/coxph.js +8 -3
- package/dist/models/glm.d.ts +128 -21
- package/dist/models/glm.js +71 -14
- package/dist/models/glmAnova.d.ts +30 -5
- package/dist/models/glmAnova.js +15 -2
- package/dist/models/glmConfint.d.ts +16 -2
- package/dist/models/glmConfint.js +9 -1
- package/dist/models/glmFamily.d.ts +27 -5
- package/dist/models/lm.d.ts +75 -17
- package/dist/models/lm.js +22 -4
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/modelFrame.d.ts +5 -1
- package/dist/models/modelMatrix.d.ts +18 -4
- package/dist/models/modelMatrix.js +3 -1
- package/dist/models/survival.d.ts +41 -9
- package/dist/models/survival.js +10 -4
- package/dist/numerics/deriv.d.ts +21 -6
- package/dist/numerics/deriv.js +16 -5
- package/dist/numerics/integrate.d.ts +37 -7
- package/dist/numerics/integrate.js +8 -2
- package/dist/numerics/interp.d.ts +63 -12
- package/dist/numerics/interp.js +30 -6
- package/dist/numerics/ode.d.ts +15 -5
- package/dist/numerics/ode.js +5 -3
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.d.ts +32 -8
- package/dist/optim/optim.js +8 -4
- package/dist/random/beta.d.ts +8 -0
- package/dist/random/beta.js +8 -0
- package/dist/random/binomial.d.ts +16 -0
- package/dist/random/binomial.js +16 -0
- package/dist/random/continuous.d.ts +51 -0
- package/dist/random/continuous.js +51 -0
- package/dist/random/extra.d.ts +66 -6
- package/dist/random/extra.js +66 -6
- package/dist/random/gamma.d.ts +33 -0
- package/dist/random/gamma.js +33 -0
- package/dist/random/hyper.d.ts +8 -0
- package/dist/random/hyper.js +8 -0
- package/dist/random/poisson.d.ts +25 -0
- package/dist/random/poisson.js +25 -0
- package/dist/random/r2dtable.d.ts +2 -0
- package/dist/random/r2dtable.js +2 -0
- package/dist/random/rank.d.ts +16 -0
- package/dist/random/rank.js +16 -0
- package/dist/random/rng.d.ts +49 -6
- package/dist/random/rng.js +29 -2
- package/dist/random/sample.d.ts +10 -2
- package/dist/random/sample.js +5 -1
- package/dist/random/streams.d.ts +13 -0
- package/dist/random/streams.js +13 -0
- package/dist/rstats.js +1 -1
- package/dist/special/besselIK.d.ts +11 -3
- package/dist/special/besselIK.js +6 -2
- package/dist/special/besselJY.d.ts +6 -2
- package/dist/special/besselJY.js +6 -2
- package/dist/special/beta.d.ts +16 -2
- package/dist/special/beta.js +16 -2
- package/dist/special/choose.d.ts +13 -5
- package/dist/special/choose.js +13 -5
- package/dist/special/erf.d.ts +8 -3
- package/dist/special/erf.js +8 -3
- package/dist/special/extra.d.ts +30 -10
- package/dist/special/extra.js +25 -9
- package/dist/special/gamma.d.ts +18 -2
- package/dist/special/gamma.js +18 -2
- package/dist/special/log1p.d.ts +16 -7
- package/dist/special/log1p.js +16 -7
- package/dist/special/psigamma.d.ts +9 -3
- package/dist/special/psigamma.js +9 -3
- package/dist/special/rCompatible.d.ts +5 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +2 -2
- package/llms.txt +2 -0
- package/package.json +1 -1
package/dist/linalg/lu.js
CHANGED
|
@@ -12,13 +12,16 @@ import { matMul } from "./ops.js";
|
|
|
12
12
|
/** Smallest normal double (LAPACK's dlamch("S")): below it, 1 / pivot would overflow. */
|
|
13
13
|
const SFMIN = 2.2250738585072014e-308;
|
|
14
14
|
/**
|
|
15
|
-
* LU decomposition with partial (row) pivoting, `x = P L U`. Equivalent to `Matrix::
|
|
16
|
-
* (LAPACK's dgetrf).
|
|
15
|
+
* LU decomposition with partial (row) pivoting, `x = P L U`. Equivalent to R's `Matrix::lu()`. The factors are those
|
|
16
|
+
* of `Matrix::expand(Matrix::lu(x))` (LAPACK's dgetrf).
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
|
-
*
|
|
20
|
+
* lu([[1, 2], [3, 4]]);
|
|
21
|
+
* // { P: [[0, 1], [1, 0]], L: [[1, 0], [0.3333333333333333, 1]], U: [[3, 4], [0, 0.6666666666666667]] }
|
|
21
22
|
* ```
|
|
23
|
+
*
|
|
24
|
+
* @category Linear algebra
|
|
22
25
|
*/
|
|
23
26
|
export function lu(x) {
|
|
24
27
|
const m = x.length;
|
|
@@ -66,6 +69,15 @@ export function lu(x) {
|
|
|
66
69
|
/**
|
|
67
70
|
* Principal components of the columns of `x` (observations as rows). Equivalent to R's `prcomp()`. The sign of each
|
|
68
71
|
* component is arbitrary, as in R.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const pc = prcomp([[1, 2], [2, 1], [3, 4], [4, 3]]);
|
|
76
|
+
* pc.sdev; // [1.632993161855452, 0.816496580927726]
|
|
77
|
+
* pc.x; // [[-1.4142, 0.7071], [-1.4142, -0.7071], [1.4142, 0.7071], [1.4142, -0.7071]] (signs may differ from R)
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @category Linear algebra
|
|
69
81
|
*/
|
|
70
82
|
export function prcomp(x, options = {}) {
|
|
71
83
|
const rows = x.map((r) => Array.from(r));
|
package/dist/linalg/matrix.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A matrix given as an array of rows. Each row may be a plain array or a `Float64Array`;
|
|
3
3
|
* all rows must have the same length. A matrix with zero rows is treated as 0 x 0.
|
|
4
|
+
*
|
|
5
|
+
* @category Linear algebra
|
|
4
6
|
*/
|
|
5
7
|
export type MatrixInput = readonly (readonly number[] | Float64Array)[];
|
|
6
8
|
/**
|
|
7
9
|
* A vector or a matrix (array of rows). Used for arguments that accept either, such as the
|
|
8
10
|
* right-hand side of `backsolve`; a vector is treated as a one-column matrix, as in R.
|
|
11
|
+
*
|
|
12
|
+
* @category Linear algebra
|
|
9
13
|
*/
|
|
10
14
|
export type VectorOrMatrix = readonly number[] | Float64Array | MatrixInput;
|
|
11
15
|
/** Column-major matrix. Element (i, j) is data[i + j * nrow] */
|
package/dist/linalg/norm.d.ts
CHANGED
|
@@ -2,9 +2,15 @@ import { type Mat, type MatrixInput } from "./matrix.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Matrix norm type for {@link norm}: `"O"`/`"1"` (one norm), `"I"` (infinity norm), `"F"`/`"E"` (Frobenius),
|
|
4
4
|
* `"M"` (maximum modulus) or `"2"` (spectral norm). Case-insensitive, as in R.
|
|
5
|
+
*
|
|
6
|
+
* @category Linear algebra
|
|
5
7
|
*/
|
|
6
8
|
export type NormType = "O" | "o" | "1" | "I" | "i" | "F" | "f" | "E" | "e" | "M" | "m" | "2";
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link norm}.
|
|
11
|
+
*
|
|
12
|
+
* @category Linear algebra
|
|
13
|
+
*/
|
|
8
14
|
export interface NormOptions {
|
|
9
15
|
/**
|
|
10
16
|
* Which norm to compute (a single character, case-insensitive). Default: `"O"`.
|
|
@@ -24,6 +30,15 @@ export interface NormOptions {
|
|
|
24
30
|
* @param x A matrix (array of rows).
|
|
25
31
|
* @param options See {@link NormOptions}.
|
|
26
32
|
* @returns The norm of `x`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* norm([[1, -2], [3, 4]]); // 6 (one norm)
|
|
37
|
+
* norm([[1, -2], [3, 4]], { type: "I" }); // 7
|
|
38
|
+
* norm([[1, -2], [3, 4]], { type: "F" }); // 5.477225575051661
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Linear algebra
|
|
27
42
|
*/
|
|
28
43
|
export declare function norm(x: MatrixInput, options?: NormOptions): number;
|
|
29
44
|
export declare function oneNorm(m: Mat): number;
|
package/dist/linalg/norm.js
CHANGED
|
@@ -15,6 +15,15 @@ import { svdValues } from "./svd.js";
|
|
|
15
15
|
* @param x A matrix (array of rows).
|
|
16
16
|
* @param options See {@link NormOptions}.
|
|
17
17
|
* @returns The norm of `x`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* norm([[1, -2], [3, 4]]); // 6 (one norm)
|
|
22
|
+
* norm([[1, -2], [3, 4]], { type: "I" }); // 7
|
|
23
|
+
* norm([[1, -2], [3, 4]], { type: "F" }); // 5.477225575051661
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @category Linear algebra
|
|
18
27
|
*/
|
|
19
28
|
export function norm(x, options = {}) {
|
|
20
29
|
const m = toMat(x);
|
package/dist/linalg/ops.d.ts
CHANGED
|
@@ -1,85 +1,205 @@
|
|
|
1
1
|
import type { Sample } from "../htest/types.js";
|
|
2
2
|
import type { DataFrame } from "../models/modelFrame.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A vector (plain array) or a matrix (array of rows).
|
|
5
|
+
*
|
|
6
|
+
* @category Linear algebra
|
|
7
|
+
*/
|
|
4
8
|
export type Operand = number | Sample | readonly (readonly number[])[];
|
|
5
|
-
type Matrix = number[][];
|
|
6
9
|
/**
|
|
7
|
-
* Matrix product. Equivalent to R's
|
|
8
|
-
*
|
|
10
|
+
* Matrix product. Equivalent to R's `%*%`. A vector is taken as a row or a column so that the product is defined
|
|
11
|
+
* (two vectors give their inner product as a 1 x 1 matrix).
|
|
9
12
|
*
|
|
10
13
|
* @example
|
|
11
14
|
* ```ts
|
|
12
15
|
* matMul([[1, 2], [3, 4]], [[5], [6]]); // [[17], [39]]
|
|
16
|
+
* matMul([1, 2, 3], [4, 5, 6]); // [[32]]
|
|
13
17
|
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Linear algebra
|
|
14
20
|
*/
|
|
15
|
-
export declare function matMul(x: Operand, y: Operand):
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
21
|
+
export declare function matMul(x: Operand, y: Operand): number[][];
|
|
22
|
+
/**
|
|
23
|
+
* Element-wise sum with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
24
|
+
* R's `+`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* add([[1, 2], [3, 4]], [10, 20]); // [[11, 12], [23, 24]]
|
|
29
|
+
* add([1, 2, 3], 2); // [3, 4, 5]
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Linear algebra
|
|
33
|
+
*/
|
|
34
|
+
export declare function add(x: Operand, y: Operand): number[] | number[][];
|
|
35
|
+
/**
|
|
36
|
+
* Element-wise difference with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
37
|
+
* R's `-`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* subtract([[1, 2], [3, 4]], [10, 20]); // [[-9, -8], [-17, -16]]
|
|
42
|
+
* subtract([1, 2, 3], 2); // [-1, 0, 1]
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Linear algebra
|
|
46
|
+
*/
|
|
47
|
+
export declare function subtract(x: Operand, y: Operand): number[] | number[][];
|
|
48
|
+
/**
|
|
49
|
+
* Element-wise product with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
50
|
+
* R's `*`. The matrix product is {@link matMul}.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* multiply([[1, 2], [3, 4]], [10, 20]); // [[10, 20], [60, 80]]
|
|
55
|
+
* multiply([1, 2, 3], 2); // [2, 4, 6]
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @category Linear algebra
|
|
59
|
+
*/
|
|
60
|
+
export declare function multiply(x: Operand, y: Operand): number[] | number[][];
|
|
61
|
+
/**
|
|
62
|
+
* Element-wise quotient with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
63
|
+
* R's `/`.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* divide([[1, 2], [3, 4]], [10, 20]); // [[0.1, 0.2], [0.15, 0.2]]
|
|
68
|
+
* divide([1, 2, 3], 2); // [0.5, 1, 1.5]
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @category Linear algebra
|
|
72
|
+
*/
|
|
73
|
+
export declare function divide(x: Operand, y: Operand): number[] | number[][];
|
|
74
|
+
/**
|
|
75
|
+
* Outer product of two vectors: the matrix of `fun(x[i], y[j])`. Equivalent to R's `outer()`. `fun` is `"*"`
|
|
26
76
|
* (default), `"+"`, `"-"`, `"/"`, `"^"` or a function of two numbers.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* outer([1, 2], [1, 2, 3]); // [[1, 2, 3], [2, 4, 6]]
|
|
81
|
+
* outer([1, 2], [1, 2, 3], "+"); // [[2, 3, 4], [3, 4, 5]]
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @category Linear algebra
|
|
85
|
+
*/
|
|
86
|
+
export declare function outer(x: Sample, y: Sample, fun?: "*" | "+" | "-" | "/" | "^" | ((a: number, b: number) => number)): number[][];
|
|
87
|
+
/**
|
|
88
|
+
* Transpose. Equivalent to R's `t()`. A vector becomes a 1-row matrix.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* t([[1, 2, 3], [4, 5, 6]]); // [[1, 4], [2, 5], [3, 6]]
|
|
93
|
+
* t([1, 2]); // [[1, 2]]
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @category Linear algebra
|
|
97
|
+
*/
|
|
98
|
+
export declare function t(x: Operand): number[][];
|
|
99
|
+
/**
|
|
100
|
+
* Options for {@link diag}.
|
|
101
|
+
*
|
|
102
|
+
* @category Linear algebra
|
|
27
103
|
*/
|
|
28
|
-
export declare function outer(x: Sample, y: Sample, fun?: "*" | "+" | "-" | "/" | "^" | ((a: number, b: number) => number)): Matrix;
|
|
29
|
-
/** Transpose. Equivalent to R's `t()`: a vector becomes a 1-row matrix. */
|
|
30
|
-
export declare function t(x: Operand): Matrix;
|
|
31
|
-
/** Options for {@link diag}. */
|
|
32
104
|
export interface DiagOptions {
|
|
105
|
+
/** Number of rows of the matrix built from a vector or a number (R's `nrow`). Default: the length of the vector. */
|
|
33
106
|
nrow?: number;
|
|
107
|
+
/** Number of columns of the matrix built from a vector or a number (R's `ncol`). Default: `nrow`. */
|
|
34
108
|
ncol?: number;
|
|
35
109
|
}
|
|
36
110
|
/**
|
|
37
|
-
* R's `diag()
|
|
38
|
-
* length 2 or more (its values recycled along the diagonal of an `nrow` x `ncol` matrix when given); and for a single
|
|
111
|
+
* Matrix diagonals, diagonal matrices and identity matrices. Equivalent to R's `diag()`. It has three meanings: the
|
|
112
|
+
* diagonal of a matrix (as a vector); the diagonal matrix of a vector of length 2 or more (its values recycled along the diagonal of an `nrow` x `ncol` matrix when given); and for a single
|
|
39
113
|
* number n, the n x n identity matrix (with `nrow`/`ncol`, a matrix with that number on the diagonal).
|
|
40
114
|
*
|
|
41
115
|
* @example
|
|
42
116
|
* ```ts
|
|
43
117
|
* diag([[1, 2], [3, 4]]); // [1, 4]
|
|
44
118
|
* diag([2, 3]); // [[2, 0], [0, 3]]
|
|
45
|
-
* diag(3); //
|
|
119
|
+
* diag(3); // [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
46
120
|
* ```
|
|
121
|
+
*
|
|
122
|
+
* @category Linear algebra
|
|
47
123
|
*/
|
|
48
|
-
export declare function diag(x: Operand, options?: DiagOptions): number[] |
|
|
124
|
+
export declare function diag(x: Operand, options?: DiagOptions): number[] | number[][];
|
|
49
125
|
/**
|
|
50
|
-
* Combine vectors and matrices as columns. Equivalent to R's `cbind()
|
|
126
|
+
* Combine vectors and matrices as columns. Equivalent to R's `cbind()`. Vectors are recycled to the number of rows.
|
|
51
127
|
* Given data frames (objects of columns), puts their columns side by side, as R's `cbind()` of data frames: all must
|
|
52
128
|
* have the same number of rows, and a column name may occur only once.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* cbind([1, 2], [3, 4]); // [[1, 3], [2, 4]]
|
|
133
|
+
* cbind([[1, 2], [3, 4]], 0); // [[1, 2, 0], [3, 4, 0]]
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @category Linear algebra
|
|
53
137
|
*/
|
|
54
|
-
export declare function cbind(...args: Operand[]):
|
|
138
|
+
export declare function cbind(...args: Operand[]): number[][];
|
|
55
139
|
export declare function cbind(...frames: DataFrame[]): DataFrame;
|
|
56
140
|
/**
|
|
57
141
|
* Combine vectors and matrices as rows. Equivalent to R's `rbind()`. Given data frames (objects of columns), stacks
|
|
58
142
|
* their rows, as R's `rbind()` of data frames: all must have the same column names, matched by name (the result has
|
|
59
143
|
* the first frame's column order).
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* rbind([1, 2], [3, 4]); // [[1, 2], [3, 4]]
|
|
148
|
+
* rbind([[1, 2], [3, 4]], [5, 6]); // [[1, 2], [3, 4], [5, 6]]
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @category Linear algebra
|
|
60
152
|
*/
|
|
61
|
-
export declare function rbind(...args: Operand[]):
|
|
153
|
+
export declare function rbind(...args: Operand[]): number[][];
|
|
62
154
|
export declare function rbind(...frames: DataFrame[]): DataFrame;
|
|
63
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Options for {@link matrix}.
|
|
157
|
+
*
|
|
158
|
+
* @category Linear algebra
|
|
159
|
+
*/
|
|
64
160
|
export interface MatrixOptions {
|
|
161
|
+
/**
|
|
162
|
+
* Number of rows (R's `nrow`). Default: the length of the data divided by `ncol` (rounded up), or the length of
|
|
163
|
+
* the data when `ncol` is not given either.
|
|
164
|
+
*/
|
|
65
165
|
nrow?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Number of columns (R's `ncol`). Default: the length of the data divided by `nrow` (rounded up), or 1 when `nrow`
|
|
168
|
+
* is not given either.
|
|
169
|
+
*/
|
|
66
170
|
ncol?: number;
|
|
67
171
|
/** Fill by rows instead of by columns (R's default). Default `false`. */
|
|
68
172
|
byrow?: boolean;
|
|
69
173
|
}
|
|
70
174
|
/**
|
|
71
|
-
* Build a matrix from data, recycled to fill it. Equivalent to R's `matrix()
|
|
175
|
+
* Build a matrix from data, recycled to fill it. Equivalent to R's `matrix()`. Filled by columns unless `byrow`.
|
|
72
176
|
*
|
|
73
177
|
* @example
|
|
74
178
|
* ```ts
|
|
75
179
|
* matrix([1, 2, 3, 4, 5, 6], { nrow: 2 }); // [[1, 3, 5], [2, 4, 6]]
|
|
76
|
-
* matrix(0, { nrow: 2, ncol: 3 }); //
|
|
180
|
+
* matrix(0, { nrow: 2, ncol: 3 }); // [[0, 0, 0], [0, 0, 0]]
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @category Linear algebra
|
|
184
|
+
*/
|
|
185
|
+
export declare function matrix(data: number | Sample, options?: MatrixOptions): number[][];
|
|
186
|
+
/**
|
|
187
|
+
* Kronecker product. Equivalent to R's `kronecker()`. Two vectors give a vector.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* kronecker([[1, 2], [3, 4]], [[1, 1]]); // [[1, 1, 2, 2], [3, 3, 4, 4]]
|
|
192
|
+
* kronecker([1, 2], [1, 10]); // [1, 10, 2, 20]
|
|
77
193
|
* ```
|
|
194
|
+
*
|
|
195
|
+
* @category Linear algebra
|
|
196
|
+
*/
|
|
197
|
+
export declare function kronecker(x: Operand, y: Operand): number[] | number[][];
|
|
198
|
+
/**
|
|
199
|
+
* Options for {@link seq}.
|
|
200
|
+
*
|
|
201
|
+
* @category Linear algebra
|
|
78
202
|
*/
|
|
79
|
-
export declare function matrix(data: number | Sample, options?: MatrixOptions): Matrix;
|
|
80
|
-
/** Kronecker product. Equivalent to R's `kronecker()` (two vectors give a vector). */
|
|
81
|
-
export declare function kronecker(x: Operand, y: Operand): number[] | Matrix;
|
|
82
|
-
/** Options for {@link seq}. */
|
|
83
203
|
export interface SeqOptions {
|
|
84
204
|
/** Increment. */
|
|
85
205
|
by?: number;
|
|
@@ -87,7 +207,7 @@ export interface SeqOptions {
|
|
|
87
207
|
lengthOut?: number;
|
|
88
208
|
}
|
|
89
209
|
/**
|
|
90
|
-
* Regular sequences. Equivalent to R's `seq()
|
|
210
|
+
* Regular sequences. Equivalent to R's `seq()`. `seq(from, to)` steps by ±1; `by` steps by the increment, up to
|
|
91
211
|
* `to`; `lengthOut` gives that many values, both ends exact. `from` or `to` may be omitted (`undefined`) when the
|
|
92
212
|
* other two are given; `seq(n)` alone is `1, 2, ..., n`.
|
|
93
213
|
*
|
|
@@ -96,6 +216,7 @@ export interface SeqOptions {
|
|
|
96
216
|
* seq(0, 1, { by: 0.25 }); // [0, 0.25, 0.5, 0.75, 1]
|
|
97
217
|
* seq(0, 1, { lengthOut: 3 }); // [0, 0.5, 1]
|
|
98
218
|
* ```
|
|
219
|
+
*
|
|
220
|
+
* @category Linear algebra
|
|
99
221
|
*/
|
|
100
222
|
export declare function seq(from?: number, to?: number, options?: SeqOptions): number[];
|
|
101
|
-
export {};
|
package/dist/linalg/ops.js
CHANGED
|
@@ -19,13 +19,16 @@ function checkRows(x) {
|
|
|
19
19
|
return nc;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Matrix product. Equivalent to R's
|
|
23
|
-
*
|
|
22
|
+
* Matrix product. Equivalent to R's `%*%`. A vector is taken as a row or a column so that the product is defined
|
|
23
|
+
* (two vectors give their inner product as a 1 x 1 matrix).
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* matMul([[1, 2], [3, 4]], [[5], [6]]); // [[17], [39]]
|
|
28
|
+
* matMul([1, 2, 3], [4, 5, 6]); // [[32]]
|
|
28
29
|
* ```
|
|
30
|
+
*
|
|
31
|
+
* @category Linear algebra
|
|
29
32
|
*/
|
|
30
33
|
export function matMul(x, y) {
|
|
31
34
|
let a;
|
|
@@ -108,19 +111,63 @@ function elementwise(x, y, f) {
|
|
|
108
111
|
const n = Math.max(u.length, v.length);
|
|
109
112
|
return Array.from({ length: n }, (_, i) => f(u[i % u.length], v[i % v.length]));
|
|
110
113
|
}
|
|
111
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Element-wise sum with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
116
|
+
* R's `+`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* add([[1, 2], [3, 4]], [10, 20]); // [[11, 12], [23, 24]]
|
|
121
|
+
* add([1, 2, 3], 2); // [3, 4, 5]
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @category Linear algebra
|
|
125
|
+
*/
|
|
112
126
|
export function add(x, y) {
|
|
113
127
|
return elementwise(x, y, (a, b) => a + b);
|
|
114
128
|
}
|
|
115
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Element-wise difference with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
131
|
+
* R's `-`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* subtract([[1, 2], [3, 4]], [10, 20]); // [[-9, -8], [-17, -16]]
|
|
136
|
+
* subtract([1, 2, 3], 2); // [-1, 0, 1]
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @category Linear algebra
|
|
140
|
+
*/
|
|
116
141
|
export function subtract(x, y) {
|
|
117
142
|
return elementwise(x, y, (a, b) => a - b);
|
|
118
143
|
}
|
|
119
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Element-wise product with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
146
|
+
* R's `*`. The matrix product is {@link matMul}.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* multiply([[1, 2], [3, 4]], [10, 20]); // [[10, 20], [60, 80]]
|
|
151
|
+
* multiply([1, 2, 3], 2); // [2, 4, 6]
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @category Linear algebra
|
|
155
|
+
*/
|
|
120
156
|
export function multiply(x, y) {
|
|
121
157
|
return elementwise(x, y, (a, b) => a * b);
|
|
122
158
|
}
|
|
123
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Element-wise quotient with R's recycling (a shorter vector is recycled down the columns of a matrix). Equivalent to
|
|
161
|
+
* R's `/`.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* divide([[1, 2], [3, 4]], [10, 20]); // [[0.1, 0.2], [0.15, 0.2]]
|
|
166
|
+
* divide([1, 2, 3], 2); // [0.5, 1, 1.5]
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @category Linear algebra
|
|
170
|
+
*/
|
|
124
171
|
export function divide(x, y) {
|
|
125
172
|
return elementwise(x, y, (a, b) => a / b);
|
|
126
173
|
}
|
|
@@ -132,8 +179,16 @@ const OUTER_OPS = {
|
|
|
132
179
|
"^": (a, b) => a ** b,
|
|
133
180
|
};
|
|
134
181
|
/**
|
|
135
|
-
* Outer product of two vectors: the matrix of `fun(x[i], y[j])`. Equivalent to R's `outer()
|
|
182
|
+
* Outer product of two vectors: the matrix of `fun(x[i], y[j])`. Equivalent to R's `outer()`. `fun` is `"*"`
|
|
136
183
|
* (default), `"+"`, `"-"`, `"/"`, `"^"` or a function of two numbers.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* outer([1, 2], [1, 2, 3]); // [[1, 2, 3], [2, 4, 6]]
|
|
188
|
+
* outer([1, 2], [1, 2, 3], "+"); // [[2, 3, 4], [3, 4, 5]]
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @category Linear algebra
|
|
137
192
|
*/
|
|
138
193
|
export function outer(x, y, fun = "*") {
|
|
139
194
|
const f = typeof fun === "function" ? fun : OUTER_OPS[fun];
|
|
@@ -143,7 +198,17 @@ export function outer(x, y, fun = "*") {
|
|
|
143
198
|
const v = Array.from(y);
|
|
144
199
|
return u.map((a) => v.map((b) => f(a, b)));
|
|
145
200
|
}
|
|
146
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Transpose. Equivalent to R's `t()`. A vector becomes a 1-row matrix.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* t([[1, 2, 3], [4, 5, 6]]); // [[1, 4], [2, 5], [3, 6]]
|
|
207
|
+
* t([1, 2]); // [[1, 2]]
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @category Linear algebra
|
|
211
|
+
*/
|
|
147
212
|
export function t(x) {
|
|
148
213
|
if (!isMatrix(x))
|
|
149
214
|
return [asVector(x)];
|
|
@@ -151,16 +216,18 @@ export function t(x) {
|
|
|
151
216
|
return Array.from({ length: nc }, (_, j) => x.map((r) => r[j]));
|
|
152
217
|
}
|
|
153
218
|
/**
|
|
154
|
-
* R's `diag()
|
|
155
|
-
* length 2 or more (its values recycled along the diagonal of an `nrow` x `ncol` matrix when given); and for a single
|
|
219
|
+
* Matrix diagonals, diagonal matrices and identity matrices. Equivalent to R's `diag()`. It has three meanings: the
|
|
220
|
+
* diagonal of a matrix (as a vector); the diagonal matrix of a vector of length 2 or more (its values recycled along the diagonal of an `nrow` x `ncol` matrix when given); and for a single
|
|
156
221
|
* number n, the n x n identity matrix (with `nrow`/`ncol`, a matrix with that number on the diagonal).
|
|
157
222
|
*
|
|
158
223
|
* @example
|
|
159
224
|
* ```ts
|
|
160
225
|
* diag([[1, 2], [3, 4]]); // [1, 4]
|
|
161
226
|
* diag([2, 3]); // [[2, 0], [0, 3]]
|
|
162
|
-
* diag(3); //
|
|
227
|
+
* diag(3); // [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
163
228
|
* ```
|
|
229
|
+
*
|
|
230
|
+
* @category Linear algebra
|
|
164
231
|
*/
|
|
165
232
|
export function diag(x, options = {}) {
|
|
166
233
|
if (isMatrix(x)) {
|
|
@@ -222,13 +289,15 @@ export function rbind(...args) {
|
|
|
222
289
|
return frames === undefined ? bindParts(args, false) : rbindFrames(frames);
|
|
223
290
|
}
|
|
224
291
|
/**
|
|
225
|
-
* Build a matrix from data, recycled to fill it. Equivalent to R's `matrix()
|
|
292
|
+
* Build a matrix from data, recycled to fill it. Equivalent to R's `matrix()`. Filled by columns unless `byrow`.
|
|
226
293
|
*
|
|
227
294
|
* @example
|
|
228
295
|
* ```ts
|
|
229
296
|
* matrix([1, 2, 3, 4, 5, 6], { nrow: 2 }); // [[1, 3, 5], [2, 4, 6]]
|
|
230
|
-
* matrix(0, { nrow: 2, ncol: 3 }); //
|
|
297
|
+
* matrix(0, { nrow: 2, ncol: 3 }); // [[0, 0, 0], [0, 0, 0]]
|
|
231
298
|
* ```
|
|
299
|
+
*
|
|
300
|
+
* @category Linear algebra
|
|
232
301
|
*/
|
|
233
302
|
export function matrix(data, options = {}) {
|
|
234
303
|
const v = asVector(data);
|
|
@@ -245,7 +314,17 @@ export function matrix(data, options = {}) {
|
|
|
245
314
|
const byrow = options.byrow ?? false;
|
|
246
315
|
return Array.from({ length: nrow }, (_, i) => Array.from({ length: ncol }, (_, j) => (len === 0 ? NaN : v[(byrow ? i * ncol + j : i + j * nrow) % len])));
|
|
247
316
|
}
|
|
248
|
-
/**
|
|
317
|
+
/**
|
|
318
|
+
* Kronecker product. Equivalent to R's `kronecker()`. Two vectors give a vector.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```ts
|
|
322
|
+
* kronecker([[1, 2], [3, 4]], [[1, 1]]); // [[1, 1, 2, 2], [3, 3, 4, 4]]
|
|
323
|
+
* kronecker([1, 2], [1, 10]); // [1, 10, 2, 20]
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @category Linear algebra
|
|
327
|
+
*/
|
|
249
328
|
export function kronecker(x, y) {
|
|
250
329
|
if (!isMatrix(x) && !isMatrix(y)) {
|
|
251
330
|
const u = asVector(x);
|
|
@@ -261,7 +340,7 @@ export function kronecker(x, y) {
|
|
|
261
340
|
return out;
|
|
262
341
|
}
|
|
263
342
|
/**
|
|
264
|
-
* Regular sequences. Equivalent to R's `seq()
|
|
343
|
+
* Regular sequences. Equivalent to R's `seq()`. `seq(from, to)` steps by ±1; `by` steps by the increment, up to
|
|
265
344
|
* `to`; `lengthOut` gives that many values, both ends exact. `from` or `to` may be omitted (`undefined`) when the
|
|
266
345
|
* other two are given; `seq(n)` alone is `1, 2, ..., n`.
|
|
267
346
|
*
|
|
@@ -270,6 +349,8 @@ export function kronecker(x, y) {
|
|
|
270
349
|
* seq(0, 1, { by: 0.25 }); // [0, 0.25, 0.5, 0.75, 1]
|
|
271
350
|
* seq(0, 1, { lengthOut: 3 }); // [0, 0.5, 1]
|
|
272
351
|
* ```
|
|
352
|
+
*
|
|
353
|
+
* @category Linear algebra
|
|
273
354
|
*/
|
|
274
355
|
export function seq(from, to, options = {}) {
|
|
275
356
|
const { by, lengthOut } = options;
|