numz 0.1.0 → 0.3.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/docs/.vscode/extensions.json +4 -0
- package/docs/.vscode/launch.json +11 -0
- package/docs/README.md +49 -0
- package/docs/astro.config.mjs +64 -0
- package/docs/package-lock.json +7592 -0
- package/docs/package.json +19 -0
- package/docs/public/favicon.svg +1 -0
- package/docs/src/assets/houston.webp +0 -0
- package/docs/src/content/docs/about.md +11 -0
- package/docs/src/content/docs/guides/example.md +11 -0
- package/docs/src/content/docs/index.mdx +40 -0
- package/docs/src/content/docs/philosophy.md +15 -0
- package/docs/src/content/docs/reference/complex/complex.mdx +66 -0
- package/docs/src/content/docs/reference/functions/arithmetic.md +14 -0
- package/docs/src/content/docs/reference/functions/mapfun.md +81 -0
- package/docs/src/content/docs/reference/functions/ufunc.md +41 -0
- package/docs/src/content/docs/reference/functions/utils.md +16 -0
- package/docs/src/content/docs/reference/matrix/matrix.mdx +97 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/pulse-train.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/pwm.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/sawtooth-train.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/sinusoid.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/square.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/periodic/triangle.md +6 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/dirac.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/noise.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/rampe.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/rect.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/signum.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/sinc.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/trapezoid.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/pulse/tri.md +12 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/arange.md +21 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/geomspace.md +21 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/linspace.md +16 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/logspace.md +20 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/nums.md +17 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/ones.md +19 -0
- package/docs/src/content/docs/reference/signal/functions/sequences/zeros.md +20 -0
- package/docs/src/content/docs/reference/stats/accum/accum-max.md +4 -0
- package/docs/src/content/docs/reference/stats/accum/accum-min.md +4 -0
- package/docs/src/content/docs/reference/stats/accum/accum-prod.md +4 -0
- package/docs/src/content/docs/reference/stats/accum/accum-sum.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/contraharmonic-mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/geo_mean.md +6 -0
- package/docs/src/content/docs/reference/stats/averages/harmonic_mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/iq-mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/mean.md +6 -0
- package/docs/src/content/docs/reference/stats/averages/midhinge.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/midrange.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/power_mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/rms.md +12 -0
- package/docs/src/content/docs/reference/stats/averages/trimmed_mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/weighted_mean.md +4 -0
- package/docs/src/content/docs/reference/stats/averages/winsorized_mean.md +4 -0
- package/docs/src/content.config.ts +7 -0
- package/docs/src/pages/a.astro +0 -0
- package/docs/src/styles/custom.css +21 -0
- package/docs/tsconfig.json +5 -0
- package/package.json +2 -2
- package/src/signal/conv/conv.js +43 -0
- package/src/signal/conv/conv2.js +71 -0
- package/src/signal/conv/index.js +2 -0
- package/src/signal/fft/fft.js +47 -0
- package/src/signal/fft/ifft.js +16 -0
- package/src/signal/fft/index.js +2 -52
- package/src/signal/fft/utils/index.js +1 -19
- package/src/signal/functions/index.js +2 -1
- package/src/signal/functions/sequence/index.js +13 -3
- package/src/signal/functions/window/index.js +142 -0
- package/src/signal/index.js +1 -1
- package/src/stats/average/index.js +2 -2
- package/test/index.js +52 -0
- package/test/index.py +14 -0
- package/src/signal/fft/fft1d/index.js +0 -18
- package/src/signal/fft/fftnd/index.js +0 -27
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "astro dev",
|
|
7
|
+
"start": "astro dev",
|
|
8
|
+
"build": "astro build",
|
|
9
|
+
"preview": "astro preview",
|
|
10
|
+
"astro": "astro"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@astrojs/starlight": "^0.37.1",
|
|
14
|
+
"astro": "^5.6.1",
|
|
15
|
+
"sharp": "^0.34.2",
|
|
16
|
+
"starlight-github-alerts": "^0.1.1",
|
|
17
|
+
"starlight-theme-obsidian": "^0.4.1"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M81 36 64 0 47 36l-1 2-9-10a6 6 0 0 0-9 9l10 10h-2L0 64l36 17h2L28 91a6 6 0 1 0 9 9l9-10 1 2 17 36 17-36v-2l9 10a6 6 0 1 0 9-9l-9-9 2-1 36-17-36-17-2-1 9-9a6 6 0 1 0-9-9l-9 10v-2Zm-17 2-2 5c-4 8-11 15-19 19l-5 2 5 2c8 4 15 11 19 19l2 5 2-5c4-8 11-15 19-19l5-2-5-2c-8-4-15-11-19-19l-2-5Z" clip-rule="evenodd"/><path d="M118 19a6 6 0 0 0-9-9l-3 3a6 6 0 1 0 9 9l3-3Zm-96 4c-2 2-6 2-9 0l-3-3a6 6 0 1 1 9-9l3 3c3 2 3 6 0 9Zm0 82c-2-2-6-2-9 0l-3 3a6 6 0 1 0 9 9l3-3c3-2 3-6 0-9Zm96 4a6 6 0 0 1-9 9l-3-3a6 6 0 1 1 9-9l3 3Z"/><style>path{fill:#000}@media (prefers-color-scheme:dark){path{fill:#fff}}</style></svg>
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Example Guide
|
|
3
|
+
description: A guide in my new Starlight docs site.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Guides lead a user through a specific task they want to accomplish, often with a sequence of steps.
|
|
7
|
+
Writing a good guide requires thinking about what your users are trying to do.
|
|
8
|
+
|
|
9
|
+
## Further reading
|
|
10
|
+
|
|
11
|
+
- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Welcome to Numz
|
|
3
|
+
description: Get started building your docs site with Starlight.
|
|
4
|
+
template: splash # Remove or comment out this line to display the site sidebar on this page.
|
|
5
|
+
hero:
|
|
6
|
+
tagline: Scientific computation with zikojs
|
|
7
|
+
image:
|
|
8
|
+
file: ../../assets/houston.webp
|
|
9
|
+
actions:
|
|
10
|
+
- text: Example Guide
|
|
11
|
+
link: /guides/example/
|
|
12
|
+
icon: right-arrow
|
|
13
|
+
- text: Read Zikojs docs
|
|
14
|
+
link: https://github.com/zakarialaoui10/zikojs
|
|
15
|
+
icon: external
|
|
16
|
+
variant: minimal
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
import { Card, CardGrid } from '@astrojs/starlight/components';
|
|
20
|
+
|
|
21
|
+
## Next steps
|
|
22
|
+
|
|
23
|
+
<CardGrid stagger>
|
|
24
|
+
<Card title="Update content" icon="pencil">
|
|
25
|
+
Edit `src/content/docs/index.mdx` to see this page change.
|
|
26
|
+
</Card>
|
|
27
|
+
<Card title="Change page layout" icon="document">
|
|
28
|
+
Delete `template: splash` in `src/content/docs/index.mdx` to display a
|
|
29
|
+
sidebar on this page.
|
|
30
|
+
</Card>
|
|
31
|
+
<Card title="Add new content" icon="add-document">
|
|
32
|
+
Add Markdown or MDX files to `src/content/docs` to create new pages.
|
|
33
|
+
</Card>
|
|
34
|
+
<Card title="Configure your site" icon="setting">
|
|
35
|
+
Edit your `sidebar` and other config in `astro.config.mjs`.
|
|
36
|
+
</Card>
|
|
37
|
+
<Card title="Read the docs" icon="open-book">
|
|
38
|
+
Learn more in [the Starlight Docs](https://starlight.astro.build/).
|
|
39
|
+
</Card>
|
|
40
|
+
</CardGrid>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: philosophy
|
|
3
|
+
description: The philosphy of numz
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Numz adopts the [**Extended array programming paradigm**](), as it is built on top of the [**ZikoJS Math module**]().
|
|
7
|
+
|
|
8
|
+
It is inspired by:
|
|
9
|
+
- **NumPy**
|
|
10
|
+
- **SciPy**
|
|
11
|
+
- **MATLAB**
|
|
12
|
+
|
|
13
|
+
Numz guarantees a **layered, shape-safe, function-first numerical computing model**, designed to scale naturally from scalars to tensors while preserving mathematical correctness and clarity.
|
|
14
|
+
|
|
15
|
+
<!-- Numz is a layered, shape-safe, function-first numerical computing library that brings true array programming and scientific mathematics to JavaScript, built on the top of [Zikojs](). -->
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Complex
|
|
3
|
+
description: complex
|
|
4
|
+
sidebar:
|
|
5
|
+
label : complex
|
|
6
|
+
---
|
|
7
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
8
|
+
|
|
9
|
+
## Declarations
|
|
10
|
+
|
|
11
|
+
### Complex Constructor
|
|
12
|
+
|
|
13
|
+
<Tabs>
|
|
14
|
+
<TabItem label="Class Constructor">
|
|
15
|
+
- `new Complex(c : Complex)`
|
|
16
|
+
- `new Complex(a : number, b : number)`
|
|
17
|
+
- `new Complex({z : number, phi : number})`
|
|
18
|
+
- `new Complex({a : number, z : number})`
|
|
19
|
+
- `new Complex({a : number, phi : number})`
|
|
20
|
+
- `new Complex({b : number, z : number})`
|
|
21
|
+
- `new Complex({b : number, phi : number})`
|
|
22
|
+
</TabItem>
|
|
23
|
+
<TabItem label="Functional Constructors">
|
|
24
|
+
- `complex(c : Complex)`
|
|
25
|
+
- `complex(a : number, b : number)`
|
|
26
|
+
- `complex({z : number, phi : number})`
|
|
27
|
+
- `complex({a : number, z : number})`
|
|
28
|
+
- `complex({a : number, phi : number})`
|
|
29
|
+
- `complex({b : number, z : number})`
|
|
30
|
+
- `complex({b : number, phi : number})`
|
|
31
|
+
</TabItem>
|
|
32
|
+
</Tabs>
|
|
33
|
+
|
|
34
|
+
### Static Factory Methods
|
|
35
|
+
|
|
36
|
+
- `Complex.Zero()` :
|
|
37
|
+
- `Complex.fromPloar(z, phi)` :
|
|
38
|
+
- `Complex.Twiddle(N, K)` :
|
|
39
|
+
- `Complex.Random.int(min, max)` :
|
|
40
|
+
- `Complex.Random.float(min, max)` :
|
|
41
|
+
|
|
42
|
+
## Getters
|
|
43
|
+
|
|
44
|
+
|Getter|Description|Type|
|
|
45
|
+
|-|-|-|
|
|
46
|
+
|`.z`|||
|
|
47
|
+
|`.phi`|||
|
|
48
|
+
|`.conj`|||
|
|
49
|
+
|`.inv`|||
|
|
50
|
+
|`.expo`|||
|
|
51
|
+
|`.sqrt`|||
|
|
52
|
+
|`.cbrt`|||
|
|
53
|
+
|`.log`|||
|
|
54
|
+
|`.cos`|||
|
|
55
|
+
|`.sin`|||
|
|
56
|
+
|`.tan`|||
|
|
57
|
+
|
|
58
|
+
## Arithmetic
|
|
59
|
+
|
|
60
|
+
- `.add(...c : (Complex | number)[])` :
|
|
61
|
+
- `.sub(...c : (Complex | number)[])` :
|
|
62
|
+
- `.mul(...c : (Complex | number)[])` :
|
|
63
|
+
- `.div(...c : (Complex | number)[])` :
|
|
64
|
+
- `.modul(...c : (Complex | number)[])` :
|
|
65
|
+
- `.pow(...c : (Complex | number)[])` :
|
|
66
|
+
- `.nthr(n : number)` :
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Mapfun - The core of Extended Array Programming
|
|
3
|
+
description: mapfun
|
|
4
|
+
sidebar:
|
|
5
|
+
order : 0
|
|
6
|
+
label : mapfun
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
**Mapfun** is the heart of Numz’s extended array programming.
|
|
12
|
+
It allows applying functions recursively to deeply nested structures — arrays, objects, or mixed types — preserving their shape and type, without manual loops or recursion.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Javascript Limitation :
|
|
16
|
+
|
|
17
|
+
While JavaScript offers a built-in `Math` module, it has limitations in flexibility and handling complex data structures:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
Math.sqrt(4) // 2
|
|
21
|
+
Math.sqrt(4, 9) // 2 (ignores extra arguments)
|
|
22
|
+
Math.sqrt([4, 9, 16]) // NaN
|
|
23
|
+
```
|
|
24
|
+
- Cannot handle multiple arguments simultaneously.
|
|
25
|
+
- Cannot map functions over arrays or objects automatically
|
|
26
|
+
- Lacks support for deeply nested or heterogeneous structures.
|
|
27
|
+
|
|
28
|
+
## Existing Solutions in Other Languages and Libraries
|
|
29
|
+
|
|
30
|
+
Array programming libraries in other languages partially solve this problem:
|
|
31
|
+
|
|
32
|
+
- **NumPy (Python):** Provides efficient vectorized operations on arrays, but primarily works with homogeneous arrays. Nested lists require manual handling.
|
|
33
|
+
|
|
34
|
+
- **MATLAB:** Supports matrix and array operations natively, excellent for linear algebra and numeric computing, but struggles with nested or mixed-type structures.
|
|
35
|
+
|
|
36
|
+
- **R Lang:** Vectorized operations are supported and convenient for statistical computing, but deeply nested lists or heterogeneous objects require custom iteration.
|
|
37
|
+
|
|
38
|
+
Even these solutions do not fully support deeply nested or heterogeneous structures in a clean, recursive, type-preserving way.
|
|
39
|
+
|
|
40
|
+
## Solution :
|
|
41
|
+
[Zikojs]() which is the core of Numz introduces mapfun, a functional, type-preserving mapper.
|
|
42
|
+
It enables you to apply any function over numbers, arrays, objects, and nested combinations thereof without side effects.
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
- Recursive Processing, Enabling transformations on deeply nested data structures.
|
|
46
|
+
- No need for explicit recursions or loops, eliminating the need for manual recursion or loops.
|
|
47
|
+
- Preserves Data Type Format.
|
|
48
|
+
- Supports Heterogeneous Structures, working with diverse, mixed data types.
|
|
49
|
+
- No Side Effect, adopting a functional approach to ensure immutability and avoid unintended
|
|
50
|
+
changes.
|
|
51
|
+
- works with any unary function, including user-defined functions.
|
|
52
|
+
- Ideal for scientific computing where operations must be applied across complex, structured datasets.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Example
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { mapfun } from "ziko/math/functions/mapfun";
|
|
59
|
+
// or import { mapfun } from "numz/functions/mapfun"
|
|
60
|
+
const sqrt = (...x) => mapfun(Math.sqrt, ...x)
|
|
61
|
+
const result = sqrt(1, 4, 9, [16, 25], {
|
|
62
|
+
x: 36,
|
|
63
|
+
y: 49,
|
|
64
|
+
z: [64, 81],
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
/*
|
|
68
|
+
result =>
|
|
69
|
+
[
|
|
70
|
+
1,
|
|
71
|
+
2,
|
|
72
|
+
3,
|
|
73
|
+
[4, 5],
|
|
74
|
+
{
|
|
75
|
+
x: 6,
|
|
76
|
+
y: 7,
|
|
77
|
+
z: [8, 9],
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
*/
|
|
81
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Universal functions
|
|
3
|
+
description: ufunc
|
|
4
|
+
sidebar:
|
|
5
|
+
order : 2
|
|
6
|
+
label : ufunc
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
- `abs(...x)` :
|
|
10
|
+
- `pow(...x)` :
|
|
11
|
+
- `sqrt(...x)` :
|
|
12
|
+
- `cbrt(...x)` :
|
|
13
|
+
- `nthr(...x)` :
|
|
14
|
+
- `croor(...x)` :
|
|
15
|
+
|
|
16
|
+
- `exp(...x)` :
|
|
17
|
+
- `ln(...x)` :
|
|
18
|
+
|
|
19
|
+
- `sign(...x)` :
|
|
20
|
+
- `floor(...x)` :
|
|
21
|
+
- `ceil(...x)` :
|
|
22
|
+
- `round(...x)` :
|
|
23
|
+
- `trunc(...x)` :
|
|
24
|
+
- `fract(...x)` :
|
|
25
|
+
|
|
26
|
+
- `cos(...x)` :
|
|
27
|
+
- `sin(...x)` :
|
|
28
|
+
- `tan(...x)` :
|
|
29
|
+
- `sec(...x)` :
|
|
30
|
+
- `acos(...x)` :
|
|
31
|
+
- `asin(...x)` :
|
|
32
|
+
- `atan(...x)` :
|
|
33
|
+
- `acot(...x)` :
|
|
34
|
+
- `cosh(...x)` :
|
|
35
|
+
- `sinh(...x)` :
|
|
36
|
+
- `tanh(...x)` :
|
|
37
|
+
- `coth(...x)` :
|
|
38
|
+
- `acosh(...x)` :
|
|
39
|
+
- `asinh(...x)` :
|
|
40
|
+
- `atanh(...x)` :
|
|
41
|
+
- `sig(...x)` :
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Utils
|
|
3
|
+
description: utils
|
|
4
|
+
sidebar:
|
|
5
|
+
order : 1
|
|
6
|
+
label : utils
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
- `deg2rad(...deg)` :
|
|
11
|
+
- `rad2deg(...rad)` :
|
|
12
|
+
- `norm(x, min, max)` :
|
|
13
|
+
- `lerp(x, min, max)` :
|
|
14
|
+
- `clamp(x, min, max)` :
|
|
15
|
+
- `hypot(...x)` :
|
|
16
|
+
- `atan2(y, x, rad? : boolean)` :
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Matrix
|
|
3
|
+
description: matrix
|
|
4
|
+
sidebar:
|
|
5
|
+
label : matrix
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
9
|
+
|
|
10
|
+
## Declarations
|
|
11
|
+
|
|
12
|
+
### Matrix Constructor
|
|
13
|
+
|
|
14
|
+
<Tabs>
|
|
15
|
+
<TabItem label="Class Constructor">
|
|
16
|
+
- `new Matrix(r, c, arr: (number|Complex)[])` :
|
|
17
|
+
- `new Matrix(m : Matrix)` :
|
|
18
|
+
- `new Matrix(arr : (number|Complex)[])` :
|
|
19
|
+
</TabItem>
|
|
20
|
+
<TabItem label="Functional Constructors">
|
|
21
|
+
- `matrix()`
|
|
22
|
+
- `matrix2(a0, a1, b0, b1)` : Creates a **2×2** matrix
|
|
23
|
+
- `matrix3(a0, a1, a2, b0, b1, b2, c0, c1, c2)` : Creates a **3×3** matrix
|
|
24
|
+
- `matrix4(a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3, d0, d1, d2, d3)` : Creates a **4×4** matrix
|
|
25
|
+
</TabItem>
|
|
26
|
+
</Tabs>
|
|
27
|
+
|
|
28
|
+
### Static Factory Methods
|
|
29
|
+
- `Matrix.zeros(r, c)` : Creates an `r × c` matrix filled with zeros.
|
|
30
|
+
- `Matrix.ones(r, c)` : Creates an `r × c` matrix filled with ones.
|
|
31
|
+
- `Matrix.eye(r, c)` : Creates an `r × c` identity matrix (ones on the diagonal, zeros elsewhere).
|
|
32
|
+
If `r !== c`, creates a rectangular diagonal matrix.
|
|
33
|
+
- `Matrix.nums(num : number|complex, r, c)` : Creates an r × c matrix filled with the specified value num, which can be a real or complex number.
|
|
34
|
+
- `Matrix.random.int(min, max)`
|
|
35
|
+
- `Matrix.random.float(min, max)`
|
|
36
|
+
|
|
37
|
+
## Indexing
|
|
38
|
+
|
|
39
|
+
- `.at(r, c)` : Returns the element at row `r` and column `c`
|
|
40
|
+
- `[Symbol.iterator]` :
|
|
41
|
+
|
|
42
|
+
## Reshape
|
|
43
|
+
|
|
44
|
+
- `.reshape(r, c)` : Reshapes the matrix to `(r × c)` without changing the total number of elements.
|
|
45
|
+
- `.reshape(r0, c0, r1, c1)` :
|
|
46
|
+
- `.hstack(...matrices: Matrix[])` : Horizontally stacks matrices by columns (same number of rows required).
|
|
47
|
+
- `.vstack(...matrices: Matrix[])` : Vertically stacks matrices by rows (same number of columns required).
|
|
48
|
+
- `.hqueue(...matrices: Matrix[])` : Appends matrices horizontally, preserving row order (row-wise concatenation).
|
|
49
|
+
- `.vqueue(...matrices: Matrix[])` : Appends matrices vertically, preserving column order (column-wise concatenation).
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Arithmetic
|
|
53
|
+
|
|
54
|
+
- `.add(...m: (Matrix | number)[])` : Element-wise addition with one or more matrices or scalars.
|
|
55
|
+
- `.sub(...m: (Matrix | number)[])` : Element-wise subtraction with one or more matrices or scalars.
|
|
56
|
+
- `.mul(...m: (Matrix | number)[])` : Element-wise multiplication with one or more matrices or scalars.
|
|
57
|
+
- `.div(...m: (Matrix | number)[])` : Element-wise division with one or more matrices or scalars.
|
|
58
|
+
- `.modulo(...m: (Matrix | number)[])` : Element-wise modulo operation with one or more matrices or scalars.
|
|
59
|
+
- `.dot(m: Matrix)` : Matrix multiplication (linear algebra dot product).
|
|
60
|
+
|
|
61
|
+
## Modifiers
|
|
62
|
+
|
|
63
|
+
- `.toPrecision(n)`
|
|
64
|
+
- `.toComplex(n)` : Casts a real-valued matrix to a complex-valued matrix with `0` imaginary components
|
|
65
|
+
- `.map(Imin, Imax, Fmin, Fmax)` : Linearly maps matrix values from the input range `[Imin, Imax]` to the output range `[Fmin, Fmax]`.
|
|
66
|
+
- `.lerp(min, max)` : Applies linear interpolation to scale matrix values into the range `[min, max]`.
|
|
67
|
+
- `.norm(min, max)` : Normalizes matrix values to the range `[min, max]`.
|
|
68
|
+
- `.clamp(min, max)` : Clamps matrix values so that all elements lie within the range `[min, max]`.
|
|
69
|
+
- `.shuffle()` : Randomly shuffles the elements of the matrix (element-wise), preserving its shape.
|
|
70
|
+
- `.shuffleRows()` : Randomly shuffles the **rows** of the matrix, keeping the order of elements within each row intact.
|
|
71
|
+
- `.shuffleCols()` : Randomly shuffles the **columns** of the matrix, keeping the order of elements within each column intact.
|
|
72
|
+
|
|
73
|
+
## Getters
|
|
74
|
+
|
|
75
|
+
| Getter | Description | Type |
|
|
76
|
+
|-------|-------------|------|
|
|
77
|
+
| `.size` | Returns the total number of elements in the matrix (`rows × cols`). | `number` |
|
|
78
|
+
| `.shape` | Returns the shape of the matrix as `[rows, cols]`. | `[number, number]` |
|
|
79
|
+
| `.det` | Returns the determinant of the matrix (only for square matrices). | `number \| Matrix` |
|
|
80
|
+
| `.inv` | Returns the inverse of the matrix (only if invertible). | `Matrix` |
|
|
81
|
+
| `.T` | Returns the transpose of the matrix. | `Matrix` |
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Checkers
|
|
85
|
+
|
|
86
|
+
|Checker|Description|
|
|
87
|
+
|-|-|
|
|
88
|
+
| `.isMatrix()` | |
|
|
89
|
+
| `.haComplex()` | |
|
|
90
|
+
| `.isSquare()` | Checks whether the matrix has the same number of rows and columns. |
|
|
91
|
+
| `.isSym()` | Checks whether the matrix is symmetric (`A = Aᵀ`). |
|
|
92
|
+
| `.isAntiSym()` | Checks whether the matrix is antisymmetric (`A = -Aᵀ`). |
|
|
93
|
+
| `.isDiag()` | Checks whether the matrix is diagonal (non-zero elements only on the main diagonal). |
|
|
94
|
+
| `.isOrtho()` | Checks whether the matrix is orthogonal (`A · Aᵀ = I`). |
|
|
95
|
+
| `.isIdemp()` | Checks whether the matrix is idempotent (`A² = A`). |
|
|
96
|
+
| `.isUpperTri()` | Checks whether the matrix is upper triangular (zeros below the main diagonal). |
|
|
97
|
+
| `.isLowerTri()` | Checks whether the matrix is lower triangular (zeros above the main diagonal). |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: arange
|
|
3
|
+
description: arange
|
|
4
|
+
sidebar :
|
|
5
|
+
order: 3
|
|
6
|
+
---
|
|
7
|
+
## Definition
|
|
8
|
+
|
|
9
|
+
## Signature
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
arange(
|
|
13
|
+
a : number | number[],
|
|
14
|
+
b : number | number[],
|
|
15
|
+
step : number ,
|
|
16
|
+
include? : boolean
|
|
17
|
+
): number[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: geomspace
|
|
3
|
+
description: geomspace
|
|
4
|
+
sidebar :
|
|
5
|
+
order: 5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Definition
|
|
9
|
+
|
|
10
|
+
## Signature
|
|
11
|
+
```ts
|
|
12
|
+
geomspace(
|
|
13
|
+
a: number | Complex | (number | Complex)[],
|
|
14
|
+
b: number | Complex | (number | Complex)[],
|
|
15
|
+
n: number,
|
|
16
|
+
endpoint?: boolean,
|
|
17
|
+
precesion?: number
|
|
18
|
+
): number[] | Complex[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: linspace
|
|
3
|
+
description: linspace
|
|
4
|
+
sidebar :
|
|
5
|
+
order: 4
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
linspace(
|
|
10
|
+
a: number | Complex | (number | Complex)[],
|
|
11
|
+
b: number | Complex | (number | Complex)[],
|
|
12
|
+
n: number,
|
|
13
|
+
endpoint?: boolean
|
|
14
|
+
): number[] | Complex[]
|
|
15
|
+
|
|
16
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: logspace
|
|
3
|
+
description: logspace
|
|
4
|
+
sidebar :
|
|
5
|
+
order: 5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Definition
|
|
9
|
+
|
|
10
|
+
## Signature
|
|
11
|
+
```ts
|
|
12
|
+
logspace(
|
|
13
|
+
a: number | Complex | (number | Complex)[],
|
|
14
|
+
b: number | Complex | (number | Complex)[],
|
|
15
|
+
n: number,
|
|
16
|
+
endpoint?: boolean,
|
|
17
|
+
): number[] | Complex[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|