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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createSchur = void 0;
var _factory = require("../../../utils/factory.js");
const name = 'schur';
const dependencies = ['typed', 'matrix', 'identity', 'multiply', 'qr', 'norm', 'subtract'];
const createSchur = exports.createSchur = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
let {
typed,
matrix,
identity,
multiply,
qr,
norm,
subtract
} = _ref;
/**
*
* Performs a real Schur decomposition of the real matrix A = UTU' where U is orthogonal
* and T is upper quasi-triangular.
* https://en.wikipedia.org/wiki/Schur_decomposition
*
* Syntax:
*
* math.schur(A)
*
* Examples:
*
* const A = [[1, 0], [-4, 3]]
* math.schur(A) // returns {T: [[3, 4], [0, 1]], R: [[0, 1], [-1, 0]]}
*
* See also:
*
* sylvester, lyap, qr
*
* @param {Array | Matrix} A Matrix A
* @return {{U: Array | Matrix, T: Array | Matrix}} Object containing both matrix U and T of the Schur Decomposition A=UTU'
*/
return typed(name, {
Array: function (X) {
const r = _schur(matrix(X));
return {
U: r.U.valueOf(),
T: r.T.valueOf()
};
},
Matrix: function (X) {
return _schur(X);
}
});
function _schur(X) {
const n = X.size()[0];
let A = X;
let U = identity(n);
let k = 0;
let A0;
do {
A0 = A;
const QR = qr(A);
const Q = QR.Q;
const R = QR.R;
A = multiply(R, Q);
U = multiply(U, Q);
if (k++ > 100) {
break;
}
} while (norm(subtract(A, A0)) > 1e-4);
return {
U,
T: A
};
}
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createLeafCount = void 0;
var _factory = require("../../utils/factory.js");
const name = 'leafCount';
const dependencies = ['parse', 'typed'];
const createLeafCount = exports.createLeafCount = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
let {
parse,
typed
} = _ref;
// This does the real work, but we don't have to recurse through
// a typed call if we separate it out
function countLeaves(node) {
let count = 0;
node.forEach(n => {
count += countLeaves(n);
});
return count || 1;
}
/**
* Gives the number of "leaf nodes" in the parse tree of the given expression
* A leaf node is one that has no subexpressions, essentially either a
* symbol or a constant. Note that `5!` has just one leaf, the '5'; the
* unary factorial operator does not add a leaf. On the other hand,
* function symbols do add leaves, so `sin(x)/cos(x)` has four leaves.
*
* The `simplify()` function should generally not increase the `leafCount()`
* of an expression, although currently there is no guarantee that it never
* does so. In many cases, `simplify()` reduces the leaf count.
*
* Syntax:
*
* math.leafCount(expr)
*
* Examples:
*
* math.leafCount('x') // 1
* math.leafCount(math.parse('a*d-b*c')) // 4
* math.leafCount('[a,b;c,d][0,1]') // 6
*
* See also:
*
* simplify
*
* @param {Node|string} expr The expression to count the leaves of
*
* @return {number} The number of leaves of `expr`
*
*/
return typed(name, {
Node: function (expr) {
return countLeaves(expr);
}
});
});

58
node_modules/mathjs/lib/cjs/function/algebra/lyap.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createLyap = void 0;
var _factory = require("../../utils/factory.js");
const name = 'lyap';
const dependencies = ['typed', 'matrix', 'sylvester', 'multiply', 'transpose'];
const createLyap = exports.createLyap = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
let {
typed,
matrix,
sylvester,
multiply,
transpose
} = _ref;
/**
*
* Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P, where
* Q is an input matrix. When Q is symmetric, P is also symmetric. Notice
* that different equivalent definitions exist for the Continuous-time
* Lyapunov equation.
* https://en.wikipedia.org/wiki/Lyapunov_equation
*
* Syntax:
*
* math.lyap(A, Q)
*
* Examples:
*
* const A = [[-2, 0], [1, -4]]
* const Q = [[3, 1], [1, 3]]
* const P = math.lyap(A, Q)
*
* See also:
*
* sylvester, schur
*
* @param {Matrix | Array} A Matrix A
* @param {Matrix | Array} Q Matrix Q
* @return {Matrix | Array} Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
*/
return typed(name, {
'Matrix, Matrix': function (A, Q) {
return sylvester(A, transpose(A), multiply(-1, Q));
},
'Array, Matrix': function (A, Q) {
return sylvester(matrix(A), transpose(matrix(A)), multiply(-1, Q));
},
'Matrix, Array': function (A, Q) {
return sylvester(A, transpose(matrix(A)), matrix(multiply(-1, Q)));
},
'Array, Array': function (A, Q) {
return sylvester(matrix(A), transpose(matrix(A)), matrix(multiply(-1, Q))).toArray();
}
});
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

103
node_modules/mathjs/lib/cjs/function/algebra/resolve.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More