@danielsimonjr/马斯特分数
MathTS的核心类型、公用事业和配置.
安装
npm install @danielsimonjr/mathts-core
使用量
import { DEFAULT_CONFIG, isNumber, isMatrix } from '@danielsimonjr/mathts-core';
import { DenseMatrix } from '@danielsimonjr/mathts-matrix';
// Factory default configuration (MathTSConfig)
const config = { ...DEFAULT_CONFIG, preferredBackend: 'wasm' };
// Type guards
console.log(isNumber(42)); // true
console.log(
isMatrix([
[1, 2],
[3, 4],
])
); // false — nested arrays are not matrices
const m = DenseMatrix.fromArray([
[1, 2],
[3, 4],
]);
console.log(isMatrix(m)); // true
API 密码
类型
BackendType- 可用的后端:'js' | 'wasm' | 'gpu'NumericType- 数字精度类型MathTSConfig- 配置接口
SI 维向量
toSiDimensionVector 返回精确度 Fraction 责任人 [L, M, T, I, Θ, N, J]; 使用
vec.map((f) => f.toNumber()) 当您需要纯数字时( 没有)
toSiDimensionNumbers 帮助者). fromSiDimensionVector 接受 SiDimensionExponent
(单位:千美元)number | Fraction)并产生长度-10 Unit 加速阵列 .
职能
-
createSeededRng(seed)编号 :SeededRng分叉的Mulberry32溪流(next, (中文(简体) ),nextInt, (中文(简体) ),normal, (中文(简体) ),fork; 数量种子匹配mulberry32,字符串是 FNV-1a UTF-8(加密安全性不高)const rng = createSeededRng(42); rng.next(); // 0.6011037519201636 rng.fork('a').next(); // 0.668102843221277 createSeededRng('a').seed; // -468965076 -
mulberry32(seed)被播种的Mulberry32 PRNG 返回 U[0, 1]样品(在加密上没有安全性) -
boxMuller(u1, u2)- Box - Muller 双 N(0, 1) 从两种制服取出样品 -
rowMajorStrides(shape)高压外形的行长向量 -
DEFAULT_CONFIG- 默认配置对象 -
isNumber(value)- 数字的防守类型 -
isComplex(value)- 复杂数字的型号警卫 -
isMatrix(value)- 类似矩阵物体的护卫类型(rows, (中文(简体) ),cols, (中文(简体) ),get, (中文(简体) ),type(中文(简体) )
许可证
麻省理工学院