feat:node-modules

This commit is contained in:
houjunxiang
2025-11-24 10:26:18 +08:00
parent 753766893b
commit 8a3e48d856
8825 changed files with 567399 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
export var columnDocs = {
name: 'column',
category: 'Matrix',
syntax: ['column(x, index)'],
description: 'Return a column from a matrix or array.',
examples: ['A = [[1, 2], [3, 4]]', 'column(A, 1)', 'column(A, 2)'],
seealso: ['row', 'matrixFromColumns']
};

View File

@@ -0,0 +1,8 @@
export var concatDocs = {
name: 'concat',
category: 'Matrix',
syntax: ['concat(A, B, C, ...)', 'concat(A, B, C, ..., dim)'],
description: 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.',
examples: ['A = [1, 2; 5, 6]', 'B = [3, 4; 7, 8]', 'concat(A, B)', 'concat(A, B, 1)', 'concat(A, B, 2)'],
seealso: ['det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var countDocs = {
name: 'count',
category: 'Matrix',
syntax: ['count(x)'],
description: 'Count the number of elements of a matrix, array or string.',
examples: ['a = [1, 2; 3, 4; 5, 6]', 'count(a)', 'size(a)', 'count("hello world")'],
seealso: ['size']
};

View File

@@ -0,0 +1,8 @@
export var crossDocs = {
name: 'cross',
category: 'Matrix',
syntax: ['cross(A, B)'],
description: 'Calculate the cross product for two vectors in three dimensional space.',
examples: ['cross([1, 1, 0], [0, 1, 1])', 'cross([3, -3, 1], [4, 9, 2])', 'cross([2, 3, 4], [5, 6, 7])'],
seealso: ['multiply', 'dot']
};

View File

@@ -0,0 +1,8 @@
export var ctransposeDocs = {
name: 'ctranspose',
category: 'Matrix',
syntax: ['x\'', 'ctranspose(x)'],
description: 'Complex Conjugate and Transpose a matrix',
examples: ['a = [1, 2, 3; 4, 5, 6]', 'a\'', 'ctranspose(a)'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var detDocs = {
name: 'det',
category: 'Matrix',
syntax: ['det(x)'],
description: 'Calculate the determinant of a matrix',
examples: ['det([1, 2; 3, 4])', 'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])'],
seealso: ['concat', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var diagDocs = {
name: 'diag',
category: 'Matrix',
syntax: ['diag(x)', 'diag(x, k)'],
description: 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.',
examples: ['diag(1:3)', 'diag(1:3, 1)', 'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]', 'diag(a)'],
seealso: ['concat', 'det', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var diffDocs = {
name: 'diff',
category: 'Matrix',
syntax: ['diff(arr)', 'diff(arr, dim)'],
description: ['Create a new matrix or array with the difference of the passed matrix or array.', 'Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference', 'If no dimension parameter is passed it is assumed as dimension 0', 'Dimension is zero-based in javascript and one-based in the parser', 'Arrays must be \'rectangular\' meaning arrays like [1, 2]', 'If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays'],
examples: ['A = [1, 2, 4, 7, 0]', 'diff(A)', 'diff(A, 1)', 'B = [[1, 2], [3, 4]]', 'diff(B)', 'diff(B, 1)', 'diff(B, 2)', 'diff(B, bignumber(2))', 'diff([[1, 2], matrix([3, 4])], 2)'],
seealso: ['subtract', 'partitionSelect']
};

View File

@@ -0,0 +1,8 @@
export var dotDocs = {
name: 'dot',
category: 'Matrix',
syntax: ['dot(A, B)', 'A * B'],
description: 'Calculate the dot product of two vectors. ' + 'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' + 'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn',
examples: ['dot([2, 4, 1], [2, 2, 3])', '[2, 4, 1] * [2, 2, 3]'],
seealso: ['multiply', 'cross']
};

View File

@@ -0,0 +1,8 @@
export var eigsDocs = {
name: 'eigs',
category: 'Matrix',
syntax: ['eigs(x)'],
description: 'Calculate the eigenvalues and optionally eigenvectors of a square matrix',
examples: ['eigs([[5, 2.3], [2.3, 1]])', 'eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })'],
seealso: ['inv']
};

View File

@@ -0,0 +1,8 @@
export var fftDocs = {
name: 'fft',
category: 'Matrix',
syntax: ['fft(x)'],
description: 'Calculate N-dimensional Fourier transform',
examples: ['fft([[1, 0], [1, 0]])'],
seealso: ['ifft']
};

View File

@@ -0,0 +1,8 @@
export var filterDocs = {
name: 'filter',
category: 'Matrix',
syntax: ['filter(x, test)'],
description: 'Filter items in a matrix.',
examples: ['isPositive(x) = x > 0', 'filter([6, -2, -1, 4, 3], isPositive)', 'filter([6, -2, 0, 1, 0], x != 0)'],
seealso: ['sort', 'map', 'forEach']
};

View File

@@ -0,0 +1,8 @@
export var flattenDocs = {
name: 'flatten',
category: 'Matrix',
syntax: ['flatten(x)'],
description: 'Flatten a multi dimensional matrix into a single dimensional matrix.',
examples: ['a = [1, 2, 3; 4, 5, 6]', 'size(a)', 'b = flatten(a)', 'size(b)'],
seealso: ['concat', 'resize', 'size', 'squeeze']
};

View File

@@ -0,0 +1,8 @@
export var forEachDocs = {
name: 'forEach',
category: 'Matrix',
syntax: ['forEach(x, callback)'],
description: 'Iterates over all elements of a matrix/array, and executes the given callback function.',
examples: ['numberOfPets = {}', 'addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;', 'forEach(["Dog","Cat","Cat"], addPet)', 'numberOfPets'],
seealso: ['map', 'sort', 'filter']
};

View File

@@ -0,0 +1,8 @@
export var getMatrixDataTypeDocs = {
name: 'getMatrixDataType',
category: 'Matrix',
syntax: ['getMatrixDataType(x)'],
description: 'Find the data type of all elements in a matrix or array, ' + 'for example "number" if all items are a number ' + 'and "Complex" if all values are complex numbers. ' + 'If a matrix contains more than one data type, it will return "mixed".',
examples: ['getMatrixDataType([1, 2, 3])', 'getMatrixDataType([[5 cm], [2 inch]])', 'getMatrixDataType([1, "text"])', 'getMatrixDataType([1, bignumber(4)])'],
seealso: ['matrix', 'sparse', 'typeOf']
};

View File

@@ -0,0 +1,8 @@
export var identityDocs = {
name: 'identity',
category: 'Matrix',
syntax: ['identity(n)', 'identity(m, n)', 'identity([m, n])'],
description: 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.',
examples: ['identity(3)', 'identity(3, 5)', 'a = [1, 2, 3; 4, 5, 6]', 'identity(size(a))'],
seealso: ['concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var ifftDocs = {
name: 'ifft',
category: 'Matrix',
syntax: ['ifft(x)'],
description: 'Calculate N-dimensional inverse Fourier transform',
examples: ['ifft([[2, 2], [0, 0]])'],
seealso: ['fft']
};

View File

@@ -0,0 +1,8 @@
export var invDocs = {
name: 'inv',
category: 'Matrix',
syntax: ['inv(x)'],
description: 'Calculate the inverse of a matrix',
examples: ['inv([1, 2; 3, 4])', 'inv(4)', '1 / 4'],
seealso: ['concat', 'det', 'diag', 'identity', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var kronDocs = {
name: 'kron',
category: 'Matrix',
syntax: ['kron(x, y)'],
description: 'Calculates the Kronecker product of 2 matrices or vectors.',
examples: ['kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])', 'kron([1,1], [2,3,4])'],
seealso: ['multiply', 'dot', 'cross']
};

View File

@@ -0,0 +1,8 @@
export var mapDocs = {
name: 'map',
category: 'Matrix',
syntax: ['map(x, callback)', 'map(x, y, ..., callback)'],
description: 'Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.',
examples: ['map([1, 2, 3], square)', 'map([1, 2], [3, 4], f(a,b) = a + b)'],
seealso: ['filter', 'forEach']
};

View File

@@ -0,0 +1,8 @@
export var matrixFromColumnsDocs = {
name: 'matrixFromColumns',
category: 'Matrix',
syntax: ['matrixFromColumns(...arr)', 'matrixFromColumns(row1, row2)', 'matrixFromColumns(row1, row2, row3)'],
description: 'Create a dense matrix from vectors as individual columns.',
examples: ['matrixFromColumns([1, 2, 3], [[4],[5],[6]])'],
seealso: ['matrix', 'matrixFromRows', 'matrixFromFunction', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var matrixFromFunctionDocs = {
name: 'matrixFromFunction',
category: 'Matrix',
syntax: ['matrixFromFunction(size, fn)', 'matrixFromFunction(size, fn, format)', 'matrixFromFunction(size, fn, format, datatype)', 'matrixFromFunction(size, format, fn)', 'matrixFromFunction(size, format, datatype, fn)'],
description: 'Create a matrix by evaluating a generating function at each index.',
examples: ['f(I) = I[1] - I[2]', 'matrixFromFunction([3,3], f)', 'g(I) = I[1] - I[2] == 1 ? 4 : 0', 'matrixFromFunction([100, 100], "sparse", g)', 'matrixFromFunction([5], random)'],
seealso: ['matrix', 'matrixFromRows', 'matrixFromColumns', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var matrixFromRowsDocs = {
name: 'matrixFromRows',
category: 'Matrix',
syntax: ['matrixFromRows(...arr)', 'matrixFromRows(row1, row2)', 'matrixFromRows(row1, row2, row3)'],
description: 'Create a dense matrix from vectors as individual rows.',
examples: ['matrixFromRows([1, 2, 3], [[4],[5],[6]])'],
seealso: ['matrix', 'matrixFromColumns', 'matrixFromFunction', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var onesDocs = {
name: 'ones',
category: 'Matrix',
syntax: ['ones(m)', 'ones(m, n)', 'ones(m, n, p, ...)', 'ones([m])', 'ones([m, n])', 'ones([m, n, p, ...])'],
description: 'Create a matrix containing ones.',
examples: ['ones(3)', 'ones(3, 5)', 'ones([2,3]) * 4.5', 'a = [1, 2, 3; 4, 5, 6]', 'ones(size(a))'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var partitionSelectDocs = {
name: 'partitionSelect',
category: 'Matrix',
syntax: ['partitionSelect(x, k)', 'partitionSelect(x, k, compare)'],
description: 'Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.',
examples: ['partitionSelect([5, 10, 1], 2)', 'partitionSelect(["C", "B", "A", "D"], 1, compareText)', 'arr = [5, 2, 1]', 'partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]', 'arr', 'partitionSelect(arr, 1, \'desc\') # returns 2, arr is now: [5, 2, 1]', 'arr'],
seealso: ['sort']
};

View File

@@ -0,0 +1,8 @@
export var pinvDocs = {
name: 'pinv',
category: 'Matrix',
syntax: ['pinv(x)'],
description: 'Calculate the MoorePenrose inverse of a matrix',
examples: ['pinv([1, 2; 3, 4])', 'pinv([[1, 0], [0, 1], [0, 1]])', 'pinv(4)'],
seealso: ['inv']
};

View File

@@ -0,0 +1,8 @@
export var rangeDocs = {
name: 'range',
category: 'Type',
syntax: ['start:end', 'start:step:end', 'range(start, end)', 'range(start, end, step)', 'range(string)'],
description: 'Create a range. Lower bound of the range is included, upper bound is excluded.',
examples: ['1:5', '3:-1:-3', 'range(3, 7)', 'range(0, 12, 2)', 'range("4:10")', 'range(1m, 1m, 3m)', 'a = [1, 2, 3, 4; 5, 6, 7, 8]', 'a[1:2, 1:2]'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var reshapeDocs = {
name: 'reshape',
category: 'Matrix',
syntax: ['reshape(x, sizes)'],
description: 'Reshape a multi dimensional array to fit the specified dimensions.',
examples: ['reshape([1, 2, 3, 4, 5, 6], [2, 3])', 'reshape([[1, 2], [3, 4]], [1, 4])', 'reshape([[1, 2], [3, 4]], [4])', 'reshape([1, 2, 3, 4], [-1, 2])'],
seealso: ['size', 'squeeze', 'resize']
};

View File

@@ -0,0 +1,8 @@
export var resizeDocs = {
name: 'resize',
category: 'Matrix',
syntax: ['resize(x, size)', 'resize(x, size, defaultValue)'],
description: 'Resize a matrix.',
examples: ['resize([1,2,3,4,5], [3])', 'resize([1,2,3], [5])', 'resize([1,2,3], [5], -1)', 'resize(2, [2, 3])', 'resize("hello", [8], "!")'],
seealso: ['size', 'subset', 'squeeze', 'reshape']
};

View File

@@ -0,0 +1,8 @@
export var rotateDocs = {
name: 'rotate',
category: 'Matrix',
syntax: ['rotate(w, theta)', 'rotate(w, theta, v)'],
description: 'Returns a 2-D rotation matrix (2x2) for a given angle (in radians). ' + 'Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.',
examples: ['rotate([1, 0], pi / 2)', 'rotate(matrix([1, 0]), unit("35deg"))', 'rotate([1, 0, 0], unit("90deg"), [0, 0, 1])', 'rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],
seealso: ['matrix', 'rotationMatrix']
};

View File

@@ -0,0 +1,8 @@
export var rotationMatrixDocs = {
name: 'rotationMatrix',
category: 'Matrix',
syntax: ['rotationMatrix(theta)', 'rotationMatrix(theta, v)', 'rotationMatrix(theta, v, format)'],
description: 'Returns a 2-D rotation matrix (2x2) for a given angle (in radians). ' + 'Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.',
examples: ['rotationMatrix(pi / 2)', 'rotationMatrix(unit("45deg"), [0, 0, 1])', 'rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],
seealso: ['cos', 'sin']
};

View File

@@ -0,0 +1,8 @@
export var rowDocs = {
name: 'row',
category: 'Matrix',
syntax: ['row(x, index)'],
description: 'Return a row from a matrix or array.',
examples: ['A = [[1, 2], [3, 4]]', 'row(A, 1)', 'row(A, 2)'],
seealso: ['column', 'matrixFromRows']
};

View File

@@ -0,0 +1,8 @@
export var sizeDocs = {
name: 'size',
category: 'Matrix',
syntax: ['size(x)'],
description: 'Calculate the size of a matrix.',
examples: ['size(2.3)', 'size("hello world")', 'a = [1, 2; 3, 4; 5, 6]', 'size(a)', 'size(1:6)'],
seealso: ['concat', 'count', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'squeeze', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var sortDocs = {
name: 'sort',
category: 'Matrix',
syntax: ['sort(x)', 'sort(x, compare)'],
description: 'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',
examples: ['sort([5, 10, 1])', 'sort(["C", "B", "A", "D"], "natural")', 'sortByLength(a, b) = size(a)[1] - size(b)[1]', 'sort(["Langdon", "Tom", "Sara"], sortByLength)', 'sort(["10", "1", "2"], "natural")'],
seealso: ['map', 'filter', 'forEach']
};

View File

@@ -0,0 +1,8 @@
export var squeezeDocs = {
name: 'squeeze',
category: 'Matrix',
syntax: ['squeeze(x)'],
description: 'Remove inner and outer singleton dimensions from a matrix.',
examples: ['a = zeros(3,2,1)', 'size(squeeze(a))', 'b = zeros(1,1,3)', 'size(squeeze(b))'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'subset', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var subsetDocs = {
name: 'subset',
category: 'Matrix',
syntax: ['value(index)', 'value(index) = replacement', 'subset(value, [index])', 'subset(value, [index], replacement)'],
description: 'Get or set a subset of the entries of a matrix or ' + 'characters of a string. ' + 'Indexes are one-based. There should be one index specification for ' + 'each dimension of the target. Each specification can be a single ' + 'index, a list of indices, or a range in colon notation `l:u`. ' + 'In a range, both the lower bound l and upper bound u are included; ' + 'and if a bound is omitted it defaults to the most extreme valid value. ' + 'The cartesian product of the indices specified in each dimension ' + 'determines the target of the operation.',
examples: ['d = [1, 2; 3, 4]', 'e = []', 'e[1, 1:2] = [5, 6]', 'e[2, :] = [7, 8]', 'f = d * e', 'f[2, 1]', 'f[:, 1]', 'f[[1,2], [1,3]] = [9, 10; 11, 12]', 'f'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'trace', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var traceDocs = {
name: 'trace',
category: 'Matrix',
syntax: ['trace(A)'],
description: 'Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.',
examples: ['A = [1, 2, 3; -1, 2, 3; 2, 0, 3]', 'trace(A)'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'transpose', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var transposeDocs = {
name: 'transpose',
category: 'Matrix',
syntax: ['x\'', 'transpose(x)'],
description: 'Transpose a matrix',
examples: ['a = [1, 2, 3; 4, 5, 6]', 'a\'', 'transpose(a)'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros']
};

View File

@@ -0,0 +1,8 @@
export var zerosDocs = {
name: 'zeros',
category: 'Matrix',
syntax: ['zeros(m)', 'zeros(m, n)', 'zeros(m, n, p, ...)', 'zeros([m])', 'zeros([m, n])', 'zeros([m, n, p, ...])'],
description: 'Create a matrix containing zeros.',
examples: ['zeros(3)', 'zeros(3, 5)', 'a = [1, 2, 3; 4, 5, 6]', 'zeros(size(a))'],
seealso: ['concat', 'det', 'diag', 'identity', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose']
};