@danielsimonjr/mathts-core

中文文档
0.26.0发布于 2026/11/11MITTypeScriptES Module近 30 天下载 5975

Core types, utilities, and configuration for MathTS

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. API
  4. Types
  5. SI dimension vectors
  6. Functions
  7. License

@danielsimonjr/mathts-core

Core types, utilities, and configuration for MathTS.

Installation

npm install @danielsimonjr/mathts-core

Usage

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

Types

  • BackendType - Available backends: 'js' | 'wasm' | 'gpu'
  • NumericType - Numeric precision types
  • MathTSConfig - Configuration interface

SI dimension vectors

toSiDimensionVector returns exact Fraction exponents [L, M, T, I, Θ, N, J]; use vec.map((f) => f.toNumber()) when you need plain numbers (there is no toSiDimensionNumbers helper). fromSiDimensionVector accepts SiDimensionExponent (number | Fraction) and produces the length-10 Unit exponent array.

Functions

  • createSeededRng(seed) / SeededRng — forkable Mulberry32 stream (next, nextInt, normal, fork); number seeds match mulberry32, strings are FNV-1a UTF-8 (not cryptographically secure)

    const rng = createSeededRng(42);
    rng.next(); // 0.6011037519201636
    rng.fork('a').next(); // 0.668102843221277
    createSeededRng('a').seed; // -468965076
    
  • mulberry32(seed) — seeded Mulberry32 PRNG returning U[0, 1) samples (not cryptographically secure)

  • boxMuller(u1, u2) — Box–Muller pair of N(0, 1) samples from two uniforms

  • rowMajorStrides(shape) — row-major stride vector for a dense tensor shape

  • DEFAULT_CONFIG - Default configuration object

  • isNumber(value) - Type guard for numbers

  • isComplex(value) - Type guard for complex numbers

  • isMatrix(value) - Type guard for matrix-like objects (rows, cols, get, type)

License

MIT

版本与发布记录

@danielsimonjr/mathts-core 共发布 50 个版本,首次发布于 2026/04/05;过去 12 个月发布了 50 个版本。

版本发布日期距今
0.26.0latest2026/11/11今天
0.25.32026/11/11今天
0.25.22026/11/10今天
0.25.12026/11/101 天前
0.25.02026/11/101 天前
0.24.52026/11/091 天前

关于 @danielsimonjr/mathts-core 的常见问题

@danielsimonjr/mathts-core 是什么?

Core types, utilities, and configuration for MathTS

如何安装 @danielsimonjr/mathts-core?

在项目目录运行 npm install @danielsimonjr/mathts-core,或使用 pnpm add / yarn add / bun add。

@danielsimonjr/mathts-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@danielsimonjr/mathts-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@danielsimonjr/mathts-core 可以商用吗?

@danielsimonjr/mathts-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@danielsimonjr/mathts-core 的下载量有多少?

根据 npm 官方下载统计,@danielsimonjr/mathts-core 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,975 次,日均约 199 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@danielsimonjr/mathts-core 还在维护吗?

最新版本 0.26.0 发布于 2026/11/11(今天);至今共发布 50 个版本,其中过去 12 个月发布了 50 个;首次发布于 2026/04/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。