mathfuse 1.0.0
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 +37 -0
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/dist/cjs/algebra/index.d.ts +99 -0
- package/dist/cjs/algebra/index.d.ts.map +1 -0
- package/dist/cjs/algebra/index.js +358 -0
- package/dist/cjs/algebra/index.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +82 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/number-theory/index.d.ts +81 -0
- package/dist/cjs/number-theory/index.d.ts.map +1 -0
- package/dist/cjs/number-theory/index.js +331 -0
- package/dist/cjs/number-theory/index.js.map +1 -0
- package/dist/cjs/numerical/index.d.ts +95 -0
- package/dist/cjs/numerical/index.d.ts.map +1 -0
- package/dist/cjs/numerical/index.js +300 -0
- package/dist/cjs/numerical/index.js.map +1 -0
- package/dist/cjs/stats/index.d.ts +32 -0
- package/dist/cjs/stats/index.d.ts.map +1 -0
- package/dist/cjs/stats/index.js +232 -0
- package/dist/cjs/stats/index.js.map +1 -0
- package/dist/esm/algebra/index.d.ts +99 -0
- package/dist/esm/algebra/index.d.ts.map +1 -0
- package/dist/esm/algebra/index.js +333 -0
- package/dist/esm/algebra/index.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/number-theory/index.d.ts +81 -0
- package/dist/esm/number-theory/index.d.ts.map +1 -0
- package/dist/esm/number-theory/index.js +311 -0
- package/dist/esm/number-theory/index.js.map +1 -0
- package/dist/esm/numerical/index.d.ts +95 -0
- package/dist/esm/numerical/index.d.ts.map +1 -0
- package/dist/esm/numerical/index.js +280 -0
- package/dist/esm/numerical/index.js.map +1 -0
- package/dist/esm/stats/index.d.ts +32 -0
- package/dist/esm/stats/index.d.ts.map +1 -0
- package/dist/esm/stats/index.js +208 -0
- package/dist/esm/stats/index.js.map +1 -0
- package/dist/types/algebra/index.d.ts +99 -0
- package/dist/types/algebra/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/number-theory/index.d.ts +81 -0
- package/dist/types/number-theory/index.d.ts.map +1 -0
- package/dist/types/numerical/index.d.ts +95 -0
- package/dist/types/numerical/index.d.ts.map +1 -0
- package/dist/types/stats/index.d.ts +32 -0
- package/dist/types/stats/index.d.ts.map +1 -0
- package/package.json +85 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to mathfuse will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-03-30
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
#### `mathfuse/stats`
|
|
13
|
+
- `mean`, `geometricMean`, `harmonicMean`, `median`, `mode`, `weightedMean`
|
|
14
|
+
- `variance`, `stdDev`, `range`, `iqr`, `mad`
|
|
15
|
+
- `percentile`, `fiveNumberSummary`
|
|
16
|
+
- `skewness`, `kurtosis`
|
|
17
|
+
- `pearsonCorrelation`, `spearmanCorrelation`, `covariance`
|
|
18
|
+
- `zScore`, `minMaxNormalize`
|
|
19
|
+
- `linearRegression` with R², slope, intercept, and predict function
|
|
20
|
+
|
|
21
|
+
#### `mathfuse/algebra`
|
|
22
|
+
- Vector: `vadd`, `vsub`, `vscale`, `vdot`, `vnorm`, `vnormalize`, `vdistance`, `cosineSimilarity`, `cross3d`, `vhadamard`
|
|
23
|
+
- Matrix: `mzeros`, `midentity`, `mtranspose`, `madd`, `mscale`, `mmul`, `mvmul`, `mdet`, `minverse`, `mtrace`, `mrank`, `msolve`
|
|
24
|
+
|
|
25
|
+
#### `mathfuse/number-theory`
|
|
26
|
+
- Primes: `isPrime` (Miller-Rabin), `primesUpTo` (sieve), `nextPrime`, `primeFactors`
|
|
27
|
+
- GCD/LCM: `gcd`, `gcdMany`, `lcm`, `lcmMany`
|
|
28
|
+
- Combinatorics: `factorial`, `binomial`, `permutations`
|
|
29
|
+
- Modular: `modPow`, `eulerTotient`
|
|
30
|
+
- Sequences: `fibonacci`, `nthFibonacci` (fast doubling), `collatz`, `digitalRoot`
|
|
31
|
+
|
|
32
|
+
#### `mathfuse/numerical`
|
|
33
|
+
- Root finding: `bisection`, `newtonRaphson`, `brent`
|
|
34
|
+
- Differentiation: `derivative`, `secondDerivative`, `gradient`
|
|
35
|
+
- Integration: `integrate` (adaptive Simpson), `gaussLegendre`
|
|
36
|
+
- Interpolation: `lerp`, `inverseLerp`, `tableInterpolate`, `lagrange`
|
|
37
|
+
- Utilities: `clamp`, `roundTo`, `approxEqual`, `remap`, `kahanSum`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Scientist Maths
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# mathfuse
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Avinashvelu03/mathfuse/actions)
|
|
4
|
+
[](https://www.npmjs.com/package/mathfuse)
|
|
5
|
+
[](https://www.npmjs.com/package/mathfuse)
|
|
6
|
+
[](https://codecov.io/gh/Avinashvelu03/mathfuse)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://bundlephobia.com/package/mathfuse)
|
|
9
|
+
[](https://www.typescriptlang.org/)
|
|
10
|
+
|
|
11
|
+
**A modern, zero-dependency TypeScript math utility library.**
|
|
12
|
+
Tree-shakeable · ESM + CJS · Browser & Node.js · Fully typed
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
| Module | What's included |
|
|
19
|
+
|--------|----------------|
|
|
20
|
+
| **`stats`** | Mean, median, mode, std dev, variance, percentiles, IQR, MAD, skewness, kurtosis, Pearson/Spearman correlation, covariance, z-score, min-max normalization, linear regression |
|
|
21
|
+
| **`algebra`** | Vector ops (add, dot, norm, normalize, cosine similarity, cross product), matrix ops (multiply, determinant, inverse, rank, transpose, solve) |
|
|
22
|
+
| **`number-theory`** | Miller-Rabin primality, Sieve of Eratosthenes, GCD/LCM, factorial, binomial, permutations, modular exponentiation, Euler's totient, Fibonacci, Collatz |
|
|
23
|
+
| **`numerical`** | Bisection, Newton-Raphson, Brent's method, numerical derivative/gradient, adaptive Simpson integration, Gauss-Legendre quadrature, Lagrange interpolation, Kahan summation |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install mathfuse
|
|
31
|
+
# or
|
|
32
|
+
yarn add mathfuse
|
|
33
|
+
# or
|
|
34
|
+
pnpm add mathfuse
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { mean, stdDev, linearRegression } from 'mathfuse';
|
|
43
|
+
// or tree-shake specific modules:
|
|
44
|
+
import { mean, stdDev } from 'mathfuse/stats';
|
|
45
|
+
import { isPrime, fibonacci } from 'mathfuse/number-theory';
|
|
46
|
+
import { newtonRaphson, integrate } from 'mathfuse/numerical';
|
|
47
|
+
import { mmul, mdet, msolve } from 'mathfuse/algebra';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
### 📊 Statistics (`mathfuse/stats`)
|
|
55
|
+
|
|
56
|
+
#### Central Tendency
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { mean, median, mode, geometricMean, harmonicMean, weightedMean } from 'mathfuse/stats';
|
|
60
|
+
|
|
61
|
+
mean([1, 2, 3, 4, 5]) // 3
|
|
62
|
+
median([3, 1, 4, 1, 5]) // 3
|
|
63
|
+
mode([1, 2, 2, 3, 3]) // [2, 3]
|
|
64
|
+
geometricMean([1, 2, 4, 8]) // 2.828...
|
|
65
|
+
harmonicMean([1, 2, 4]) // 1.714...
|
|
66
|
+
weightedMean([1, 2, 3], [1, 2, 3]) // 2.333...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Spread & Dispersion
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { variance, stdDev, range, iqr, mad } from 'mathfuse/stats';
|
|
73
|
+
|
|
74
|
+
variance([2, 4, 4, 4, 5, 5, 7, 9]) // 4.571 (sample)
|
|
75
|
+
variance([2, 4, 4, 4, 5, 5, 7, 9], true) // 4.0 (population)
|
|
76
|
+
stdDev([2, 4, 4, 4, 5, 5, 7, 9], true) // 2.0
|
|
77
|
+
iqr([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) // 4.5
|
|
78
|
+
mad([1, 1, 2, 2, 4, 6, 9]) // 1.0
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Percentiles
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { percentile, fiveNumberSummary } from 'mathfuse/stats';
|
|
85
|
+
|
|
86
|
+
percentile([1,2,3,4,5,6,7,8,9,10], 90) // 9.1
|
|
87
|
+
fiveNumberSummary([1,2,3,4,5]) // [1, 1.5, 3, 4.5, 5]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Correlation & Regression
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { pearsonCorrelation, spearmanCorrelation, linearRegression } from 'mathfuse/stats';
|
|
94
|
+
|
|
95
|
+
const x = [1, 2, 3, 4, 5];
|
|
96
|
+
const y = [2, 4, 5, 4, 5];
|
|
97
|
+
|
|
98
|
+
pearsonCorrelation(x, y) // 0.8320...
|
|
99
|
+
spearmanCorrelation(x, y) // 0.8207...
|
|
100
|
+
|
|
101
|
+
const reg = linearRegression(x, y);
|
|
102
|
+
reg.slope // 0.7
|
|
103
|
+
reg.intercept // 1.7
|
|
104
|
+
reg.r2 // 0.6923
|
|
105
|
+
reg.predict(6) // 5.9
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Normalization
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { zScore, minMaxNormalize } from 'mathfuse/stats';
|
|
112
|
+
|
|
113
|
+
zScore([1, 2, 3, 4, 5]) // [-1.41, -0.71, 0, 0.71, 1.41]
|
|
114
|
+
minMaxNormalize([1, 2, 3, 4, 5]) // [0, 0.25, 0.5, 0.75, 1]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### 🔢 Number Theory (`mathfuse/number-theory`)
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { isPrime, primesUpTo, nextPrime, primeFactors } from 'mathfuse/number-theory';
|
|
123
|
+
|
|
124
|
+
isPrime(999_983) // true (Miller-Rabin)
|
|
125
|
+
primesUpTo(20) // [2, 3, 5, 7, 11, 13, 17, 19]
|
|
126
|
+
nextPrime(100) // 101
|
|
127
|
+
primeFactors(360) // [2, 2, 2, 3, 3, 5]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { gcd, lcm, factorial, binomial, fibonacci } from 'mathfuse/number-theory';
|
|
132
|
+
|
|
133
|
+
gcd(48, 18) // 6
|
|
134
|
+
lcm(4, 6) // 12
|
|
135
|
+
factorial(10) // 3_628_800
|
|
136
|
+
binomial(10, 3) // 120
|
|
137
|
+
fibonacci(8) // [0, 1, 1, 2, 3, 5, 8, 13]
|
|
138
|
+
nthFibonacci(50) // 12586269025
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### 🧮 Linear Algebra (`mathfuse/algebra`)
|
|
144
|
+
|
|
145
|
+
#### Vectors
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { vadd, vdot, vnorm, cosineSimilarity, cross3d } from 'mathfuse/algebra';
|
|
149
|
+
|
|
150
|
+
vadd([1,2,3], [4,5,6]) // [5, 7, 9]
|
|
151
|
+
vdot([1,2,3], [4,5,6]) // 32
|
|
152
|
+
vnorm([3, 4]) // 5
|
|
153
|
+
cosineSimilarity([1,0], [1,1]) // 0.7071...
|
|
154
|
+
cross3d([1,0,0], [0,1,0]) // [0, 0, 1]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### Matrices
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { mmul, mdet, minverse, msolve } from 'mathfuse/algebra';
|
|
161
|
+
|
|
162
|
+
const A = [[2,1], [-1,3]];
|
|
163
|
+
mdet(A) // 7
|
|
164
|
+
minverse(A) // [[0.428, -0.142], [0.142, 0.285]]
|
|
165
|
+
msolve(A, [5,0]) // [3, 1] (solves Ax = b)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### 📐 Numerical Methods (`mathfuse/numerical`)
|
|
171
|
+
|
|
172
|
+
#### Root Finding
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { bisection, newtonRaphson, brent } from 'mathfuse/numerical';
|
|
176
|
+
|
|
177
|
+
const f = (x: number) => x ** 2 - 2; // root at √2
|
|
178
|
+
|
|
179
|
+
bisection(f, 1, 2).root // 1.4142135623...
|
|
180
|
+
newtonRaphson(f, 1.5).root // 1.4142135623...
|
|
181
|
+
brent(f, 1, 2).root // 1.4142135623...
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Calculus
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { derivative, integrate } from 'mathfuse/numerical';
|
|
188
|
+
|
|
189
|
+
derivative(Math.sin, Math.PI / 4) // ≈ cos(π/4) ≈ 0.7071
|
|
190
|
+
integrate(Math.sin, 0, Math.PI) // ≈ 2.0 (exact: 2)
|
|
191
|
+
integrate(x => x ** 2, 0, 1) // ≈ 0.333 (exact: 1/3)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Interpolation
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import { lerp, tableInterpolate, lagrange } from 'mathfuse/numerical';
|
|
198
|
+
|
|
199
|
+
lerp(0, 100, 0.3) // 30
|
|
200
|
+
tableInterpolate([0,1,2,3], [0,1,4,9], 1.5) // 2.5
|
|
201
|
+
lagrange([0, 1, 2], [0, 1, 4], 1.5) // 2.25
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Tree Shaking
|
|
207
|
+
|
|
208
|
+
mathfuse is fully tree-shakeable. Import only what you need:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// ✅ Only the functions you import will be bundled
|
|
212
|
+
import { mean, stdDev } from 'mathfuse/stats';
|
|
213
|
+
import { isPrime } from 'mathfuse/number-theory';
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Browser Support
|
|
219
|
+
|
|
220
|
+
mathfuse targets ES2020 and works in all modern browsers and Node.js ≥ 16.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Contributing
|
|
225
|
+
|
|
226
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) and open an issue before submitting a PR for large changes.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
git clone https://github.com/Avinashvelu03/mathfuse.git
|
|
230
|
+
cd mathfuse
|
|
231
|
+
npm install
|
|
232
|
+
npm test
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
[MIT](LICENSE) © Scientist Maths
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module algebra
|
|
3
|
+
* Vector and matrix operations using plain JS arrays.
|
|
4
|
+
* All operations return new values — inputs are never mutated.
|
|
5
|
+
*/
|
|
6
|
+
export type Vector = number[];
|
|
7
|
+
export type Matrix = number[][];
|
|
8
|
+
/**
|
|
9
|
+
* Vector addition: a + b
|
|
10
|
+
*/
|
|
11
|
+
export declare function vadd(a: Vector, b: Vector): Vector;
|
|
12
|
+
/**
|
|
13
|
+
* Vector subtraction: a − b
|
|
14
|
+
*/
|
|
15
|
+
export declare function vsub(a: Vector, b: Vector): Vector;
|
|
16
|
+
/**
|
|
17
|
+
* Scalar multiplication: c * v
|
|
18
|
+
*/
|
|
19
|
+
export declare function vscale(v: Vector, c: number): Vector;
|
|
20
|
+
/**
|
|
21
|
+
* Dot product: a · b
|
|
22
|
+
*/
|
|
23
|
+
export declare function vdot(a: Vector, b: Vector): number;
|
|
24
|
+
/**
|
|
25
|
+
* L2 (Euclidean) norm of a vector.
|
|
26
|
+
*/
|
|
27
|
+
export declare function vnorm(v: Vector, p?: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Normalized unit vector (direction only).
|
|
30
|
+
*/
|
|
31
|
+
export declare function vnormalize(v: Vector): Vector;
|
|
32
|
+
/**
|
|
33
|
+
* Euclidean distance between two vectors.
|
|
34
|
+
*/
|
|
35
|
+
export declare function vdistance(a: Vector, b: Vector): number;
|
|
36
|
+
/**
|
|
37
|
+
* Cosine similarity between two vectors: (a · b) / (|a| |b|)
|
|
38
|
+
*/
|
|
39
|
+
export declare function cosineSimilarity(a: Vector, b: Vector): number;
|
|
40
|
+
/**
|
|
41
|
+
* Cross product of two 3D vectors.
|
|
42
|
+
*/
|
|
43
|
+
export declare function cross3d(a: Vector, b: Vector): Vector;
|
|
44
|
+
/**
|
|
45
|
+
* Element-wise (Hadamard) product.
|
|
46
|
+
*/
|
|
47
|
+
export declare function vhadamard(a: Vector, b: Vector): Vector;
|
|
48
|
+
/**
|
|
49
|
+
* Create an n×m matrix filled with a value (default 0).
|
|
50
|
+
*/
|
|
51
|
+
export declare function mzeros(n: number, m: number): Matrix;
|
|
52
|
+
/**
|
|
53
|
+
* Create an n×n identity matrix.
|
|
54
|
+
*/
|
|
55
|
+
export declare function midentity(n: number): Matrix;
|
|
56
|
+
/**
|
|
57
|
+
* Transpose a matrix.
|
|
58
|
+
*/
|
|
59
|
+
export declare function mtranspose(m: Matrix): Matrix;
|
|
60
|
+
/**
|
|
61
|
+
* Matrix addition.
|
|
62
|
+
*/
|
|
63
|
+
export declare function madd(a: Matrix, b: Matrix): Matrix;
|
|
64
|
+
/**
|
|
65
|
+
* Matrix scalar multiplication.
|
|
66
|
+
*/
|
|
67
|
+
export declare function mscale(m: Matrix, c: number): Matrix;
|
|
68
|
+
/**
|
|
69
|
+
* Matrix multiplication (naive O(n³)).
|
|
70
|
+
*/
|
|
71
|
+
export declare function mmul(a: Matrix, b: Matrix): Matrix;
|
|
72
|
+
/**
|
|
73
|
+
* Matrix-vector product: m · v
|
|
74
|
+
*/
|
|
75
|
+
export declare function mvmul(m: Matrix, v: Vector): Vector;
|
|
76
|
+
/**
|
|
77
|
+
* Determinant via LU decomposition (in-place, returns sign + value).
|
|
78
|
+
* @example mdet([[1,2],[3,4]]) // -2
|
|
79
|
+
*/
|
|
80
|
+
export declare function mdet(m: Matrix): number;
|
|
81
|
+
/**
|
|
82
|
+
* Matrix inverse via Gauss-Jordan elimination.
|
|
83
|
+
* Throws if the matrix is singular.
|
|
84
|
+
*/
|
|
85
|
+
export declare function minverse(m: Matrix): Matrix;
|
|
86
|
+
/**
|
|
87
|
+
* Matrix trace — sum of diagonal elements.
|
|
88
|
+
*/
|
|
89
|
+
export declare function mtrace(m: Matrix): number;
|
|
90
|
+
/**
|
|
91
|
+
* Matrix rank via Gaussian elimination.
|
|
92
|
+
*/
|
|
93
|
+
export declare function mrank(m: Matrix): number;
|
|
94
|
+
/**
|
|
95
|
+
* Solve Ax = b using Gauss-Jordan elimination.
|
|
96
|
+
* @returns solution vector x
|
|
97
|
+
*/
|
|
98
|
+
export declare function msolve(A: Matrix, b: Vector): Vector;
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/algebra/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9B,MAAM,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;AAUhC;;GAEG;AACH,wBAAgB,IA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